|
| 1 | +// check-pass |
| 2 | +// revisions: old new |
| 3 | +//[new] compile-flags: -Ztrait-solver=next |
| 4 | + |
| 5 | +// If we use canonical goals during trait solving we have to reevaluate |
| 6 | +// the root goal of a cycle until we hit a fixpoint. |
| 7 | +// |
| 8 | +// Here `main` has a goal `(?0, ?1): Trait` which is canonicalized to |
| 9 | +// `exists<^0, ^1> (^0, ^1): Trait`. |
| 10 | +// |
| 11 | +// - `exists<^0, ^1> (^0, ^1): Trait` -instantiate-> `(?0, ?1): Trait` |
| 12 | +// -`(?1, ?0): Trait` -canonicalize-> `exists<^0, ^1> (^0, ^1): Trait` |
| 13 | +// - COINDUCTIVE CYCLE OK (no constraints) |
| 14 | +// - `(): ConstrainToU32<?0>` -canonicalize-> `exists<^0> (): ConstrainToU32<^0>` |
| 15 | +// - OK (^0 = u32 -apply-> ?0 = u32) |
| 16 | +// - OK (?0 = u32 -canonicalize-> ^0 = u32) |
| 17 | +// - coinductive cycle with provisional result != final result, rerun |
| 18 | +// |
| 19 | +// - `exists<^0, ^1> (^0, ^1): Trait` -instantiate-> `(?0, ?1): Trait` |
| 20 | +// -`(?1, ?0): Trait` -canonicalize-> `exists<^0, ^1> (^0, ^1): Trait` |
| 21 | +// - COINDUCTIVE CYCLE OK (^0 = u32 -apply-> ?1 = u32) |
| 22 | +// - `(): ConstrainToU32<?0>` -canonicalize-> `exists<^0> (): ConstrainToU32<^0>` |
| 23 | +// - OK (^0 = u32 -apply-> ?1 = u32) |
| 24 | +// - OK (?0 = u32, ?1 = u32 -canonicalize-> ^0 = u32, ^1 = u32) |
| 25 | +// - coinductive cycle with provisional result != final result, rerun |
| 26 | +// |
| 27 | +// - `exists<^0, ^1> (^0, ^1): Trait` -instantiate-> `(?0, ?1): Trait` |
| 28 | +// -`(?1, ?0): Trait` -canonicalize-> `exists<^0, ^1> (^0, ^1): Trait` |
| 29 | +// - COINDUCTIVE CYCLE OK (^0 = u32, ^1 = u32 -apply-> ?1 = u32, ?0 = u32) |
| 30 | +// - `(): ConstrainToU32<?0>` -canonicalize-> `exists<^0> (): ConstrainToU32<^0>` |
| 31 | +// - OK (^0 = u32 -apply-> ?1 = u32) |
| 32 | +// - OK (?0 = u32, ?1 = u32 -canonicalize-> ^0 = u32, ^1 = u32) |
| 33 | +// - coinductive cycle with provisional result == final result, DONE |
| 34 | +#![feature(rustc_attrs)] |
| 35 | +#[rustc_coinductive] |
| 36 | +trait Trait {} |
| 37 | + |
| 38 | +impl<T, U> Trait for (T, U) |
| 39 | +where |
| 40 | + (U, T): Trait, |
| 41 | + (): ConstrainToU32<T>, |
| 42 | +{} |
| 43 | + |
| 44 | +trait ConstrainToU32<T> {} |
| 45 | +impl ConstrainToU32<u32> for () {} |
| 46 | + |
| 47 | +fn impls_trait<T, U>() |
| 48 | +where |
| 49 | + (T, U): Trait, |
| 50 | +{} |
| 51 | + |
| 52 | +fn main() { |
| 53 | + impls_trait::<_, _>(); |
| 54 | +} |
0 commit comments