Skip to content

warn(needless_borrow) creates false positive when using derive(Debug) #2740

Closed
@U007D

Description

@U007D

Note: false positive is only emitted when #[derive(Debug)] attribute is present:

#[derive(Debug)]  // must be present to get false positive
pub struct Crowd<'a> {
    people: &'a [usize],
}

gives

   Compiling playground v0.0.1 (file:///playground)
warning: this pattern creates a reference to a reference
 --> src/main.rs:7:5
  |
7 |     people: &'a [usize],
  |     ^^^^^^^^^^^^^^^^^^^ help: change this to: `people: &'a [usize]`
  |
note: lint level defined here
 --> src/main.rs:2:9
  |
2 | #![warn(needless_borrow)]
  |         ^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.195/index.html#needless_borrow

warning: this pattern creates a reference to a reference
 --> src/main.rs:7:5
  |
7 |     people: &'a [usize],
  |     ^^^^^^^^^^^^^^^^^^^ help: change this to: `people: &'a [usize]`
  |
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.195/index.html#needless_borrow

    Finished dev [unoptimized + debuginfo] target(s) in 0.66 secs

playground example

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingT-macrosType: Issues with macros and macro expansion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions