Skip to content

Commit 8fe1b1d

Browse files
Update tests
1 parent 984e536 commit 8fe1b1d

Some content is hidden

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

47 files changed

+105
-415
lines changed

src/test/compile-fail/issue-52443.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
fn main() {
22
[(); & { loop { continue } } ]; //~ ERROR mismatched types
3-
//~^ ERROR `loop` is not allowed in a `const`
3+
44
[(); loop { break }]; //~ ERROR mismatched types
5-
//~^ ERROR `loop` is not allowed in a `const`
5+
66
[(); {while true {break}; 0}];
7-
//~^ ERROR `while` is not allowed in a `const`
8-
//~| WARN denote infinite loops with
7+
//~^ WARN denote infinite loops with
8+
99
[(); { for _ in 0usize.. {}; 0}];
1010
//~^ ERROR `for` is not allowed in a `const`
1111
//~| ERROR calls in constants are limited to constant functions

src/test/ui/async-await/issue-70594.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ async fn fun() {
44
[1; ().await];
55
//~^ error: `await` is only allowed inside `async` functions and blocks
66
//~| error: `.await` is not allowed in a `const`
7-
//~| error: `loop` is not allowed in a `const`
87
//~| error: `.await` is not allowed in a `const`
98
//~| error: the trait bound `(): std::future::Future` is not satisfied
109
}

src/test/ui/async-await/issue-70594.stderr

+2-11
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ error[E0744]: `.await` is not allowed in a `const`
1212
LL | [1; ().await];
1313
| ^^^^^^^^
1414

15-
error[E0658]: `loop` is not allowed in a `const`
16-
--> $DIR/issue-70594.rs:4:9
17-
|
18-
LL | [1; ().await];
19-
| ^^^^^^^^
20-
|
21-
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
22-
= help: add `#![feature(const_loop)]` to the crate attributes to enable
23-
2415
error[E0744]: `.await` is not allowed in a `const`
2516
--> $DIR/issue-70594.rs:4:9
2617
|
@@ -35,7 +26,7 @@ LL | [1; ().await];
3526
|
3627
= note: required by `std::future::Future::poll`
3728

38-
error: aborting due to 5 previous errors
29+
error: aborting due to 4 previous errors
3930

40-
Some errors have detailed explanations: E0277, E0658, E0728, E0744.
31+
Some errors have detailed explanations: E0277, E0728, E0744.
4132
For more information about an error, try `rustc --explain E0277`.

src/test/ui/closures/issue-52437.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
fn main() {
22
[(); &(&'static: loop { |x| {}; }) as *const _ as usize]
33
//~^ ERROR: invalid label name `'static`
4-
//~| ERROR: `loop` is not allowed in a `const`
54
//~| ERROR: type annotations needed
65
//~| ERROR mismatched types
76
}

src/test/ui/closures/issue-52437.stderr

+2-11
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ error: invalid label name `'static`
44
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
55
| ^^^^^^^
66

7-
error[E0658]: `loop` is not allowed in a `const`
8-
--> $DIR/issue-52437.rs:2:13
9-
|
10-
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
12-
|
13-
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
14-
= help: add `#![feature(const_loop)]` to the crate attributes to enable
15-
167
error[E0282]: type annotations needed
178
--> $DIR/issue-52437.rs:2:30
189
|
@@ -27,7 +18,7 @@ LL | fn main() {
2718
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
2819
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[(); _]`
2920

30-
error: aborting due to 4 previous errors
21+
error: aborting due to 3 previous errors
3122

32-
Some errors have detailed explanations: E0282, E0308, E0658.
23+
Some errors have detailed explanations: E0282, E0308.
3324
For more information about an error, try `rustc --explain E0282`.

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

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ fn main() {
44
let _ = [(); {
55
let mut n = 113383; // #20 in https://oeis.org/A006884
66
while n != 0 {
7-
//~^ ERROR `while` is not allowed in a `const`
87
n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
98
//~^ ERROR evaluation of constant value failed
109
}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
error[E0658]: `while` is not allowed in a `const`
2-
--> $DIR/infinite_loop.rs:6:9
3-
|
4-
LL | / while n != 0 {
5-
LL | |
6-
LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
7-
LL | |
8-
LL | | }
9-
| |_________^
10-
|
11-
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
12-
= help: add `#![feature(const_loop)]` to the crate attributes to enable
13-
141
error[E0080]: evaluation of constant value failed
15-
--> $DIR/infinite_loop.rs:8:17
2+
--> $DIR/infinite_loop.rs:7:17
163
|
174
LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
185
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
196

20-
error: aborting due to 2 previous errors
7+
error: aborting due to previous error
218

22-
Some errors have detailed explanations: E0080, E0658.
23-
For more information about an error, try `rustc --explain E0080`.
9+
For more information about this error, try `rustc --explain E0080`.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
fn main() {
22
[(); { &loop { break } as *const _ as usize } ];
3-
//~^ ERROR `loop` is not allowed in a `const`
4-
//~| ERROR casting pointers to integers in constants is unstable
3+
//~^ ERROR casting pointers to integers in constants is unstable
54
//~| ERROR evaluation of constant value failed
65
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
error[E0658]: `loop` is not allowed in a `const`
2-
--> $DIR/issue-52442.rs:2:14
3-
|
4-
LL | [(); { &loop { break } as *const _ as usize } ];
5-
| ^^^^^^^^^^^^^^
6-
|
7-
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
8-
= help: add `#![feature(const_loop)]` to the crate attributes to enable
9-
101
error[E0658]: casting pointers to integers in constants is unstable
112
--> $DIR/issue-52442.rs:2:13
123
|
@@ -22,7 +13,7 @@ error[E0080]: evaluation of constant value failed
2213
LL | [(); { &loop { break } as *const _ as usize } ];
2314
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
2415

25-
error: aborting due to 3 previous errors
16+
error: aborting due to 2 previous errors
2617

2718
Some errors have detailed explanations: E0080, E0658.
2819
For more information about an error, try `rustc --explain E0080`.

src/test/ui/consts/const-eval/issue-52475.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ fn main() {
33
let mut x = &0;
44
let mut n = 0;
55
while n < 5 {
6-
//~^ ERROR `while` is not allowed in a `const`
76
n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
87
x = &0; // Materialize a new AllocId
98
}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
error[E0658]: `while` is not allowed in a `const`
2-
--> $DIR/issue-52475.rs:5:9
3-
|
4-
LL | / while n < 5 {
5-
LL | |
6-
LL | | n = (n + 1) % 5;
7-
LL | | x = &0; // Materialize a new AllocId
8-
LL | | }
9-
| |_________^
10-
|
11-
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
12-
= help: add `#![feature(const_loop)]` to the crate attributes to enable
13-
141
error[E0080]: evaluation of constant value failed
15-
--> $DIR/issue-52475.rs:7:17
2+
--> $DIR/issue-52475.rs:6:17
163
|
174
LL | n = (n + 1) % 5;
185
| ^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
196

20-
error: aborting due to 2 previous errors
7+
error: aborting due to previous error
218

22-
Some errors have detailed explanations: E0080, E0658.
23-
For more information about an error, try `rustc --explain E0080`.
9+
For more information about this error, try `rustc --explain E0080`.

src/test/ui/consts/const-eval/issue-62272.rs

-11
This file was deleted.

src/test/ui/consts/const-eval/issue-62272.stderr

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(const_loop)]
2-
31
static _X: () = loop {}; //~ ERROR could not evaluate static initializer
42

53
fn main() {}

src/test/ui/consts/const-eval/issue-70723.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: could not evaluate static initializer
2-
--> $DIR/issue-70723.rs:3:17
2+
--> $DIR/issue-70723.rs:1:17
33
|
44
LL | static _X: () = loop {};
55
| ^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)

src/test/ui/consts/const-eval/livedrop.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(const_if_match)]
2-
#![feature(const_loop)]
3-
41
const _: Option<Vec<i32>> = {
52
let mut never_returned = Some(Vec::new());
63
let mut always_returned = None; //~ ERROR destructors cannot be evaluated at compile-time

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0493]: destructors cannot be evaluated at compile-time
2-
--> $DIR/livedrop.rs:6:9
2+
--> $DIR/livedrop.rs:3:9
33
|
44
LL | let mut always_returned = None;
55
| ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors
+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
// run-pass
2+
13
// Using labeled break in a while loop has caused an illegal instruction being
24
// generated, and an ICE later.
35
//
46
// See https://github.com/rust-lang/rust/issues/51350 for more information.
5-
//
6-
// It is now forbidden by the HIR const-checker.
7-
//
8-
// See https://github.com/rust-lang/rust/pull/66170.
97

10-
const CRASH: () = 'a: while break 'a {}; //~ ERROR `while` is not allowed in a `const`
8+
#[allow(unreachable_code)]
9+
const _: () = 'a: while break 'a {};
1110

1211
fn main() {}

src/test/ui/consts/const-labeled-break.stderr

-12
This file was deleted.

src/test/ui/consts/const_limit/const_eval_limit_not_reached.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// check-pass
22

33
#![feature(const_eval_limit)]
4-
#![feature(const_loop)]
54

65
// This needs to be higher than the number of loop iterations since each pass through the loop may
76
// hit more than one terminator.

src/test/ui/consts/const_limit/const_eval_limit_reached.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(const_eval_limit)]
2-
#![feature(const_loop)]
32
#![const_eval_limit = "500"]
43

54
const X: usize = {

src/test/ui/consts/const_limit/const_eval_limit_reached.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: any use of this value will cause an error
2-
--> $DIR/const_eval_limit_reached.rs:7:11
2+
--> $DIR/const_eval_limit_reached.rs:6:5
33
|
44
LL | / const X: usize = {
55
LL | | let mut x = 0;

src/test/ui/consts/control-flow/basics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// run-pass
44

55
#![feature(const_panic)]
6-
#![feature(const_loop)]
76
#![feature(const_fn)]
87

98
const X: u32 = 4;

src/test/ui/consts/control-flow/drop-fail.precise.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0493]: destructors cannot be evaluated at compile-time
2-
--> $DIR/drop-fail.rs:9:9
2+
--> $DIR/drop-fail.rs:8:9
33
|
44
LL | let x = Some(Vec::new());
55
| ^ constants cannot evaluate destructors
66

77
error[E0493]: destructors cannot be evaluated at compile-time
8-
--> $DIR/drop-fail.rs:40:9
8+
--> $DIR/drop-fail.rs:39:9
99
|
1010
LL | let mut tmp = None;
1111
| ^^^^^^^ constants cannot evaluate destructors

src/test/ui/consts/control-flow/drop-fail.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// revisions: stock precise
22

3-
#![feature(const_loop)]
43
#![cfg_attr(precise, feature(const_precise_live_drops))]
54

65
// `x` is *not* always moved into the final value and may be dropped inside the initializer.

src/test/ui/consts/control-flow/drop-fail.stock.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0493]: destructors cannot be evaluated at compile-time
2-
--> $DIR/drop-fail.rs:9:9
2+
--> $DIR/drop-fail.rs:8:9
33
|
44
LL | let x = Some(Vec::new());
55
| ^ constants cannot evaluate destructors
@@ -8,7 +8,7 @@ LL | };
88
| - value is dropped here
99

1010
error[E0493]: destructors cannot be evaluated at compile-time
11-
--> $DIR/drop-fail.rs:22:9
11+
--> $DIR/drop-fail.rs:21:9
1212
|
1313
LL | let vec_tuple = (Vec::new(),);
1414
| ^^^^^^^^^ constants cannot evaluate destructors
@@ -17,7 +17,7 @@ LL | };
1717
| - value is dropped here
1818

