-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Skip overlapping spans in argument error suggestions #151909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rust-bors
merged 1 commit into
rust-lang:main
from
chenyukang:yukang-fix-151607-disjoint-spans
Feb 3, 2026
+110
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
tests/ui/argument-suggestions/disjoint-spans-issue-151607.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Regression test for #151607 | ||
| // The ICE was "all spans must be disjoint" when emitting diagnostics | ||
| // with overlapping suggestion spans. | ||
|
|
||
| struct B; | ||
| struct D; | ||
| struct F; | ||
| fn foo(g: F, y: F, e: &E) { | ||
| //~^ ERROR cannot find type `E` in this scope | ||
| foo(B, g, D, E, F, G) | ||
| //~^ ERROR this function takes 3 arguments but 6 arguments were supplied | ||
| //~| ERROR cannot find value `E` in this scope | ||
| //~| ERROR cannot find value `G` in this scope | ||
| } | ||
|
|
||
| fn main() {} |
85 changes: 85 additions & 0 deletions
85
tests/ui/argument-suggestions/disjoint-spans-issue-151607.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| error[E0425]: cannot find type `E` in this scope | ||
| --> $DIR/disjoint-spans-issue-151607.rs:8:24 | ||
| | | ||
| LL | struct B; | ||
| | --------- similarly named struct `B` defined here | ||
| ... | ||
| LL | fn foo(g: F, y: F, e: &E) { | ||
| | ^ | ||
| | | ||
| help: a struct with a similar name exists | ||
| | | ||
| LL - fn foo(g: F, y: F, e: &E) { | ||
| LL + fn foo(g: F, y: F, e: &B) { | ||
| | | ||
| help: you might be missing a type parameter | ||
| | | ||
| LL | fn foo<E>(g: F, y: F, e: &E) { | ||
| | +++ | ||
|
|
||
| error[E0425]: cannot find value `E` in this scope | ||
| --> $DIR/disjoint-spans-issue-151607.rs:10:18 | ||
| | | ||
| LL | foo(B, g, D, E, F, G) | ||
| | ^ | ||
| | | ||
| help: a local variable with a similar name exists | ||
| | | ||
| LL - foo(B, g, D, E, F, G) | ||
| LL + foo(B, g, D, e, F, G) | ||
| | | ||
| help: consider importing one of these constants | ||
| | | ||
| LL + use std::f128::consts::E; | ||
| | | ||
| LL + use std::f16::consts::E; | ||
| | | ||
| LL + use std::f32::consts::E; | ||
| | | ||
| LL + use std::f64::consts::E; | ||
| | | ||
|
|
||
| error[E0425]: cannot find value `G` in this scope | ||
| --> $DIR/disjoint-spans-issue-151607.rs:10:24 | ||
| | | ||
| LL | foo(B, g, D, E, F, G) | ||
| | ^ | ||
| | | ||
| help: a local variable with a similar name exists | ||
| | | ||
| LL - foo(B, g, D, E, F, G) | ||
| LL + foo(B, g, D, E, F, g) | ||
| | | ||
| help: you might be missing a const parameter | ||
| | | ||
| LL | fn foo<const G: /* Type */>(g: F, y: F, e: &E) { | ||
| | +++++++++++++++++++++ | ||
|
|
||
| error[E0061]: this function takes 3 arguments but 6 arguments were supplied | ||
| --> $DIR/disjoint-spans-issue-151607.rs:10:5 | ||
| | | ||
| LL | foo(B, g, D, E, F, G) | ||
| | ^^^ - - - unexpected argument #4 | ||
| | | | | ||
| | | unexpected argument #3 of type `D` | ||
| | unexpected argument #1 of type `B` | ||
| | | ||
| note: function defined here | ||
| --> $DIR/disjoint-spans-issue-151607.rs:8:4 | ||
| | | ||
| LL | fn foo(g: F, y: F, e: &E) { | ||
| | ^^^ ----- | ||
| help: consider borrowing here | ||
| | | ||
| LL | foo(B, g, D, E, F, &G) | ||
| | + | ||
| help: remove the extra arguments | ||
| | | ||
| LL - foo(B, g, D, E, F, G) | ||
| LL + foo(, g, F, G) | ||
| | | ||
|
|
||
| error: aborting due to 4 previous errors | ||
|
|
||
| Some errors have detailed explanations: E0061, E0425. | ||
| For more information about an error, try `rustc --explain E0061`. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the diagnostic is a bit sus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you like to revisit this in a follow up pr maybe somewhere later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i also noticed this, i'm working on another branch.