Skip to content

Spurious E0308 in latest release and pre-release versions #23344

Description

@ohell

After latest system update on Arch, rust lang and VScode and extensions all got updated. Now there are many false E0308 errors. I am attaching the two simplest cases below. I have to revert to version 0.3.2719 in order to silence this noise.

rust-analyzer version: 0.4.3045, 0.3.3041 both show these errors, 0.3.2719 does not

rustc version: 1.88.0 (6b00bc388 2025-06-23)

editor or extension: VSCode extension version 0.3041

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

repository link (if public, optional): (eg. rust-analyzer)

code snippet to reproduce:

impl std::fmt::Display for Counter {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.get())    // E0308: expected Result<(), Error>, found ()
    }
}

pub fn open_reader(path: Option<&Path>) -> io::Result<Box<dyn BufRead + Send>> {
    // Treat None or "-" as stdin
    if path.is_none_or(|p| p.as_os_str() == "-") {
        return Ok(Box::new(BufReader::with_capacity(1 << 26, std::io::stdin())));   // E0308: expected Box<dyn BufRead + Send, Global>, found Box<BufReader<Stdin>, Global>
    }
/*
...
*/
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions