Skip to content

Commit

Permalink
Bump Ruby checkout to 3.0 (#400)
Browse files Browse the repository at this point in the history
* Bump checkout to 3.0

* Fix build

* Fix Ruby initialization

* Update now-invalid fixture

* Rollback gc change
  • Loading branch information
reese authored Dec 31, 2022
1 parent ac657fc commit fa8c56b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion fixtures/small/nested_destructuring_actual.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_1, (_2, _3) = []
_a, (_b, _c) = []
2 changes: 1 addition & 1 deletion fixtures/small/nested_destructuring_expected.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_1, (_2, _3) = []
_a, (_b, _c) = []
6 changes: 3 additions & 3 deletions librubyfmt/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ fn main() -> Output {
#[cfg(target_os = "linux")]
let libname = "ruby-static";
#[cfg(target_os = "macos")]
let libname = "ruby.2.7-static";
let libname = "ruby.3.0-static";
#[cfg(all(target_arch = "x86_64", windows))]
let libname = "x64-vcruntime140-ruby270-static";
let libname = "x64-vcruntime140-ruby300-static";
#[cfg(all(target_arch = "x86", windows))]
let libname = "vcruntime140-ruby270-static";
let libname = "vcruntime140-ruby300-static";
#[cfg(all(target_env = "gnu", windows))]
compile_error!("rubyfmt on Windows is currently only supported with msvc");

Expand Down
2 changes: 1 addition & 1 deletion librubyfmt/ruby_checkout
Submodule ruby_checkout updated 4130 files
34 changes: 16 additions & 18 deletions librubyfmt/rubyfmt_lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,25 @@ def escape_percent_array_paren_content(part, pattern)

define_method(:"on_#{event}_add") do |parts, part|
delim = parts[1][0][1]
parts.tap do |node|
unless delim.end_with?('[')
delim_start = delim[-1]
delim_close = DELIM_CLOSE_PAREN[delim_start]
pattern = if delim_close
/(?<!\\)(?:\\\\)*(?:\\[#{Regexp.escape(delim_start)}#{Regexp.escape(delim_close)}]|[\[\]])/
else
/(?<!\\)(?:\\\\)*(?:\\#{Regexp.escape(delim_start)}|[\[\]])/
end
if part[0].is_a?(Array)
part.each do |sub_part|
escape_percent_array_paren_content(sub_part, pattern)
end
else
escape_percent_array_paren_content(part, pattern)

unless delim.end_with?('[')
delim_start = delim[-1]
delim_close = DELIM_CLOSE_PAREN[delim_start]
pattern = if delim_close
/(?<!\\)(?:\\\\)*(?:\\[#{Regexp.escape(delim_start)}#{Regexp.escape(delim_close)}]|[\[\]])/
else
/(?<!\\)(?:\\\\)*(?:\\#{Regexp.escape(delim_start)}|[\[\]])/
end
if part[0].is_a?(Array)
part.each do |sub_part|
escape_percent_array_paren_content(sub_part, pattern)
end
else
escape_percent_array_paren_content(part, pattern)
end
node[1] << part
end
parts[1] << part

super(parts, part)
end
end
Expand Down Expand Up @@ -569,5 +569,3 @@ def on___end__(val)
end
end
end

GC.disable
2 changes: 2 additions & 0 deletions librubyfmt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use simplelog::{ConfigBuilder, LevelFilter, TermLogger, TerminalMode};

extern "C" {
pub fn Init_ripper();
pub fn rb_gc_disable();
}

pub struct RubyfmtString(Box<str>);
Expand Down Expand Up @@ -193,6 +194,7 @@ unsafe fn load_ripper() -> Result<(), ()> {
"../ruby_checkout/ext/ripper/lib/ripper/sexp.rb"
))?;

rb_gc_disable();
Ok(())
}

Expand Down

0 comments on commit fa8c56b

Please sign in to comment.