@@ -2623,7 +2623,7 @@ pub trait HashStableContext {
2623
2623
fn span_data_to_lines_and_cols (
2624
2624
& mut self ,
2625
2625
span : & SpanData ,
2626
- ) -> Option < ( StableSourceFileId , usize , BytePos , usize , BytePos ) > ;
2626
+ ) -> Option < ( & SourceFile , usize , BytePos , usize , BytePos ) > ;
2627
2627
fn hashing_controls ( & self ) -> HashingControls ;
2628
2628
}
2629
2629
@@ -2659,15 +2659,15 @@ where
2659
2659
return ;
2660
2660
}
2661
2661
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 ;
2671
2671
}
2672
2672
2673
2673
// If this is not an empty or invalid span, we want to hash the last
@@ -2680,25 +2680,19 @@ where
2680
2680
} ;
2681
2681
2682
2682
Hash :: hash ( & TAG_VALID_SPAN , hasher) ;
2683
- Hash :: hash ( & file, hasher) ;
2683
+ Hash :: hash ( & file. stable_id , hasher) ;
2684
2684
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 ;
2702
2696
}
2703
2697
2704
2698
// Hash both the length and the end location (line/column) of a span. If we
0 commit comments