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
|
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)