chris-morgan / mopa

MOPA: My Own Personal Any. A macro to implement all the `Any` methods on your own trait.
Other
112 stars 9 forks source link

Clippy complains about generated code #11

Open Ploppz opened 5 years ago

Ploppz commented 5 years ago
warning: unsafe function's docs miss `# Safety` section
  --> src/lib.rs:40:1
   |
40 | mopafy!(Widget);
   | ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(clippy::missing_safety_doc)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

warning: transmute from a pointer type (`*mut ()`) to a reference type (`&T`)
  --> src/lib.rs:40:1
   |
40 | mopafy!(Widget);
   | ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(clippy::transmute_ptr_to_ref)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref
   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

warning: unsafe function's docs miss `# Safety` section
  --> src/lib.rs:40:1
   |
40 | mopafy!(Widget);
   | ^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

warning: transmute from a pointer type (`*mut ()`) to a reference type (`&mut T`)
  --> src/lib.rs:40:1
   |
40 | mopafy!(Widget);
   | ^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref
   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

warning: unsafe function's docs miss `# Safety` section
  --> src/lib.rs:40:1
   |
40 | mopafy!(Widget);
   | ^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
   = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
AndiDog commented 2 years ago

Still happens with Rust 1.57.

Workaround (lib.rs / main.rs):

#![allow(clippy::transmute_ptr_to_ref)] // https://github.com/chris-morgan/mopa/issues/11
extern crate mopa;

Then cargo clippy does not complain anymore.