Skip to content

clippy::use_self seems to trigger in some odd places #10127

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

Closed
coredoesdev opened this issue Dec 29, 2022 · 4 comments
Closed

clippy::use_self seems to trigger in some odd places #10127

coredoesdev opened this issue Dec 29, 2022 · 4 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@coredoesdev
Copy link

Summary

I have a simple enum which for some reason is triggering clippy::use_self. Following it's suggestion results in code that is (to no surprise) uncompilable as it suggests replacing the enum name with Self.

Lint Name

clippy::use_self

Reproducer

I tried this code:

// Architecture
/// Represents a system architecture
//
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)]
pub enum Architecture {
    #[allow(non_camel_case_types)]
    amd64,
    #[allow(non_camel_case_types)]
    arm64,
    #[allow(non_camel_case_types)]
    armv7,
}

I saw this happen:

warning: unnecessary structure name repetition
  --> libmangrove/src/platform.rs:10:10
   |
10 | pub enum Architecture {
   |          ^^^^^^^^^^^^ help: use the applicable keyword: `Self`
   |
   = note: `#[warn(clippy::use_self)]` implied by `#[warn(clippy::nursery)]`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self

I have no idea if I am causing this or if it is an actual bug as my codebase is quite large, but I am pretty sure this is a bug.

Version

rustc 1.65.0                                                                                                                                     
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-unknown-linux-gnu
release: 1.65.0
LLVM version: 15.0.0

Additional Labels

No response

@coredoesdev coredoesdev added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Dec 29, 2022
@coredoesdev
Copy link
Author

coredoesdev commented Dec 29, 2022

It looks like this is a duplicate of #6902 which has been closed as resolved; this is a very similar situation. Either a bug with serde or here.

@kraktus
Copy link
Contributor

kraktus commented Dec 30, 2022

Hey, thanks for reporting,

With your code, I cannot reproduce this issue on stable or nightly: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=e78b9597b9e6ab6d18be4526180cd8d1

Updating your rust version should fix the issue, otherwise we’d need more code to try to find the root issue.

@kraktus
Copy link
Contributor

kraktus commented Jan 24, 2025

Blast from the past! 😄

@samueltardieu
Copy link
Contributor

Yeah, I'm doing some bookeeping on inactive issues.

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 I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

3 participants