rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

`static mut` deprecation

Open wmmc88 opened this issue 10 months ago • 1 comments

There is a current pre-RFC for deprecating static mut in Rust 2024, in favor of better alternatives. I think bindgen should start using some of these alternatives instead of generating code that will become deprecated in the near-term. My understanding of the pre-RFC is that we should be using SyncUnsafeCell in these FFI scenarios instead of static mut

Input C/C++ Header

extern const void* FOO;

Bindgen Invocation

bindgen::Builder::default()
    .header("input.h")
    .generate()
    .unwrap()

Actual Results

extern "C" {
    pub static mut Foo: *const ::core::ffi::c_void;
}

Expected Results

wmmc88 avatar Apr 03 '24 05:04 wmmc88