Skip to content

RA gets confused if field name coincides with function parameters #15034

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
SchrodingerZhu opened this issue Jun 12, 2023 · 2 comments
Closed
Labels
C-bug Category: bug

Comments

@SchrodingerZhu
Copy link

#[derive(Eq, PartialEq, Hash)]
struct A {
    state: usize,
}

which expands to

 #[automatically_derived]
    impl ::core::hash::Hash for A {
        fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
            ::core::hash::Hash::hash(&self.state, state)
        }
    }

Here state is a function parameter for Hash::hash. RA somehow gets confused by this similarity and generates a false positive.

image

rust-analyzer version: 0.4.1548-standalone (d567091 2023-06-11)

rustc version: rustc 1.71.0-nightly (74c482104 2023-05-04)

relevant settings: n/a

@SchrodingerZhu SchrodingerZhu added the C-bug Category: bug label Jun 12, 2023
@flodiebold
Copy link
Member

flodiebold commented Jun 12, 2023

Duplicate of #14860 / #11681.

@SchrodingerZhu
Copy link
Author

Glad to know this is captured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants