fire debug assertion when `expected` and `found` item look the same in diagnostic?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Sometimes rustc outputs silly error hints like
= note: expected trait `for<'a> <for<'a> fn(&'a u32) -> &'a u32 {function2} as FnOnce<(&'a u32,)>>`
found trait `for<'a> <for<'a> fn(&'a u32) -> &'a u32 {function2} as FnOnce<(&'a u32,)>>`
where "expected" and "found" look like they are the same which is quite unhelpful.
(example from https://github.com/rust-lang/rust/issues/114883 )
I wonder if we should have a debug assertion in these cases (rustc displaying both types being identical although they shouldn't be) that helps catch these kid of diagnostic mishaps, similar to the "span must not be empty and have no suggestion" and "span must not have overlapping parts" debug assertions.
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 reviewing the diagnostic behavior shown in issue #114883 and tracing where rustc formats the expected and found traits. Determine where an assertion can check for identical displayed items without affecting valid diagnostics. Done means the assertion catches this diagnostic mishap and relevant diagnostic tests still pass.
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