Skip to content

Commit c8fac77

Browse files
committed
fix: Emit suggestion filename if primary diagnostic span is dummy
1 parent f26e580 commit c8fac77

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,9 @@ impl HumanEmitter {
20782078
// file name, saving in verbosity, but if it *isn't* we do need it, otherwise we're
20792079
// telling users to make a change but not clarifying *where*.
20802080
let loc = sm.lookup_char_pos(parts[0].span.lo());
2081-
if loc.file.name != sm.span_to_filename(span) && loc.file.name.is_real() {
2081+
if (span.is_dummy() || loc.file.name != sm.span_to_filename(span))
2082+
&& loc.file.name.is_real()
2083+
{
20822084
// --> file.rs:line:col
20832085
// |
20842086
let arrow = self.file_start();

tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ error[E0259]: the name `std` is defined multiple times
22
|
33
= note: `std` must be defined only once in the type namespace of this module
44
help: you can use `as` to change the binding name of the import
5+
--> $DIR/resolve-conflict-extern-crate-vs-extern-crate.rs:1:17
56
|
67
LL | extern crate std as other_std;
78
| ++++++++++++

0 commit comments

Comments
 (0)