Skip to content

Clippy emits warnings when pedantic lints are enabled with derive macro #99

@Squitch1

Description

@Squitch1

Using the derive macros, clippy emits warnings when clippy::pedantic lints are enabled for structures containing fields typed with Option<&Foo>. These errors are emitted on the latest version of Rust, both on the stable and nightly branches.

Here is a minimal reproduction code:

#[derive(bitcode::Decode, bitcode::Encode)]
pub struct Foo<'a> {
    pub bar: Option<&'a str>,
}

And here are the warnings:

error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>`
|
| #[derive(bitcode::Decode, bitcode::Encode)]
|                           ^^^^^^^^^^^^^^^
|
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
...
   = note: this error originates in the derive macro `bitcode::Encode` (in Nightly builds, run with -Z macro-backtrace for more info)

error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>`
|
| #[derive(bitcode::Decode, bitcode::Encode)]
|          ^^^^^^^^^^^^^^^
|
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
...
   = note: this error originates in the derive macro `bitcode::Decode` (in Nightly builds, run with -Z macro-backtrace for more info)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions