rust-lang / rust-lang/rust-analyzer

MIR eval loses block local trait implementations when evaluating

Open
#16,337 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-mir C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description


#[test]
fn regression_block_def_map() {
    check_pass(
        r#"
//- minicore: sized
trait Write {
    fn write(&mut self) {
        trait SpecWriteFmt {
            fn spec_write_fmt(self);
        }
        impl<W: Write + ?Sized> SpecWriteFmt for &mut W {
            #[inline]
            default fn spec_write_fmt(self) {}
        }
        impl<W: Write> SpecWriteFmt for &mut W {
            #[inline]
            fn spec_write_fmt(self) {}
        }
        self.spec_write_fmt()
    }
}
struct C;
impl Write for C {}
fn main() {
    C.write();
}
"#,
    );
}

see https://github.com/rust-lang/rust-analyzer/pull/16299

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

Start with the regression_block_def_map test in the issue and run it in rust-analyzer. Trace MIR evaluation for the block-local trait implementations in the reproducer; done when check_pass succeeds without losing those implementations. The issue also points to pull request 16299 for related context.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.