Skip to content

Commit 5d17987

Browse files
committed
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.
1 parent 8f19fd0 commit 5d17987

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
error[E0275]: overflow evaluating the requirement `Element: MetaSized`
2+
--> $DIR/overflow.rs:16:16
3+
|
4+
LL | struct Element(<Box<Box<Element>> as ParseTokens>::Output);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: required for `Box<Element>` to implement `ParseTokens`
8+
--> $DIR/overflow.rs:12:31
9+
|
10+
LL | impl<T: ParseTokens + ?Sized> ParseTokens for Box<T> {
11+
| - ^^^^^^^^^^^ ^^^^^^
12+
| |
13+
| unsatisfied trait bound introduced here
14+
= note: 1 redundant requirement hidden
15+
= note: required for `Box<Box<Element>>` to implement `ParseTokens`
16+
17+
error[E0275]: overflow evaluating the requirement `Box<Element>: ParseTokens`
18+
--> $DIR/overflow.rs:18:22
19+
|
20+
LL | impl ParseTokens for Element {
21+
| ^^^^^^^
22+
|
23+
note: required for `Box<Box<Element>>` to implement `ParseTokens`
24+
--> $DIR/overflow.rs:12:31
25+
|
26+
LL | impl<T: ParseTokens + ?Sized> ParseTokens for Box<T> {
27+
| ----------- ^^^^^^^^^^^ ^^^^^^
28+
| |
29+
| unsatisfied trait bound introduced here
30+
note: required because it appears within the type `Element`
31+
--> $DIR/overflow.rs:16:8
32+
|
33+
LL | struct Element(<Box<Box<Element>> as ParseTokens>::Output);
34+
| ^^^^^^^
35+
note: required by a bound in `ParseTokens`
36+
--> $DIR/overflow.rs:9:1
37+
|
38+
LL | / trait ParseTokens {
39+
LL | | type Output;
40+
LL | | }
41+
| |_^ required by this bound in `ParseTokens`
42+
43+
error: aborting due to 2 previous errors
44+
45+
For more information about this error, try `rustc --explain E0275`.

tests/ui/sized-hierarchy/overflow.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ compile-flags: --crate-type=lib
2+
//@ revisions: current next
3+
//@ ignore-compare-mode-next-solver (explicit revisions)
4+
//@[next] check-pass
5+
//@[next] compile-flags: -Znext-solver
6+
7+
use std::marker::PhantomData;
8+
9+
trait ParseTokens {
10+
type Output;
11+
}
12+
impl<T: ParseTokens + ?Sized> ParseTokens for Box<T> {
13+
type Output = ();
14+
}
15+
16+
struct Element(<Box<Box<Element>> as ParseTokens>::Output);
17+
//[current]~^ ERROR overflow evaluating
18+
impl ParseTokens for Element {
19+
//[current]~^ ERROR overflow evaluating
20+
type Output = ();
21+
}

0 commit comments

Comments
 (0)