rust-lang / rust-lang/rust-analyzer

FP `expected [&(dyn Foo + 'static); 2], found [&i32; 2]`

Open
#22,983 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.