@@ -118,10 +118,6 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
118
118
self . cx . infcx . tcx
119
119
}
120
120
121
- fn infcx ( & self ) -> & ' a InferCtxt < ' a , ' gcx , ' tcx > {
122
- self . cx . infcx
123
- }
124
-
125
121
fn sanitize_type ( & mut self , parent : & fmt:: Debug , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
126
122
if ty. needs_infer ( ) || ty. has_escaping_regions ( ) || ty. references_error ( ) {
127
123
span_mirbug_and_err ! ( self , parent, "bad type {:?}" , ty)
@@ -292,30 +288,11 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
292
288
} ;
293
289
294
290
if let Some ( field) = variant. fields . get ( field. index ( ) ) {
295
- Ok ( self . normalize ( field. ty ( tcx, substs) ) )
291
+ Ok ( self . cx . normalize ( & field. ty ( tcx, substs) ) )
296
292
} else {
297
293
Err ( FieldAccessError :: OutOfRange { field_count : variant. fields . len ( ) } )
298
294
}
299
295
}
300
-
301
- fn normalize ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
302
- let infcx = self . infcx ( ) ;
303
- let mut selcx = traits:: SelectionContext :: new ( infcx) ;
304
- let cause = traits:: ObligationCause :: misc ( self . last_span , 0 ) ;
305
- let traits:: Normalized { value : ty, obligations } =
306
- traits:: normalize ( & mut selcx, cause, & ty) ;
307
-
308
- debug ! ( "normalize: ty={:?} obligations={:?}" ,
309
- ty,
310
- obligations) ;
311
-
312
- let mut fulfill_cx = & mut self . cx . fulfillment_cx ;
313
- for obligation in obligations {
314
- fulfill_cx. register_predicate_obligation ( infcx, obligation) ;
315
- }
316
-
317
- ty
318
- }
319
296
}
320
297
321
298
pub struct TypeChecker < ' a , ' gcx : ' a +' tcx , ' tcx : ' a > {
@@ -373,7 +350,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
373
350
}
374
351
}
375
352
376
- fn check_terminator ( & self ,
353
+ fn check_terminator ( & mut self ,
377
354
mir : & Mir < ' tcx > ,
378
355
term : & Terminator < ' tcx > ) {
379
356
debug ! ( "check_terminator: {:?}" , term) ;
@@ -431,6 +408,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
431
408
}
432
409
} ;
433
410
let sig = tcx. erase_late_bound_regions ( & func_ty. sig ) ;
411
+ let sig = self . normalize ( & sig) ;
434
412
self . check_call_dest ( mir, term, & sig, destination) ;
435
413
436
414
if self . is_box_free ( func) {
@@ -558,6 +536,27 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
558
536
}
559
537
}
560
538
539
+
540
+ fn normalize < T > ( & mut self , value : & T ) -> T
541
+ where T : fmt:: Debug + TypeFoldable < ' tcx >
542
+ {
543
+ let mut selcx = traits:: SelectionContext :: new ( self . infcx ) ;
544
+ let cause = traits:: ObligationCause :: misc ( self . last_span , 0 ) ;
545
+ let traits:: Normalized { value, obligations } =
546
+ traits:: normalize ( & mut selcx, cause, value) ;
547
+
548
+ debug ! ( "normalize: value={:?} obligations={:?}" ,
549
+ value,
550
+ obligations) ;
551
+
552
+ let mut fulfill_cx = & mut self . fulfillment_cx ;
553
+ for obligation in obligations {
554
+ fulfill_cx. register_predicate_obligation ( self . infcx , obligation) ;
555
+ }
556
+
557
+ value
558
+ }
559
+
561
560
fn verify_obligations ( & mut self , mir : & Mir < ' tcx > ) {
562
561
self . last_span = mir. span ;
563
562
if let Err ( e) = self . fulfillment_cx . select_all_or_error ( self . infcx ) {
0 commit comments