Skip to content

fix: Emit suggestion filename if primary diagnostic span is dummy #143264

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
merged 1 commit into from
Jul 1, 2025

Conversation

Muscraft
Copy link
Member

@Muscraft Muscraft commented Jul 1, 2025

While working on using annotate-snippets as rustc's emitter, I came across tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr, which lacked a filename for both the annotation and the suggestion, which seemed like a bug to me. After some investigation, I found that this is happening because the primary span is a dummy, so its filename doesn't get output, and its filename matches the one for the suggestion, so the suggestion's filename doesn't get output. To fix this issue, I made it so that the filename for a suggestion will get output if the primary span is a dummy.

@rustbot
Copy link
Collaborator

rustbot commented Jul 1, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 1, 2025
@compiler-errors
Copy link
Member

Yeah, part of this comes from the fact that we don't distinguish "dummy span" from "actually we kinda want to point to the beginning of the root module" (or, sometimes we just have nowhere better to point).

This change seems fine and is low impact anyways so LGTM

r? compiler-errors @bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 1, 2025

📌 Commit c8fac77 has been approved by compiler-errors

It is now in the queue for this repository.

@rustbot rustbot assigned compiler-errors and unassigned SparrowLii Jul 1, 2025
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 1, 2025
bors added a commit that referenced this pull request Jul 1, 2025
Rollup of 8 pull requests

Successful merges:

 - #143125 (Disable f16 on Aarch64 without neon for llvm < 20.1.1)
 - #143156 (inherit `#[align]` from trait method prototypes)
 - #143178 (rustdoc default faviocon)
 - #143234 (Replace `ItemCtxt::report_placeholder_type_error` match with a call to `TyCtxt::def_descr`)
 - #143245 (mbe: Add tests and restructure metavariable expressions)
 - #143257 (Upgrade dependencies in run-make-support)
 - #143263 (linkify CodeSuggestion in doc comments)
 - #143264 (fix: Emit suggestion filename if primary diagnostic span is dummy)

Failed merges:

 - #143251 (bootstrap: add build.tidy-extra-checks option)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3944c8c into rust-lang:master Jul 1, 2025
10 checks passed
rust-timer added a commit that referenced this pull request Jul 1, 2025
Rollup merge of #143264 - Muscraft:fix-suggestion-filename, r=compiler-errors

fix: Emit suggestion filename if primary diagnostic span is dummy

While working on using `annotate-snippets` as `rustc`'s emitter, I came across [`tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr`](https://github.com/rust-lang/rust/blob/b03b3a7ec92682be2917540b679478d41c95a30c/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr), which lacked a filename for both the annotation and the suggestion, which seemed like a bug to me. After some investigation, I found that this is happening because the primary span is a dummy, so its filename doesn't get output, and its filename matches the one for the suggestion, so the suggestion's filename doesn't get output. To fix this issue, I made it so that the filename for a suggestion will get output if the primary span is a dummy.
@rustbot rustbot added this to the 1.90.0 milestone Jul 1, 2025
@Muscraft Muscraft deleted the fix-suggestion-filename branch July 1, 2025 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants