diff options
author | Alan Wu <[email protected]> | 2025-02-20 18:29:48 -0500 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2025-04-18 21:52:59 +0900 |
commit | 26e15ed6295e67aaaa21eda8a2a82def9d5c91c4 (patch) | |
tree | 80c79040621fdc209f08ca75594427c0dbc5fdf5 | |
parent | e5d4769bc5266fa6f3e50fc629aa0a3e99df856a (diff) |
Fix 2024 edition errors
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13131
-rw-r--r-- | zjit/src/backend/lir.rs | 2 | ||||
-rw-r--r-- | zjit/src/cruby.rs | 2 | ||||
-rw-r--r-- | zjit/src/lib.rs | 8 | ||||
-rw-r--r-- | zjit/src/options.rs | 6 |
4 files changed, 9 insertions, 9 deletions
diff --git a/zjit/src/backend/lir.rs b/zjit/src/backend/lir.rs index a4f49260c2..f7865f4b96 100644 --- a/zjit/src/backend/lir.rs +++ b/zjit/src/backend/lir.rs @@ -1363,7 +1363,7 @@ impl Assembler pub fn reorder_reg_moves(old_moves: &Vec<(Reg, Opnd)>) -> Vec<(Reg, Opnd)> { // Return the index of a move whose destination is not used as a source if any. fn find_safe_move(moves: &Vec<(Reg, Opnd)>) -> Option<usize> { - moves.iter().enumerate().find(|(_, &(dest_reg, _))| { + moves.iter().enumerate().find(|&(_, &(dest_reg, _))| { moves.iter().all(|&(_, src_opnd)| src_opnd != Opnd::Reg(dest_reg)) }).map(|(index, _)| index) } diff --git a/zjit/src/cruby.rs b/zjit/src/cruby.rs index 7707a143e3..379fdbaa16 100644 --- a/zjit/src/cruby.rs +++ b/zjit/src/cruby.rs @@ -117,7 +117,7 @@ pub use autogened::*; // Parsing it would result in a lot of duplicate definitions. // Use bindgen for functions that are defined in headers or in yjit.c. #[cfg_attr(test, allow(unused))] // We don't link against C code when testing -extern "C" { +unsafe extern "C" { pub fn rb_check_overloaded_cme( me: *const rb_callable_method_entry_t, ci: *const rb_callinfo, diff --git a/zjit/src/lib.rs b/zjit/src/lib.rs index 6e2ad693c7..82f58edbe7 100644 --- a/zjit/src/lib.rs +++ b/zjit/src/lib.rs @@ -20,11 +20,11 @@ use state::ZJITState; use crate::cruby::*; #[allow(non_upper_case_globals)] -#[no_mangle] +#[unsafe(no_mangle)] pub static mut rb_zjit_enabled_p: bool = false; /// Initialize ZJIT, given options allocated by rb_zjit_init_options() -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn rb_zjit_init(options: *const u8) { // Catch panics to avoid UB for unwinding into C frames. // See https://doc.rust-lang.org/nomicon/exception-safety.html @@ -67,7 +67,7 @@ fn rb_bug_panic_hook() { let _ = stderr().write_all(b"ruby: ZJIT has panicked. More info to follow...\n"); // Always show a Rust backtrace. - env::set_var("RUST_BACKTRACE", "1"); + env::set_var("RUST_BACKTRACE", "1"); // TODO(alan) go to init, set force backtrace previous_hook(panic_info); // TODO: enable CRuby's SEGV handler @@ -79,7 +79,7 @@ fn rb_bug_panic_hook() { } /// Generate JIT code for a given ISEQ, which takes EC and CFP as its arguments. -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn rb_zjit_iseq_gen_entry_point(iseq: IseqPtr, _ec: EcPtr) -> *const u8 { // TODO: acquire the VM barrier diff --git a/zjit/src/options.rs b/zjit/src/options.rs index 981d2c3cc5..40189555f8 100644 --- a/zjit/src/options.rs +++ b/zjit/src/options.rs @@ -3,7 +3,7 @@ use std::{ffi::CStr, os::raw::c_char}; // This option is exposed to the C side in a global variable for performance, see vm.c // Number of method calls after which to start generating code // Threshold==1 means compile on first execution -#[no_mangle] +#[unsafe(no_mangle)] #[allow(non_upper_case_globals)] pub static mut rb_zjit_call_threshold: u64 = 1; @@ -45,7 +45,7 @@ pub(crate) use get_option; /// Allocate Options on the heap, initialize it, and return the address of it. /// The return value will be modified by rb_zjit_parse_option() and then /// passed to rb_zjit_init() for initialization. -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn rb_zjit_init_options() -> *const u8 { let options = init_options(); Box::into_raw(Box::new(options)) as *const u8 @@ -61,7 +61,7 @@ pub fn init_options() -> Options { } /// Parse a --zjit* command-line flag -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn rb_zjit_parse_option(options: *const u8, str_ptr: *const c_char) -> bool { let options = unsafe { &mut *(options as *mut Options) }; parse_option(options, str_ptr).is_some() |