Skip to content

Commit 37ebce3

Browse files
committed
add regression test
1 parent 7e29b88 commit 37ebce3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//@ compile-flags: -Znext-solver
2+
//@ check-pass
3+
4+
// A regression test for trait-system-refactor-initiative#210.
5+
//
6+
// Trying to prove `T: Trait<...>` ends up trying to apply all the where-clauses,
7+
// most of which require normalizing some `Alias<T, ...>`. This then requires us
8+
// to prove `T: Trait<...>` again.
9+
//
10+
// This results in a lot of solver cycles whose initial result differs from their
11+
// final result. Reevaluating all of them results in exponential blowup and hangs.
12+
//
13+
// With #144991 we now don't reevaluate cycle heads if their provisional value
14+
// didn't actually impact the final result, avoiding these reruns and allowing us
15+
// to compile this in less than a second.
16+
17+
struct A;
18+
struct B;
19+
struct C;
20+
21+
type Alias<T, U> = <T as Trait<U>>::Assoc;
22+
trait Trait<T> {
23+
type Assoc;
24+
}
25+
26+
fn foo<T>()
27+
where
28+
T: Trait<A> + Trait<B> + Trait<C>,
29+
T: Trait<Alias<T, A>>,
30+
T: Trait<Alias<T, B>>,
31+
T: Trait<Alias<T, C>>,
32+
T: Trait<Alias<T, Alias<T, A>>>,
33+
T: Trait<Alias<T, Alias<T, B>>>,
34+
T: Trait<Alias<T, Alias<T, C>>>,
35+
T: Trait<Alias<T, Alias<T, Alias<T, A>>>>,
36+
T: Trait<Alias<T, Alias<T, Alias<T, B>>>>,
37+
T: Trait<Alias<T, Alias<T, Alias<T, C>>>>,
38+
T: Trait<Alias<T, Alias<T, Alias<T, Alias<T, A>>>>>,
39+
T: Trait<Alias<T, Alias<T, Alias<T, Alias<T, B>>>>>,
40+
T: Trait<Alias<T, Alias<T, Alias<T, Alias<T, C>>>>>,
41+
{
42+
}
43+
fn main() {}
44+

0 commit comments

Comments
 (0)