rust-lang / rust-lang/rust-analyzer
RA fails to resolve type of match arm identifier
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 69
Description
rust-analyzer version: 0.3.2282-standalone (2df4ecfc74 2025-01-26)
rustc version: rustc 1.83.0 (90b35a623 2024-11-26)
editor or extension: VSCode extension version 0.3.2282
code snippet to reproduce:
fn need_bytes_mut(_: &mut [u8]) {}
fn main() {
let mut string = String::new();
match unsafe { string.as_bytes_mut() } {
[] => {}
bytes => {
need_bytes_mut(bytes);
}
}
}
The code compiles, but type hint for bytes is unkown and RA reports an error. If line 6 is deleted, everything will be fine.
And str's method as_bytes_mut is not resolved, no auto-comple, no quick doc lookup.
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 with the provided Rust snippet and reproduce the failure in rust-analyzer with the reported versions. Investigate match-arm identifier type inference and method resolution around the unsafe as_bytes_mut call; done means the bytes hint and diagnostic are correct, and as_bytes_mut resolves with completion and documentation lookup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100