@@ -5,14 +5,17 @@ use rustc_middle::ty::{
5
5
self , ConstVid , FloatVid , IntVid , RegionVid , Ty , TyCtxt , TyVid , TypeFoldable , TypeFolder ,
6
6
TypeSuperFoldable ,
7
7
} ;
8
+ use rustc_span:: Span ;
8
9
use rustc_type_ir:: TypeVisitableExt ;
9
10
use tracing:: instrument;
10
11
use ut:: UnifyKey ;
11
12
12
13
use super :: VariableLengths ;
13
14
use crate :: infer:: type_variable:: TypeVariableOrigin ;
14
15
use 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
+ } ;
16
19
17
20
fn vars_since_snapshot < ' tcx , T > (
18
21
table : & UnificationTable < ' _ , ' tcx , T > ,
25
28
T :: from_index ( snapshot_var_len as u32 ) ..T :: from_index ( table. len ( ) as u32 )
26
29
}
27
30
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
+
28
39
fn const_vars_since_snapshot < ' tcx > (
29
40
table : & mut UnificationTable < ' _ , ' tcx , ConstVidKey < ' tcx > > ,
30
41
snapshot_var_len : usize ,
@@ -128,7 +139,7 @@ struct SnapshotVarData {
128
139
region_vars : ( Range < RegionVid > , Vec < RegionVariableOrigin > ) ,
129
140
type_vars : ( Range < TyVid > , Vec < TypeVariableOrigin > ) ,
130
141
int_vars : Range < IntVid > ,
131
- float_vars : Range < FloatVid > ,
142
+ float_vars : ( Range < FloatVid > , Vec < Span > ) ,
132
143
const_vars : ( Range < ConstVid > , Vec < ConstVariableOrigin > ) ,
133
144
}
134
145
@@ -141,8 +152,7 @@ impl SnapshotVarData {
141
152
let type_vars = inner. type_variables ( ) . vars_since_snapshot ( vars_pre_snapshot. type_var_len ) ;
142
153
let int_vars =
143
154
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 ) ;
146
156
147
157
let const_vars = const_vars_since_snapshot (
148
158
& mut inner. const_unification_table ( ) ,
@@ -156,7 +166,7 @@ impl SnapshotVarData {
156
166
region_vars. 0 . is_empty ( )
157
167
&& type_vars. 0 . is_empty ( )
158
168
&& int_vars. is_empty ( )
159
- && float_vars. is_empty ( )
169
+ && float_vars. 0 . is_empty ( )
160
170
&& const_vars. 0 . is_empty ( )
161
171
}
162
172
}
@@ -201,8 +211,10 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx> {
201
211
}
202
212
}
203
213
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)
206
218
} else {
207
219
ty
208
220
}
0 commit comments