rust-lang / rust-lang/rust-analyzer
FP `expected [&(dyn Foo + 'static); 2], found [&i32; 2]`
Open
Nobody has claimed this yet.
C-bug
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
trait Foo {}
impl Foo for isize {}
fn foo(_: [&dyn Foo; 2]) {}
fn main() {
let r = &1;
let _: [&dyn Foo; 2] = [r; 2];
foo([&1; 2]);
}
rustc compiles this but rust-analyzer diagnostics . says
at crate ra, file /tmp/ra/src/main.rs: Error RustcHardError("E0308") from LineCol { line: 7, col: 8 } to LineCol { line: 7, col: 15 }: expected [&(dyn Foo + 'static); 2], found [&i32; 2]
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
Reproduce the diagnostic in /tmp/ra/src/main.rs using the provided Rust snippet, then compare rust-analyzer diagnostics with rustc's result. Trace the diagnostic path for the reported E0308 and verify that the valid array coercion no longer produces a hard error, with regression coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100