Suggest only Span without source changes when source code is unavailable#144585
Suggest only Span without source changes when source code is unavailable#144585xizheyin wants to merge 1 commit into
Conversation
|
|
|
Some changes occurred in src/tools/compiletest cc @jieyouxu |
|
Looks like jieyou is busy r? compiler |
|
This feels very sus. How does this handle stable vs beta vs nightly vs in-tree std sources? I feel like there's a reason why ui tests don't get to access std sources, which is to prevent different diagnostics depending on availability of std sources, and which std sources? |
Is it possible to normalize the content of the source code and just let us know that the source code is displayed in stderr? I'm curious what kind of impact different versions (stable/nightly/beta/in-tree) would have, I don't know enough about CI. Any examples of this? |
show-std-sourcefef27bc to
1eb0f64
Compare
| help: consider dereferencing here | ||
| --> $SRC_DIR/core/src/macros/mod.rs:LL:COL | ||
|
|
There was a problem hiding this comment.
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.
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.
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.
This comment was marked as duplicate.
Sorry, something went wrong.
There was a problem hiding this comment.
This pr is to solve the problem that UI test can't be reproduced to make suggestions in std.
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/?
There was a problem hiding this comment.
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?
|
For further explanation, I moved the comments here. When fixing the problems listed in #142403, we found that the bug could not be reproduced in ui test. After investigation, I found that span suggestion and span note are not realized in the same way, so I submitted this pr to make std visible in ui tests. In daily use, the source of std should be visible, and execution will fall to the else branch, so these will not be displayed. This new test is a bug recorded in #142403, only for verifying this code change, I will fix it in later pr. |
|
r? @estebank |
|
I think the changes are ok, but I would like to restrict the output at least to nightly and ideally behind a CC @Muscraft for output changes. |
This comment has been minimized.
This comment has been minimized.
|
cc @Muscraft |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
e17fa36 to
d46eda8
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I set it as a new zflag, enabled only during UI tests: if the source code isn't available, then print "span".
The results were as expected; the blessed UI test exposed some existing diagnostic bugs in the compiler, printing the contents of external macros(in std library). However, I think this might need to be fixed in a future PR.
@rustbot ready
| show_suggestions_with_unavailable_source: bool = (false, parse_bool, [UNTRACKED], | ||
| "show span-only suggestions when the source code is unavailable"), |
There was a problem hiding this comment.
I added a option show_suggestions_with_unavailable_source.
| help: check for equality instead of pattern matching | ||
| --> $SRC_DIR/alloc/src/macros.rs:LL:COL |
View all comments
UI tests hide std library sources so diagnostics match what users may see when std sources are unavailable.
In those cases, suggestions whose spans point into std macros cannot be rendered as source patches.
Before this change, if all substitutions for a suggestion were filtered out because the source could not be loaded, the suggestion was dropped entirely. This meant useful help messages could disappear in UI test output, while it will appear in user's terminal.
This adds a
-Zshow-suggestions-with-unavailable-sourceflag and enables it for UI tests. When the annotate-snippet emitter cannot render a suggestion as a patch, but the original suggestion points to unavailable source, it now emits a span-only help instead:cc #139316 (comment)