@@ -2597,10 +2597,7 @@ pub trait HashStableContext {
25972597 /// we don't have easy access to a `Session`
25982598 fn unstable_opts_incremental_ignore_spans ( & self ) -> bool ;
25992599 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 > ;
26042601 fn hashing_controls ( & self ) -> HashingControls ;
26052602}
26062603
@@ -2641,6 +2638,7 @@ where
26412638 if def_span. contains ( span) {
26422639 // This span is enclosed in a definition: only hash the relative position.
26432640 Hash :: hash ( & TAG_RELATIVE_SPAN , hasher) ;
2641+ parent. hash_stable ( ctx, hasher) ;
26442642 ( span. lo - def_span. lo ) . to_u32 ( ) . hash_stable ( ctx, hasher) ;
26452643 ( span. hi - def_span. lo ) . to_u32 ( ) . hash_stable ( ctx, hasher) ;
26462644 return ;
@@ -2650,32 +2648,15 @@ where
26502648 // If this is not an empty or invalid span, we want to hash the last
26512649 // position that belongs to it, as opposed to hashing the first
26522650 // 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 {
26552652 Hash :: hash ( & TAG_INVALID_SPAN , hasher) ;
26562653 return ;
26572654 } ;
26582655
26592656 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) ;
26792660 }
26802661}
26812662
0 commit comments