unsafe_no_drop_flag


#1

What’s the story of #[unsafe_no_drop_flag] as per Rust 1.1? Is there still drop flag overhead in Rust structures?

I have a struct wrapping a value from C API to define some safe methods:

// This really comes from another crate
mod ffi {
    #[repr(C)]
    pub struct RawValue {
        // ...
    }
}

#[repr(C)]
#[unsafe_no_drop_flag]
struct Value(ffi::RawValue);

The implementation of Drop for Value uses the contents of the C structure to determine when the value has been destroyed, so the extraneous flag is not needed. If I remove the unsafe_no_drop_flag attribute, does this make an array of Value different in layout from an array of RawValue?


#2

unsafe_no_drop_flag sadly lives on as a necessary evil into even today’s 1.3. @pnkfelix is on the job, but it’s a rather herculean task to kill the (in struct) drop flag once and for all.