fix: Emit suggestion filename if primary diagnostic span is dummy

This commit is contained in:
Scott Schafer
2025-06-26 18:21:47 -06:00
parent f26e580230
commit c8fac7779e
2 changed files with 4 additions and 1 deletions

View File

@@ -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();