From c8fac7779e75c16cfb49d7bb95809dbb6e19d5f7 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Thu, 26 Jun 2025 18:21:47 -0600 Subject: fix: Emit suggestion filename if primary diagnostic span is dummy --- compiler/rustc_errors/src/emitter.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_errors/src') diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index e333de4b660..3f5872f34a6 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -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(); -- cgit 1.4.1-3-g733a5