rust-lang / rust-lang/rust-analyzer

`std` uses a `Thin` trait alias which breaks mir eval

Open
#15,566 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-mir A-ty C-bug
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.