diff --git a/crates/rb-sys-build/src/utils.rs b/crates/rb-sys-build/src/utils.rs index dc768ec7..1e3e1272 100644 --- a/crates/rb-sys-build/src/utils.rs +++ b/crates/rb-sys-build/src/utils.rs @@ -35,6 +35,7 @@ macro_rules! memoize { ($type:ty: $val:expr) => {{ static INIT: std::sync::Once = std::sync::Once::new(); static mut VALUE: Option<$type> = None; + #[allow(static_mut_refs)] unsafe { INIT.call_once(|| { VALUE = Some($val); diff --git a/crates/rb-sys/Cargo.toml b/crates/rb-sys/Cargo.toml index 6e94ca65..30853e46 100644 --- a/crates/rb-sys/Cargo.toml +++ b/crates/rb-sys/Cargo.toml @@ -17,14 +17,11 @@ rust-version = "1.65" rb-sys-build = { version = "0.9.103", path = "../rb-sys-build" } [dev-dependencies] -rb-sys = { path = ".", features = [ - "link-ruby", - "stable-api-compiled-fallback", -] } +rb-sys = { path = ".", features = ["link-ruby"] } rusty-fork = "0.3.0" [features] -default = [] +default = ["stable-api-compiled-fallback"] link-ruby = [] fuzz = [] no-link-ruby = [] @@ -57,4 +54,4 @@ unexpected_cfgs = { level = "warn", check-cfg = [ "cfg(rb_sys_gem)", "cfg(rb_sys_use_stable_api_compiled_fallback)", "cfg(rb_sys_force_stable_api_compiled)", -] } \ No newline at end of file +] } diff --git a/crates/rb-sys/src/stable_api.rs b/crates/rb-sys/src/stable_api.rs index 10b34f9c..42438289 100644 --- a/crates/rb-sys/src/stable_api.rs +++ b/crates/rb-sys/src/stable_api.rs @@ -61,11 +61,21 @@ pub trait StableApiDefinition { /// Get the class from a VALUE which contains an RBasic struct. /// /// `VALUE` is a valid pointer to a non-immediate object. + /// + /// # Safety + /// This function is unsafe because it dereferences a raw pointer to get + /// access to underlying RBasic struct. The caller must ensure that the + /// `VALUE` is a valid pointer to an RBasic struct. unsafe fn rbasic_class(&self, obj: VALUE) -> Option>; /// Checks if the given object is frozen. /// /// `VALUE` is a valid pointer to a non-immediate object. + /// + /// # Safety + /// This function is unsafe because it may dereference a raw pointer to get + /// access to underlying RBasic struct. The caller must ensure that the + /// `VALUE` is a valid pointer to an RBasic struct. unsafe fn frozen_p(&self, obj: VALUE) -> bool; /// Tests if a bignum is positive. @@ -82,6 +92,7 @@ pub trait StableApiDefinition { /// This function is unsafe because it dereferences a raw pointer to get /// access to underlying RBasic struct. The caller must ensure that the /// `VALUE` is a valid pointer to a bignum. + #[inline] unsafe fn bignum_negative_p(&self, obj: VALUE) -> bool { !self.bignum_positive_p(obj) } diff --git a/examples/rust_reverse/ext/rust_reverse/src/lib.rs b/examples/rust_reverse/ext/rust_reverse/src/lib.rs index 5001e154..236af89c 100644 --- a/examples/rust_reverse/ext/rust_reverse/src/lib.rs +++ b/examples/rust_reverse/ext/rust_reverse/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_c_str_literals)] + use rb_sys::tracking_allocator::ManuallyTracked; use rb_sys::*; use std::os::raw::c_long;