How to suppress a warning for "drop_with_repr_extern" in fine detail?

I am currently experimenting with multi-threaded code, and its performance is affected by whether two data members have the same cache line or not.

To avoid a false exchange, I need to specify the layout structwithout the intervention of the Rust compiler, and therefore I use repr(C). However, this structalso implements Drop, and therefore the compiler warns of "incompatibility" in repr(C)and Drop, which I care nothing for.

However, the attempt to silence this useless warning turned out to be outside of me.

The following is an example :

#[repr(C)]
#[derive(Default, Debug)]
struct Simple<T> {
    item: T,
}

impl<T> Drop for Simple<T> {
    fn drop(&mut self) {}
}

fn main() {
    println!("{:?}", Simple::<u32>::default());
}

which emits #[warn(drop_with_repr_extern)].

I tried to specify #[allow(drop_with_repr_extern)]:

  • at struct
  • at impl Drop
  • at mod

. , .

: ?

. , , ; .

+4
1

rustc_lint/builtin.rs:

, ctx.tcx.lang_items.drop_trait() Drop . . . , - , Drop impl, , .

+2

All Articles