Skip to content

use_self still gives false positives #6902

Closed
@imp

Description

@imp

Now that #6818 is fixed and the fix (#6833) has made its way to the nightly there are still cases of false positives:

Lint name: use_self

I tried this code:

#![deny(clippy::use_self)]
use serde::Deserialize;

#[derive(Debug, Deserialize)]
#[serde(untagged)]
enum Direction {
    North,
}

fn main() {
    let d = Direction::North;

    println!("{:?}", d);
}

I expected to see this happen: clippy clean - no warning/errors

Instead, this happened:

    Checking playground v0.0.1 (/playground)
error: unnecessary structure name repetition
 --> src/main.rs:6:6
  |
6 |   enum Direction {
  |  ______^
7 | |     North,
  | |____^ help: use the applicable keyword: `Self`
  |
note: the lint level is defined here
 --> src/main.rs:1:9
  |
1 | #![deny(clippy::use_self)]
  |         ^^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self

error: aborting due to previous error

error: could not compile `playground`

To learn more, run the command again with --verbose.

Interestingly enough it the code generated by #[serde(untagged)] that triggers this lint. If this line is commented out then clippy seems to be happy

Meta

  • cargo clippy -V: clippy 0.1.52 (2021-03-13 acca818)

  • rustc -Vv:

rustc 1.52.0-nightly (acca81892 2021-03-13)
binary: rustc
commit-hash: acca818928654807ed3bc1ce0e97df118f8716c8
commit-date: 2021-03-13
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions