Update tests
This commit is contained in:
parent
7c46e42512
commit
d84f0c8d32
47 changed files with 105 additions and 415 deletions
|
|
@ -4,7 +4,6 @@ async fn fun() {
|
|||
[1; ().await];
|
||||
//~^ error: `await` is only allowed inside `async` functions and blocks
|
||||
//~| error: `.await` is not allowed in a `const`
|
||||
//~| error: `loop` is not allowed in a `const`
|
||||
//~| error: `.await` is not allowed in a `const`
|
||||
//~| error: `()` is not a future
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,6 @@ error[E0744]: `.await` is not allowed in a `const`
|
|||
LL | [1; ().await];
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0658]: `loop` is not allowed in a `const`
|
||||
--> $DIR/issue-70594.rs:4:9
|
||||
|
|
||||
LL | [1; ().await];
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0744]: `.await` is not allowed in a `const`
|
||||
--> $DIR/issue-70594.rs:4:9
|
||||
|
|
||||
|
|
@ -36,7 +27,7 @@ LL | [1; ().await];
|
|||
= help: the trait `std::future::Future` is not implemented for `()`
|
||||
= note: required by `std::future::Future::poll`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0658, E0728, E0744.
|
||||
Some errors have detailed explanations: E0277, E0728, E0744.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
fn main() {
|
||||
[(); &(&'static: loop { |x| {}; }) as *const _ as usize]
|
||||
//~^ ERROR: invalid label name `'static`
|
||||
//~| ERROR: `loop` is not allowed in a `const`
|
||||
//~| ERROR: type annotations needed
|
||||
//~| ERROR mismatched types
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,6 @@ error: invalid label name `'static`
|
|||
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0658]: `loop` is not allowed in a `const`
|
||||
--> $DIR/issue-52437.rs:2:13
|
||||
|
|
||||
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-52437.rs:2:30
|
||||
|
|
||||
|
|
@ -27,7 +18,7 @@ LL | fn main() {
|
|||
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[(); _]`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0282, E0308, E0658.
|
||||
Some errors have detailed explanations: E0282, E0308.
|
||||
For more information about an error, try `rustc --explain E0282`.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ fn main() {
|
|||
let _ = [(); {
|
||||
let mut n = 113383; // #20 in https://oeis.org/A006884
|
||||
while n != 0 {
|
||||
//~^ ERROR `while` is not allowed in a `const`
|
||||
n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,9 @@
|
|||
error[E0658]: `while` is not allowed in a `const`
|
||||
--> $DIR/infinite_loop.rs:6:9
|
||||
|
|
||||
LL | / while n != 0 {
|
||||
LL | |
|
||||
LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/infinite_loop.rs:8:17
|
||||
--> $DIR/infinite_loop.rs:7:17
|
||||
|
|
||||
LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
Some errors have detailed explanations: E0080, E0658.
|
||||
For more information about an error, try `rustc --explain E0080`.
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
fn main() {
|
||||
[(); { &loop { break } as *const _ as usize } ];
|
||||
//~^ ERROR `loop` is not allowed in a `const`
|
||||
//~| ERROR casting pointers to integers in constants is unstable
|
||||
//~^ ERROR casting pointers to integers in constants is unstable
|
||||
//~| ERROR evaluation of constant value failed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
error[E0658]: `loop` is not allowed in a `const`
|
||||
--> $DIR/issue-52442.rs:2:14
|
||||
|
|
||||
LL | [(); { &loop { break } as *const _ as usize } ];
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: casting pointers to integers in constants is unstable
|
||||
--> $DIR/issue-52442.rs:2:13
|
||||
|
|
||||
|
|
@ -22,7 +13,7 @@ error[E0080]: evaluation of constant value failed
|
|||
LL | [(); { &loop { break } as *const _ as usize } ];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0080, E0658.
|
||||
For more information about an error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ fn main() {
|
|||
let mut x = &0;
|
||||
let mut n = 0;
|
||||
while n < 5 {
|
||||
//~^ ERROR `while` is not allowed in a `const`
|
||||
n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
|
||||
x = &0; // Materialize a new AllocId
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,9 @@
|
|||
error[E0658]: `while` is not allowed in a `const`
|
||||
--> $DIR/issue-52475.rs:5:9
|
||||
|
|
||||
LL | / while n < 5 {
|
||||
LL | |
|
||||
LL | | n = (n + 1) % 5;
|
||||
LL | | x = &0; // Materialize a new AllocId
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/issue-52475.rs:7:17
|
||||
--> $DIR/issue-52475.rs:6:17
|
||||
|
|
||||
LL | n = (n + 1) % 5;
|
||||
| ^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
Some errors have detailed explanations: E0080, E0658.
|
||||
For more information about an error, try `rustc --explain E0080`.
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
// `loop`s unconditionally-broken-from used to be allowed in constants, but are now forbidden by
|
||||
// the HIR const-checker.
|
||||
//
|
||||
// See https://github.com/rust-lang/rust/pull/66170 and
|
||||
// https://github.com/rust-lang/rust/issues/62272.
|
||||
|
||||
const FOO: () = loop { break; }; //~ ERROR `loop` is not allowed in a `const`
|
||||
|
||||
fn main() {
|
||||
[FOO; { let x; loop { x = 5; break; } x }]; //~ ERROR `loop` is not allowed in a `const`
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
error[E0658]: `loop` is not allowed in a `const`
|
||||
--> $DIR/issue-62272.rs:7:17
|
||||
|
|
||||
LL | const FOO: () = loop { break; };
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `loop` is not allowed in a `const`
|
||||
--> $DIR/issue-62272.rs:10:20
|
||||
|
|
||||
LL | [FOO; { let x; loop { x = 5; break; } x }];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_loop)]
|
||||
|
||||
static _X: () = loop {}; //~ ERROR could not evaluate static initializer
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/issue-70723.rs:3:17
|
||||
--> $DIR/issue-70723.rs:1:17
|
||||
|
|
||||
LL | static _X: () = loop {};
|
||||
| ^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
#![feature(const_if_match)]
|
||||
#![feature(const_loop)]
|
||||
|
||||
const _: Option<Vec<i32>> = {
|
||||
let mut never_returned = Some(Vec::new());
|
||||
let mut always_returned = None; //~ ERROR destructors cannot be evaluated at compile-time
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/livedrop.rs:6:9
|
||||
--> $DIR/livedrop.rs:3:9
|
||||
|
|
||||
LL | let mut always_returned = None;
|
||||
| ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
// run-pass
|
||||
|
||||
// Using labeled break in a while loop has caused an illegal instruction being
|
||||
// generated, and an ICE later.
|
||||
//
|
||||
// See https://github.com/rust-lang/rust/issues/51350 for more information.
|
||||
//
|
||||
// It is now forbidden by the HIR const-checker.
|
||||
//
|
||||
// See https://github.com/rust-lang/rust/pull/66170.
|
||||
|
||||
const CRASH: () = 'a: while break 'a {}; //~ ERROR `while` is not allowed in a `const`
|
||||
#[allow(unreachable_code)]
|
||||
const _: () = 'a: while break 'a {};
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
error[E0658]: `while` is not allowed in a `const`
|
||||
--> $DIR/const-labeled-break.rs:10:19
|
||||
|
|
||||
LL | const CRASH: () = 'a: while break 'a {};
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(const_eval_limit)]
|
||||
#![feature(const_loop)]
|
||||
|
||||
// This needs to be higher than the number of loop iterations since each pass through the loop may
|
||||
// hit more than one terminator.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#![feature(const_eval_limit)]
|
||||
#![feature(const_loop)]
|
||||
#![const_eval_limit = "500"]
|
||||
|
||||
const X: usize = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: any use of this value will cause an error
|
||||
--> $DIR/const_eval_limit_reached.rs:7:11
|
||||
--> $DIR/const_eval_limit_reached.rs:6:5
|
||||
|
|
||||
LL | / const X: usize = {
|
||||
LL | | let mut x = 0;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
// run-pass
|
||||
|
||||
#![feature(const_panic)]
|
||||
#![feature(const_loop)]
|
||||
#![feature(const_fn)]
|
||||
|
||||
const X: u32 = 4;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:9:9
|
||||
--> $DIR/drop-fail.rs:8:9
|
||||
|
|
||||
LL | let x = Some(Vec::new());
|
||||
| ^ constants cannot evaluate destructors
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:40:9
|
||||
--> $DIR/drop-fail.rs:39:9
|
||||
|
|
||||
LL | let mut tmp = None;
|
||||
| ^^^^^^^ constants cannot evaluate destructors
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
// revisions: stock precise
|
||||
|
||||
#![feature(const_loop)]
|
||||
#![cfg_attr(precise, feature(const_precise_live_drops))]
|
||||
|
||||
// `x` is *not* always moved into the final value and may be dropped inside the initializer.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:9:9
|
||||
--> $DIR/drop-fail.rs:8:9
|
||||
|
|
||||
LL | let x = Some(Vec::new());
|
||||
| ^ constants cannot evaluate destructors
|
||||
|
|
@ -8,7 +8,7 @@ LL | };
|
|||
| - value is dropped here
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:22:9
|
||||
--> $DIR/drop-fail.rs:21:9
|
||||
|
|
||||
LL | let vec_tuple = (Vec::new(),);
|
||||
| ^^^^^^^^^ constants cannot evaluate destructors
|
||||
|
|
@ -17,7 +17,7 @@ LL | };
|
|||
| - value is dropped here
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:30:9
|
||||
--> $DIR/drop-fail.rs:29:9
|
||||
|
|
||||
LL | let x: Result<_, Vec<i32>> = Ok(Vec::new());
|
||||
| ^ constants cannot evaluate destructors
|
||||
|
|
@ -26,7 +26,7 @@ LL | };
|
|||
| - value is dropped here
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/drop-fail.rs:40:9
|
||||
--> $DIR/drop-fail.rs:39:9
|
||||
|
|
||||
LL | let mut tmp = None;
|
||||
| ^^^^^^^ constants cannot evaluate destructors
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// run-pass
|
||||
// revisions: stock precise
|
||||
|
||||
#![feature(const_loop)]
|
||||
#![cfg_attr(precise, feature(const_precise_live_drops))]
|
||||
|
||||
// `x` is always moved into the final value and is not dropped inside the initializer.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// run-pass
|
||||
// gate-test-const_precise_live_drops
|
||||
|
||||
#![feature(const_loop)]
|
||||
#![feature(const_precise_live_drops)]
|
||||
|
||||
const _: Vec<i32> = {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
// Ensure that *any* assignment to the return place of a value with interior mutability
|
||||
// disqualifies it from promotion.
|
||||
|
||||
#![feature(const_loop)]
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
const X: Option<Cell<i32>> = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/interior-mutability.rs:42:26
|
||||
--> $DIR/interior-mutability.rs:40:26
|
||||
|
|
||||
LL | let x: &'static _ = &X;
|
||||
| ---------- ^ creates a temporary which is freed while still in use
|
||||
|
|
@ -10,7 +10,7 @@ LL | }
|
|||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/interior-mutability.rs:43:26
|
||||
--> $DIR/interior-mutability.rs:41:26
|
||||
|
|
||||
LL | let y: &'static _ = &Y;
|
||||
| ---------- ^ creates a temporary which is freed while still in use
|
||||
|
|
@ -21,7 +21,7 @@ LL | }
|
|||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/interior-mutability.rs:44:26
|
||||
--> $DIR/interior-mutability.rs:42:26
|
||||
|
|
||||
LL | let z: &'static _ = &Z;
|
||||
| ---------- ^ creates a temporary which is freed while still in use
|
||||
|
|
|
|||
|
|
@ -1,29 +1,22 @@
|
|||
// Ensure that loops are forbidden in a const context unless `#![feature(const_loop)]` is enabled.
|
||||
const _: () = loop { break (); };
|
||||
|
||||
// gate-test-const_loop
|
||||
// revisions: stock loop_
|
||||
|
||||
#![cfg_attr(loop_, feature(const_loop))]
|
||||
|
||||
const _: () = loop {}; //[stock]~ ERROR `loop` is not allowed in a `const`
|
||||
|
||||
static FOO: i32 = loop { break 4; }; //[stock]~ ERROR `loop` is not allowed in a `static`
|
||||
static FOO: i32 = loop { break 4; };
|
||||
|
||||
const fn foo() {
|
||||
loop {} //[stock]~ ERROR `loop` is not allowed in a `const fn`
|
||||
loop {}
|
||||
}
|
||||
|
||||
pub trait Foo {
|
||||
const BAR: i32 = loop { break 4; }; //[stock]~ ERROR `loop` is not allowed in a `const`
|
||||
const BAR: i32 = loop { break 4; };
|
||||
}
|
||||
|
||||
impl Foo for () {
|
||||
const BAR: i32 = loop { break 4; }; //[stock]~ ERROR `loop` is not allowed in a `const`
|
||||
const BAR: i32 = loop { break 4; };
|
||||
}
|
||||
|
||||
fn non_const_outside() {
|
||||
const fn const_inside() {
|
||||
loop {} //[stock]~ ERROR `loop` is not allowed in a `const fn`
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +29,6 @@ const fn const_outside() {
|
|||
fn main() {
|
||||
let x = [0; {
|
||||
while false {}
|
||||
//[stock]~^ ERROR `while` is not allowed in a `const`
|
||||
4
|
||||
}];
|
||||
}
|
||||
|
|
@ -44,11 +36,11 @@ fn main() {
|
|||
const _: i32 = {
|
||||
let mut x = 0;
|
||||
|
||||
while x < 4 { //[stock]~ ERROR `while` is not allowed in a `const`
|
||||
while x < 4 {
|
||||
x += 1;
|
||||
}
|
||||
|
||||
while x < 8 { //[stock]~ ERROR `while` is not allowed in a `const`
|
||||
while x < 8 {
|
||||
x += 1;
|
||||
}
|
||||
|
||||
|
|
@ -58,11 +50,11 @@ const _: i32 = {
|
|||
const _: i32 = {
|
||||
let mut x = 0;
|
||||
|
||||
for i in 0..4 { //[stock,loop_]~ ERROR `for` is not allowed in a `const`
|
||||
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
|
||||
x += i;
|
||||
}
|
||||
|
||||
for i in 0..4 { //[stock,loop_]~ ERROR `for` is not allowed in a `const`
|
||||
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
|
||||
x += i;
|
||||
}
|
||||
|
||||
|
|
@ -72,14 +64,14 @@ const _: i32 = {
|
|||
const _: i32 = {
|
||||
let mut x = 0;
|
||||
|
||||
loop { //[stock]~ ERROR `loop` is not allowed in a `const`
|
||||
loop {
|
||||
x += 1;
|
||||
if x == 4 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
loop { //[stock]~ ERROR `loop` is not allowed in a `const`
|
||||
loop {
|
||||
x += 1;
|
||||
if x == 8 {
|
||||
break;
|
||||
|
|
@ -91,7 +83,7 @@ const _: i32 = {
|
|||
|
||||
const _: i32 = {
|
||||
let mut x = 0;
|
||||
while let None = Some(x) { } //[stock]~ ERROR `while` is not allowed in a `const`
|
||||
while let None = Some(x) { } //[stock]~ ERROR `while` is not allowed in a `const`
|
||||
while let None = Some(x) { }
|
||||
while let None = Some(x) { }
|
||||
x
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0744]: `for` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:61:5
|
||||
--> $DIR/loop.rs:53:5
|
||||
|
|
||||
LL | / for i in 0..4 {
|
||||
LL | | x += i;
|
||||
|
|
@ -7,7 +7,7 @@ LL | | }
|
|||
| |_____^
|
||||
|
||||
error[E0744]: `for` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:65:5
|
||||
--> $DIR/loop.rs:57:5
|
||||
|
|
||||
LL | / for i in 0..4 {
|
||||
LL | | x += i;
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
error[E0658]: `loop` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:8:15
|
||||
|
|
||||
LL | const _: () = loop {};
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `loop` is not allowed in a `static`
|
||||
--> $DIR/loop.rs:10:19
|
||||
|
|
||||
LL | static FOO: i32 = loop { break 4; };
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `loop` is not allowed in a `const fn`
|
||||
--> $DIR/loop.rs:13:5
|
||||
|
|
||||
LL | loop {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `loop` is not allowed in a `const fn`
|
||||
--> $DIR/loop.rs:26:9
|
||||
|
|
||||
LL | loop {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `while` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:38:9
|
||||
|
|
||||
LL | while false {}
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `while` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:47:5
|
||||
|
|
||||
LL | / while x < 4 {
|
||||
LL | | x += 1;
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `while` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:51:5
|
||||
|
|
||||
LL | / while x < 8 {
|
||||
LL | | x += 1;
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0744]: `for` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:61:5
|
||||
|
|
||||
LL | / for i in 0..4 {
|
||||
LL | | x += i;
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
||||
error[E0744]: `for` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:65:5
|
||||
|
|
||||
LL | / for i in 0..4 {
|
||||
LL | | x += i;
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
||||
error[E0658]: `loop` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:75:5
|
||||
|
|
||||
LL | / loop {
|
||||
LL | | x += 1;
|
||||
LL | | if x == 4 {
|
||||
LL | | break;
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `loop` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:82:5
|
||||
|
|
||||
LL | / loop {
|
||||
LL | | x += 1;
|
||||
LL | | if x == 8 {
|
||||
LL | | break;
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `while` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:94:5
|
||||
|
|
||||
LL | while let None = Some(x) { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `while` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:95:5
|
||||
|
|
||||
LL | while let None = Some(x) { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `loop` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:17:22
|
||||
|
|
||||
LL | const BAR: i32 = loop { break 4; };
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: `loop` is not allowed in a `const`
|
||||
--> $DIR/loop.rs:21:22
|
||||
|
|
||||
LL | const BAR: i32 = loop { break 4; };
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0658, E0744.
|
||||
For more information about an error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
const fn foo() {
|
||||
loop {} //~ ERROR `loop` is not allowed in a `const fn`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
error[E0658]: `loop` is not allowed in a `const fn`
|
||||
--> $DIR/loop_ice.rs:2:5
|
||||
|
|
||||
LL | loop {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
// Don't allow unstable features in stable functions without `allow_internal_unstable`.
|
||||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
#![feature(staged_api)]
|
||||
#![feature(const_loop, const_fn)]
|
||||
#![feature(const_transmute, const_fn)]
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
|
||||
const fn foo() -> i32 {
|
||||
loop { return 42; } //~ ERROR `loop` is not allowed in a `const fn`
|
||||
pub const fn foo() -> i32 {
|
||||
unsafe { std::mem::transmute(4u32) } //~ ERROR is not stable as `const fn`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
error[E0744]: `loop` is not allowed in a `const fn`
|
||||
--> $DIR/internal-unstable-const.rs:9:5
|
||||
error[E0723]: can only call other `const fn` within a `const fn`, but `const std::intrinsics::transmute::<u32, i32>` is not stable as `const fn`
|
||||
--> $DIR/internal-unstable-const.rs:11:14
|
||||
|
|
||||
LL | loop { return 42; }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
LL | unsafe { std::mem::transmute(4u32) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
|
||||
= help: add `#![feature(const_fn)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0744`.
|
||||
For more information about this error, try `rustc --explain E0723`.
|
||||
|
|
|
|||
|
|
@ -10,5 +10,4 @@ fn main() {
|
|||
|
||||
[(); return while let Some(n) = Some(0) {}];
|
||||
//~^ ERROR return statement outside of function body
|
||||
//~| ERROR `while` is not allowed in a `const`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
error[E0658]: `while` is not allowed in a `const`
|
||||
--> $DIR/issue-51714.rs:11:17
|
||||
|
|
||||
LL | [(); return while let Some(n) = Some(0) {}];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
|
||||
error[E0572]: return statement outside of function body
|
||||
--> $DIR/issue-51714.rs:2:14
|
||||
|
|
||||
|
|
@ -31,7 +22,6 @@ error[E0572]: return statement outside of function body
|
|||
LL | [(); return while let Some(n) = Some(0) {}];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0572, E0658.
|
||||
For more information about an error, try `rustc --explain E0572`.
|
||||
For more information about this error, try `rustc --explain E0572`.
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@
|
|||
#![allow(incomplete_features)]
|
||||
|
||||
pub trait MyTrait {
|
||||
fn method(&self);
|
||||
fn method(&self) -> Option<()>;
|
||||
}
|
||||
|
||||
impl const MyTrait for () {
|
||||
fn method(&self) {
|
||||
loop {} //~ ERROR `loop` is not allowed in a `const fn`
|
||||
fn method(&self) -> Option<()> {
|
||||
Some(())?; //~ ERROR `?` is not allowed in a `const fn`
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
error[E0658]: `loop` is not allowed in a `const fn`
|
||||
error[E0744]: `?` is not allowed in a `const fn`
|
||||
--> $DIR/hir-const-check.rs:12:9
|
||||
|
|
||||
LL | loop {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
|
||||
= help: add `#![feature(const_loop)]` to the crate attributes to enable
|
||||
LL | Some(())?;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
For more information about this error, try `rustc --explain E0744`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue