Skip to content

Commit fc2d9ce

Browse files
authored
Merge pull request #206 from scalexm/master
Fix an implied bounds bug
2 parents f36ae45 + 368ce9a commit fc2d9ce

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

src/rules.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl StructDatum {
312312
/// ```notrust
313313
/// -- Rule WellFormed-Type
314314
/// forall<T> {
315-
/// WF(Foo<T>) :- Implemented(T: Eq).
315+
/// WF(Foo<T>) :- WF(T: Eq).
316316
/// }
317317
///
318318
/// -- Rule Implied-Bound-From-Type
@@ -361,7 +361,13 @@ impl StructDatum {
361361
.map_ref(|bound_datum| ProgramClauseImplication {
362362
consequence: WellFormed::Ty(bound_datum.self_ty.clone().cast()).cast(),
363363

364-
conditions: { bound_datum.where_clauses.iter().cloned().casted().collect() },
364+
conditions: bound_datum
365+
.where_clauses
366+
.iter()
367+
.cloned()
368+
.map(|wc| wc.map(|bound| bound.into_well_formed_goal()))
369+
.casted()
370+
.collect(),
365371
})
366372
.cast();
367373

@@ -802,7 +808,7 @@ impl AssociatedTyDatum {
802808
/// ```notrust
803809
/// -- Rule WellFormed-AssocTy
804810
/// forall<Self, 'a, T> {
805-
/// WellFormed((Foo::Assoc)<Self, 'a, T>) :- Implemented(Self: Foo), WC.
811+
/// WellFormed((Foo::Assoc)<Self, 'a, T>) :- WellFormed(Self: Foo), WellFormed(WC).
806812
/// }
807813
///
808814
/// -- Rule Implied-WC-From-AssocTy
@@ -876,15 +882,21 @@ impl AssociatedTyDatum {
876882
// Well-formedness of projection type.
877883
//
878884
// forall<Self> {
879-
// WellFormed((Foo::Assoc)<Self>) :- Implemented(Self: Foo), WC.
885+
// WellFormed((Foo::Assoc)<Self>) :- WellFormed(Self: Foo), WellFormed(WC).
880886
// }
881887
clauses.push(
882888
Binders {
883889
binders: binders.clone(),
884890
value: ProgramClauseImplication {
885891
consequence: WellFormed::Ty(app_ty.clone()).cast(),
886-
conditions: iter::once(trait_ref.clone().cast())
887-
.chain(self.where_clauses.iter().cloned().casted())
892+
conditions: iter::once(WellFormed::Trait(trait_ref.clone()).cast())
893+
.chain(
894+
self.where_clauses
895+
.iter()
896+
.cloned()
897+
.map(|wc| wc.map(|bound| bound.into_well_formed_goal()))
898+
.casted(),
899+
)
888900
.collect(),
889901
},
890902
}

src/test.rs

+20
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,26 @@ fn higher_ranked_implied_bounds() {
24382438
}
24392439
}
24402440

2441+
#[test]
2442+
fn recursive_where_clause_on_type() {
2443+
test! {
2444+
program {
2445+
trait Bar { }
2446+
trait Foo where Self: Bar { }
2447+
2448+
struct S where S: Foo { }
2449+
2450+
impl Foo for S { }
2451+
}
2452+
2453+
goal {
2454+
WellFormed(S)
2455+
} yields {
2456+
"No possible solution"
2457+
}
2458+
}
2459+
}
2460+
24412461
#[test]
24422462
fn deref_goal() {
24432463
test! {

0 commit comments

Comments
 (0)