@@ -5,13 +5,16 @@ use rustc_middle::ty::{
55 self , ConstVid , FloatVid , IntVid , RegionVid , Ty , TyCtxt , TyVid , TypeFoldable , TypeFolder ,
66 TypeSuperFoldable , TypeVisitableExt ,
77} ;
8+ use rustc_span:: Span ;
89use tracing:: instrument;
910use ut:: UnifyKey ;
1011
1112use super :: VariableLengths ;
1213use crate :: infer:: type_variable:: TypeVariableOrigin ;
1314use crate :: infer:: unify_key:: { ConstVariableValue , ConstVidKey } ;
14- use crate :: infer:: { ConstVariableOrigin , InferCtxt , RegionVariableOrigin , UnificationTable } ;
15+ use crate :: infer:: {
16+ ConstVariableOrigin , InferCtxt , InferCtxtInner , RegionVariableOrigin , UnificationTable ,
17+ } ;
1518
1619fn vars_since_snapshot < ' tcx , T > (
1720 table : & UnificationTable < ' _ , ' tcx , T > ,
2427 T :: from_index ( snapshot_var_len as u32 ) ..T :: from_index ( table. len ( ) as u32 )
2528}
2629
30+ fn float_vars_since_snapshot (
31+ inner : & mut InferCtxtInner < ' _ > ,
32+ snapshot_var_len : usize ,
33+ ) -> ( Range < FloatVid > , Vec < Span > ) {
34+ let range = vars_since_snapshot ( & inner. float_unification_table ( ) , snapshot_var_len) ;
35+ ( range. clone ( ) , range. map ( |index| inner. float_origin_span_storage [ index] ) . collect ( ) )
36+ }
37+
2738fn const_vars_since_snapshot < ' tcx > (
2839 table : & mut UnificationTable < ' _ , ' tcx , ConstVidKey < ' tcx > > ,
2940 snapshot_var_len : usize ,
@@ -128,7 +139,7 @@ struct SnapshotVarData {
128139 region_vars : ( Range < RegionVid > , Vec < RegionVariableOrigin > ) ,
129140 type_vars : ( Range < TyVid > , Vec < TypeVariableOrigin > ) ,
130141 int_vars : Range < IntVid > ,
131- float_vars : Range < FloatVid > ,
142+ float_vars : ( Range < FloatVid > , Vec < Span > ) ,
132143 const_vars : ( Range < ConstVid > , Vec < ConstVariableOrigin > ) ,
133144}
134145
@@ -141,8 +152,7 @@ impl SnapshotVarData {
141152 let type_vars = inner. type_variables ( ) . vars_since_snapshot ( vars_pre_snapshot. type_var_len ) ;
142153 let int_vars =
143154 vars_since_snapshot ( & inner. int_unification_table ( ) , vars_pre_snapshot. int_var_len ) ;
144- let float_vars =
145- vars_since_snapshot ( & inner. float_unification_table ( ) , vars_pre_snapshot. float_var_len ) ;
155+ let float_vars = float_vars_since_snapshot ( & mut inner, vars_pre_snapshot. float_var_len ) ;
146156
147157 let const_vars = const_vars_since_snapshot (
148158 & mut inner. const_unification_table ( ) ,
@@ -156,7 +166,7 @@ impl SnapshotVarData {
156166 region_vars. 0 . is_empty ( )
157167 && type_vars. 0 . is_empty ( )
158168 && int_vars. is_empty ( )
159- && float_vars. is_empty ( )
169+ && float_vars. 0 . is_empty ( )
160170 && const_vars. 0 . is_empty ( )
161171 }
162172}
@@ -201,8 +211,10 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx> {
201211 }
202212 }
203213 ty:: FloatVar ( vid) => {
204- if self . snapshot_vars . float_vars . contains ( & vid) {
205- self . infcx . next_float_var ( )
214+ if self . snapshot_vars . float_vars . 0 . contains ( & vid) {
215+ let idx = vid. as_usize ( ) - self . snapshot_vars . float_vars . 0 . start . as_usize ( ) ;
216+ let span = self . snapshot_vars . float_vars . 1 [ idx] ;
217+ self . infcx . next_float_var ( span)
206218 } else {
207219 ty
208220 }
0 commit comments