Skip to content

Commit fcd7fe2

Browse files
committed
Add failing tests for where clauses
1 parent b5d9422 commit fcd7fe2

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

src/rules/wf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl WfSolver {
325325
let goal = Goal::Implies(hypotheses, Box::new(goal))
326326
.quantify(QuantifierKind::ForAll, impl_datum.binders.binders.clone());
327327

328-
println!("{:?}", goal);
328+
debug!("WF trait goal: {:?}", goal);
329329

330330
match self.solver_choice.solve_root_goal(&self.env, &goal.into_closed_goal()).unwrap() {
331331
Some(sol) => sol.is_unique(),

src/solve/test.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,76 @@ fn normalize_gat_with_where_clause() {
669669
}
670670
}
671671

672+
#[test]
673+
fn normalize_gat_with_where_clause2() {
674+
test! {
675+
program {
676+
trait Bar<T> { }
677+
trait Foo<T> {
678+
type Item<U> where U: Bar<T>;
679+
}
680+
681+
struct i32 { }
682+
impl<T> Foo<T> for i32 {
683+
type Item<U> = U;
684+
}
685+
}
686+
687+
goal {
688+
forall<T, U> {
689+
exists<V> {
690+
Normalize(<i32 as Foo<T>>::Item<U> -> V)
691+
}
692+
}
693+
} yields {
694+
"No possible solution"
695+
}
696+
697+
goal {
698+
forall<T, U> {
699+
exists<V> {
700+
if (U: Bar<T>) {
701+
Normalize(<i32 as Foo<T>>::Item<U> -> V)
702+
}
703+
}
704+
}
705+
} yields {
706+
"Unique; substitution [?0 := !2]"
707+
}
708+
}
709+
}
710+
711+
#[test]
712+
fn normalize_gat_with_higher_ranked_trait_bound() {
713+
test! {
714+
program {
715+
trait Foo<'a, T> { }
716+
struct i32 { }
717+
718+
trait Bar<'a, T> {
719+
type Item<V>: Foo<'a, T> where forall<'b> V: Foo<'b, T>;
720+
}
721+
722+
impl<'a, T> Foo<'a, T> for i32 { }
723+
impl<'a, T> Bar<'a, T> for i32 {
724+
type Item<V> = i32;
725+
}
726+
}
727+
728+
goal {
729+
forall<'a, T, V> {
730+
if (forall<'b> { V: Foo<'b, T> }) {
731+
exists<U> {
732+
Normalize(<i32 as Bar<'a, T>>::Item<V> -> U)
733+
}
734+
}
735+
}
736+
} yields {
737+
"Unique; substitution [?0 := i32], lifetime constraints []"
738+
}
739+
}
740+
}
741+
672742
#[test]
673743
fn normalize_implied_bound() {
674744
test! {

0 commit comments

Comments
 (0)