Incorrect suggestion diff highlight for nonexistent variant
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
enum A {
B(),
}
fn foo(_: A) {}
fn main() {
foo(A::C);
}
Current output
As shown in the screenshot attached, the diff marked with plus in the suggestion highlights the opening parenthesis in green.
Desired output
- The plus diff should highlight the replacement
B, not the parenthesis. - In the absence of a
use A::B;statement,A::Bshould be suggested as the replacement instead ofB.
Rationale and extra context
This bug affects latest stable 1.89.0 (29483883e 2025-08-04) and beta 1.90.0-beta.10 (67cb8e039 2025-09-11). In latest nightly 1.92.0-nightly (52618eb33 2025-09-14), this triggers a ICE as describe in issue #146261. This bug was discovered during the investigation of that ICE bug, might be the root cause of it.
Rust Version
rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.7
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 issue with the provided Rust snippet on the stable, beta, and nightly versions listed. Trace the compiler's suggestion diff handling for the nonexistent variant and compare it with the ICE investigation in issue #146261; done means the diff highlights B and suggests A::B when no use statement exists, without triggering the ICE.
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