@@ -432,6 +432,9 @@ pub fn impossible_predicates<'tcx>(
432
432
debug ! ( "impossible_predicates(predicates={:?})" , predicates) ;
433
433
434
434
let result = tcx. infer_ctxt ( ) . enter ( |infcx| {
435
+ // HACK: Set tainted by errors to gracefully exit in case of overflow.
436
+ infcx. set_tainted_by_errors ( ) ;
437
+
435
438
let param_env = ty:: ParamEnv :: reveal_all ( ) ;
436
439
let mut selcx = SelectionContext :: new ( & infcx) ;
437
440
let mut fulfill_cx = FulfillmentContext :: new ( ) ;
@@ -448,6 +451,9 @@ pub fn impossible_predicates<'tcx>(
448
451
449
452
let errors = fulfill_cx. select_all_or_error ( & infcx) ;
450
453
454
+ // Clean up after ourselves
455
+ let _ = infcx. inner . borrow_mut ( ) . opaque_type_storage . take_opaque_types ( ) ;
456
+
451
457
!errors. is_empty ( )
452
458
} ) ;
453
459
debug ! ( "impossible_predicates = {:?}" , result) ;
@@ -461,6 +467,14 @@ fn subst_and_check_impossible_predicates<'tcx>(
461
467
debug ! ( "subst_and_check_impossible_predicates(key={:?})" , key) ;
462
468
463
469
let mut predicates = tcx. predicates_of ( key. 0 ) . instantiate ( tcx, key. 1 ) . predicates ;
470
+
471
+ // Specifically check trait fulfillment to avoid an error when trying to resolve
472
+ // associated items.
473
+ if let Some ( trait_def_id) = tcx. trait_of_item ( key. 0 ) {
474
+ let trait_ref = ty:: TraitRef :: from_method ( tcx, trait_def_id, key. 1 ) ;
475
+ predicates. push ( ty:: Binder :: dummy ( trait_ref) . to_poly_trait_predicate ( ) . to_predicate ( tcx) ) ;
476
+ }
477
+
464
478
predicates. retain ( |predicate| !predicate. needs_subst ( ) ) ;
465
479
let result = impossible_predicates ( tcx, predicates) ;
466
480
0 commit comments