diff --git a/src/librustc_traits/lowering.rs b/src/librustc_traits/lowering.rs index 1b73cd480990..9da2c49ee5d7 100644 --- a/src/librustc_traits/lowering.rs +++ b/src/librustc_traits/lowering.rs @@ -251,16 +251,15 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>( // Rule Normalize-From-Impl (see rustc guide) // // ```impl Trait for A0 - // where WC // { - // type AssocType where WC1 = T; + // type AssocType where WC = T; // }``` // // ``` // forall { // forall { // Normalize(>::AssocType -> T) :- - // WC && WC1 + // Implemented(A0: Trait) && WC // } // } // ``` @@ -276,19 +275,18 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>( let trait_ref = tcx.impl_trait_ref(impl_id).unwrap(); // `T` let ty = tcx.type_of(item_id); + // `Implemented(A0: Trait)` + let trait_implemented = ty::Binder::dummy(ty::TraitPredicate { trait_ref }.lower()); // `WC` - let impl_where_clauses = tcx.predicates_of(impl_id).predicates.lower(); - // `WC1` let item_where_clauses = tcx.predicates_of(item_id).predicates.lower(); - // `WC && WC1` - let mut where_clauses = vec![]; - where_clauses.extend(impl_where_clauses); + // `Implemented(A0: Trait) && WC` + let mut where_clauses = vec![trait_implemented]; where_clauses.extend(item_where_clauses); // `>::AssocType` let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.name); // `Normalize(>::AssocType -> T)` let normalize_goal = DomainGoal::Normalize(ty::ProjectionPredicate { projection_ty, ty }); - // `Normalize(... -> T) :- WC && WC1` + // `Normalize(... -> T) :- ...` let clause = ProgramClause { goal: normalize_goal, hypotheses: where_clauses.into_iter().map(|wc| wc.into()).collect(), diff --git a/src/test/ui/chalkify/lower_impl.stderr b/src/test/ui/chalkify/lower_impl.stderr index 5a32b8567b99..f253f9847d16 100644 --- a/src/test/ui/chalkify/lower_impl.stderr +++ b/src/test/ui/chalkify/lower_impl.stderr @@ -4,7 +4,7 @@ error: Implemented(T: Foo) :- ProjectionEq(::Item == i LL | #[rustc_dump_program_clauses] //~ ERROR Implemented(T: Foo) :- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Normalize(::Assoc == std::vec::Vec) :- ProjectionEq(::Item == i32), Implemented(T: std::iter::Iterator), Implemented(T: std::marker::Sized). +error: Normalize(::Assoc == std::vec::Vec) :- Implemented(T: Bar). --> $DIR/lower_impl.rs:23:5 | LL | #[rustc_dump_program_clauses] //~ ERROR Normalize(::Assoc == std::vec::Vec) :-