@@ -6,13 +6,16 @@ use rustc_middle::ty::{
66 self , ConstVid , FloatVid , IntVid , RegionVid , Ty , TyCtxt , TyVid , TypeFoldable , TypeFolder ,
77 TypeSuperFoldable , TypeVisitableExt ,
88} ;
9+ use rustc_span:: Span ;
910use tracing:: instrument;
1011use ut:: UnifyKey ;
1112
1213use super :: VariableLengths ;
1314use crate :: infer:: type_variable:: TypeVariableOrigin ;
1415use crate :: infer:: unify_key:: { ConstVariableValue , ConstVidKey } ;
15- use crate :: infer:: { ConstVariableOrigin , InferCtxt , RegionVariableOrigin , UnificationTable } ;
16+ use crate :: infer:: {
17+ ConstVariableOrigin , InferCtxt , InferCtxtInner , RegionVariableOrigin , UnificationTable ,
18+ } ;
1619
1720fn vars_since_snapshot < ' tcx , T > (
1821 table : & UnificationTable < ' _ , ' tcx , T > ,
2528 T :: from_index ( snapshot_var_len as u32 ) ..T :: from_index ( table. len ( ) as u32 )
2629}
2730
31+ fn float_vars_since_snapshot (
32+ inner : & mut InferCtxtInner < ' _ > ,
33+ snapshot_var_len : usize ,
34+ ) -> ( Range < FloatVid > , Vec < Span > ) {
35+ let range = vars_since_snapshot ( & inner. float_unification_table ( ) , snapshot_var_len) ;
36+ ( range. clone ( ) , range. map ( |index| inner. float_origin_span_storage [ index] ) . collect ( ) )
37+ }
38+
2839fn const_vars_since_snapshot < ' tcx > (
2940 table : & mut UnificationTable < ' _ , ' tcx , ConstVidKey < ' tcx > > ,
3041 snapshot_var_len : usize ,
@@ -130,7 +141,7 @@ struct SnapshotVarData<'tcx> {
130141 region_vars : ( Range < RegionVid > , Vec < RegionVariableOrigin < ' tcx > > ) ,
131142 type_vars : ( Range < TyVid > , Vec < TypeVariableOrigin > ) ,
132143 int_vars : Range < IntVid > ,
133- float_vars : Range < FloatVid > ,
144+ float_vars : ( Range < FloatVid > , Vec < Span > ) ,
134145 const_vars : ( Range < ConstVid > , Vec < ConstVariableOrigin > ) ,
135146}
136147
@@ -143,8 +154,7 @@ impl<'tcx> SnapshotVarData<'tcx> {
143154 let type_vars = inner. type_variables ( ) . vars_since_snapshot ( vars_pre_snapshot. type_var_len ) ;
144155 let int_vars =
145156 vars_since_snapshot ( & inner. int_unification_table ( ) , vars_pre_snapshot. int_var_len ) ;
146- let float_vars =
147- vars_since_snapshot ( & inner. float_unification_table ( ) , vars_pre_snapshot. float_var_len ) ;
157+ let float_vars = float_vars_since_snapshot ( & mut inner, vars_pre_snapshot. float_var_len ) ;
148158
149159 let const_vars = const_vars_since_snapshot (
150160 & mut inner. const_unification_table ( ) ,
@@ -158,7 +168,7 @@ impl<'tcx> SnapshotVarData<'tcx> {
158168 region_vars. 0 . is_empty ( )
159169 && type_vars. 0 . is_empty ( )
160170 && int_vars. is_empty ( )
161- && float_vars. is_empty ( )
171+ && float_vars. 0 . is_empty ( )
162172 && const_vars. 0 . is_empty ( )
163173 }
164174}
@@ -203,8 +213,10 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx> {
203213 }
204214 }
205215 ty:: FloatVar ( vid) => {
206- if self . snapshot_vars . float_vars . contains ( & vid) {
207- self . infcx . next_float_var ( )
216+ if self . snapshot_vars . float_vars . 0 . contains ( & vid) {
217+ let idx = vid. as_usize ( ) - self . snapshot_vars . float_vars . 0 . start . as_usize ( ) ;
218+ let span = self . snapshot_vars . float_vars . 1 [ idx] ;
219+ self . infcx . next_float_var ( span)
208220 } else {
209221 ty
210222 }
0 commit comments