Update tests

This commit is contained in:
Dylan MacKenzie 2020-05-21 12:49:38 -07:00
parent 696084c764
commit d6139f76c0
78 changed files with 228 additions and 1192 deletions

View File

@ -2,7 +2,8 @@
// run-pass
#![feature(const_fn, const_if_match)]
#![feature(const_fn)]
#[derive(PartialEq, Debug, Clone)]
struct N(u8);

View File

@ -2,7 +2,8 @@ struct Project;
struct Value;
static settings_dir: String = format!("");
//~^ ERROR `match` is not allowed in a `static`
//~^ ERROR calls in statics are limited to constant functions
//~| ERROR calls in statics are limited to constant functions
fn from_string(_: String) -> Value {
Value
@ -11,6 +12,7 @@ fn set_editor(_: Value) {}
fn main() {
let settings_data = from_string(settings_dir);
//~^ ERROR cannot move out of static item
let args: i32 = 0;
match args {

View File

@ -1,13 +1,26 @@
error[E0658]: `match` is not allowed in a `static`
error[E0507]: cannot move out of static item `settings_dir`
--> $DIR/issue-64453.rs:14:37
|
LL | let settings_data = from_string(settings_dir);
| ^^^^^^^^^^^^ move occurs because `settings_dir` has type `std::string::String`, which does not implement the `Copy` trait
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
--> $DIR/issue-64453.rs:4:31
|
LL | static settings_dir: String = format!("");
| ^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
--> $DIR/issue-64453.rs:4:31
|
LL | static settings_dir: String = format!("");
| ^^^^^^^^^^^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0658`.
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0015, E0507.
For more information about an error, try `rustc --explain E0015`.

View File

@ -7,7 +7,6 @@ fn main() {
//~^ 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
//~| ERROR `if` is not allowed in a `const`
}
n
}];

View File

@ -5,22 +5,11 @@ LL | / while n != 0 {
LL | |
LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
LL | |
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
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const`
--> $DIR/infinite_loop.rs:8:17
|
LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0080]: evaluation of constant value failed
--> $DIR/infinite_loop.rs:8:17
@ -28,7 +17,7 @@ error[E0080]: evaluation of constant value failed
LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
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`.

View File

@ -10,7 +10,6 @@ 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
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0080]: evaluation of constant value failed
--> $DIR/issue-52475.rs:7:17

View File

@ -5,7 +5,6 @@ fn main() {
let _: [u8; 0] = [4; {
match &1 as *const i32 as usize {
//~^ ERROR casting pointers to integers in constants
//~| ERROR `match` is not allowed in a `const`
//~| ERROR evaluation of constant value failed
0 => 42,
n => n,

View File

@ -1,18 +1,3 @@
error[E0658]: `match` is not allowed in a `const`
--> $DIR/match-test-ptr-null.rs:6:9
|
LL | / match &1 as *const i32 as usize {
LL | |
LL | |
LL | |
LL | | 0 => 42,
LL | | n => n,
LL | | }
| |_________^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: casting pointers to integers in constants is unstable
--> $DIR/match-test-ptr-null.rs:6:15
|
@ -28,7 +13,7 @@ error[E0080]: evaluation of constant value failed
LL | match &1 as *const i32 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`.

View File

@ -6,7 +6,6 @@ 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
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error: aborting due to previous error

View File

@ -1,12 +1,12 @@
#![allow(warnings)]
// check-pass
const x: bool = match Some(true) { //~ ERROR `match` is not allowed in a `const`
const _: bool = match Some(true) {
Some(value) => true,
_ => false
};
const y: bool = {
match Some(true) { //~ ERROR `match` is not allowed in a `const`
const _: bool = {
match Some(true) {
Some(value) => true,
_ => false
}

View File

@ -1,28 +0,0 @@
error[E0658]: `match` is not allowed in a `const`
--> $DIR/const-match-pattern-arm.rs:3:17
|
LL | const x: bool = match Some(true) {
| _________________^
LL | | Some(value) => true,
LL | | _ => false
LL | | };
| |_^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const`
--> $DIR/const-match-pattern-arm.rs:9:5
|
LL | / match Some(true) {
LL | | Some(value) => true,
LL | | _ => false
LL | | }
| |_____^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,6 +1,5 @@
// run-pass
#![feature(const_if_match)]
#![warn(indirect_structural_match)]
struct CustomEq;

View File

@ -1,6 +1,5 @@
// check-pass
#![feature(const_if_match)]
#![warn(indirect_structural_match)]
//~^ NOTE lint level is defined here

View File

@ -1,11 +1,11 @@
warning: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/custom-eq-branch-warn.rs:33:9
--> $DIR/custom-eq-branch-warn.rs:32:9
|
LL | BAR_BAZ => panic!(),
| ^^^^^^^
|
note: the lint level is defined here
--> $DIR/custom-eq-branch-warn.rs:4:9
--> $DIR/custom-eq-branch-warn.rs:3:9
|
LL | #![warn(indirect_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,4 +1,3 @@
#![feature(const_if_match)]
#![warn(indirect_structural_match)]
struct NoEq;

View File

@ -1,11 +1,11 @@
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/no-eq-branch-fail.rs:22:9
--> $DIR/no-eq-branch-fail.rs:21:9
|
LL | BAR_BAZ => panic!(),
| ^^^^^^^
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
--> $DIR/no-eq-branch-fail.rs:22:9
--> $DIR/no-eq-branch-fail.rs:21:9
|
LL | BAR_BAZ => panic!(),
| ^^^^^^^

View File

@ -2,6 +2,5 @@ fn main() {}
const fn slice(&[a, b]: &[i32]) -> i32 {
//~^ ERROR refutable pattern in function argument
//~| ERROR loops and conditional expressions are not stable in const fn
a + b
}

View File

@ -6,16 +6,6 @@ LL | const fn slice(&[a, b]: &[i32]) -> i32 {
|
= note: the matched value is of type `&[i32]`
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/const_let_refutable.rs:3:17
|
LL | const fn slice(&[a, b]: &[i32]) -> i32 {
| ^^^^^^
|
= 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
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0005, E0723.
For more information about an error, try `rustc --explain E0005`.
For more information about this error, try `rustc --explain E0005`.

View File

@ -1,7 +1,7 @@
// check-pass
#![feature(const_eval_limit)]
#![feature(const_loop, const_if_match)]
#![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.

View File

@ -1,7 +1,6 @@
#![feature(const_eval_limit)]
#![feature(const_loop, const_if_match)]
#![const_eval_limit="500"]
#![feature(const_loop)]
#![const_eval_limit = "500"]
const X: usize = {
let mut x = 0;

View File

@ -1,5 +1,5 @@
error: any use of this value will cause an error
--> $DIR/const_eval_limit_reached.rs:8:5
--> $DIR/const_eval_limit_reached.rs:7:11
|
LL | / const X: usize = {
LL | | let mut x = 0;

View File

@ -1,13 +1,13 @@
// check-pass
const _: bool = false && false;
const _: bool = true && false;
const _: bool = {
let mut x = true && false;
//~^ ERROR new features like let bindings are not permitted
x
};
const _: bool = {
let x = true && false;
//~^ ERROR new features like let bindings are not permitted
x
};

View File

@ -1,26 +0,0 @@
error: new features like let bindings are not permitted in constants which also use short circuiting operators
--> $DIR/const_short_circuit.rs:4:9
|
LL | let mut x = true && false;
| ^^^^^
|
note: use of `&&` operator here does not actually short circuit due to the const evaluator presently not being able to do control flow. See issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information.
--> $DIR/const_short_circuit.rs:4:22
|
LL | let mut x = true && false;
| ^^
error: new features like let bindings are not permitted in constants which also use short circuiting operators
--> $DIR/const_short_circuit.rs:9:9
|
LL | let x = true && false;
| ^
|
note: use of `&&` operator here does not actually short circuit due to the const evaluator presently not being able to do control flow. See issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information.
--> $DIR/const_short_circuit.rs:9:18
|
LL | let x = true && false;
| ^^
error: aborting due to 2 previous errors

View File

@ -1,13 +0,0 @@
error: any use of this value will cause an error
--> $DIR/assert.rs:12:15
|
LL | const _: () = assert!(false);
| --------------^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:12:15
|
= note: `#[deny(const_err)]` on by default
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View File

@ -1,23 +0,0 @@
error[E0658]: panicking in constants is unstable
--> $DIR/assert.rs:8:15
|
LL | const _: () = assert!(true);
| ^^^^^^^^^^^^^
|
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: panicking in constants is unstable
--> $DIR/assert.rs:12:15
|
LL | const _: () = assert!(false);
| ^^^^^^^^^^^^^^
|
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,23 +1,13 @@
error[E0658]: `if` is not allowed in a `const`
--> $DIR/assert.rs:8:15
|
LL | const _: () = assert!(true);
| ^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: `if` is not allowed in a `const`
--> $DIR/assert.rs:12:15
error: any use of this value will cause an error
--> $DIR/assert.rs:10:15
|
LL | const _: () = assert!(false);
| ^^^^^^^^^^^^^^
| --------------^^^^^^^^^^^^^^-
| |
| the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:10:15
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: `#[deny(const_err)]` on by default
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,17 +1,14 @@
// Test that `assert` works only when both `const_if_match` and `const_panic` are enabled.
// Test that `assert` works when `const_panic` is enabled.
// revisions: stock if_match panic both
// revisions: stock panic
#![cfg_attr(any(both, if_match), feature(const_if_match))]
#![cfg_attr(any(both, panic), feature(const_panic))]
#![cfg_attr(panic, feature(const_panic))]
const _: () = assert!(true);
//[stock,panic]~^ ERROR `if` is not allowed in a `const`
//[if_match]~^^ ERROR panicking in constants is unstable
//[stock]~^ ERROR panicking in constants is unstable
const _: () = assert!(false);
//[stock,panic]~^ ERROR `if` is not allowed in a `const`
//[if_match]~^^ ERROR panicking in constants is unstable
//[both]~^^^ ERROR any use of this value will cause an error
//[stock]~^ ERROR panicking in constants is unstable
//[panic]~^^ ERROR any use of this value will cause an error
fn main() {}

View File

@ -1,21 +1,21 @@
error[E0658]: `if` is not allowed in a `const`
--> $DIR/assert.rs:8:15
error[E0658]: panicking in constants is unstable
--> $DIR/assert.rs:7:15
|
LL | const _: () = assert!(true);
| ^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: `if` is not allowed in a `const`
--> $DIR/assert.rs:12:15
error[E0658]: panicking in constants is unstable
--> $DIR/assert.rs:10:15
|
LL | const _: () = assert!(false);
| ^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors

View File

@ -3,7 +3,6 @@
// run-pass
#![feature(const_panic)]
#![feature(const_if_match)]
#![feature(const_loop)]
#![feature(const_fn)]

View File

@ -1,11 +1,11 @@
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:10:9
--> $DIR/drop-fail.rs:9:9
|
LL | let x = Some(Vec::new());
| ^ constants cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:41:9
--> $DIR/drop-fail.rs:40:9
|
LL | let mut tmp = None;
| ^^^^^^^ constants cannot evaluate destructors

View File

@ -1,6 +1,5 @@
// revisions: stock precise
#![feature(const_if_match)]
#![feature(const_loop)]
#![cfg_attr(precise, feature(const_precise_live_drops))]

View File

@ -1,5 +1,5 @@
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:10:9
--> $DIR/drop-fail.rs:9: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:23:9
--> $DIR/drop-fail.rs:22: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:31:9
--> $DIR/drop-fail.rs:30: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:41:9
--> $DIR/drop-fail.rs:40:9
|
LL | let mut tmp = None;
| ^^^^^^^ constants cannot evaluate destructors

View File

@ -1,7 +1,6 @@
// run-pass
// revisions: stock precise
#![feature(const_if_match)]
#![feature(const_loop)]
#![cfg_attr(precise, feature(const_precise_live_drops))]

View File

@ -1,7 +1,6 @@
// run-pass
// gate-test-const_precise_live_drops
#![feature(const_if_match)]
#![feature(const_loop)]
#![feature(const_precise_live_drops)]

View File

@ -2,8 +2,6 @@
// check-pass
#![feature(const_if_match)]
enum E {
A,
B,

View File

@ -1,14 +0,0 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/feature-gate-const-if-match.rs:108:1
|
LL | / fn main() {
LL | | let _ = [0; {
LL | | let x = if false { 0 } else { 1 };
LL | |
... |
LL | | }];
LL | | }
| |_^
error: aborting due to previous error

View File

@ -1,25 +1,10 @@
// Ensure that `if`, `if let` and `match` are only allowed in the various const contexts when
// `#![feature(const_if_match)]` is enabled. When the feature gate is removed, the `#[rustc_error]`
// on `main` should be removed and this test converted to `check-pass`.
// check-pass
// revisions: stock if_match
const _: i32 = if true { 5 } else { 6 };
#![feature(rustc_attrs)]
#![cfg_attr(if_match, feature(const_if_match))]
const _: i32 = if let Some(true) = Some(false) { 0 } else { 1 };
const _: i32 = if true { //[stock]~ ERROR `if` is not allowed in a `const`
5
} else {
6
};
const _: i32 = if let Some(true) = Some(false) { //[stock]~ ERROR `if` is not allowed in a `const`
0
} else {
1
};
const _: i32 = match 1 { //[stock]~ ERROR `match` is not allowed in a `const`
const _: i32 = match 1 {
2 => 3,
4 => 5,
_ => 0,
@ -27,91 +12,85 @@ const _: i32 = match 1 { //[stock]~ ERROR `match` is not allowed in a `const`
static FOO: i32 = {
let x = if true { 0 } else { 1 };
//[stock]~^ ERROR `if` is not allowed in a `static`
let x = match x { 0 => 1, _ => 0 };
//[stock]~^ ERROR `match` is not allowed in a `static`
let x = match x {
0 => 1,
_ => 0,
};
if let Some(x) = Some(x) { x } else { 1 }
//[stock]~^ ERROR `if` is not allowed in a `static`
};
static mut BAR: i32 = {
let x = if true { 0 } else { 1 };
//[stock]~^ ERROR `if` is not allowed in a `static mut`
let x = match x { 0 => 1, _ => 0 };
//[stock]~^ ERROR `match` is not allowed in a `static mut`
let x = match x {
0 => 1,
_ => 0,
};
if let Some(x) = Some(x) { x } else { 1 }
//[stock]~^ ERROR `if` is not allowed in a `static mut`
};
const fn if_() -> i32 {
if true { 5 } else { 6 } //[stock]~ ERROR `if` is not allowed in a `const fn`
if true { 5 } else { 6 }
}
const fn if_let(a: Option<bool>) -> i32 {
if let Some(true) = a { //[stock]~ ERROR `if` is not allowed in a `const fn`
0
} else {
1
}
if let Some(true) = a { 0 } else { 1 }
}
const fn match_(i: i32) -> i32 {
match i { //[stock]~ ERROR `match` is not allowed in a `const fn`
match i {
i if i > 10 => i,
1 => 2,
_ => 0
_ => 0,
}
}
pub trait Foo {
const IF: i32 = if true { 5 } else { 6 };
//[stock]~^ ERROR `if` is not allowed in a `const`
const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 };
//[stock]~^ ERROR `if` is not allowed in a `const`
const MATCH: i32 = match 0 { 1 => 2, _ => 0 };
//[stock]~^ ERROR `match` is not allowed in a `const`
const MATCH: i32 = match 0 {
1 => 2,
_ => 0,
};
}
impl Foo for () {
const IF: i32 = if true { 5 } else { 6 };
//[stock]~^ ERROR `if` is not allowed in a `const`
const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 };
//[stock]~^ ERROR `if` is not allowed in a `const`
const MATCH: i32 = match 0 { 1 => 2, _ => 0 };
//[stock]~^ ERROR `match` is not allowed in a `const`
const MATCH: i32 = match 0 {
1 => 2,
_ => 0,
};
}
fn non_const_outside() {
const fn const_inside(y: bool) -> i32 {
let x = if y { 0 } else { 1 };
//[stock]~^ ERROR `if` is not allowed in a `const fn`
let x = match x { 0 => 1, _ => 0 };
//[stock]~^ ERROR `match` is not allowed in a `const fn`
let x = match x {
0 => 1,
_ => 0,
};
if let Some(x) = Some(x) { x } else { 1 }
//[stock]~^ ERROR `if` is not allowed in a `const fn`
}
}
const fn const_outside() {
fn non_const_inside(y: bool) -> i32 {
let x = if y { 0 } else { 1 };
let x = match x { 0 => 1, _ => 0 };
let x = match x {
0 => 1,
_ => 0,
};
if let Some(x) = Some(x) { x } else { 1 }
}
}
#[rustc_error]
fn main() { //[if_match]~ ERROR fatal error triggered by #[rustc_error]
fn main() {
let _ = [0; {
let x = if false { 0 } else { 1 };
//[stock]~^ ERROR `if` is not allowed in a `const`
let x = match x { 0 => 1, _ => 0 };
//[stock]~^ ERROR `match` is not allowed in a `const`
let x = match x {
0 => 1,
_ => 0,
};
if let Some(x) = Some(x) { x } else { 1 }
//[stock]~^ ERROR `if` is not allowed in a `const`
}];
}

View File

@ -1,242 +0,0 @@
error[E0658]: `if` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:10:16
|
LL | const _: i32 = if true {
| ________________^
LL | | 5
LL | | } else {
LL | | 6
LL | | };
| |_^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:16:16
|
LL | const _: i32 = if let Some(true) = Some(false) {
| ________________^
LL | | 0
LL | | } else {
LL | | 1
LL | | };
| |_^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:22:16
|
LL | const _: i32 = match 1 {
| ________________^
LL | | 2 => 3,
LL | | 4 => 5,
LL | | _ => 0,
LL | | };
| |_^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `static`
--> $DIR/feature-gate-const-if-match.rs:29:13
|
LL | let x = if true { 0 } else { 1 };
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `static`
--> $DIR/feature-gate-const-if-match.rs:31:13
|
LL | let x = match x { 0 => 1, _ => 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `static`
--> $DIR/feature-gate-const-if-match.rs:33:5
|
LL | if let Some(x) = Some(x) { x } else { 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `static mut`
--> $DIR/feature-gate-const-if-match.rs:38:13
|
LL | let x = if true { 0 } else { 1 };
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `static mut`
--> $DIR/feature-gate-const-if-match.rs:40:13
|
LL | let x = match x { 0 => 1, _ => 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `static mut`
--> $DIR/feature-gate-const-if-match.rs:42:5
|
LL | if let Some(x) = Some(x) { x } else { 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const fn`
--> $DIR/feature-gate-const-if-match.rs:47:5
|
LL | if true { 5 } else { 6 }
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const fn`
--> $DIR/feature-gate-const-if-match.rs:51:5
|
LL | / if let Some(true) = a {
LL | | 0
LL | | } else {
LL | | 1
LL | | }
| |_____^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const fn`
--> $DIR/feature-gate-const-if-match.rs:59:5
|
LL | / match i {
LL | | i if i > 10 => i,
LL | | 1 => 2,
LL | | _ => 0
LL | | }
| |_____^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const fn`
--> $DIR/feature-gate-const-if-match.rs:90:17
|
LL | let x = if y { 0 } else { 1 };
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const fn`
--> $DIR/feature-gate-const-if-match.rs:92:17
|
LL | let x = match x { 0 => 1, _ => 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const fn`
--> $DIR/feature-gate-const-if-match.rs:94:9
|
LL | if let Some(x) = Some(x) { x } else { 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:110:17
|
LL | let x = if false { 0 } else { 1 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:112:17
|
LL | let x = match x { 0 => 1, _ => 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:114:9
|
LL | if let Some(x) = Some(x) { x } else { 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:67:21
|
LL | const IF: i32 = if true { 5 } else { 6 };
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:70:25
|
LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:73:24
|
LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:78:21
|
LL | const IF: i32 = if true { 5 } else { 6 };
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `if` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:81:25
|
LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const`
--> $DIR/feature-gate-const-if-match.rs:84:24
|
LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error: aborting due to 24 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,7 +1,6 @@
// Ensure that *any* assignment to the return place of a value with interior mutability
// disqualifies it from promotion.
#![feature(const_if_match)]
#![feature(const_loop)]
use std::cell::Cell;
@ -39,7 +38,6 @@ const Z: Option<Cell<i32>> = {
z
};
fn main() {
let x: &'static _ = &X; //~ ERROR temporary value dropped while borrowed
let y: &'static _ = &Y; //~ ERROR temporary value dropped while borrowed

View File

@ -1,5 +1,5 @@
error[E0716]: temporary value dropped while borrowed
--> $DIR/interior-mutability.rs:44:26
--> $DIR/interior-mutability.rs:42: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:45:26
--> $DIR/interior-mutability.rs:43: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:46:26
--> $DIR/interior-mutability.rs:44:26
|
LL | let z: &'static _ = &Z;
| ---------- ^ creates a temporary which is freed while still in use

View File

@ -1,16 +1,14 @@
// revisions: stock if_match
#![cfg_attr(if_match, feature(const_if_match))]
enum Thing { This, That }
enum Thing {
This,
That,
}
fn non_const() -> Thing {
Thing::This
}
pub const Q: i32 = match non_const() {
//[stock]~^ ERROR `match` is not allowed in a `const`
//[if_match]~^^ ERROR calls in constants are limited to constant functions
//~^ ERROR calls in constants are limited to constant functions
Thing::This => 1,
Thing::That => 0
};

View File

@ -1,5 +1,5 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> $DIR/issue-46843.rs:11:26
--> $DIR/issue-46843.rs:10:26
|
LL | pub const Q: i32 = match non_const() {
| ^^^^^^^^^^^

View File

@ -1,18 +0,0 @@
error[E0658]: `match` is not allowed in a `const`
--> $DIR/issue-46843.rs:11:20
|
LL | pub const Q: i32 = match non_const() {
| ____________________^
LL | |
LL | |
LL | | Thing::This => 1,
LL | | Thing::That => 0
LL | | };
| |_^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,13 +1,6 @@
// revisions: stock if_match
#![cfg_attr(if_match, feature(const_if_match))]
fn main() {
enum Foo {
Drop = assert_eq!(1, 1)
//[stock,if_match]~^ ERROR `if` may be missing an `else` clause
//[stock]~^^ ERROR `match` is not allowed in a `const`
//[stock]~| ERROR `match` is not allowed in a `const`
//[stock]~| ERROR `if` is not allowed in a `const`
Drop = assert_eq!(1, 1),
//~^ ERROR `if` may be missing an `else` clause
}
}

View File

@ -1,7 +1,7 @@
error[E0317]: `if` may be missing an `else` clause
--> $DIR/issue-50577.rs:7:16
--> $DIR/issue-50577.rs:3:16
|
LL | Drop = assert_eq!(1, 1)
LL | Drop = assert_eq!(1, 1),
| ^^^^^^^^^^^^^^^^
| |
| expected `()`, found `isize`

View File

@ -1,47 +0,0 @@
error[E0658]: `match` is not allowed in a `const`
--> $DIR/issue-50577.rs:7:16
|
LL | Drop = assert_eq!(1, 1)
| ^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: `if` is not allowed in a `const`
--> $DIR/issue-50577.rs:7:16
|
LL | Drop = assert_eq!(1, 1)
| ^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: `match` is not allowed in a `const`
--> $DIR/issue-50577.rs:7:16
|
LL | Drop = assert_eq!(1, 1)
| ^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0317]: `if` may be missing an `else` clause
--> $DIR/issue-50577.rs:7:16
|
LL | Drop = assert_eq!(1, 1)
| ^^^^^^^^^^^^^^^^
| |
| expected `()`, found `isize`
| found here
|
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0317, E0658.
For more information about an error, try `rustc --explain E0317`.

View File

@ -1,19 +0,0 @@
error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:63:5
|
LL | / for i in 0..4 {
LL | | x += i;
LL | | }
| |_____^
error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:67:5
|
LL | / for i in 0..4 {
LL | | x += i;
LL | | }
| |_____^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0744`.

View File

@ -1,151 +0,0 @@
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:10: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:12: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:15: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:28: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:40: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:49: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:53: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:63:5
|
LL | / for i in 0..4 {
LL | | x += i;
LL | | }
| |_____^
error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:67:5
|
LL | / for i in 0..4 {
LL | | x += i;
LL | | }
| |_____^
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:77: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:84: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:96: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:97: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:19: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:23: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`.

View File

@ -1,39 +1,5 @@
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:40:9
|
LL | while false {}
| ^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: `#![feature(const_loop)]` alone is not sufficient, since this loop expression contains an implicit conditional
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:49:5
|
LL | / while x < 4 {
LL | | x += 1;
LL | | }
| |_____^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: `#![feature(const_loop)]` alone is not sufficient, since this loop expression contains an implicit conditional
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:53:5
|
LL | / while x < 8 {
LL | | x += 1;
LL | | }
| |_____^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: `#![feature(const_loop)]` alone is not sufficient, since this loop expression contains an implicit conditional
error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:63:5
--> $DIR/loop.rs:61:5
|
LL | / for i in 0..4 {
LL | | x += i;
@ -41,56 +7,13 @@ LL | | }
| |_____^
error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:67:5
--> $DIR/loop.rs:65:5
|
LL | / for i in 0..4 {
LL | | x += i;
LL | | }
| |_____^
error[E0658]: `if` is not allowed in a `const`
--> $DIR/loop.rs:79:9
|
LL | / if x == 4 {
LL | | break;
LL | | }
| |_________^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error: aborting due to 2 previous errors
error[E0658]: `if` is not allowed in a `const`
--> $DIR/loop.rs:86:9
|
LL | / if x == 8 {
LL | | break;
LL | | }
| |_________^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:96:5
|
LL | while let None = Some(x) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: `#![feature(const_loop)]` alone is not sufficient, since this loop expression contains an implicit conditional
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:97:5
|
LL | while let None = Some(x) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= note: `#![feature(const_loop)]` alone is not sufficient, since this loop expression contains an implicit conditional
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0658, E0744.
For more information about an error, try `rustc --explain E0658`.
For more information about this error, try `rustc --explain E0744`.

View File

@ -1,31 +1,29 @@
// Ensure that loops are forbidden in a const context unless `#![feature(const_loop)]` is enabled.
// `while` loops require `#![feature(const_if_match)]` to be enabled as well.
// gate-test-const_loop
// revisions: stock if_match loop_ both
// revisions: stock loop_
#![cfg_attr(any(both, if_match), feature(const_if_match))]
#![cfg_attr(any(both, loop_), feature(const_loop))]
#![cfg_attr(loop_, feature(const_loop))]
const _: () = loop {}; //[stock,if_match]~ ERROR `loop` is not allowed in a `const`
const _: () = loop {}; //[stock]~ ERROR `loop` is not allowed in a `const`
static FOO: i32 = loop { break 4; }; //[stock,if_match]~ ERROR `loop` is not allowed in a `static`
static FOO: i32 = loop { break 4; }; //[stock]~ ERROR `loop` is not allowed in a `static`
const fn foo() {
loop {} //[stock,if_match]~ ERROR `loop` is not allowed in a `const fn`
loop {} //[stock]~ ERROR `loop` is not allowed in a `const fn`
}
pub trait Foo {
const BAR: i32 = loop { break 4; }; //[stock,if_match]~ ERROR `loop` is not allowed in a `const`
const BAR: i32 = loop { break 4; }; //[stock]~ ERROR `loop` is not allowed in a `const`
}
impl Foo for () {
const BAR: i32 = loop { break 4; }; //[stock,if_match]~ ERROR `loop` is not allowed in a `const`
const BAR: i32 = loop { break 4; }; //[stock]~ ERROR `loop` is not allowed in a `const`
}
fn non_const_outside() {
const fn const_inside() {
loop {} //[stock,if_match]~ ERROR `loop` is not allowed in a `const fn`
loop {} //[stock]~ ERROR `loop` is not allowed in a `const fn`
}
}
@ -38,7 +36,7 @@ const fn const_outside() {
fn main() {
let x = [0; {
while false {}
//[stock,if_match,loop_]~^ ERROR `while` is not allowed in a `const`
//[stock]~^ ERROR `while` is not allowed in a `const`
4
}];
}
@ -46,11 +44,11 @@ fn main() {
const _: i32 = {
let mut x = 0;
while x < 4 { //[stock,if_match,loop_]~ ERROR `while` is not allowed in a `const`
while x < 4 { //[stock]~ ERROR `while` is not allowed in a `const`
x += 1;
}
while x < 8 { //[stock,if_match,loop_]~ ERROR `while` is not allowed in a `const`
while x < 8 { //[stock]~ ERROR `while` is not allowed in a `const`
x += 1;
}
@ -60,11 +58,11 @@ const _: i32 = {
const _: i32 = {
let mut x = 0;
for i in 0..4 { //[stock,if_match,loop_,both]~ ERROR `for` is not allowed in a `const`
for i in 0..4 { //[stock,loop_]~ ERROR `for` is not allowed in a `const`
x += i;
}
for i in 0..4 { //[stock,if_match,loop_,both]~ ERROR `for` is not allowed in a `const`
for i in 0..4 { //[stock,loop_]~ ERROR `for` is not allowed in a `const`
x += i;
}
@ -74,16 +72,16 @@ const _: i32 = {
const _: i32 = {
let mut x = 0;
loop { //[stock,if_match]~ ERROR `loop` is not allowed in a `const`
loop { //[stock]~ ERROR `loop` is not allowed in a `const`
x += 1;
if x == 4 { //[stock,loop_]~ ERROR `if` is not allowed in a `const`
if x == 4 {
break;
}
}
loop { //[stock,if_match]~ ERROR `loop` is not allowed in a `const`
loop { //[stock]~ ERROR `loop` is not allowed in a `const`
x += 1;
if x == 8 { //[stock,loop_]~ ERROR `if` is not allowed in a `const`
if x == 8 {
break;
}
}
@ -93,7 +91,7 @@ const _: i32 = {
const _: i32 = {
let mut x = 0;
while let None = Some(x) { } //[stock,if_match,loop_]~ ERROR `while` is not allowed in a `const`
while let None = Some(x) { } //[stock,if_match,loop_]~ 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) { } //[stock]~ ERROR `while` is not allowed in a `const`
x
};

View File

@ -1,5 +1,5 @@
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:10:15
--> $DIR/loop.rs:8:15
|
LL | const _: () = loop {};
| ^^^^^^^
@ -8,7 +8,7 @@ LL | const _: () = loop {};
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `static`
--> $DIR/loop.rs:12:19
--> $DIR/loop.rs:10:19
|
LL | static FOO: i32 = loop { break 4; };
| ^^^^^^^^^^^^^^^^^
@ -17,7 +17,7 @@ LL | static FOO: i32 = loop { break 4; };
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const fn`
--> $DIR/loop.rs:15:5
--> $DIR/loop.rs:13:5
|
LL | loop {}
| ^^^^^^^
@ -26,7 +26,7 @@ LL | loop {}
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const fn`
--> $DIR/loop.rs:28:9
--> $DIR/loop.rs:26:9
|
LL | loop {}
| ^^^^^^^
@ -35,17 +35,16 @@ LL | loop {}
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:40:9
--> $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
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:49:5
--> $DIR/loop.rs:47:5
|
LL | / while x < 4 {
LL | | x += 1;
@ -54,10 +53,9 @@ 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
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:53:5
--> $DIR/loop.rs:51:5
|
LL | / while x < 8 {
LL | | x += 1;
@ -66,10 +64,9 @@ 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
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:63:5
--> $DIR/loop.rs:61:5
|
LL | / for i in 0..4 {
LL | | x += i;
@ -77,7 +74,7 @@ LL | | }
| |_____^
error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:67:5
--> $DIR/loop.rs:65:5
|
LL | / for i in 0..4 {
LL | | x += i;
@ -85,7 +82,7 @@ LL | | }
| |_____^
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:77:5
--> $DIR/loop.rs:75:5
|
LL | / loop {
LL | | x += 1;
@ -98,19 +95,8 @@ 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]: `if` is not allowed in a `const`
--> $DIR/loop.rs:79:9
|
LL | / if x == 4 {
LL | | break;
LL | | }
| |_________^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:84:5
--> $DIR/loop.rs:82:5
|
LL | / loop {
LL | | x += 1;
@ -123,39 +109,26 @@ 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]: `if` is not allowed in a `const`
--> $DIR/loop.rs:86:9
|
LL | / if x == 8 {
LL | | break;
LL | | }
| |_________^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:96:5
--> $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
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:97:5
--> $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
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:19:22
--> $DIR/loop.rs:17:22
|
LL | const BAR: i32 = loop { break 4; };
| ^^^^^^^^^^^^^^^^^
@ -164,7 +137,7 @@ LL | const BAR: i32 = loop { break 4; };
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:23:22
--> $DIR/loop.rs:21:22
|
LL | const BAR: i32 = loop { break 4; };
| ^^^^^^^^^^^^^^^^^
@ -172,7 +145,7 @@ 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 17 previous errors
error: aborting due to 15 previous errors
Some errors have detailed explanations: E0658, E0744.
For more information about an error, try `rustc --explain E0658`.

View File

@ -2,7 +2,6 @@
// run-pass
#![feature(const_if_match)]
#![feature(const_panic)]
const X: i32 = {

View File

@ -1,8 +0,0 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/short-circuit.rs:14:1
|
LL | fn main() {}
| ^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -1,14 +1,14 @@
// Test that both `&&` and `||` actually short-circuit when the `const_if_match` feature flag is
// enabled. Without the feature flag, both sides are evaluated unconditionally.
// run-pass
// revisions: stock if_match
// Test that both `&&` and `||` actually short-circuit.
// Formerly, both sides were evaluated unconditionally
#![feature(rustc_attrs)]
#![feature(const_panic)]
#![cfg_attr(if_match, feature(const_if_match))]
const _: bool = true || panic!(); //[stock]~ ERROR any use of this value will cause an error
const _: bool = false && panic!(); //[stock]~ ERROR any use of this value will cause an error
const TRUE: bool = true || panic!();
const FALSE: bool = false && panic!();
#[rustc_error]
fn main() {} //[if_match]~ ERROR fatal error triggered by #[rustc_error]
fn main() {
assert!(TRUE);
assert!(!FALSE);
}

View File

@ -1,23 +0,0 @@
error: any use of this value will cause an error
--> $DIR/short-circuit.rs:10:25
|
LL | const _: bool = true || panic!();
| ------------------------^^^^^^^^-
| |
| the evaluated program panicked at 'explicit panic', $DIR/short-circuit.rs:10:25
|
= note: `#[deny(const_err)]` on by default
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error
--> $DIR/short-circuit.rs:11:26
|
LL | const _: bool = false && panic!();
| -------------------------^^^^^^^^-
| |
| the evaluated program panicked at 'explicit panic', $DIR/short-circuit.rs:11:26
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors

View File

@ -1,7 +1,5 @@
// check-pass
#![feature(const_if_match)]
enum Foo {
Prob,
}

View File

@ -1,8 +1,6 @@
// The `?` operator is still not const-evaluatable because it calls `From::from` on the error
// variant.
#![feature(const_if_match)]
const fn opt() -> Option<i32> {
let x = Some(2);
x?; //~ ERROR `?` is not allowed in a `const fn`

View File

@ -1,5 +1,5 @@
error[E0744]: `?` is not allowed in a `const fn`
--> $DIR/try.rs:8:5
--> $DIR/try.rs:6:5
|
LL | x?;
| ^^

View File

@ -98,13 +98,13 @@ const fn foo30_2(x: *mut u32) -> usize { x as usize }
const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
//~^ ERROR casting pointers to ints is unstable
const fn foo30_6() -> bool { let x = true; x }
const fn foo36(a: bool, b: bool) -> bool { a && b }
//~^ ERROR loops and conditional expressions are not stable in const fn
const fn foo37(a: bool, b: bool) -> bool { a || b }
//~^ ERROR loops and conditional expressions are not stable in const fn
const fn inc(x: &mut i32) { *x += 1 }
//~^ ERROR mutable references in const fn are unstable
// ok
const fn foo36(a: bool, b: bool) -> bool { a && b }
const fn foo37(a: bool, b: bool) -> bool { a || b }
fn main() {}
impl<T: std::fmt::Debug> Foo<T> {

View File

@ -166,26 +166,8 @@ LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize }
= 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[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:101:44
|
LL | const fn foo36(a: bool, b: bool) -> bool { a && b }
| ^^^^^^
|
= 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[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:103:44
|
LL | const fn foo37(a: bool, b: bool) -> bool { a || b }
| ^^^^^^
|
= 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[E0723]: mutable references in const fn are unstable
--> $DIR/min_const_fn.rs:105:14
--> $DIR/min_const_fn.rs:101:14
|
LL | const fn inc(x: &mut i32) { *x += 1 }
| ^
@ -283,7 +265,7 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
= 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 32 previous errors
error: aborting due to 30 previous errors
Some errors have detailed explanations: E0493, E0723.
For more information about an error, try `rustc --explain E0493`.

View File

@ -2,8 +2,7 @@
// aux-build:static_cross_crate.rs
#![allow(const_err)]
// `const_if_match` is a HIR check and thus needed even when unleashed.
#![feature(exclusive_range_pattern, half_open_range_patterns, const_if_match)]
#![feature(exclusive_range_pattern, half_open_range_patterns)]
extern crate static_cross_crate;

View File

@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/const_refers_to_static_cross_crate.rs:12:1
--> $DIR/const_refers_to_static_cross_crate.rs:11:1
|
LL | / const SLICE_MUT: &[u8; 1] = {
LL | |
@ -11,13 +11,13 @@ LL | | };
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
error: could not evaluate constant pattern
--> $DIR/const_refers_to_static_cross_crate.rs:40:9
--> $DIR/const_refers_to_static_cross_crate.rs:39:9
|
LL | SLICE_MUT => true,
| ^^^^^^^^^
error[E0080]: it is undefined behavior to use this value
--> $DIR/const_refers_to_static_cross_crate.rs:18:1
--> $DIR/const_refers_to_static_cross_crate.rs:17:1
|
LL | / const U8_MUT: &u8 = {
LL | |
@ -29,13 +29,13 @@ LL | | };
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
error: could not evaluate constant pattern
--> $DIR/const_refers_to_static_cross_crate.rs:49:9
--> $DIR/const_refers_to_static_cross_crate.rs:48:9
|
LL | U8_MUT => true,
| ^^^^^^
warning: any use of this value will cause an error
--> $DIR/const_refers_to_static_cross_crate.rs:27:14
--> $DIR/const_refers_to_static_cross_crate.rs:26:14
|
LL | / const U8_MUT2: &u8 = {
LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] }
@ -46,19 +46,19 @@ LL | | };
| |__-
|
note: the lint level is defined here
--> $DIR/const_refers_to_static_cross_crate.rs:25:8
--> $DIR/const_refers_to_static_cross_crate.rs:24:8
|
LL | #[warn(const_err)]
| ^^^^^^^^^
error: could not evaluate constant pattern
--> $DIR/const_refers_to_static_cross_crate.rs:60:9
--> $DIR/const_refers_to_static_cross_crate.rs:59:9
|
LL | U8_MUT2 => true,
| ^^^^^^^
warning: any use of this value will cause an error
--> $DIR/const_refers_to_static_cross_crate.rs:33:51
--> $DIR/const_refers_to_static_cross_crate.rs:32:51
|
LL | / const U8_MUT3: &u8 = {
LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
@ -69,37 +69,37 @@ LL | | };
| |__-
|
note: the lint level is defined here
--> $DIR/const_refers_to_static_cross_crate.rs:31:8
--> $DIR/const_refers_to_static_cross_crate.rs:30:8
|
LL | #[warn(const_err)]
| ^^^^^^^^^
error: could not evaluate constant pattern
--> $DIR/const_refers_to_static_cross_crate.rs:68:9
--> $DIR/const_refers_to_static_cross_crate.rs:67:9
|
LL | U8_MUT3 => true,
| ^^^^^^^
error: could not evaluate constant pattern
--> $DIR/const_refers_to_static_cross_crate.rs:40:9
--> $DIR/const_refers_to_static_cross_crate.rs:39:9
|
LL | SLICE_MUT => true,
| ^^^^^^^^^
error: could not evaluate constant pattern
--> $DIR/const_refers_to_static_cross_crate.rs:49:9
--> $DIR/const_refers_to_static_cross_crate.rs:48:9
|
LL | U8_MUT => true,
| ^^^^^^
error: could not evaluate constant pattern
--> $DIR/const_refers_to_static_cross_crate.rs:60:9
--> $DIR/const_refers_to_static_cross_crate.rs:59:9
|
LL | U8_MUT2 => true,
| ^^^^^^^
error: could not evaluate constant pattern
--> $DIR/const_refers_to_static_cross_crate.rs:68:9
--> $DIR/const_refers_to_static_cross_crate.rs:67:9
|
LL | U8_MUT3 => true,
| ^^^^^^^
@ -107,57 +107,52 @@ LL | U8_MUT3 => true,
warning: skipping const checks
|
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:15:15
--> $DIR/const_refers_to_static_cross_crate.rs:14:15
|
LL | unsafe { &static_cross_crate::ZERO }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:15:15
--> $DIR/const_refers_to_static_cross_crate.rs:14:15
|
LL | unsafe { &static_cross_crate::ZERO }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:21:15
--> $DIR/const_refers_to_static_cross_crate.rs:20:15
|
LL | unsafe { &static_cross_crate::ZERO[0] }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:21:15
--> $DIR/const_refers_to_static_cross_crate.rs:20:15
|
LL | unsafe { &static_cross_crate::ZERO[0] }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:21:15
--> $DIR/const_refers_to_static_cross_crate.rs:20:15
|
LL | unsafe { &static_cross_crate::ZERO[0] }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:27:17
--> $DIR/const_refers_to_static_cross_crate.rs:26:17
|
LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:33:20
--> $DIR/const_refers_to_static_cross_crate.rs:32:20
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:33:20
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:33:20
--> $DIR/const_refers_to_static_cross_crate.rs:32:20
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_panic` feature
--> $DIR/const_refers_to_static_cross_crate.rs:33:77
--> $DIR/const_refers_to_static_cross_crate.rs:32:77
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:33:20
--> $DIR/const_refers_to_static_cross_crate.rs:32:20
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -4,7 +4,6 @@
// gate was not enabled in libcore.
#![stable(feature = "core", since = "1.6.0")]
#![feature(const_if_match)]
#![feature(rustc_const_unstable)]
#![feature(staged_api)]

View File

@ -1,11 +1,11 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/unstable-const-fn-in-libcore.rs:24:26
--> $DIR/unstable-const-fn-in-libcore.rs:23:26
|
LL | Opt::None => f(),
| ^^^
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/unstable-const-fn-in-libcore.rs:19:53
--> $DIR/unstable-const-fn-in-libcore.rs:18:53
|
LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
| ^ constant functions cannot evaluate destructors
@ -14,7 +14,7 @@ LL | }
| - value is dropped here
error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/unstable-const-fn-in-libcore.rs:19:47
--> $DIR/unstable-const-fn-in-libcore.rs:18:47
|
LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
| ^^^^ constant functions cannot evaluate destructors

View File

@ -1,7 +1,6 @@
// run-pass
#![feature(const_panic)]
#![feature(const_if_match)]
//! Make sure that we read and write enum discriminants correctly for corner cases caused
//! by layout optimizations.

View File

@ -1,10 +1,12 @@
#![stable(feature = "rust1", since = "1.0.0")]
#![feature(staged_api)]
#![feature(const_if_match)]
#![feature(const_loop, const_fn)]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
const fn foo() -> i32 {
if true { 4 } else { 5 } //~ loops and conditional expressions are not stable in const fn
loop { return 42; } //~ ERROR `loop` is not allowed in a `const fn`
}
fn main() {}

View File

@ -1,12 +1,9 @@
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/internal-unstable-const.rs:7:5
error[E0744]: `loop` is not allowed in a `const fn`
--> $DIR/internal-unstable-const.rs:9:5
|
LL | if true { 4 } else { 5 }
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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
LL | loop { return 42; }
| ^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0723`.
For more information about this error, try `rustc --explain E0744`.

View File

@ -6,7 +6,6 @@ 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
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0572]: return statement outside of function body
--> $DIR/issue-51714.rs:2:14

View File

@ -19,7 +19,6 @@ fn c() {
fn d() {
[0; match [|f @ &ref _| () ] {} ]
//~^ ERROR expected identifier, found reserved identifier `_`
//~| ERROR `match` is not allowed in a `const`
//~| ERROR mismatched types
}

View File

@ -26,15 +26,6 @@ error: expected identifier, found reserved identifier `_`
LL | [0; match [|f @ &ref _| () ] {} ]
| ^ expected identifier, found reserved identifier
error[E0658]: `match` is not allowed in a `const`
--> $DIR/issue-66706.rs:20:9
|
LL | [0; match [|f @ &ref _| () ] {} ]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0282]: type annotations needed
--> $DIR/issue-66706.rs:2:11
|
@ -65,7 +56,7 @@ LL | fn d() {
LL | [0; match [|f @ &ref _| () ] {} ]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]`
error: aborting due to 9 previous errors
error: aborting due to 8 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`.

View File

@ -1,35 +1,30 @@
// check-pass
#![feature(or_patterns)]
const fn foo((Ok(a) | Err(a)): Result<i32, i32>) {
//~^ ERROR or-pattern is not allowed in a `const fn`
let x = Ok(3);
let Ok(y) | Err(y) = x;
//~^ ERROR or-pattern is not allowed in a `const fn`
}
const X: () = {
let x = Ok(3);
let Ok(y) | Err(y) = x;
//~^ ERROR or-pattern is not allowed in a `const`
};
static Y: () = {
let x = Ok(3);
let Ok(y) | Err(y) = x;
//~^ ERROR or-pattern is not allowed in a `static`
};
static mut Z: () = {
let x = Ok(3);
let Ok(y) | Err(y) = x;
//~^ ERROR or-pattern is not allowed in a `static mut`
};
fn main() {
let _: [(); {
let x = Ok(3);
let Ok(y) | Err(y) = x;
//~^ ERROR or-pattern is not allowed in a `const`
2
}];
}

View File

@ -1,57 +0,0 @@
error[E0658]: or-pattern is not allowed in a `const fn`
--> $DIR/feature-gate-const-fn.rs:3:15
|
LL | const fn foo((Ok(a) | Err(a)): Result<i32, i32>) {
| ^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: or-pattern is not allowed in a `const fn`
--> $DIR/feature-gate-const-fn.rs:6:9
|
LL | let Ok(y) | Err(y) = x;
| ^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: or-pattern is not allowed in a `const`
--> $DIR/feature-gate-const-fn.rs:12:9
|
LL | let Ok(y) | Err(y) = x;
| ^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: or-pattern is not allowed in a `static`
--> $DIR/feature-gate-const-fn.rs:18:9
|
LL | let Ok(y) | Err(y) = x;
| ^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: or-pattern is not allowed in a `static mut`
--> $DIR/feature-gate-const-fn.rs:24:9
|
LL | let Ok(y) | Err(y) = x;
| ^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: or-pattern is not allowed in a `const`
--> $DIR/feature-gate-const-fn.rs:31:13
|
LL | let Ok(y) | Err(y) = x;
| ^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,13 +1,10 @@
fn main() {
[(); return match 0 { n => n }];
//~^ ERROR: return statement outside of function body
//~| ERROR: `match` is not allowed in a `const`
[(); return match 0 { 0 => 0 }];
//~^ ERROR: return statement outside of function body
//~| ERROR: `match` is not allowed in a `const`
[(); return match () { 'a' => 0, _ => 0 }];
//~^ ERROR: return statement outside of function body
//~| ERROR: `match` is not allowed in a `const`
}

View File

@ -1,30 +1,3 @@
error[E0658]: `match` is not allowed in a `const`
--> $DIR/return-match-array-const.rs:2:17
|
LL | [(); return match 0 { n => n }];
| ^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const`
--> $DIR/return-match-array-const.rs:6:17
|
LL | [(); return match 0 { 0 => 0 }];
| ^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const`
--> $DIR/return-match-array-const.rs:10:17
|
LL | [(); return match () { 'a' => 0, _ => 0 }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0572]: return statement outside of function body
--> $DIR/return-match-array-const.rs:2:10
|
@ -32,18 +5,17 @@ LL | [(); return match 0 { n => n }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0572]: return statement outside of function body
--> $DIR/return-match-array-const.rs:6:10
--> $DIR/return-match-array-const.rs:5:10
|
LL | [(); return match 0 { 0 => 0 }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0572]: return statement outside of function body
--> $DIR/return-match-array-const.rs:10:10
--> $DIR/return-match-array-const.rs:8:10
|
LL | [(); return match () { 'a' => 0, _ => 0 }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors
error: aborting due to 3 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`.

View File

@ -216,17 +216,14 @@ fn inside_const_generic_arguments() {
if let A::<{
true && let 1 = 1 //~ ERROR `let` expressions are not supported here
//~| ERROR `match` is not allowed in a `const`
}>::O = 5 {}
while let A::<{
true && let 1 = 1 //~ ERROR `let` expressions are not supported here
//~| ERROR `match` is not allowed in a `const`
}>::O = 5 {}
if A::<{
true && let 1 = 1 //~ ERROR `let` expressions are not supported here
//~| ERROR `match` is not allowed in a `const`
}>::O == 5 {}
// In the cases above we have `ExprKind::Block` to help us out.

View File

@ -1,5 +1,5 @@
error: expected one of `,` or `>`, found `&&`
--> $DIR/disallowed-positions.rs:239:14
--> $DIR/disallowed-positions.rs:236:14
|
LL | true && let 1 = 1
| ^^ expected one of `,` or `>`
@ -482,7 +482,7 @@ LL | true && let 1 = 1
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
--> $DIR/disallowed-positions.rs:223:17
--> $DIR/disallowed-positions.rs:222:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
@ -491,7 +491,7 @@ LL | true && let 1 = 1
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
--> $DIR/disallowed-positions.rs:228:17
--> $DIR/disallowed-positions.rs:226:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
@ -516,33 +516,6 @@ LL | #![feature(let_chains)] // Avoid inflating `.stderr` with overzealous gates
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
error[E0658]: `match` is not allowed in a `const`
--> $DIR/disallowed-positions.rs:218:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const`
--> $DIR/disallowed-positions.rs:223:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0658]: `match` is not allowed in a `const`
--> $DIR/disallowed-positions.rs:228:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:32:8
|
@ -983,7 +956,7 @@ LL | let 0 = 0?;
= help: the trait `std::ops::Try` is not implemented for `{integer}`
= note: required by `std::ops::Try::into_result`
error: aborting due to 106 previous errors; 2 warnings emitted
error: aborting due to 103 previous errors; 2 warnings emitted
Some errors have detailed explanations: E0277, E0308, E0600, E0614, E0658.
Some errors have detailed explanations: E0277, E0308, E0600, E0614.
For more information about an error, try `rustc --explain E0277`.

View File

@ -9,7 +9,7 @@ pub trait MyTrait {
impl const MyTrait for () {
fn method(&self) {
match *self {} //~ ERROR `match` is not allowed in a `const fn`
loop {} //~ ERROR `loop` is not allowed in a `const fn`
}
}

View File

@ -1,11 +1,11 @@
error[E0658]: `match` is not allowed in a `const fn`
error[E0658]: `loop` is not allowed in a `const fn`
--> $DIR/hir-const-check.rs:12:9
|
LL | match *self {}
| ^^^^^^^^^^^^^^
LL | loop {}
| ^^^^^^^
|
= note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
= 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