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
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,9 @@ impl HumanEmitter {
// file name, saving in verbosity, but if it *isn't* we do need it, otherwise we're
// telling users to make a change but not clarifying *where*.
let loc = sm.lookup_char_pos(parts[0].span.lo());
if loc.file.name != sm.span_to_filename(span) && loc.file.name.is_real() {
if (span.is_dummy() || loc.file.name != sm.span_to_filename(span))
&& loc.file.name.is_real()
{
// --> file.rs:line:col
// |
let arrow = self.file_start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ error[E0259]: the name `std` is defined multiple times
|
= note: `std` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
--> $DIR/resolve-conflict-extern-crate-vs-extern-crate.rs:1:17
|
LL | extern crate std as other_std;
| ++++++++++++
Expand Down
Loading