rust-lang / rust-lang/rust-analyzer
Type error false positive when refining impl trait in RPITIT
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
versions: rustc 1.94 (stable, RA 2026-03-25) to rustc 1.98.0 (current nightly, rustc/RA 2026-07-02)
editor or extension: VSCode, nvim (rustaceanvim)
relevant settings: tested on default settings
Rust-Analyzer does not support refined impl trait types in RPITIT. However, since 1.94, this also causes type errors in code that passes cargo build:
trait Trait {
fn method(&self) -> impl Sized;
}
#[expect(refining_impl_trait)]
impl Trait for i32 {
fn method(&self) -> i32 {
*self
}
}
fn main() {
let _: i32 = 1i32.method(); // rust-analyzer: expected i32, found impl Sized
}
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 RPITIT example from the issue in rust-analyzer with the stated stable and nightly versions, then compare its diagnostic with cargo build. Trace the type inference or method-resolution path that reports “expected i32, found impl Sized”; done means rust-analyzer accepts the example without a false positive while preserving relevant diagnostics.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100