From 72e655355e237ff1b9fdaeb024e8e46569178e3c Mon Sep 17 00:00:00 2001 From: scalexm Date: Sun, 16 Jul 2017 08:16:48 +0200 Subject: [PATCH] Do not expand where clauses for default impls --- src/lower/mod.rs | 11 +++++------ src/solve/test.rs | 8 +------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/lower/mod.rs b/src/lower/mod.rs index cf2120e7d30..5049d705668 100644 --- a/src/lower/mod.rs +++ b/src/lower/mod.rs @@ -826,7 +826,7 @@ impl ir::Program { program_clauses.extend(self.struct_data.values().flat_map(|d| d.to_program_clauses(self))); program_clauses.extend(self.trait_data.values().flat_map(|d| d.to_program_clauses(self))); program_clauses.extend(self.associated_ty_data.values().flat_map(|d| d.to_program_clauses(self))); - program_clauses.extend(self.default_impl_data.iter().map(|d| d.to_program_clause(self))); + program_clauses.extend(self.default_impl_data.iter().map(|d| d.to_program_clause())); for datum in self.impl_data.values() { // If we encounter a negative impl, do not generate any rule. Negative impls @@ -894,18 +894,17 @@ impl ir::DefaultImplDatum { /// (Box>>: Send), WF(Box>>: Send) /// } /// ``` - fn to_program_clause(&self, program: &ir::Program) -> ir::ProgramClause { + fn to_program_clause(&self) -> ir::ProgramClause { ir::ProgramClause { implication: self.binders.map_ref(|bound| { ir::ProgramClauseImplication { consequence: bound.trait_ref.clone().cast(), conditions: { - let wc = bound.accessible_tys.iter().cloned().flat_map(|ty| { - let goal: ir::DomainGoal = ir::TraitRef { + let wc = bound.accessible_tys.iter().cloned().map(|ty| { + ir::TraitRef { trait_id: bound.trait_ref.trait_id, parameters: vec![ir::ParameterKind::Ty(ty)], - }.cast(); - goal.expanded(program) + } }); wc.casted().collect() diff --git a/src/solve/test.rs b/src/solve/test.rs index daa2b1ab980..19132b001db 100644 --- a/src/solve/test.rs +++ b/src/solve/test.rs @@ -1539,13 +1539,7 @@ fn coinductive_semantics() { "CannotProve" } - // `WellFormed(T)` is needed here because of the expanded bound `WellFormed(Ptr>: Send)` - // on the default `List: Send` impl, which will need that `List` is well-formed in order to be - // proven, which will in turn need that `T` is well-formed. - // - // In fact, as soon as there is a field which is referencing `T` with an indirection like `Foo>`, - // we need to add the `WellFormed(T)` because the `if (T: Send)` elaborates `WellFormed(T: Send)` but not - // `WellFormed(T)`. This is not an issue, but is maybe a bit inconsistent. + // `WellFormed(T)` because of the hand-written impl for `Ptr`. goal { forall { if (WellFormed(T), T: Send) {