Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
U007D opened this issue May 10, 2018 · 1 comment
Closed

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

U007D opened this issue May 10, 2018 · 1 comment
Labels
C-bug Category: Clippy is not doing the correct thing T-macros Type: Issues with macros and macro expansion

Comments

@U007D
Copy link

U007D commented May 10, 2018

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

@phansch phansch added C-bug Category: Clippy is not doing the correct thing T-macros Type: Issues with macros and macro expansion labels May 10, 2018
@phansch
Copy link
Member

phansch commented May 10, 2018

Looks like the macro check in check_pat of needless_borrow is not working because of rust-lang/rust#49154.

Also: #2651

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing T-macros Type: Issues with macros and macro expansion
Projects
None yet
Development

No branches or pull requests

2 participants