-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Suggest only Span without source changes when source code is unavailable #144585
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
Open
xizheyin
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
xizheyin:show-std-source
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+105
−6
Open
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
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,20 @@ | ||
enum Foo<T> { | ||
Bar { | ||
v23: T, | ||
y: isize | ||
} | ||
} | ||
|
||
fn f(x: &Foo) { //~ ERROR missing generics for enum `Foo` [E0107] | ||
match *x { | ||
Foo::Bar { y: y, v23: x } => { | ||
assert_eq!(x, 1); | ||
assert_eq!(y, 2); //~ ERROR can't compare `&isize` with `{integer}` [E0277] | ||
} | ||
} | ||
} | ||
|
||
pub fn main() { | ||
let x = Foo::Bar { x: 1, y: 2 }; //~ ERROR variant `Foo<_>::Bar` has no field named `x` [E0559] | ||
f(&x); | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/ui/compiletest-self-test/help-show-std-source.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,39 @@ | ||
error[E0107]: missing generics for enum `Foo` | ||
--> $DIR/help-show-std-source.rs:8:10 | ||
| | ||
LL | fn f(x: &Foo) { | ||
| ^^^ expected 1 generic argument | ||
| | ||
note: enum defined here, with 1 generic parameter: `T` | ||
--> $DIR/help-show-std-source.rs:1:6 | ||
| | ||
LL | enum Foo<T> { | ||
| ^^^ - | ||
help: add missing generic argument | ||
| | ||
LL | fn f(x: &Foo<T>) { | ||
| +++ | ||
|
||
error[E0277]: can't compare `&isize` with `{integer}` | ||
--> $DIR/help-show-std-source.rs:12:13 | ||
| | ||
LL | assert_eq!(y, 2); | ||
| ^^^^^^^^^^^^^^^^ no implementation for `&isize == {integer}` | ||
| | ||
= help: the trait `PartialEq<{integer}>` is not implemented for `&isize` | ||
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider dereferencing here | ||
--> $SRC_DIR/core/src/macros/mod.rs:LL:COL | ||
|
||
error[E0559]: variant `Foo<_>::Bar` has no field named `x` | ||
--> $DIR/help-show-std-source.rs:18:24 | ||
| | ||
LL | let x = Foo::Bar { x: 1, y: 2 }; | ||
| ^ `Foo<_>::Bar` does not have this field | ||
| | ||
= note: available fields are: `v23` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0107, E0277, E0559. | ||
For more information about an error, try `rustc --explain E0107`. |
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.
I've written up this change in the PR description above, and it should have a similar mechanism to span_note for now.
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 don't think we should be suggesting changes to code the user doesn't own, specially for stdlib. For a suggestion here it should be pointing at the parameters instead (which might be difficult to accomplish).
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.
Yes, this is exactly the problem we need to solve.
This pr is to solve the problem that UI test can't be reproduced to make suggestions in std. Being able to reproduce compiler bugs will make review easier.
This comment was marked as duplicate.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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'm not 100% convinced this is the right problem to solve -- do we actually need the standard library sources, or can we just
s/std/external crate/
?Uh oh!
There was an error while loading. Please reload this page.
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.
Another way is to use two files to represent two crate in ui test to simulate this situation. (If full reproduction is not required)
That is what this comment points out.
#144266 (comment)
But I think it is reasonable to be able to reproduce any bug in the test.
@compiler-errors What do you think?