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