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