@@ -2635,7 +2635,7 @@ pub trait HashStableContext {
26352635 fn span_data_to_lines_and_cols (
26362636 & mut self ,
26372637 span : & SpanData ,
2638- ) -> Option < ( StableSourceFileId , usize , BytePos , usize , BytePos ) > ;
2638+ ) -> Option < ( & SourceFile , usize , BytePos , usize , BytePos ) > ;
26392639 fn hashing_controls ( & self ) -> HashingControls ;
26402640}
26412641
@@ -2671,15 +2671,15 @@ where
26712671 return ;
26722672 }
26732673
2674- if let Some ( parent) = span. parent {
2675- let parent_span = ctx . def_span ( parent) . data_untracked ( ) ;
2676- if parent_span . contains ( span) {
2677- // This span is enclosed in a definition: only hash the relative position.
2678- Hash :: hash ( & TAG_RELATIVE_SPAN , hasher ) ;
2679- Hash :: hash ( & ( span . lo - parent_span . lo ) , hasher) ;
2680- Hash :: hash ( & ( span. hi - parent_span . lo ) , hasher) ;
2681- return ;
2682- }
2674+ let parent = span. parent . map ( |parent| ctx . def_span ( parent ) . data_untracked ( ) ) ;
2675+ if let Some ( parent ) = parent
2676+ && parent . contains ( span)
2677+ {
2678+ // This span is enclosed in a definition: only hash the relative position.
2679+ Hash :: hash ( & TAG_RELATIVE_SPAN , hasher) ;
2680+ Hash :: hash ( & ( span. lo - parent . lo ) , hasher) ;
2681+ Hash :: hash ( & ( span . hi - parent . lo ) , hasher ) ;
2682+ return ;
26832683 }
26842684
26852685 // If this is not an empty or invalid span, we want to hash the last
@@ -2692,25 +2692,19 @@ where
26922692 } ;
26932693
26942694 Hash :: hash ( & TAG_VALID_SPAN , hasher) ;
2695- Hash :: hash ( & file, hasher) ;
2695+ Hash :: hash ( & file. stable_id , hasher) ;
26962696
2697- if let Some ( parent) = span. parent {
2698- let parent_span = ctx. def_span ( parent) . data_untracked ( ) ;
2699- let Some ( ( parent_file, ..) ) = ctx. span_data_to_lines_and_cols ( & parent_span) else {
2700- Hash :: hash ( & TAG_INVALID_SPAN , hasher) ;
2701- return ;
2702- } ;
2703-
2704- if parent_file == file {
2705- // This span is relative to another span in the same file,
2706- // only hash the relative position.
2707- Hash :: hash ( & TAG_RELATIVE_SPAN , hasher) ;
2708- // Use signed difference as `span` may start before `parent_span`,
2709- // for instance attributes start before their item's span.
2710- Hash :: hash ( & ( span. lo . to_u32 ( ) as isize - parent_span. lo . to_u32 ( ) as isize ) , hasher) ;
2711- Hash :: hash ( & ( span. hi . to_u32 ( ) as isize - parent_span. lo . to_u32 ( ) as isize ) , hasher) ;
2712- return ;
2713- }
2697+ if let Some ( parent) = parent
2698+ && file. contains ( parent. lo )
2699+ {
2700+ // This span is relative to another span in the same file,
2701+ // only hash the relative position.
2702+ Hash :: hash ( & TAG_RELATIVE_SPAN , hasher) ;
2703+ // Use signed difference as `span` may start before `parent`,
2704+ // for instance attributes start before their item's span.
2705+ Hash :: hash ( & ( span. lo . to_u32 ( ) as isize - parent. lo . to_u32 ( ) as isize ) , hasher) ;
2706+ Hash :: hash ( & ( span. hi . to_u32 ( ) as isize - parent. lo . to_u32 ( ) as isize ) , hasher) ;
2707+ return ;
27142708 }
27152709
27162710 // Hash both the length and the end location (line/column) of a span. If we
0 commit comments