@@ -2597,10 +2597,7 @@ pub trait HashStableContext {
2597
2597
/// we don't have easy access to a `Session`
2598
2598
fn unstable_opts_incremental_ignore_spans ( & self ) -> bool ;
2599
2599
fn def_span ( & self , def_id : LocalDefId ) -> Span ;
2600
- fn span_data_to_lines_and_cols (
2601
- & mut self ,
2602
- span : & SpanData ,
2603
- ) -> Option < ( Arc < SourceFile > , usize , BytePos , usize , BytePos ) > ;
2600
+ fn span_to_file ( & mut self , span : & SpanData ) -> Option < StableSourceFileId > ;
2604
2601
fn hashing_controls ( & self ) -> HashingControls ;
2605
2602
}
2606
2603
@@ -2641,6 +2638,7 @@ where
2641
2638
if def_span. contains ( span) {
2642
2639
// This span is enclosed in a definition: only hash the relative position.
2643
2640
Hash :: hash ( & TAG_RELATIVE_SPAN , hasher) ;
2641
+ parent. hash_stable ( ctx, hasher) ;
2644
2642
( span. lo - def_span. lo ) . to_u32 ( ) . hash_stable ( ctx, hasher) ;
2645
2643
( span. hi - def_span. lo ) . to_u32 ( ) . hash_stable ( ctx, hasher) ;
2646
2644
return ;
@@ -2650,32 +2648,15 @@ where
2650
2648
// If this is not an empty or invalid span, we want to hash the last
2651
2649
// position that belongs to it, as opposed to hashing the first
2652
2650
// position past it.
2653
- let Some ( ( file, line_lo, col_lo, line_hi, col_hi) ) = ctx. span_data_to_lines_and_cols ( & span)
2654
- else {
2651
+ let Some ( stable_id) = ctx. span_to_file ( & span) else {
2655
2652
Hash :: hash ( & TAG_INVALID_SPAN , hasher) ;
2656
2653
return ;
2657
2654
} ;
2658
2655
2659
2656
Hash :: hash ( & TAG_VALID_SPAN , hasher) ;
2660
- Hash :: hash ( & file. stable_id , hasher) ;
2661
-
2662
- // Hash both the length and the end location (line/column) of a span. If we
2663
- // hash only the length, for example, then two otherwise equal spans with
2664
- // different end locations will have the same hash. This can cause a problem
2665
- // during incremental compilation wherein a previous result for a query that
2666
- // depends on the end location of a span will be incorrectly reused when the
2667
- // end location of the span it depends on has changed (see issue #74890). A
2668
- // similar analysis applies if some query depends specifically on the length
2669
- // of the span, but we only hash the end location. So hash both.
2670
-
2671
- let col_lo_trunc = ( col_lo. 0 as u64 ) & 0xFF ;
2672
- let line_lo_trunc = ( ( line_lo as u64 ) & 0xFF_FF_FF ) << 8 ;
2673
- let col_hi_trunc = ( col_hi. 0 as u64 ) & 0xFF << 32 ;
2674
- let line_hi_trunc = ( ( line_hi as u64 ) & 0xFF_FF_FF ) << 40 ;
2675
- let col_line = col_lo_trunc | line_lo_trunc | col_hi_trunc | line_hi_trunc;
2676
- let len = ( span. hi - span. lo ) . 0 ;
2677
- Hash :: hash ( & col_line, hasher) ;
2678
- Hash :: hash ( & len, hasher) ;
2657
+ Hash :: hash ( & stable_id, hasher) ;
2658
+ Hash :: hash ( & span. lo . 0 , hasher) ;
2659
+ Hash :: hash ( & span. hi . 0 , hasher) ;
2679
2660
}
2680
2661
}
2681
2662
0 commit comments