rust-lang / rust-lang/rust-analyzer
`std` uses a `Thin` trait alias which breaks mir eval
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
https://doc.rust-lang.org/std/ptr/fn.null_mut.html is defined as:
pub const fn null_mut<T: ?Sized + Thin>() -> *mut T;
where Thin is defined as:
pub trait Thin = Pointee<Metadata = ()>;
r-a currently does not handle trait aliases correctly, as such mir eval bails out on almost all code that does Vec allocations via Vec::with_capacity because we lack the knowledge that Metadata = () in null_mut resulting in a Expected <T as Pointee>::Metadata, found () error.
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 MIR evaluation failure through Vec::with_capacity and inspect how trait aliases are handled around std::ptr::null_mut and Thin. The work is done when MIR evaluation recognizes that Thin implies Pointee::Metadata = () and no longer reports the metadata mismatch.
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