Skip to content

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

Open
@newpavlov

Description

@newpavlov

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-chalkchalk related issueA-tytype system / type inference / traits / method resolutionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions