diff options
| author | David Wood <david.wood2@arm.com> | 2025-05-13 06:44:21 +0000 |
|---|---|---|
| committer | David Wood <david.wood2@arm.com> | 2025-06-16 23:04:35 +0000 |
| commit | 5d17987d7189a883c3c42a6eb17255e2ea060d6f (patch) | |
| tree | f03cc011f347c12001a5f466c82fcefb956f9667 | |
| parent | 8f19fd08413fec85cd69e98f26d029fb9ba3800a (diff) | |
| download | rust-5d17987d7189a883c3c42a6eb17255e2ea060d6f.tar.gz rust-5d17987d7189a883c3c42a6eb17255e2ea060d6f.zip | |
tests: add overflow test
This test case is a reduction from the `hwc` crate on GitHub, following a crater run. It passes with the next solver but fails on the current solver due to a known limitation of the current solver. It starts fails on the current solver with the `sized_hierarchy` changes because `?Sized` is now a proper bound.
| -rw-r--r-- | tests/ui/sized-hierarchy/overflow.current.stderr | 45 | ||||
| -rw-r--r-- | tests/ui/sized-hierarchy/overflow.rs | 21 |
2 files changed, 66 insertions, 0 deletions
diff --git a/tests/ui/sized-hierarchy/overflow.current.stderr b/tests/ui/sized-hierarchy/overflow.current.stderr new file mode 100644 index 00000000000..e90548aa78c --- /dev/null +++ b/tests/ui/sized-hierarchy/overflow.current.stderr @@ -0,0 +1,45 @@ +error[E0275]: overflow evaluating the requirement `Element: MetaSized` + --> $DIR/overflow.rs:16:16 + | +LL | struct Element(<Box<Box<Element>> as ParseTokens>::Output); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: required for `Box<Element>` to implement `ParseTokens` + --> $DIR/overflow.rs:12:31 + | +LL | impl<T: ParseTokens + ?Sized> ParseTokens for Box<T> { + | - ^^^^^^^^^^^ ^^^^^^ + | | + | unsatisfied trait bound introduced here + = note: 1 redundant requirement hidden + = note: required for `Box<Box<Element>>` to implement `ParseTokens` + +error[E0275]: overflow evaluating the requirement `Box<Element>: ParseTokens` + --> $DIR/overflow.rs:18:22 + | +LL | impl ParseTokens for Element { + | ^^^^^^^ + | +note: required for `Box<Box<Element>>` to implement `ParseTokens` + --> $DIR/overflow.rs:12:31 + | +LL | impl<T: ParseTokens + ?Sized> ParseTokens for Box<T> { + | ----------- ^^^^^^^^^^^ ^^^^^^ + | | + | unsatisfied trait bound introduced here +note: required because it appears within the type `Element` + --> $DIR/overflow.rs:16:8 + | +LL | struct Element(<Box<Box<Element>> as ParseTokens>::Output); + | ^^^^^^^ +note: required by a bound in `ParseTokens` + --> $DIR/overflow.rs:9:1 + | +LL | / trait ParseTokens { +LL | | type Output; +LL | | } + | |_^ required by this bound in `ParseTokens` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/sized-hierarchy/overflow.rs b/tests/ui/sized-hierarchy/overflow.rs new file mode 100644 index 00000000000..e1af4885e53 --- /dev/null +++ b/tests/ui/sized-hierarchy/overflow.rs @@ -0,0 +1,21 @@ +//@ compile-flags: --crate-type=lib +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] check-pass +//@[next] compile-flags: -Znext-solver + +use std::marker::PhantomData; + +trait ParseTokens { + type Output; +} +impl<T: ParseTokens + ?Sized> ParseTokens for Box<T> { + type Output = (); +} + +struct Element(<Box<Box<Element>> as ParseTokens>::Output); +//[current]~^ ERROR overflow evaluating +impl ParseTokens for Element { +//[current]~^ ERROR overflow evaluating + type Output = (); +} |
