taiki-e / pin-project-lite

A lightweight version of pin-project written with declarative macros.
https://docs.rs/pin-project-lite
Apache License 2.0
216 stars 15 forks source link

Allow clippy::ref_option_ref #44

Closed Kestrer closed 3 years ago

Kestrer commented 3 years ago

The following code:

#![warn(clippy::pedantic)]

pin_project_lite::pin_project! {
    struct X<'a> {
        inner: Option<&'a mut i32>,
    }
}

Generates a warning when run using Clippy:

warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>`
 --> src/lib.rs:3:1
  |
3 | / pin_project_lite::pin_project! {
4 | |     struct X<'a> {
5 | |         inner: Option<&'a mut i32>,
6 | |     }
7 | | }
  | |_^
  |
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![warn(clippy::pedantic)]
  |         ^^^^^^^^^^^^^^^^
  = note: `#[warn(clippy::ref_option_ref)]` implied by `#[warn(clippy::pedantic)]`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
  = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

It would be very appreciated if this could be avoided.

taiki-e commented 3 years ago

Thanks for the report! Published 0.2.2 which fixes this issue.