diff options
| author | lcnr <rust@lcnr.de> | 2022-12-04 03:19:10 +0000 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2022-12-19 16:46:17 +0000 |
| commit | a213bb36c953d2c342d8ae9303704e57bc8aab33 (patch) | |
| tree | 01fa1c6b8fa4b3e5099424ef9aba0c282fb43d94 /src/test | |
| parent | 4653c93e4442d88bf3278067183c8fdc0be74a1f (diff) | |
| download | rust-a213bb36c953d2c342d8ae9303704e57bc8aab33.tar.gz rust-a213bb36c953d2c342d8ae9303704e57bc8aab33.zip | |
implement the skeleton of the updated trait solver
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/traits/solver-cycles/inductive-canonical-cycle.rs | 28 | ||||
| -rw-r--r-- | src/test/ui/traits/solver-cycles/inductive-canonical-cycle.stderr | 26 |
2 files changed, 54 insertions, 0 deletions
diff --git a/src/test/ui/traits/solver-cycles/inductive-canonical-cycle.rs b/src/test/ui/traits/solver-cycles/inductive-canonical-cycle.rs new file mode 100644 index 00000000000..a3bb76d7e3b --- /dev/null +++ b/src/test/ui/traits/solver-cycles/inductive-canonical-cycle.rs @@ -0,0 +1,28 @@ +// known-bug + +// This should compile but fails with the current solver. +// +// This checks that the new solver uses `Ambiguous` when hitting the +// inductive cycle here when proving `exists<^0, ^1> (): Trait<^0, ^1>` +// which requires proving `Trait<?1, ?0>` but that has the same +// canonical representation. +trait Trait<T, U> {} + +impl<T, U> Trait<T, U> for () +where + (): Trait<U, T>, + T: OtherTrait, +{} + +trait OtherTrait {} +impl OtherTrait for u32 {} + +fn require_trait<T, U>() +where + (): Trait<T, U> +{} + +fn main() { + require_trait::<_, _>(); + //~^ ERROR overflow evaluating +} diff --git a/src/test/ui/traits/solver-cycles/inductive-canonical-cycle.stderr b/src/test/ui/traits/solver-cycles/inductive-canonical-cycle.stderr new file mode 100644 index 00000000000..e4b84e07822 --- /dev/null +++ b/src/test/ui/traits/solver-cycles/inductive-canonical-cycle.stderr @@ -0,0 +1,26 @@ +error[E0275]: overflow evaluating the requirement `_: Sized` + --> $DIR/inductive-canonical-cycle.rs:26:5 + | +LL | require_trait::<_, _>(); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_canonical_cycle`) +note: required for `()` to implement `Trait<_, _>` + --> $DIR/inductive-canonical-cycle.rs:11:12 + | +LL | impl<T, U> Trait<T, U> for () + | ^^^^^^^^^^^ ^^ + = note: 128 redundant requirements hidden + = note: required for `()` to implement `Trait<_, _>` +note: required by a bound in `require_trait` + --> $DIR/inductive-canonical-cycle.rs:22:9 + | +LL | fn require_trait<T, U>() + | ------------- required by a bound in this +LL | where +LL | (): Trait<T, U> + | ^^^^^^^^^^^ required by this bound in `require_trait` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. |
