rust-lang / rust-lang/rust-analyzer
rust-analyzer showing different errors than rustc
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: rust-analyzer 1.89.0 (2948388 2025-08-04)
rustc version: rustc 1.89.0 (29483883e 2025-08-04)
editor or extension: GNU Emacs 30.2
code snippet to reproduce:
// add your code here
fn main() {
let _ = (6_u8 & 7_u16) as u32;
}
rust-analyzer gives a confusing error: non-primative cast: '<u8 as BitAnd<u16>>::Output' as 'u32'
while rustc gives the following diagnostics:
error[E0308]: mismatched types
--> src/main.rs:2:21
|
2 | let _ = (6_u8 & 7_u16) as u32;
| ^^^^^ expected `u8`, found `u16`
error[E0277]: no implementation for `u8 & u16`
--> src/main.rs:2:19
|
2 | let _ = (6_u8 & 7_u16) as u32;
| ^ no implementation for `u8 & u16`
|
= help: the trait `BitAnd<u16>` is not implemented for `u8`
= help: the following other types implement trait `BitAnd<Rhs>`:
`&u8` implements `BitAnd<u8>`
`&u8` implements `BitAnd`
`u8` implements `BitAnd<&u8>`
`u8` implements `BitAnd`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Rust snippet in the issue and comparing rust-analyzer's diagnostic with rustc's output. Trace the diagnostic path responsible for the non-primitive-cast message; done means the invalid mixed-type bitwise operation produces diagnostics that are no longer confusing and align with rustc's relevant errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100