1
Fork 0

Bless const tests with improved diagnostics

This commit is contained in:
Dylan MacKenzie 2019-11-06 12:29:30 -08:00
parent 67336bb399
commit 3ce8ca45d6
37 changed files with 443 additions and 244 deletions

View file

@ -10,6 +10,7 @@ const fn f(x: usize) -> usize {
//~| ERROR E0019 //~| ERROR E0019
//~| ERROR E0019 //~| ERROR E0019
//~| ERROR E0080 //~| ERROR E0080
//~| ERROR E0744
sum += i; sum += i;
} }
sum sum

View file

@ -1,12 +1,16 @@
fn main() { fn main() {
[(); & { loop { continue } } ]; //~ ERROR mismatched types [(); & { loop { continue } } ]; //~ ERROR mismatched types
//~^ ERROR `loop` is not allowed in a `const`
[(); loop { break }]; //~ ERROR mismatched types [(); loop { break }]; //~ ERROR mismatched types
//~^ ERROR `loop` is not allowed in a `const`
[(); {while true {break}; 0}]; [(); {while true {break}; 0}];
//~^ ERROR constant contains unimplemented expression type //~^ ERROR constant contains unimplemented expression type
//~| ERROR constant contains unimplemented expression type //~| ERROR constant contains unimplemented expression type
//~| ERROR `while` is not allowed in a `const`
//~| WARN denote infinite loops with //~| WARN denote infinite loops with
[(); { for _ in 0usize.. {}; 0}]; [(); { for _ in 0usize.. {}; 0}];
//~^ ERROR calls in constants are limited to constant functions //~^ ERROR calls in constants are limited to constant functions
//~| ERROR `for` is not allowed in a `const`
//~| ERROR references in constants may only refer to immutable values //~| ERROR references in constants may only refer to immutable values
//~| ERROR constant contains unimplemented expression type //~| ERROR constant contains unimplemented expression type
//~| ERROR constant contains unimplemented expression type //~| ERROR constant contains unimplemented expression type

View file

@ -2,9 +2,7 @@ struct Project;
struct Value; struct Value;
static settings_dir: String = format!(""); static settings_dir: String = format!("");
//~^ ERROR [E0019] //~^ ERROR `match` is not allowed in a `static`
//~| ERROR [E0015]
//~| ERROR [E0015]
fn from_string(_: String) -> Value { fn from_string(_: String) -> Value {
Value Value
@ -13,7 +11,6 @@ fn set_editor(_: Value) {}
fn main() { fn main() {
let settings_data = from_string(settings_dir); let settings_data = from_string(settings_dir);
//~^ ERROR cannot move out of static item `settings_dir` [E0507]
let args: i32 = 0; let args: i32 = 0;
match args { match args {

View file

@ -1,10 +1,4 @@
error[E0507]: cannot move out of static item `settings_dir` error[E0744]: `match` is not allowed in a `static`
--> $DIR/issue-64453.rs:15: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[E0019]: static contains unimplemented expression type
--> $DIR/issue-64453.rs:4:31 --> $DIR/issue-64453.rs:4:31
| |
LL | static settings_dir: String = format!(""); LL | static settings_dir: String = format!("");
@ -12,23 +6,6 @@ LL | static settings_dir: String = format!("");
| |
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants error: aborting due to previous error
--> $DIR/issue-64453.rs:4:31
|
LL | static settings_dir: String = format!("");
| ^^^^^^^^^^^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants For more information about this error, try `rustc --explain E0744`.
--> $DIR/issue-64453.rs:4:31
|
LL | static settings_dir: String = format!("");
| ^^^^^^^^^^^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0015, E0019, E0507.
For more information about an error, try `rustc --explain E0015`.

View file

@ -1,5 +1,6 @@
fn main() { fn main() {
[(); &(&'static: loop { |x| {}; }) as *const _ as usize] [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
//~^ ERROR: invalid label name `'static` //~^ ERROR: invalid label name `'static`
//~| ERROR: `loop` is not allowed in a `const`
//~| ERROR: type annotations needed //~| ERROR: type annotations needed
} }

View file

@ -4,12 +4,19 @@ error: invalid label name `'static`
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
| ^^^^^^^ | ^^^^^^^
error[E0744]: `loop` is not allowed in a `const`
--> $DIR/issue-52437.rs:2:13
|
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0282]: type annotations needed error[E0282]: type annotations needed
--> $DIR/issue-52437.rs:2:30 --> $DIR/issue-52437.rs:2:30
| |
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
| ^ consider giving this closure parameter a type | ^ consider giving this closure parameter a type
error: aborting due to 2 previous errors error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0282`. Some errors have detailed explanations: E0282, E0744.
For more information about an error, try `rustc --explain E0282`.

View file

@ -7,8 +7,10 @@ fn main() {
while n != 0 { while n != 0 {
//~^ ERROR constant contains unimplemented expression type //~^ ERROR constant contains unimplemented expression type
//~| ERROR constant contains unimplemented expression type //~| ERROR constant contains unimplemented expression type
//~| ERROR `while` is not allowed in a `const`
n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
//~^ ERROR evaluation of constant value failed //~^ ERROR evaluation of constant value failed
//~| ERROR `if` is not allowed in a `const`
} }
n n
}]; }];

View file

@ -1,3 +1,21 @@
error[E0744]: `while` is not allowed in a `const`
--> $DIR/infinite_loop.rs:7:9
|
LL | / while n != 0 {
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_________^
error[E0744]: `if` is not allowed in a `const`
--> $DIR/infinite_loop.rs:11:17
|
LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0019]: constant contains unimplemented expression type error[E0019]: constant contains unimplemented expression type
--> $DIR/infinite_loop.rs:7:15 --> $DIR/infinite_loop.rs:7:15
| |
@ -10,7 +28,8 @@ error[E0019]: constant contains unimplemented expression type
LL | / while n != 0 { LL | / while n != 0 {
LL | | LL | |
LL | | LL | |
LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; LL | |
... |
LL | | LL | |
LL | | } LL | | }
| |_________^ | |_________^
@ -29,12 +48,12 @@ LL | | }];
| |_____^ | |_____^
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/infinite_loop.rs:10:20 --> $DIR/infinite_loop.rs:11:20
| |
LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
| ^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate | ^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
error: aborting due to 3 previous errors error: aborting due to 5 previous errors
Some errors have detailed explanations: E0019, E0080. Some errors have detailed explanations: E0019, E0080, E0744.
For more information about an error, try `rustc --explain E0019`. For more information about an error, try `rustc --explain E0019`.

View file

@ -4,7 +4,8 @@ fn main() {
let mut x = &0; let mut x = &0;
let mut n = 0; let mut n = 0;
while n < 5 { while n < 5 {
//~^ ERROR constant contains unimplemented expression type //~^ ERROR `while` is not allowed in a `const`
//~| ERROR constant contains unimplemented expression type
//~| ERROR constant contains unimplemented expression type //~| ERROR constant contains unimplemented expression type
n = (n + 1) % 5; //~ ERROR evaluation of constant value failed n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
x = &0; // Materialize a new AllocId x = &0; // Materialize a new AllocId

View file

@ -1,3 +1,15 @@
error[E0744]: `while` is not allowed in a `const`
--> $DIR/issue-52475.rs:6:9
|
LL | / while n < 5 {
LL | |
LL | |
LL | |
LL | | n = (n + 1) % 5;
LL | | x = &0; // Materialize a new AllocId
LL | | }
| |_________^
error[E0019]: constant contains unimplemented expression type error[E0019]: constant contains unimplemented expression type
--> $DIR/issue-52475.rs:6:15 --> $DIR/issue-52475.rs:6:15
| |
@ -10,6 +22,7 @@ error[E0019]: constant contains unimplemented expression type
LL | / while n < 5 { LL | / while n < 5 {
LL | | LL | |
LL | | LL | |
LL | |
LL | | n = (n + 1) % 5; LL | | n = (n + 1) % 5;
LL | | x = &0; // Materialize a new AllocId LL | | x = &0; // Materialize a new AllocId
LL | | } LL | | }
@ -29,12 +42,12 @@ LL | | }];
| |_____^ | |_____^
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/issue-52475.rs:9:17 --> $DIR/issue-52475.rs:10:17
| |
LL | n = (n + 1) % 5; LL | n = (n + 1) % 5;
| ^^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate | ^^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
error: aborting due to 3 previous errors error: aborting due to 4 previous errors
Some errors have detailed explanations: E0019, E0080. Some errors have detailed explanations: E0019, E0080, E0744.
For more information about an error, try `rustc --explain E0019`. For more information about an error, try `rustc --explain E0019`.

View file

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

View file

@ -1,3 +1,15 @@
error[E0744]: `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 | | n => n,
LL | | }
| |_________^
error[E0658]: casting pointers to integers in constants is unstable error[E0658]: casting pointers to integers in constants is unstable
--> $DIR/match-test-ptr-null.rs:6:15 --> $DIR/match-test-ptr-null.rs:6:15
| |
@ -14,7 +26,7 @@ LL | match &1 as *const i32 as usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0019]: constant contains unimplemented expression type error[E0019]: constant contains unimplemented expression type
--> $DIR/match-test-ptr-null.rs:10:13 --> $DIR/match-test-ptr-null.rs:11:13
| |
LL | 0 => 42, LL | 0 => 42,
| ^ | ^
@ -25,7 +37,7 @@ error[E0080]: evaluation of constant value failed
LL | match &1 as *const i32 as usize { LL | match &1 as *const i32 as usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants | ^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
error: aborting due to 4 previous errors error: aborting due to 5 previous errors
Some errors have detailed explanations: E0019, E0080, E0658. Some errors have detailed explanations: E0019, E0080, E0658, E0744.
For more information about an error, try `rustc --explain E0019`. For more information about an error, try `rustc --explain E0019`.

View file

@ -1,21 +1,21 @@
const _: i32 = if true { //~ ERROR if expression is not allowed in a const const _: i32 = if true { //~ ERROR `if` is not allowed in a `const`
5 5
} else { } else {
6 6
}; };
const _: i32 = match 1 { //~ ERROR match expression is not allowed in a const const _: i32 = match 1 { //~ ERROR `match` is not allowed in a `const`
2 => 3, 2 => 3,
4 => 5, 4 => 5,
_ => 0, _ => 0,
}; };
const fn foo() -> i32 { const fn foo() -> i32 {
if true { 5 } else { 6 } //~ ERROR if expression is not allowed in a const fn if true { 5 } else { 6 } //~ ERROR `if` is not allowed in a `const fn`
} }
const fn bar() -> i32 { const fn bar() -> i32 {
match 0 { 1 => 2, _ => 0 } //~ ERROR match expression is not allowed in a const fn match 0 { 1 => 2, _ => 0 } //~ ERROR `match` is not allowed in a `const fn`
} }
fn main() {} fn main() {}

View file

@ -1,15 +1,37 @@
error[E0019]: constant contains unimplemented expression type error[E0744]: `if` is not allowed in a `const`
--> $DIR/const-if.rs:1:20 --> $DIR/const-if.rs:1:16
| |
LL | const _X: i32 = if true { 5 } else { 6 }; LL | const _: i32 = if true {
| ^^^^ | ________________^
LL | | 5
LL | | } else {
LL | | 6
LL | | };
| |_^
error[E0019]: constant contains unimplemented expression type error[E0744]: `match` is not allowed in a `const`
--> $DIR/const-if.rs:1:17 --> $DIR/const-if.rs:7:16
| |
LL | const _X: i32 = if true { 5 } else { 6 }; LL | const _: i32 = match 1 {
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ________________^
LL | | 2 => 3,
LL | | 4 => 5,
LL | | _ => 0,
LL | | };
| |_^
error: aborting due to 2 previous errors error[E0744]: `if` is not allowed in a `const fn`
--> $DIR/const-if.rs:14:5
|
LL | if true { 5 } else { 6 }
| ^^^^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0019`. error[E0744]: `match` is not allowed in a `const fn`
--> $DIR/const-if.rs:18:5
|
LL | match 0 { 1 => 2, _ => 0 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0744`.

View file

@ -1,17 +1,17 @@
const _: () = loop {}; //~ ERROR loop is not allowed in a const const _: () = loop {}; //~ ERROR `loop` is not allowed in a `const`
static FOO: i32 = loop { break 4; }; //~ ERROR loop is not allowed in a static static FOO: i32 = loop { break 4; }; //~ ERROR `loop` is not allowed in a `static`
const fn foo() { const fn foo() {
loop {} //~ ERROR loop is not allowed in a const fn loop {} //~ ERROR `loop` is not allowed in a `const fn`
} }
pub trait Foo { pub trait Foo {
const BAR: i32 = loop { break 4; }; //~ ERROR loop is not allowed in a const const BAR: i32 = loop { break 4; }; //~ ERROR `loop` is not allowed in a `const`
} }
impl Foo for () { impl Foo for () {
const BAR: i32 = loop { break 4; }; //~ ERROR loop is not allowed in a const const BAR: i32 = loop { break 4; }; //~ ERROR `loop` is not allowed in a `const`
} }
fn non_const_outside() { fn non_const_outside() {
@ -39,11 +39,11 @@ fn main() {
const _: i32 = { const _: i32 = {
let mut x = 0; let mut x = 0;
while x < 4 { //~ ERROR while loop is not allowed in a const while x < 4 { //~ ERROR `while` is not allowed in a `const`
x += 1; x += 1;
} }
while x < 8 { //~ ERROR while loop is not allowed in a const while x < 8 { //~ ERROR `while` is not allowed in a `const`
x += 1; x += 1;
} }
@ -53,11 +53,11 @@ const _: i32 = {
const _: i32 = { const _: i32 = {
let mut x = 0; let mut x = 0;
for i in 0..4 { //~ ERROR for loop is not allowed in a const for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
x += i; x += i;
} }
for i in 0..4 { //~ ERROR for loop is not allowed in a const for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
x += i; x += i;
} }
@ -67,16 +67,16 @@ const _: i32 = {
const _: i32 = { const _: i32 = {
let mut x = 0; let mut x = 0;
loop { //~ ERROR loop is not allowed in a const loop { //~ ERROR `loop` is not allowed in a `const`
x += 1; x += 1;
if x == 4 { //~ ERROR if expression is not allowed in a const if x == 4 { //~ ERROR `if` is not allowed in a `const`
break; break;
} }
} }
loop { //~ ERROR loop is not allowed in a const loop { //~ ERROR `loop` is not allowed in a `const`
x += 1; x += 1;
if x == 8 { //~ ERROR if expression is not allowed in a const if x == 8 { //~ ERROR `if` is not allowed in a `const`
break; break;
} }
} }
@ -86,7 +86,7 @@ const _: i32 = {
const _: i32 = { const _: i32 = {
let mut x = 0; let mut x = 0;
while let None = Some(x) { } //~ ERROR while loop is not allowed in a const while let None = Some(x) { } //~ ERROR `while let` is not allowed in a `const`
while let None = Some(x) { } //~ ERROR while loop is not allowed in a const while let None = Some(x) { } //~ ERROR `while let` is not allowed in a `const`
x x
}; };

View file

@ -1,60 +1,140 @@
error[E0019]: constant contains unimplemented expression type error[E0744]: `loop` is not allowed in a `const`
--> $DIR/const-loop.rs:4:11 --> $DIR/const-loop.rs:1:15
| |
LL | while x < 4 { LL | const _: () = loop {};
| ^^^^^ | ^^^^^^^
error[E0019]: constant contains unimplemented expression type error[E0744]: `loop` is not allowed in a `static`
--> $DIR/const-loop.rs:4:5 --> $DIR/const-loop.rs:3:19
|
LL | static FOO: i32 = loop { break 4; };
| ^^^^^^^^^^^^^^^^^
error[E0744]: `loop` is not allowed in a `const fn`
--> $DIR/const-loop.rs:6:5
|
LL | loop {}
| ^^^^^^^
error[E0744]: `loop` is not allowed in a `const fn`
--> $DIR/const-loop.rs:19:9
|
LL | loop {}
| ^^^^^^^
error[E0744]: `while` is not allowed in a `const`
--> $DIR/const-loop.rs:31:9
|
LL | while false {}
| ^^^^^^^^^^^^^^
error[E0744]: `while` is not allowed in a `const`
--> $DIR/const-loop.rs:42:5
| |
LL | / while x < 4 { LL | / while x < 4 {
LL | |
LL | |
LL | | x += 1; LL | | x += 1;
LL | | } LL | | }
| |_____^ | |_____^
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0744]: `while` is not allowed in a `const`
--> $DIR/const-loop.rs:20:14 --> $DIR/const-loop.rs:46:5
| |
LL | for i in 0..4 { LL | / while x < 8 {
| ^^^^ LL | | x += 1;
LL | | }
| |_____^
error[E0019]: constant contains unimplemented expression type error[E0744]: `for` is not allowed in a `const`
--> $DIR/const-loop.rs:20:14 --> $DIR/const-loop.rs:56:5
| |
LL | for i in 0..4 { LL | / for i in 0..4 {
| ^^^^ LL | | x += i;
LL | | }
| |_____^
error[E0017]: references in constants may only refer to immutable values error[E0744]: `for` is not allowed in a `const`
--> $DIR/const-loop.rs:20:14 --> $DIR/const-loop.rs:60:5
| |
LL | for i in 0..4 { LL | / for i in 0..4 {
| ^^^^ constants require immutable values LL | | x += i;
LL | | }
| |_____^
error[E0019]: constant contains unimplemented expression type error[E0744]: `loop` is not allowed in a `const`
--> $DIR/const-loop.rs:20:9 --> $DIR/const-loop.rs:70:5
| |
LL | for i in 0..4 { LL | / loop {
| ^ LL | | x += 1;
LL | | if x == 4 {
LL | | break;
LL | | }
LL | | }
| |_____^
error[E0019]: constant contains unimplemented expression type error[E0744]: `if` is not allowed in a `const`
--> $DIR/const-loop.rs:41:12 --> $DIR/const-loop.rs:72:9
|
LL | if x == 4 {
| ^^^^^^
error[E0019]: constant contains unimplemented expression type
--> $DIR/const-loop.rs:41:9
| |
LL | / if x == 4 { LL | / if x == 4 {
LL | |
LL | |
LL | | break; LL | | break;
LL | | } LL | | }
| |_________^ | |_________^
error: aborting due to 8 previous errors error[E0744]: `loop` is not allowed in a `const`
--> $DIR/const-loop.rs:77:5
|
LL | / loop {
LL | | x += 1;
LL | | if x == 8 {
LL | | break;
LL | | }
LL | | }
| |_____^
Some errors have detailed explanations: E0015, E0017, E0019. error[E0744]: `if` is not allowed in a `const`
For more information about an error, try `rustc --explain E0015`. --> $DIR/const-loop.rs:79:9
|
LL | / if x == 8 {
LL | | break;
LL | | }
| |_________^
error[E0744]: `while let` is not allowed in a `const`
--> $DIR/const-loop.rs:89:5
|
LL | while let None = Some(x) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0744]: `while let` is not allowed in a `const`
--> $DIR/const-loop.rs:90:5
|
LL | while let None = Some(x) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0744]: `loop` is not allowed in a `const`
--> $DIR/const-loop.rs:10:22
|
LL | const BAR: i32 = loop { break 4; };
| ^^^^^^^^^^^^^^^^^
error[E0744]: `loop` is not allowed in a `const`
--> $DIR/const-loop.rs:14:22
|
LL | const BAR: i32 = loop { break 4; };
| ^^^^^^^^^^^^^^^^^
error[E0019]: constant contains unimplemented expression type
--> $DIR/const-loop.rs:31:15
|
LL | while false {}
| ^^^^^
error[E0019]: constant contains unimplemented expression type
--> $DIR/const-loop.rs:31:9
|
LL | while false {}
| ^^^^^^^^^^^^^^
error: aborting due to 19 previous errors
Some errors have detailed explanations: E0019, E0744.
For more information about an error, try `rustc --explain E0019`.

View file

@ -1,17 +1,13 @@
#![allow(warnings)] #![allow(warnings)]
const x: bool = match Some(true) { const x: bool = match Some(true) { //~ ERROR `match` is not allowed in a `const`
//~^ ERROR: constant contains unimplemented expression type [E0019]
Some(value) => true, Some(value) => true,
//~^ ERROR: constant contains unimplemented expression type [E0019]
_ => false _ => false
}; };
const y: bool = { const y: bool = {
match Some(true) { match Some(true) { //~ ERROR `match` is not allowed in a `const`
//~^ ERROR: constant contains unimplemented expression type [E0019]
Some(value) => true, Some(value) => true,
//~^ ERROR: constant contains unimplemented expression type [E0019]
_ => false _ => false
} }
}; };

View file

@ -1,27 +1,22 @@
error[E0019]: constant contains unimplemented expression type error[E0744]: `match` is not allowed in a `const`
--> $DIR/const-match-pattern-arm.rs:3:23 --> $DIR/const-match-pattern-arm.rs:3:17
| |
LL | const x: bool = match Some(true) { LL | const x: bool = match Some(true) {
| ^^^^^^^^^^ | _________________^
LL | | Some(value) => true,
LL | | _ => false
LL | | };
| |_^
error[E0019]: constant contains unimplemented expression type error[E0744]: `match` is not allowed in a `const`
--> $DIR/const-match-pattern-arm.rs:5:5 --> $DIR/const-match-pattern-arm.rs:9:5
| |
LL | Some(value) => true, LL | / match Some(true) {
| ^^^^^^^^^^^ LL | | Some(value) => true,
LL | | _ => false
LL | | }
| |_____^
error[E0019]: constant contains unimplemented expression type error: aborting due to 2 previous errors
--> $DIR/const-match-pattern-arm.rs:11:11
|
LL | match Some(true) {
| ^^^^^^^^^^
error[E0019]: constant contains unimplemented expression type For more information about this error, try `rustc --explain E0744`.
--> $DIR/const-match-pattern-arm.rs:13:9
|
LL | Some(value) => true,
| ^^^^^^^^^^^
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0019`.

View file

@ -1,5 +1,5 @@
const fn foo() { const fn foo() {
loop {} //~ ERROR loops are not allowed in const fn loop {} //~ ERROR `loop` is not allowed in a `const fn`
} }
fn main() {} fn main() {}

View file

@ -1,12 +1,9 @@
error[E0723]: loops are not allowed in const fn error[E0744]: `loop` is not allowed in a `const fn`
--> $DIR/loop_ice.rs:2:5 --> $DIR/loop_ice.rs:2:5
| |
LL | loop {} LL | loop {}
| ^^^^^^^ | ^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add `#![feature(const_fn)]` to the crate attributes to enable
error: aborting due to previous error 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

@ -161,25 +161,7 @@ LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize }
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: loops and conditional expressions are not stable in const fn error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:100:38 --> $DIR/min_const_fn.rs:101:44
|
LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: loops are not allowed in const fn
--> $DIR/min_const_fn.rs:102:29
|
LL | const fn foo30_5(b: bool) { while b { } }
| ^^^^^^^^^^^
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= 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:105:44
| |
LL | const fn foo36(a: bool, b: bool) -> bool { a && b } LL | const fn foo36(a: bool, b: bool) -> bool { a && b }
| ^^^^^^ | ^^^^^^
@ -188,7 +170,7 @@ LL | const fn foo36(a: bool, b: bool) -> bool { a && b }
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: loops and conditional expressions are not stable in const fn error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:107:44 --> $DIR/min_const_fn.rs:103:44
| |
LL | const fn foo37(a: bool, b: bool) -> bool { a || b } LL | const fn foo37(a: bool, b: bool) -> bool { a || b }
| ^^^^^^ | ^^^^^^
@ -197,7 +179,7 @@ LL | const fn foo37(a: bool, b: bool) -> bool { a || b }
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: mutable references in const fn are unstable error[E0723]: mutable references in const fn are unstable
--> $DIR/min_const_fn.rs:109:14 --> $DIR/min_const_fn.rs:105:14
| |
LL | const fn inc(x: &mut i32) { *x += 1 } LL | const fn inc(x: &mut i32) { *x += 1 }
| ^ | ^
@ -206,7 +188,7 @@ LL | const fn inc(x: &mut i32) { *x += 1 }
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:114:6 --> $DIR/min_const_fn.rs:110:6
| |
LL | impl<T: std::fmt::Debug> Foo<T> { LL | impl<T: std::fmt::Debug> Foo<T> {
| ^ | ^
@ -215,7 +197,7 @@ LL | impl<T: std::fmt::Debug> Foo<T> {
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:119:6 --> $DIR/min_const_fn.rs:115:6
| |
LL | impl<T: std::fmt::Debug + Sized> Foo<T> { LL | impl<T: std::fmt::Debug + Sized> Foo<T> {
| ^ | ^
@ -224,7 +206,7 @@ LL | impl<T: std::fmt::Debug + Sized> Foo<T> {
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:124:6 --> $DIR/min_const_fn.rs:120:6
| |
LL | impl<T: Sync + Sized> Foo<T> { LL | impl<T: Sync + Sized> Foo<T> {
| ^ | ^
@ -233,7 +215,7 @@ LL | impl<T: Sync + Sized> Foo<T> {
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: `impl Trait` in const fn is unstable error[E0723]: `impl Trait` in const fn is unstable
--> $DIR/min_const_fn.rs:130:24 --> $DIR/min_const_fn.rs:126:24
| |
LL | const fn no_rpit2() -> AlanTuring<impl std::fmt::Debug> { AlanTuring(0) } LL | const fn no_rpit2() -> AlanTuring<impl std::fmt::Debug> { AlanTuring(0) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -242,7 +224,7 @@ LL | const fn no_rpit2() -> AlanTuring<impl std::fmt::Debug> { AlanTuring(0) }
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:132:34 --> $DIR/min_const_fn.rs:128:34
| |
LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {} LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
@ -251,7 +233,7 @@ LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:134:22 --> $DIR/min_const_fn.rs:130:22
| |
LL | const fn no_apit(_x: impl std::fmt::Debug) {} LL | const fn no_apit(_x: impl std::fmt::Debug) {}
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
@ -260,7 +242,7 @@ LL | const fn no_apit(_x: impl std::fmt::Debug) {}
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: `impl Trait` in const fn is unstable error[E0723]: `impl Trait` in const fn is unstable
--> $DIR/min_const_fn.rs:135:23 --> $DIR/min_const_fn.rs:131:23
| |
LL | const fn no_rpit() -> impl std::fmt::Debug {} LL | const fn no_rpit() -> impl std::fmt::Debug {}
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
@ -269,7 +251,7 @@ LL | const fn no_rpit() -> impl std::fmt::Debug {}
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:136:23 --> $DIR/min_const_fn.rs:132:23
| |
LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {}
| ^^ | ^^
@ -278,7 +260,7 @@ LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {}
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:137:32 --> $DIR/min_const_fn.rs:133:32
| |
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -287,7 +269,7 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:142:41 --> $DIR/min_const_fn.rs:138:41
| |
LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -296,7 +278,7 @@ LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: function pointers in const fn are unstable error[E0723]: function pointers in const fn are unstable
--> $DIR/min_const_fn.rs:145:21 --> $DIR/min_const_fn.rs:141:21
| |
LL | const fn no_fn_ptrs(_x: fn()) {} LL | const fn no_fn_ptrs(_x: fn()) {}
| ^^ | ^^
@ -305,7 +287,7 @@ LL | const fn no_fn_ptrs(_x: fn()) {}
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error[E0723]: function pointers in const fn are unstable error[E0723]: function pointers in const fn are unstable
--> $DIR/min_const_fn.rs:147:27 --> $DIR/min_const_fn.rs:143:27
| |
LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
| ^^^^ | ^^^^
@ -313,7 +295,7 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn)]` to the crate attributes to enable
error: aborting due to 36 previous errors error: aborting due to 34 previous errors
Some errors have detailed explanations: E0493, E0723. Some errors have detailed explanations: E0493, E0723.
For more information about an error, try `rustc --explain E0493`. For more information about an error, try `rustc --explain E0493`.

View file

@ -2,11 +2,11 @@ enum Foo {
Prob, Prob,
} }
const FOO: u32 = match Foo::Prob { //~ ERROR unimplemented expression type const FOO: u32 = match Foo::Prob { //~ ERROR `match` is not allowed in a `const`
Foo::Prob => 42, Foo::Prob => 42,
}; };
const BAR: u32 = match Foo::Prob { //~ ERROR unimplemented expression type const BAR: u32 = match Foo::Prob { //~ ERROR `match` is not allowed in a `const`
x => 42, x => 42,
}; };
@ -14,8 +14,7 @@ impl Foo {
pub const fn as_val(&self) -> u8 { pub const fn as_val(&self) -> u8 {
use self::Foo::*; use self::Foo::*;
match *self { match *self { //~ ERROR `match` is not allowed in a `const fn`
//~^ ERROR loops and conditional expressions are not stable in const fn
Prob => 0x1, Prob => 0x1,
} }
} }

View file

@ -1,25 +1,29 @@
error[E0019]: constant contains unimplemented expression type error[E0744]: `match` is not allowed in a `const`
--> $DIR/single_variant_match_ice.rs:5:24 --> $DIR/single_variant_match_ice.rs:5:18
| |
LL | const FOO: u32 = match Foo::Prob { LL | const FOO: u32 = match Foo::Prob {
| ^^^^^^^^^ | __________________^
LL | | Foo::Prob => 42,
LL | | };
| |_^
error[E0019]: constant contains unimplemented expression type error[E0744]: `match` is not allowed in a `const`
--> $DIR/single_variant_match_ice.rs:9:24 --> $DIR/single_variant_match_ice.rs:9:18
| |
LL | const BAR: u32 = match Foo::Prob { LL | const BAR: u32 = match Foo::Prob {
| ^^^^^^^^^ | __________________^
LL | | x => 42,
LL | | };
| |_^
error[E0723]: loops and conditional expressions are not stable in const fn error[E0744]: `match` is not allowed in a `const fn`
--> $DIR/single_variant_match_ice.rs:17:15 --> $DIR/single_variant_match_ice.rs:17:9
| |
LL | match *self { LL | / match *self {
| ^^^^^ LL | | Prob => 0x1,
| LL | | }
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 | |_________^
= help: add `#![feature(const_fn)]` to the crate attributes to enable
error: aborting due to 3 previous errors error: aborting due to 3 previous errors
Some errors have detailed explanations: E0019, E0723. For more information about this error, try `rustc --explain E0744`.
For more information about an error, try `rustc --explain E0019`.

View file

@ -5,9 +5,8 @@ fn non_const() -> Thing {
} }
pub const Q: i32 = match non_const() { pub const Q: i32 = match non_const() {
//~^ ERROR E0015 //~^ ERROR `match` is not allowed in a `const`
//~^^ ERROR unimplemented expression type Thing::This => 1,
Thing::This => 1, //~ ERROR unimplemented expression type
Thing::That => 0 Thing::That => 0
}; };

View file

@ -1,22 +1,14 @@
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0744]: `match` is not allowed in a `const`
--> $DIR/issue-46843.rs:7:26 --> $DIR/issue-46843.rs:7:20
| |
LL | pub const Q: i32 = match non_const() { LL | pub const Q: i32 = match non_const() {
| ^^^^^^^^^^^ | ____________________^
LL | |
LL | | Thing::This => 1,
LL | | Thing::That => 0
LL | | };
| |_^
error[E0019]: constant contains unimplemented expression type error: aborting due to previous error
--> $DIR/issue-46843.rs:7:26
|
LL | pub const Q: i32 = match non_const() {
| ^^^^^^^^^^^
error[E0019]: constant contains unimplemented expression type For more information about this error, try `rustc --explain E0744`.
--> $DIR/issue-46843.rs:10:5
|
LL | Thing::This => 1,
| ^^^^^^^^^^^
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0015, E0019.
For more information about an error, try `rustc --explain E0015`.

View file

@ -2,5 +2,8 @@ fn main() {
enum Foo { enum Foo {
Drop = assert_eq!(1, 1) Drop = assert_eq!(1, 1)
//~^ ERROR if may be missing an else clause //~^ ERROR if may be missing an else clause
//~| ERROR `match` is not allowed in a `const`
//~| ERROR `match` is not allowed in a `const`
//~| ERROR `if` is not allowed in a `const`
} }
} }

View file

@ -1,3 +1,27 @@
error[E0744]: `match` is not allowed in a `const`
--> $DIR/issue-50577.rs:3:16
|
LL | Drop = assert_eq!(1, 1)
| ^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0744]: `if` is not allowed in a `const`
--> $DIR/issue-50577.rs:3:16
|
LL | Drop = assert_eq!(1, 1)
| ^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0744]: `match` is not allowed in a `const`
--> $DIR/issue-50577.rs:3:16
|
LL | Drop = assert_eq!(1, 1)
| ^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0317]: if may be missing an else clause error[E0317]: if may be missing an else clause
--> $DIR/issue-50577.rs:3:16 --> $DIR/issue-50577.rs:3:16
| |
@ -13,6 +37,7 @@ LL | Drop = assert_eq!(1, 1)
= help: consider adding an `else` block that evaluates to the expected type = help: consider adding an `else` block that evaluates to the expected type
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0317`. Some errors have detailed explanations: E0317, E0744.
For more information about an error, try `rustc --explain E0317`.

View file

@ -1,4 +1,5 @@
fn main() { fn main() {
Vec::<[(); 1 + for x in 0..1 {}]>::new(); Vec::<[(); 1 + for x in 0..1 {}]>::new();
//~^ ERROR cannot add //~^ ERROR cannot add
//~| ERROR `for` is not allowed in a `const`
} }

View file

@ -1,3 +1,9 @@
error[E0744]: `for` is not allowed in a `const`
--> $DIR/issue-50582.rs:2:20
|
LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
| ^^^^^^^^^^^^^^^^
error[E0277]: cannot add `()` to `{integer}` error[E0277]: cannot add `()` to `{integer}`
--> $DIR/issue-50582.rs:2:18 --> $DIR/issue-50582.rs:2:18
| |
@ -6,6 +12,7 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
| |
= help: the trait `std::ops::Add<()>` is not implemented for `{integer}` = help: the trait `std::ops::Add<()>` is not implemented for `{integer}`
error: aborting due to previous error error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`. Some errors have detailed explanations: E0277, E0744.
For more information about an error, try `rustc --explain E0277`.

View file

@ -1,4 +1,5 @@
fn main() { fn main() {
|y: Vec<[(); for x in 0..2 {}]>| {}; |y: Vec<[(); for x in 0..2 {}]>| {};
//~^ ERROR mismatched types //~^ ERROR mismatched types
//~| ERROR `for` is not allowed in a `const`
} }

View file

@ -1,3 +1,9 @@
error[E0744]: `for` is not allowed in a `const`
--> $DIR/issue-50585.rs:2:18
|
LL | |y: Vec<[(); for x in 0..2 {}]>| {};
| ^^^^^^^^^^^^^^^^
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/issue-50585.rs:2:18 --> $DIR/issue-50585.rs:2:18
| |
@ -7,6 +13,7 @@ LL | |y: Vec<[(); for x in 0..2 {}]>| {};
= note: expected type `usize` = note: expected type `usize`
found type `()` found type `()`
error: aborting due to previous error error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`. Some errors have detailed explanations: E0308, E0744.
For more information about an error, try `rustc --explain E0308`.

View file

@ -10,4 +10,5 @@ fn main() {
[(); return while let Some(n) = Some(0) {}]; [(); return while let Some(n) = Some(0) {}];
//~^ ERROR return statement outside of function body //~^ ERROR return statement outside of function body
//~| ERROR `while let` is not allowed in a `const`
} }

View file

@ -1,3 +1,9 @@
error[E0744]: `while let` is not allowed in a `const`
--> $DIR/issue-51714.rs:11:17
|
LL | [(); return while let Some(n) = Some(0) {}];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0572]: return statement outside of function body error[E0572]: return statement outside of function body
--> $DIR/issue-51714.rs:2:14 --> $DIR/issue-51714.rs:2:14
| |
@ -22,6 +28,7 @@ error[E0572]: return statement outside of function body
LL | [(); return while let Some(n) = Some(0) {}]; LL | [(); return while let Some(n) = Some(0) {}];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0572`. Some errors have detailed explanations: E0572, E0744.
For more information about an error, try `rustc --explain E0572`.

View file

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

View file

@ -1,3 +1,21 @@
error[E0744]: `match` is not allowed in a `const`
--> $DIR/return-match-array-const.rs:2:17
|
LL | [(); return match 0 { n => n }];
| ^^^^^^^^^^^^^^^^^^
error[E0744]: `match` is not allowed in a `const`
--> $DIR/return-match-array-const.rs:6:17
|
LL | [(); return match 0 { 0 => 0 }];
| ^^^^^^^^^^^^^^^^^^
error[E0744]: `match` is not allowed in a `const`
--> $DIR/return-match-array-const.rs:10:17
|
LL | [(); return match () { 'a' => 0, _ => 0 }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0572]: return statement outside of function body error[E0572]: return statement outside of function body
--> $DIR/return-match-array-const.rs:2:10 --> $DIR/return-match-array-const.rs:2:10
| |
@ -5,17 +23,18 @@ LL | [(); return match 0 { n => n }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0572]: return statement outside of function body error[E0572]: return statement outside of function body
--> $DIR/return-match-array-const.rs:4:10 --> $DIR/return-match-array-const.rs:6:10
| |
LL | [(); return match 0 { 0 => 0 }]; LL | [(); return match 0 { 0 => 0 }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0572]: return statement outside of function body error[E0572]: return statement outside of function body
--> $DIR/return-match-array-const.rs:6:10 --> $DIR/return-match-array-const.rs:10:10
| |
LL | [(); return match () { 'a' => 0, _ => 0 }]; LL | [(); return match () { 'a' => 0, _ => 0 }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0572`. Some errors have detailed explanations: E0572, E0744.
For more information about an error, try `rustc --explain E0572`.

View file

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

View file

@ -1,5 +1,5 @@
error: expected one of `,` or `>`, found `&&` error: expected one of `,` or `>`, found `&&`
--> $DIR/disallowed-positions.rs:242:14 --> $DIR/disallowed-positions.rs:245:14
| |
LL | true && let 1 = 1 LL | true && let 1 = 1
| ^^ expected one of `,` or `>` | ^^ 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 = note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here error: `let` expressions are not supported here
--> $DIR/disallowed-positions.rs:224:17 --> $DIR/disallowed-positions.rs:225:17
| |
LL | true && let 1 = 1 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 = note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here error: `let` expressions are not supported here
--> $DIR/disallowed-positions.rs:230:17 --> $DIR/disallowed-positions.rs:232:17
| |
LL | true && let 1 = 1 LL | true && let 1 = 1
| ^^^^^^^^^ | ^^^^^^^^^
@ -513,6 +513,24 @@ warning: the feature `let_chains` is incomplete and may cause the compiler to cr
LL | #![feature(let_chains)] // Avoid inflating `.stderr` with overzealous gates in this test. LL | #![feature(let_chains)] // Avoid inflating `.stderr` with overzealous gates in this test.
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0744]: `match` is not allowed in a `const`
--> $DIR/disallowed-positions.rs:218:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
error[E0744]: `match` is not allowed in a `const`
--> $DIR/disallowed-positions.rs:225:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
error[E0744]: `match` is not allowed in a `const`
--> $DIR/disallowed-positions.rs:232:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:32:8 --> $DIR/disallowed-positions.rs:32:8
| |
@ -966,30 +984,30 @@ LL | true && let 1 = 1
| ^ | ^
error[E0019]: constant contains unimplemented expression type error[E0019]: constant contains unimplemented expression type
--> $DIR/disallowed-positions.rs:224:25 --> $DIR/disallowed-positions.rs:225:25
| |
LL | true && let 1 = 1 LL | true && let 1 = 1
| ^ | ^
error[E0019]: constant contains unimplemented expression type error[E0019]: constant contains unimplemented expression type
--> $DIR/disallowed-positions.rs:224:21 --> $DIR/disallowed-positions.rs:225:21
| |
LL | true && let 1 = 1 LL | true && let 1 = 1
| ^ | ^
error[E0019]: constant contains unimplemented expression type error[E0019]: constant contains unimplemented expression type
--> $DIR/disallowed-positions.rs:230:25 --> $DIR/disallowed-positions.rs:232:25
| |
LL | true && let 1 = 1 LL | true && let 1 = 1
| ^ | ^
error[E0019]: constant contains unimplemented expression type error[E0019]: constant contains unimplemented expression type
--> $DIR/disallowed-positions.rs:230:21 --> $DIR/disallowed-positions.rs:232:21
| |
LL | true && let 1 = 1 LL | true && let 1 = 1
| ^ | ^
error: aborting due to 109 previous errors error: aborting due to 112 previous errors
Some errors have detailed explanations: E0019, E0277, E0308, E0600, E0614. Some errors have detailed explanations: E0019, E0277, E0308, E0600, E0614, E0744.
For more information about an error, try `rustc --explain E0019`. For more information about an error, try `rustc --explain E0019`.