1919
error[E0493]: destructors cannot be evaluated at compile-time
20-
--> $DIR/drop-fail.rs:30:9
20+
--> $DIR/drop-fail.rs:29:9
2121
|
2222
LL | let x: Result<_, Vec<i32>> = Ok(Vec::new());
2323
| ^ constants cannot evaluate destructors
@@ -26,7 +26,7 @@ LL | };
2626
| - value is dropped here
2727

2828
error[E0493]: destructors cannot be evaluated at compile-time
29-
--> $DIR/drop-fail.rs:40:9
29+
--> $DIR/drop-fail.rs:39:9
3030
|
3131
LL | let mut tmp = None;
3232
| ^^^^^^^ constants cannot evaluate destructors

src/test/ui/consts/control-flow/drop-pass.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// run-pass
22
// revisions: stock precise
33

4-
#![feature(const_loop)]
54
#![cfg_attr(precise, feature(const_precise_live_drops))]
65

76
// `x` is always moved into the final value and is not dropped inside the initializer.

src/test/ui/consts/control-flow/drop-precise.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// run-pass
22
// gate-test-const_precise_live_drops
33

4-
#![feature(const_loop)]
54
#![feature(const_precise_live_drops)]
65

76
const _: Vec<i32> = {

src/test/ui/consts/control-flow/interior-mutability.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Ensure that *any* assignment to the return place of a value with interior mutability
22
// disqualifies it from promotion.
33

4-
#![feature(const_loop)]
5-
64
use std::cell::Cell;
75

86
const X: Option<Cell<i32>> = {

0 commit comments

Comments
 (0)