Skip to content

Commit 8492460

Browse files
committed
Also check TraitRef with impossible predicates.
1 parent e209e85 commit 8492460

File tree

1 file changed

+8
-0
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+8
-0
lines changed

compiler/rustc_trait_selection/src/traits/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,14 @@ fn subst_and_check_impossible_predicates<'tcx>(
461461
debug!("subst_and_check_impossible_predicates(key={:?})", key);
462462

463463
let mut predicates = tcx.predicates_of(key.0).instantiate(tcx, key.1).predicates;
464+
465+
// Specifically check trait fulfillment to avoid an error when trying to resolve
466+
// associated items.
467+
if let Some(trait_def_id) = tcx.trait_of_item(key.0) {
468+
let trait_ref = ty::TraitRef::from_method(tcx, trait_def_id, key.1);
469+
predicates.push(ty::Binder::dummy(trait_ref).to_poly_trait_predicate().to_predicate(tcx));
470+
}
471+
464472
predicates.retain(|predicate| !predicate.needs_subst());
465473
let result = impossible_predicates(tcx, predicates);
466474

0 commit comments

Comments
 (0)