Skip to content

Commit a929960

Browse files
authored
Rollup merge of #148792 - chenyukang:yukang-fix-file-name, r=Muscraft
Prefer to use file.stable_id over file.name from source map From #148735 (comment) r? `@Muscraft`
2 parents c9158ce + b1542c9 commit a929960

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ impl HumanEmitter {
17041704
}
17051705
// print out the span location and spacer before we print the annotated source
17061706
// to do this, we need to know if this span will be primary
1707-
let is_primary = primary_lo.file.name == annotated_file.file.name;
1707+
let is_primary = primary_lo.file.stable_id == annotated_file.file.stable_id;
17081708
if is_primary {
17091709
let loc = primary_lo.clone();
17101710
if !self.short_message {
@@ -3108,7 +3108,7 @@ impl FileWithAnnotatedLines {
31083108
) {
31093109
for slot in file_vec.iter_mut() {
31103110
// Look through each of our files for the one we're adding to
3111-
if slot.file.name == file.name {
3111+
if slot.file.stable_id == file.stable_id {
31123112
// See if we already have a line for it
31133113
for line_slot in &mut slot.lines {
31143114
if line_slot.line_index == line_index {

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ impl server::Span for Rustc<'_, '_> {
749749
let self_loc = self.psess().source_map().lookup_char_pos(first.lo());
750750
let other_loc = self.psess().source_map().lookup_char_pos(second.lo());
751751

752-
if self_loc.file.name != other_loc.file.name {
752+
if self_loc.file.stable_id != other_loc.file.stable_id {
753753
return None;
754754
}
755755

0 commit comments

Comments
 (0)