@@ -2623,7 +2623,7 @@ pub trait HashStableContext {
26232623 fn span_data_to_lines_and_cols (
26242624 & mut self ,
26252625 span : & SpanData ,
2626- ) -> Option < ( StableSourceFileId , usize , BytePos , usize , BytePos ) > ;
2626+ ) -> Option < ( & SourceFile , usize , BytePos , usize , BytePos ) > ;
26272627 fn hashing_controls ( & self ) -> HashingControls ;
26282628}
26292629
@@ -2659,15 +2659,15 @@ where
26592659 return ;
26602660 }
26612661
2662- if let Some ( parent) = span. parent {
2663- let parent_span = ctx . def_span ( parent) . data_untracked ( ) ;
2664- if parent_span . contains ( span) {
2665- // This span is enclosed in a definition: only hash the relative position.
2666- Hash :: hash ( & TAG_RELATIVE_SPAN , hasher ) ;
2667- Hash :: hash ( & ( span . lo - parent_span . lo ) , hasher) ;
2668- Hash :: hash ( & ( span. hi - parent_span . lo ) , hasher) ;
2669- return ;
2670- }
2662+ let parent = span. parent . map ( |parent| ctx . def_span ( parent ) . data_untracked ( ) ) ;
2663+ if let Some ( parent ) = parent
2664+ && parent . contains ( span)
2665+ {
2666+ // This span is enclosed in a definition: only hash the relative position.
2667+ Hash :: hash ( & TAG_RELATIVE_SPAN , hasher) ;
2668+ Hash :: hash ( & ( span. lo - parent . lo ) , hasher) ;
2669+ Hash :: hash ( & ( span . hi - parent . lo ) , hasher ) ;
2670+ return ;
26712671 }
26722672
26732673 // If this is not an empty or invalid span, we want to hash the last
@@ -2680,25 +2680,19 @@ where
26802680 } ;
26812681
26822682 Hash :: hash ( & TAG_VALID_SPAN , hasher) ;
2683- Hash :: hash ( & file, hasher) ;
2683+ Hash :: hash ( & file. stable_id , hasher) ;
26842684
2685- if let Some ( parent) = span. parent {
2686- let parent_span = ctx. def_span ( parent) . data_untracked ( ) ;
2687- let Some ( ( parent_file, ..) ) = ctx. span_data_to_lines_and_cols ( & parent_span) else {
2688- Hash :: hash ( & TAG_INVALID_SPAN , hasher) ;
2689- return ;
2690- } ;
2691-
2692- if parent_file == file {
2693- // This span is relative to another span in the same file,
2694- // only hash the relative position.
2695- Hash :: hash ( & TAG_RELATIVE_SPAN , hasher) ;
2696- // Use signed difference as `span` may start before `parent_span`,
2697- // for instance attributes start before their item's span.
2698- Hash :: hash ( & ( span. lo . to_u32 ( ) as isize - parent_span. lo . to_u32 ( ) as isize ) , hasher) ;
2699- Hash :: hash ( & ( span. hi . to_u32 ( ) as isize - parent_span. lo . to_u32 ( ) as isize ) , hasher) ;
2700- return ;
2701- }
2685+ if let Some ( parent) = parent
2686+ && file. contains ( parent. lo )
2687+ {
2688+ // This span is relative to another span in the same file,
2689+ // only hash the relative position.
2690+ Hash :: hash ( & TAG_RELATIVE_SPAN , hasher) ;
2691+ // Use signed difference as `span` may start before `parent`,
2692+ // for instance attributes start before their item's span.
2693+ Hash :: hash ( & ( span. lo . to_u32 ( ) as isize - parent. lo . to_u32 ( ) as isize ) , hasher) ;
2694+ Hash :: hash ( & ( span. hi . to_u32 ( ) as isize - parent. lo . to_u32 ( ) as isize ) , hasher) ;
2695+ return ;
27022696 }
27032697
27042698 // Hash both the length and the end location (line/column) of a span. If we
0 commit comments