@@ -193,25 +193,17 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
193193 . unwrap ( )
194194 . borrow_region_constraints ( )
195195 . opportunistic_resolve_var ( self . tcx , vid) ;
196- let info = CanonicalVarInfo {
197- kind : CanonicalVarKind :: Region ,
198- } ;
199196 debug ! (
200197 "canonical: region var found with vid {:?}, \
201198 opportunistically resolved to {:?}",
202199 vid, r
203200 ) ;
204- let cvar = self . canonical_var ( info, r. into ( ) ) ;
205- self . tcx ( ) . mk_region ( ty:: ReCanonical ( cvar) )
201+ self . canonical_var_for_region ( r)
206202 }
207203
208204 ty:: ReStatic => {
209205 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)
215207 } else {
216208 r
217209 }
@@ -224,11 +216,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
224216 | ty:: ReEmpty
225217 | ty:: ReErased => {
226218 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)
232220 } else {
233221 r
234222 }
@@ -414,6 +402,14 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
414402 }
415403 }
416404
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+
417413 /// Given a type variable `ty_var` of the given kind, first check
418414 /// if `ty_var` is bound to anything; if so, canonicalize
419415 /// *that*. Otherwise, create a new canonical variable for
0 commit comments