Skip to content

Rust analyzer reports errors not reported by rustc #22454

@DanielT

Description

@DanielT

Rust analyzer version: 0.3.2913 (Linux)
rustc version: 1.95.0

I have a program that causes rust-analyzer to report errors where rustc does not.

I've reduced my program to a short repro example:

// lib.rs
pub fn testcase(xml_str: &str) {
    let mut reader = quick_xml::Reader::from_str(xml_str);
    match reader.read_event().unwrap() {
        quick_xml::events::Event::GeneralRef(bytes_ref) => {
            match bytes_ref.as_ref() {
                b"amp" => {}
                b"lt" => {}
                b"apos" => {}
                _ => {}
            };
        }
        _ => {}
    }
}
# Cargo.toml
[package]
name = "ra-bug-repro"
edition = "2024"

[dependencies]
quick-xml = "0.40.1"
zip = "8.6.0"

Rust analyzer reports:

Line 7: expected &[u8; 3], found &'static [u8; 2]
Line 8: expected &[u8; 3], found &'static [u8; 4]

I made a particularly interesting discovery while reducing my code to the testcase: If the dependency on zip is removed in Cargo.toml then rust-analyzer no longer reports any errors. Just including this dependency, even unused, changes the behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions