@@ -2634,7 +2634,7 @@ pub trait HashStableContext {
2634
2634
fn span_data_to_lines_and_cols (
2635
2635
& mut self ,
2636
2636
span : & SpanData ,
2637
- ) -> Option < ( StableSourceFileId , usize , BytePos , usize , BytePos ) > ;
2637
+ ) -> Option < ( & SourceFile , usize , BytePos , usize , BytePos ) > ;
2638
2638
fn hashing_controls ( & self ) -> HashingControls ;
2639
2639
}
2640
2640
@@ -2670,15 +2670,15 @@ where
2670
2670
return ;
2671
2671
}
2672
2672
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 ;
2682
2682
}
2683
2683
2684
2684
// If this is not an empty or invalid span, we want to hash the last
@@ -2691,25 +2691,19 @@ where
2691
2691
} ;
2692
2692
2693
2693
Hash :: hash ( & TAG_VALID_SPAN , hasher) ;
2694
- Hash :: hash ( & file, hasher) ;
2694
+ Hash :: hash ( & file. stable_id , hasher) ;
2695
2695
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 ;
2713
2707
}
2714
2708
2715
2709
// Hash both the length and the end location (line/column) of a span. If we
0 commit comments