Skip to content

Commit 5c377f3

Browse files
Reorganize, bless and add tests for const control flow
This creates a new test directory, `ui/consts/control-flow` to hold tests related to control flow in a const context. It also blesses all existing tests with the new error messages, and adds new tests for the `const_if_match` feature.
1 parent 26d93f3 commit 5c377f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1180
-308
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
error[E0744]: `match` is not allowed in a `static`
1+
error[E0658]: `match` is not allowed in a `static`
22
--> $DIR/issue-64453.rs:4:31
33
|
44
LL | static settings_dir: String = format!("");
55
| ^^^^^^^^^^^
66
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/49146
8+
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
79
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
810

911
error: aborting due to previous error
1012

11-
For more information about this error, try `rustc --explain E0744`.
13+
For more information about this error, try `rustc --explain E0658`.

src/test/ui/consts/const-eval/infinite_loop.stderr

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ LL | |
99
LL | | }
1010
| |_________^
1111

12-
error[E0744]: `if` is not allowed in a `const`
12+
error[E0658]: `if` is not allowed in a `const`
1313
--> $DIR/infinite_loop.rs:9:17
1414
|
1515
LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
|
18+
= note: for more information, see https://github.com/rust-lang/rust/issues/49146
19+
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
1720

1821
warning: Constant evaluating a complex constant, this might take some time
1922
--> $DIR/infinite_loop.rs:4:18
@@ -36,5 +39,5 @@ LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
3639

3740
error: aborting due to 3 previous errors
3841

39-
Some errors have detailed explanations: E0080, E0744.
42+
Some errors have detailed explanations: E0080, E0658, E0744.
4043
For more information about an error, try `rustc --explain E0080`.

src/test/ui/consts/const-eval/match-test-ptr-null.stderr

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0744]: `match` is not allowed in a `const`
1+
error[E0658]: `match` is not allowed in a `const`
22
--> $DIR/match-test-ptr-null.rs:6:9
33
|
44
LL | / match &1 as *const i32 as usize {
@@ -9,6 +9,9 @@ LL | | 0 => 42,
99
LL | | n => n,
1010
LL | | }
1111
| |_________^
12+
|
13+
= note: for more information, see https://github.com/rust-lang/rust/issues/49146
14+
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
1215

1316
error[E0658]: casting pointers to integers in constants is unstable
1417
--> $DIR/match-test-ptr-null.rs:6:15
@@ -27,5 +30,5 @@ LL | match &1 as *const i32 as usize {
2730

2831
error: aborting due to 3 previous errors
2932

30-
Some errors have detailed explanations: E0080, E0658, E0744.
33+
Some errors have detailed explanations: E0080, E0658.
3134
For more information about an error, try `rustc --explain E0080`.

src/test/ui/consts/const-if.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/test/ui/consts/const-if.stderr

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/test/ui/consts/const-loop.rs

Lines changed: 0 additions & 90 deletions
This file was deleted.
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0744]: `match` is not allowed in a `const`
1+
error[E0658]: `match` is not allowed in a `const`
22
--> $DIR/const-match-pattern-arm.rs:3:17
33
|
44
LL | const x: bool = match Some(true) {
@@ -7,16 +7,22 @@ LL | | Some(value) => true,
77
LL | | _ => false
88
LL | | };
99
| |_^
10+
|
11+
= note: for more information, see https://github.com/rust-lang/rust/issues/49146
12+
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
1013

11-
error[E0744]: `match` is not allowed in a `const`
14+
error[E0658]: `match` is not allowed in a `const`
1215
--> $DIR/const-match-pattern-arm.rs:9:5
1316
|
1417
LL | / match Some(true) {
1518
LL | | Some(value) => true,
1619
LL | | _ => false
1720
LL | | }
1821
| |_____^
22+
|
23+
= note: for more information, see https://github.com/rust-lang/rust/issues/49146
24+
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
1925

2026
error: aborting due to 2 previous errors
2127

22-
For more information about this error, try `rustc --explain E0744`.
28+
For more information about this error, try `rustc --explain E0658`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error: any use of this value will cause an error
2+
--> $DIR/assert.rs:12:15
3+
|
4+
LL | const _: () = assert!(false);
5+
| --------------^^^^^^^^^^^^^^-
6+
| |
7+
| the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:12:15
8+
|
9+
= note: `#[deny(const_err)]` on by default
10+
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
11+
12+
error: aborting due to previous error
13+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0658]: panicking in constants is unstable
2+
--> $DIR/assert.rs:8:15
3+
|
4+
LL | const _: () = assert!(true);
5+
| ^^^^^^^^^^^^^
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/51999
8+
= help: add `#![feature(const_panic)]` to the crate attributes to enable
9+
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
10+
11+
error[E0658]: panicking in constants is unstable
12+
--> $DIR/assert.rs:12:15
13+
|
14+
LL | const _: () = assert!(false);
15+
| ^^^^^^^^^^^^^^
16+
|
17+
= note: for more information, see https://github.com/rust-lang/rust/issues/51999
18+
= help: add `#![feature(const_panic)]` to the crate attributes to enable
19+
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
20+
21+
error: aborting due to 2 previous errors
22+
23+
For more information about this error, try `rustc --explain E0658`.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0658]: `if` is not allowed in a `const`
2+
--> $DIR/assert.rs:8:15
3+
|
4+
LL | const _: () = assert!(true);
5+
| ^^^^^^^^^^^^^
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/49146
8+
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
9+
10+
error[E0658]: `if` is not allowed in a `const`
11+
--> $DIR/assert.rs:12:15
12+
|
13+
LL | const _: () = assert!(false);
14+
| ^^^^^^^^^^^^^^
15+
|
16+
= note: for more information, see https://github.com/rust-lang/rust/issues/49146
17+
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)