@@ -193,25 +193,17 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
193
193
. unwrap ( )
194
194
. borrow_region_constraints ( )
195
195
. opportunistic_resolve_var ( self . tcx , vid) ;
196
- let info = CanonicalVarInfo {
197
- kind : CanonicalVarKind :: Region ,
198
- } ;
199
196
debug ! (
200
197
"canonical: region var found with vid {:?}, \
201
198
opportunistically resolved to {:?}",
202
199
vid, r
203
200
) ;
204
- let cvar = self . canonical_var ( info, r. into ( ) ) ;
205
- self . tcx ( ) . mk_region ( ty:: ReCanonical ( cvar) )
201
+ self . canonical_var_for_region ( r)
206
202
}
207
203
208
204
ty:: ReStatic => {
209
205
if self . canonicalize_region_mode . static_region {
210
- let info = CanonicalVarInfo {
211
- kind : CanonicalVarKind :: Region ,
212
- } ;
213
- let cvar = self . canonical_var ( info, r. into ( ) ) ;
214
- self . tcx ( ) . mk_region ( ty:: ReCanonical ( cvar) )
206
+ self . canonical_var_for_region ( r)
215
207
} else {
216
208
r
217
209
}
@@ -224,11 +216,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
224
216
| ty:: ReEmpty
225
217
| ty:: ReErased => {
226
218
if self . canonicalize_region_mode . other_free_regions {
227
- let info = CanonicalVarInfo {
228
- kind : CanonicalVarKind :: Region ,
229
- } ;
230
- let cvar = self . canonical_var ( info, r. into ( ) ) ;
231
- self . tcx ( ) . mk_region ( ty:: ReCanonical ( cvar) )
219
+ self . canonical_var_for_region ( r)
232
220
} else {
233
221
r
234
222
}
@@ -414,6 +402,14 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
414
402
}
415
403
}
416
404
405
+ fn canonical_var_for_region ( & mut self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
406
+ let info = CanonicalVarInfo {
407
+ kind : CanonicalVarKind :: Region ,
408
+ } ;
409
+ let cvar = self . canonical_var ( info, r. into ( ) ) ;
410
+ self . tcx ( ) . mk_region ( ty:: ReCanonical ( cvar) )
411
+ }
412
+
417
413
/// Given a type variable `ty_var` of the given kind, first check
418
414
/// if `ty_var` is bound to anything; if so, canonicalize
419
415
/// *that*. Otherwise, create a new canonical variable for
0 commit comments