Skip to content

Commit b9c6dba

Browse files
committed
extend where clauses
1 parent a6d4d2b commit b9c6dba

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/librustc_traits/lowering.rs

+18-15
Original file line numberDiff line numberDiff line change
@@ -289,21 +289,24 @@ fn program_clauses_for_trait<'a, 'tcx>(
289289
// WellFormed(Self: Trait<P1..Pn>) :- Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)
290290
// }
291291

292-
let wellformed_clauses = where_clauses
293-
.into_iter()
294-
.map(|wc| wc.lower())
295-
// WellFormed(Self: Trait<P1..Pn>) :- Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)
296-
.map(|wc| {
297-
wc.map_bound(|goal| ProgramClause {
298-
goal: goal.into_wellformed_goal(),
299-
hypotheses: tcx.mk_goals(
300-
where_clauses
301-
.into_iter()
302-
.map(|wc| Goal::from_poly_domain_goal(wc.lower(), tcx)),
303-
),
304-
})
305-
})
306-
.map(Clause::ForAll);
292+
//Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)
293+
let mut extend_where_clauses = vec![ty::Binder::dummy(trait_pred.lower())];
294+
extend_where_clauses.extend(
295+
where_clauses
296+
.into_iter()
297+
.map(|wc| wc.lower().map_bound(|wc| wc.into_wellformed_goal())),
298+
);
299+
300+
// WellFormed(Self: Trait<P1..Pn>) :- Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)
301+
let clause = ProgramClause {
302+
goal: DomainGoal::WellFormed(WellFormed::Trait(trait_pred)),
303+
hypotheses: tcx.mk_goals(
304+
extend_where_clauses
305+
.into_iter()
306+
.map(|wc| Goal::from_poly_domain_goal(wc, tcx)),
307+
),
308+
};
309+
let wellformed_clauses = iter::once(Clause::ForAll(ty::Binder::dummy(clause)));
307310

308311
tcx.mk_clauses(
309312
clauses

0 commit comments

Comments
 (0)