diff options
| author | Caio <c410.f3r@gmail.com> | 2024-04-06 17:08:59 -0300 |
|---|---|---|
| committer | Caio <c410.f3r@gmail.com> | 2024-04-07 17:38:07 -0300 |
| commit | ab8994d93e469d3f804e978e379e8342b0c6fe3b (patch) | |
| tree | 393e4373c4f705aecef0db083e0da73fd3b50edd /tests/ui/recursion | |
| parent | 9d5cdf75aa42faaf0b58ba21a510117e8d0051a3 (diff) | |
| download | rust-ab8994d93e469d3f804e978e379e8342b0c6fe3b.tar.gz rust-ab8994d93e469d3f804e978e379e8342b0c6fe3b.zip | |
Move tests
Diffstat (limited to 'tests/ui/recursion')
| -rw-r--r-- | tests/ui/recursion/issue-23302-1.rs | 7 | ||||
| -rw-r--r-- | tests/ui/recursion/issue-23302-1.stderr | 22 | ||||
| -rw-r--r-- | tests/ui/recursion/issue-23302-2.rs | 8 | ||||
| -rw-r--r-- | tests/ui/recursion/issue-23302-2.stderr | 22 | ||||
| -rw-r--r-- | tests/ui/recursion/issue-23302-3.rs | 5 | ||||
| -rw-r--r-- | tests/ui/recursion/issue-23302-3.stderr | 28 |
6 files changed, 92 insertions, 0 deletions
diff --git a/tests/ui/recursion/issue-23302-1.rs b/tests/ui/recursion/issue-23302-1.rs new file mode 100644 index 00000000000..24e79dc5811 --- /dev/null +++ b/tests/ui/recursion/issue-23302-1.rs @@ -0,0 +1,7 @@ +// Check that an enum with recursion in the discriminant throws +// the appropriate error (rather than, say, blowing the stack). +enum X { + A = X::A as isize, //~ ERROR E0391 +} + +fn main() { } diff --git a/tests/ui/recursion/issue-23302-1.stderr b/tests/ui/recursion/issue-23302-1.stderr new file mode 100644 index 00000000000..234060ab5c8 --- /dev/null +++ b/tests/ui/recursion/issue-23302-1.stderr @@ -0,0 +1,22 @@ +error[E0391]: cycle detected when simplifying constant for the type system `X::A::{constant#0}` + --> $DIR/issue-23302-1.rs:4:9 + | +LL | A = X::A as isize, + | ^^^^^^^^^^^^^ + | +note: ...which requires const-evaluating + checking `X::A::{constant#0}`... + --> $DIR/issue-23302-1.rs:4:9 + | +LL | A = X::A as isize, + | ^^^^^^^^^^^^^ + = note: ...which again requires simplifying constant for the type system `X::A::{constant#0}`, completing the cycle +note: cycle used when checking that `X` is well-formed + --> $DIR/issue-23302-1.rs:3:1 + | +LL | enum X { + | ^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/recursion/issue-23302-2.rs b/tests/ui/recursion/issue-23302-2.rs new file mode 100644 index 00000000000..e89c7eab503 --- /dev/null +++ b/tests/ui/recursion/issue-23302-2.rs @@ -0,0 +1,8 @@ +// Since `Y::B` here defaults to `Y::A+1`, this is also a +// recursive definition. +enum Y { + A = Y::B as isize, //~ ERROR E0391 + B, +} + +fn main() { } diff --git a/tests/ui/recursion/issue-23302-2.stderr b/tests/ui/recursion/issue-23302-2.stderr new file mode 100644 index 00000000000..9bd95239c83 --- /dev/null +++ b/tests/ui/recursion/issue-23302-2.stderr @@ -0,0 +1,22 @@ +error[E0391]: cycle detected when simplifying constant for the type system `Y::A::{constant#0}` + --> $DIR/issue-23302-2.rs:4:9 + | +LL | A = Y::B as isize, + | ^^^^^^^^^^^^^ + | +note: ...which requires const-evaluating + checking `Y::A::{constant#0}`... + --> $DIR/issue-23302-2.rs:4:9 + | +LL | A = Y::B as isize, + | ^^^^^^^^^^^^^ + = note: ...which again requires simplifying constant for the type system `Y::A::{constant#0}`, completing the cycle +note: cycle used when checking that `Y` is well-formed + --> $DIR/issue-23302-2.rs:3:1 + | +LL | enum Y { + | ^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/recursion/issue-23302-3.rs b/tests/ui/recursion/issue-23302-3.rs new file mode 100644 index 00000000000..da75f330798 --- /dev/null +++ b/tests/ui/recursion/issue-23302-3.rs @@ -0,0 +1,5 @@ +const A: i32 = B; //~ ERROR cycle detected + +const B: i32 = A; + +fn main() { } diff --git a/tests/ui/recursion/issue-23302-3.stderr b/tests/ui/recursion/issue-23302-3.stderr new file mode 100644 index 00000000000..8a152f58966 --- /dev/null +++ b/tests/ui/recursion/issue-23302-3.stderr @@ -0,0 +1,28 @@ +error[E0391]: cycle detected when simplifying constant for the type system `A` + --> $DIR/issue-23302-3.rs:1:1 + | +LL | const A: i32 = B; + | ^^^^^^^^^^^^ + | +note: ...which requires const-evaluating + checking `A`... + --> $DIR/issue-23302-3.rs:1:16 + | +LL | const A: i32 = B; + | ^ +note: ...which requires simplifying constant for the type system `B`... + --> $DIR/issue-23302-3.rs:3:1 + | +LL | const B: i32 = A; + | ^^^^^^^^^^^^ +note: ...which requires const-evaluating + checking `B`... + --> $DIR/issue-23302-3.rs:3:16 + | +LL | const B: i32 = A; + | ^ + = note: ...which again requires simplifying constant for the type system `A`, completing the cycle + = note: cycle used when running analysis passes on this crate + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. |
