@@ -418,15 +418,14 @@ where
418
418
Ok ( resolved_value)
419
419
}
420
420
421
- /// Normalizes the predicates and checks whether they hold in an empty
422
- /// environment. If this returns false, then either normalize
423
- /// encountered an error or one of the predicates did not hold. Used
424
- /// when creating vtables to check for unsatisfiable methods.
425
- pub fn normalize_and_test_predicates < ' tcx > (
421
+ /// Normalizes the predicates and checks whether they hold in an empty environment. If this
422
+ /// returns true, then either normalize encountered an error or one of the predicates did not
423
+ /// hold. Used when creating vtables to check for unsatisfiable methods.
424
+ pub fn impossible_predicates < ' tcx > (
426
425
tcx : TyCtxt < ' tcx > ,
427
426
predicates : Vec < ty:: Predicate < ' tcx > > ,
428
427
) -> bool {
429
- debug ! ( "normalize_and_test_predicates (predicates={:?})" , predicates) ;
428
+ debug ! ( "impossible_predicates (predicates={:?})" , predicates) ;
430
429
431
430
let result = tcx. infer_ctxt ( ) . enter ( |infcx| {
432
431
let param_env = ty:: ParamEnv :: reveal_all ( ) ;
@@ -443,22 +442,23 @@ pub fn normalize_and_test_predicates<'tcx>(
443
442
fulfill_cx. register_predicate_obligation ( & infcx, obligation) ;
444
443
}
445
444
446
- fulfill_cx. select_all_or_error ( & infcx) . is_ok ( )
445
+ fulfill_cx. select_all_or_error ( & infcx) . is_err ( )
447
446
} ) ;
448
- debug ! ( "normalize_and_test_predicates (predicates={:?}) = {:?}" , predicates, result) ;
447
+ debug ! ( "impossible_predicates (predicates={:?}) = {:?}" , predicates, result) ;
449
448
result
450
449
}
451
450
452
- fn substitute_normalize_and_test_predicates < ' tcx > (
451
+ fn subst_and_check_impossible_predicates < ' tcx > (
453
452
tcx : TyCtxt < ' tcx > ,
454
453
key : ( DefId , SubstsRef < ' tcx > ) ,
455
454
) -> bool {
456
- debug ! ( "substitute_normalize_and_test_predicates (key={:?})" , key) ;
455
+ debug ! ( "subst_and_check_impossible_predicates (key={:?})" , key) ;
457
456
458
- let predicates = tcx. predicates_of ( key. 0 ) . instantiate ( tcx, key. 1 ) . predicates ;
459
- let result = normalize_and_test_predicates ( tcx, predicates) ;
457
+ let mut predicates = tcx. predicates_of ( key. 0 ) . instantiate ( tcx, key. 1 ) . predicates ;
458
+ predicates. retain ( |predicate| !predicate. needs_subst ( ) ) ;
459
+ let result = impossible_predicates ( tcx, predicates) ;
460
460
461
- debug ! ( "substitute_normalize_and_test_predicates (key={:?}) = {:?}" , key, result) ;
461
+ debug ! ( "subst_and_check_impossible_predicates (key={:?}) = {:?}" , key, result) ;
462
462
result
463
463
}
464
464
@@ -510,7 +510,7 @@ fn vtable_methods<'tcx>(
510
510
// Note that this method could then never be called, so we
511
511
// do not want to try and codegen it, in that case (see #23435).
512
512
let predicates = tcx. predicates_of ( def_id) . instantiate_own ( tcx, substs) ;
513
- if ! normalize_and_test_predicates ( tcx, predicates. predicates ) {
513
+ if impossible_predicates ( tcx, predicates. predicates ) {
514
514
debug ! ( "vtable_methods: predicates do not hold" ) ;
515
515
return None ;
516
516
}
@@ -558,8 +558,8 @@ pub fn provide(providers: &mut ty::query::Providers) {
558
558
specializes : specialize:: specializes,
559
559
codegen_fulfill_obligation : codegen:: codegen_fulfill_obligation,
560
560
vtable_methods,
561
- substitute_normalize_and_test_predicates,
562
561
type_implements_trait,
562
+ subst_and_check_impossible_predicates,
563
563
..* providers
564
564
} ;
565
565
}
0 commit comments