@@ -418,15 +418,14 @@ where
418418 Ok ( resolved_value)
419419}
420420
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 > (
426425 tcx : TyCtxt < ' tcx > ,
427426 predicates : Vec < ty:: Predicate < ' tcx > > ,
428427) -> bool {
429- debug ! ( "normalize_and_test_predicates (predicates={:?})" , predicates) ;
428+ debug ! ( "impossible_predicates (predicates={:?})" , predicates) ;
430429
431430 let result = tcx. infer_ctxt ( ) . enter ( |infcx| {
432431 let param_env = ty:: ParamEnv :: reveal_all ( ) ;
@@ -443,22 +442,23 @@ pub fn normalize_and_test_predicates<'tcx>(
443442 fulfill_cx. register_predicate_obligation ( & infcx, obligation) ;
444443 }
445444
446- fulfill_cx. select_all_or_error ( & infcx) . is_ok ( )
445+ fulfill_cx. select_all_or_error ( & infcx) . is_err ( )
447446 } ) ;
448- debug ! ( "normalize_and_test_predicates (predicates={:?}) = {:?}" , predicates, result) ;
447+ debug ! ( "impossible_predicates (predicates={:?}) = {:?}" , predicates, result) ;
449448 result
450449}
451450
452- fn substitute_normalize_and_test_predicates < ' tcx > (
451+ fn subst_and_check_impossible_predicates < ' tcx > (
453452 tcx : TyCtxt < ' tcx > ,
454453 key : ( DefId , SubstsRef < ' tcx > ) ,
455454) -> bool {
456- debug ! ( "substitute_normalize_and_test_predicates (key={:?})" , key) ;
455+ debug ! ( "subst_and_check_impossible_predicates (key={:?})" , key) ;
457456
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) ;
460460
461- debug ! ( "substitute_normalize_and_test_predicates (key={:?}) = {:?}" , key, result) ;
461+ debug ! ( "subst_and_check_impossible_predicates (key={:?}) = {:?}" , key, result) ;
462462 result
463463}
464464
@@ -510,7 +510,7 @@ fn vtable_methods<'tcx>(
510510 // Note that this method could then never be called, so we
511511 // do not want to try and codegen it, in that case (see #23435).
512512 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 ) {
514514 debug ! ( "vtable_methods: predicates do not hold" ) ;
515515 return None ;
516516 }
@@ -558,8 +558,8 @@ pub fn provide(providers: &mut ty::query::Providers) {
558558 specializes : specialize:: specializes,
559559 codegen_fulfill_obligation : codegen:: codegen_fulfill_obligation,
560560 vtable_methods,
561- substitute_normalize_and_test_predicates,
562561 type_implements_trait,
562+ subst_and_check_impossible_predicates,
563563 ..* providers
564564 } ;
565565}
0 commit comments