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

rust-analyzer uses an identically named method from a wrong trait #18526

Open
newpavlov opened this issue Nov 18, 2024 · 3 comments
Open

rust-analyzer uses an identically named method from a wrong trait #18526

newpavlov opened this issue Nov 18, 2024 · 3 comments
Labels
A-chalk chalk related issue A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@newpavlov
Copy link

Using rust-analyzer on this crate (note the commit hash) results in two false-positive compilation errors (i.e. compiling the same code with cargo produces no errors). One of the errors is on this line:

    #[inline]
    fn encrypt_to_vec<'msg, 'aad>(
        &self,
        nonce: &Nonce<Self>,
        pt_payload: impl Into<Payload<'msg, 'aad>>,
    ) -> Result<Vec<u8>> {
        let mut buf = Vec::new();
        self.encrypt_to_buffer(nonce, pt_payload, &mut buf)?;
        // expected 4 arguments, found 3 (E0107)         ^
        Ok(buf)
    }

Clicking on the encrypt_to_buffer method jumps to the DynAead::encrypt_to_buffer method, while Aead::encrypt_to_buffer should've been used instead.

rust-analyzer version: 0.3.2188
rustc version: 1.84.0-nightly (5ec7d6eee 2024-11-17)

@newpavlov newpavlov added the C-bug Category: bug label Nov 18, 2024
@lnicola
Copy link
Member

lnicola commented Nov 18, 2024

Probably same as #5514.

@lnicola lnicola added A-ty type system / type inference / traits / method resolution A-chalk chalk related issue labels Nov 18, 2024
@newpavlov
Copy link
Author

Considering that the issue is 4 years old, it does not look like it. The code was working fine until I updated rust-analyzer today. Unfortunately, I don't know the exact version which I was using before.

@newpavlov
Copy link
Author

newpavlov commented Nov 18, 2024

v0.3.2180 handles the code without issues, so it's a relatively recent regression.

UPD: I was wrong. For some reason the errors did not get triggered without saving the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-chalk chalk related issue A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants