Skip to content

Commit 72e6553

Browse files
committed
Do not expand where clauses for default impls
1 parent 4844044 commit 72e6553

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/lower/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ impl ir::Program {
826826
program_clauses.extend(self.struct_data.values().flat_map(|d| d.to_program_clauses(self)));
827827
program_clauses.extend(self.trait_data.values().flat_map(|d| d.to_program_clauses(self)));
828828
program_clauses.extend(self.associated_ty_data.values().flat_map(|d| d.to_program_clauses(self)));
829-
program_clauses.extend(self.default_impl_data.iter().map(|d| d.to_program_clause(self)));
829+
program_clauses.extend(self.default_impl_data.iter().map(|d| d.to_program_clause()));
830830

831831
for datum in self.impl_data.values() {
832832
// If we encounter a negative impl, do not generate any rule. Negative impls
@@ -894,18 +894,17 @@ impl ir::DefaultImplDatum {
894894
/// (Box<Option<MyList<T>>>: Send), WF(Box<Option<MyList<T>>>: Send)
895895
/// }
896896
/// ```
897-
fn to_program_clause(&self, program: &ir::Program) -> ir::ProgramClause {
897+
fn to_program_clause(&self) -> ir::ProgramClause {
898898
ir::ProgramClause {
899899
implication: self.binders.map_ref(|bound| {
900900
ir::ProgramClauseImplication {
901901
consequence: bound.trait_ref.clone().cast(),
902902
conditions: {
903-
let wc = bound.accessible_tys.iter().cloned().flat_map(|ty| {
904-
let goal: ir::DomainGoal = ir::TraitRef {
903+
let wc = bound.accessible_tys.iter().cloned().map(|ty| {
904+
ir::TraitRef {
905905
trait_id: bound.trait_ref.trait_id,
906906
parameters: vec![ir::ParameterKind::Ty(ty)],
907-
}.cast();
908-
goal.expanded(program)
907+
}
909908
});
910909

911910
wc.casted().collect()

src/solve/test.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,13 +1539,7 @@ fn coinductive_semantics() {
15391539
"CannotProve"
15401540
}
15411541

1542-
// `WellFormed(T)` is needed here because of the expanded bound `WellFormed(Ptr<List<T>>: Send)`
1543-
// on the default `List<T>: Send` impl, which will need that `List<T>` is well-formed in order to be
1544-
// proven, which will in turn need that `T` is well-formed.
1545-
//
1546-
// In fact, as soon as there is a field which is referencing `T` with an indirection like `Foo<Bar<T>>`,
1547-
// we need to add the `WellFormed(T)` because the `if (T: Send)` elaborates `WellFormed(T: Send)` but not
1548-
// `WellFormed(T)`. This is not an issue, but is maybe a bit inconsistent.
1542+
// `WellFormed(T)` because of the hand-written impl for `Ptr<T>`.
15491543
goal {
15501544
forall<T> {
15511545
if (WellFormed(T), T: Send) {

0 commit comments

Comments
 (0)