File tree 2 files changed +75
-0
lines changed
tests/ui/traits/new-solver/cycles
2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ // compile-flags: -Ztrait-solver=next
2
+ #![ feature( rustc_attrs, trivial_bounds) ]
3
+
4
+ // We have to be careful here:
5
+ //
6
+ // We either have the provisional result of `A -> B -> A` on the
7
+ // stack, which is a fully coinductive cycle. Accessing the
8
+ // provisional result for `B` as part of the `A -> C -> B -> A` cycle
9
+ // has to make sure we don't just use the result of `A -> B -> A` as the
10
+ // new cycle is inductive.
11
+ //
12
+ // Alternatively, if we have `A -> C -> A` first, then `A -> B -> A` has
13
+ // a purely inductive stack, so something could also go wrong here.
14
+
15
+ #[ rustc_coinductive]
16
+ trait A { }
17
+ #[ rustc_coinductive]
18
+ trait B { }
19
+ trait C { }
20
+
21
+ impl < T : B + C > A for T { }
22
+ impl < T : A > B for T { }
23
+ impl < T : B > C for T { }
24
+
25
+ fn impls_a < T : A > ( ) { }
26
+
27
+ // The same test with reordered where clauses to make sure we're actually testing anything.
28
+ #[ rustc_coinductive]
29
+ trait AR { }
30
+ #[ rustc_coinductive]
31
+ trait BR { }
32
+ trait CR { }
33
+
34
+ impl < T : CR + BR > AR for T { }
35
+ impl < T : AR > BR for T { }
36
+ impl < T : BR > CR for T { }
37
+
38
+ fn impls_ar < T : AR > ( ) { }
39
+
40
+ fn main ( ) {
41
+ impls_a :: < ( ) > ( ) ;
42
+ //~^ ERROR overflow evaluating the requirement `(): A`
43
+
44
+ impls_ar :: < ( ) > ( ) ;
45
+ //~^ ERROR overflow evaluating the requirement `(): AR`
46
+ }
Original file line number Diff line number Diff line change
1
+ error[E0275]: overflow evaluating the requirement `(): A`
2
+ --> $DIR/inductive-not-on-stack.rs:41:5
3
+ |
4
+ LL | impls_a::<()>();
5
+ | ^^^^^^^^^^^^^
6
+ |
7
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_not_on_stack`)
8
+ note: required by a bound in `impls_a`
9
+ --> $DIR/inductive-not-on-stack.rs:25:15
10
+ |
11
+ LL | fn impls_a<T: A>() {}
12
+ | ^ required by this bound in `impls_a`
13
+
14
+ error[E0275]: overflow evaluating the requirement `(): AR`
15
+ --> $DIR/inductive-not-on-stack.rs:44:5
16
+ |
17
+ LL | impls_ar::<()>();
18
+ | ^^^^^^^^^^^^^^
19
+ |
20
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_not_on_stack`)
21
+ note: required by a bound in `impls_ar`
22
+ --> $DIR/inductive-not-on-stack.rs:38:16
23
+ |
24
+ LL | fn impls_ar<T: AR>() {}
25
+ | ^^ required by this bound in `impls_ar`
26
+
27
+ error: aborting due to 2 previous errors
28
+
29
+ For more information about this error, try `rustc --explain E0275`.
You can’t perform that action at this time.
0 commit comments