From 3ce8ca45d63a65e0c0eaaa4a29f8ce3ccf5350b9 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Wed, 6 Nov 2019 12:29:30 -0800 Subject: [PATCH] Bless const tests with improved diagnostics --- .../compile-fail/consts/const-fn-error.rs | 1 + src/test/compile-fail/issue-52443.rs | 4 + src/test/ui/borrowck/issue-64453.rs | 5 +- src/test/ui/borrowck/issue-64453.stderr | 29 +--- src/test/ui/closures/issue-52437.rs | 1 + src/test/ui/closures/issue-52437.stderr | 11 +- .../ui/consts/const-eval/infinite_loop.rs | 2 + .../ui/consts/const-eval/infinite_loop.stderr | 27 ++- src/test/ui/consts/const-eval/issue-52475.rs | 3 +- .../ui/consts/const-eval/issue-52475.stderr | 19 ++- .../consts/const-eval/match-test-ptr-null.rs | 1 + .../const-eval/match-test-ptr-null.stderr | 18 +- src/test/ui/consts/const-if.rs | 8 +- src/test/ui/consts/const-if.stderr | 42 +++-- src/test/ui/consts/const-loop.rs | 30 ++-- src/test/ui/consts/const-loop.stderr | 154 +++++++++++++----- src/test/ui/consts/const-match-pattern-arm.rs | 8 +- .../ui/consts/const-match-pattern-arm.stderr | 39 ++--- src/test/ui/consts/min_const_fn/loop_ice.rs | 2 +- .../ui/consts/min_const_fn/loop_ice.stderr | 7 +- .../consts/min_const_fn/min_const_fn.stderr | 50 ++---- .../ui/consts/single_variant_match_ice.rs | 7 +- .../ui/consts/single_variant_match_ice.stderr | 38 +++-- src/test/ui/issues/issue-46843.rs | 5 +- src/test/ui/issues/issue-46843.stderr | 30 ++-- src/test/ui/issues/issue-50577.rs | 3 + src/test/ui/issues/issue-50577.stderr | 29 +++- src/test/ui/issues/issue-50582.rs | 1 + src/test/ui/issues/issue-50582.stderr | 11 +- src/test/ui/issues/issue-50585.rs | 1 + src/test/ui/issues/issue-50585.stderr | 11 +- src/test/ui/issues/issue-51714.rs | 1 + src/test/ui/issues/issue-51714.stderr | 11 +- .../ui/return/return-match-array-const.rs | 12 +- .../ui/return/return-match-array-const.stderr | 27 ++- .../disallowed-positions.rs | 3 + .../disallowed-positions.stderr | 36 +++- 37 files changed, 443 insertions(+), 244 deletions(-) diff --git a/src/test/compile-fail/consts/const-fn-error.rs b/src/test/compile-fail/consts/const-fn-error.rs index 1de23f2a5e9..6f414dab88e 100644 --- a/src/test/compile-fail/consts/const-fn-error.rs +++ b/src/test/compile-fail/consts/const-fn-error.rs @@ -10,6 +10,7 @@ const fn f(x: usize) -> usize { //~| ERROR E0019 //~| ERROR E0019 //~| ERROR E0080 + //~| ERROR E0744 sum += i; } sum diff --git a/src/test/compile-fail/issue-52443.rs b/src/test/compile-fail/issue-52443.rs index 28d9937b5e8..90b9a1c265a 100644 --- a/src/test/compile-fail/issue-52443.rs +++ b/src/test/compile-fail/issue-52443.rs @@ -1,12 +1,16 @@ fn main() { [(); & { loop { continue } } ]; //~ ERROR mismatched types + //~^ ERROR `loop` is not allowed in a `const` [(); loop { break }]; //~ ERROR mismatched types + //~^ ERROR `loop` is not allowed in a `const` [(); {while true {break}; 0}]; //~^ 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 [(); { for _ in 0usize.. {}; 0}]; //~^ 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 constant contains unimplemented expression type //~| ERROR constant contains unimplemented expression type diff --git a/src/test/ui/borrowck/issue-64453.rs b/src/test/ui/borrowck/issue-64453.rs index d8ab6b6e25f..8a405edb046 100644 --- a/src/test/ui/borrowck/issue-64453.rs +++ b/src/test/ui/borrowck/issue-64453.rs @@ -2,9 +2,7 @@ struct Project; struct Value; static settings_dir: String = format!(""); -//~^ ERROR [E0019] -//~| ERROR [E0015] -//~| ERROR [E0015] +//~^ ERROR `match` is not allowed in a `static` fn from_string(_: String) -> Value { Value @@ -13,7 +11,6 @@ fn set_editor(_: Value) {} fn main() { let settings_data = from_string(settings_dir); - //~^ ERROR cannot move out of static item `settings_dir` [E0507] let args: i32 = 0; match args { diff --git a/src/test/ui/borrowck/issue-64453.stderr b/src/test/ui/borrowck/issue-64453.stderr index 6987417fe19..f437880a165 100644 --- a/src/test/ui/borrowck/issue-64453.stderr +++ b/src/test/ui/borrowck/issue-64453.stderr @@ -1,10 +1,4 @@ -error[E0507]: cannot move out of static item `settings_dir` - --> $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 +error[E0744]: `match` is not allowed in a `static` --> $DIR/issue-64453.rs:4:31 | 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) -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 outside of the current crate (in Nightly builds, run with -Z external-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 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`. +For more information about this error, try `rustc --explain E0744`. diff --git a/src/test/ui/closures/issue-52437.rs b/src/test/ui/closures/issue-52437.rs index 6ac5380a5aa..1e649a556e0 100644 --- a/src/test/ui/closures/issue-52437.rs +++ b/src/test/ui/closures/issue-52437.rs @@ -1,5 +1,6 @@ fn main() { [(); &(&'static: loop { |x| {}; }) as *const _ as usize] //~^ ERROR: invalid label name `'static` + //~| ERROR: `loop` is not allowed in a `const` //~| ERROR: type annotations needed } diff --git a/src/test/ui/closures/issue-52437.stderr b/src/test/ui/closures/issue-52437.stderr index e76f942e9ba..b4b40336aa9 100644 --- a/src/test/ui/closures/issue-52437.stderr +++ b/src/test/ui/closures/issue-52437.stderr @@ -4,12 +4,19 @@ error: invalid label name `'static` 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 --> $DIR/issue-52437.rs:2:30 | LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] | ^ 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`. diff --git a/src/test/ui/consts/const-eval/infinite_loop.rs b/src/test/ui/consts/const-eval/infinite_loop.rs index 8fa5b0a961f..ee1d588e553 100644 --- a/src/test/ui/consts/const-eval/infinite_loop.rs +++ b/src/test/ui/consts/const-eval/infinite_loop.rs @@ -7,8 +7,10 @@ fn main() { while n != 0 { //~^ 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 }; //~^ ERROR evaluation of constant value failed + //~| ERROR `if` is not allowed in a `const` } n }]; diff --git a/src/test/ui/consts/const-eval/infinite_loop.stderr b/src/test/ui/consts/const-eval/infinite_loop.stderr index 68e7fdb1251..bf5d2c8c328 100644 --- a/src/test/ui/consts/const-eval/infinite_loop.stderr +++ b/src/test/ui/consts/const-eval/infinite_loop.stderr @@ -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 --> $DIR/infinite_loop.rs:7:15 | @@ -10,7 +28,8 @@ error[E0019]: constant contains unimplemented expression type LL | / while n != 0 { LL | | LL | | -LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; +LL | | +... | LL | | LL | | } | |_________^ @@ -29,12 +48,12 @@ LL | | }]; | |_____^ 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 }; | ^^^^^^^^^^ 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`. diff --git a/src/test/ui/consts/const-eval/issue-52475.rs b/src/test/ui/consts/const-eval/issue-52475.rs index b42249e57fa..b9cdf09b85f 100644 --- a/src/test/ui/consts/const-eval/issue-52475.rs +++ b/src/test/ui/consts/const-eval/issue-52475.rs @@ -4,7 +4,8 @@ fn main() { let mut x = &0; let mut n = 0; 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 n = (n + 1) % 5; //~ ERROR evaluation of constant value failed x = &0; // Materialize a new AllocId diff --git a/src/test/ui/consts/const-eval/issue-52475.stderr b/src/test/ui/consts/const-eval/issue-52475.stderr index 1e83cbcff2b..25d56e3fac4 100644 --- a/src/test/ui/consts/const-eval/issue-52475.stderr +++ b/src/test/ui/consts/const-eval/issue-52475.stderr @@ -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 --> $DIR/issue-52475.rs:6:15 | @@ -10,6 +22,7 @@ error[E0019]: constant contains unimplemented expression type LL | / while n < 5 { LL | | LL | | +LL | | LL | | n = (n + 1) % 5; LL | | x = &0; // Materialize a new AllocId LL | | } @@ -29,12 +42,12 @@ LL | | }]; | |_____^ error[E0080]: evaluation of constant value failed - --> $DIR/issue-52475.rs:9:17 + --> $DIR/issue-52475.rs:10:17 | LL | n = (n + 1) % 5; | ^^^^^^^^^^^ 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`. diff --git a/src/test/ui/consts/const-eval/match-test-ptr-null.rs b/src/test/ui/consts/const-eval/match-test-ptr-null.rs index 5b89b0262ac..0dc3652bbee 100644 --- a/src/test/ui/consts/const-eval/match-test-ptr-null.rs +++ b/src/test/ui/consts/const-eval/match-test-ptr-null.rs @@ -5,6 +5,7 @@ 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 constant contains unimplemented expression type //~| ERROR evaluation of constant value failed 0 => 42, //~ ERROR constant contains unimplemented expression type diff --git a/src/test/ui/consts/const-eval/match-test-ptr-null.stderr b/src/test/ui/consts/const-eval/match-test-ptr-null.stderr index 3d34ac42662..ab4d28c0455 100644 --- a/src/test/ui/consts/const-eval/match-test-ptr-null.stderr +++ b/src/test/ui/consts/const-eval/match-test-ptr-null.stderr @@ -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 --> $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 - --> $DIR/match-test-ptr-null.rs:10:13 + --> $DIR/match-test-ptr-null.rs:11:13 | LL | 0 => 42, | ^ @@ -25,7 +37,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 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`. diff --git a/src/test/ui/consts/const-if.rs b/src/test/ui/consts/const-if.rs index 440723a3fe1..94cce60453d 100644 --- a/src/test/ui/consts/const-if.rs +++ b/src/test/ui/consts/const-if.rs @@ -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 } else { 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, 4 => 5, _ => 0, }; 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 { - 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() {} diff --git a/src/test/ui/consts/const-if.stderr b/src/test/ui/consts/const-if.stderr index 655fcdae587..6fb2a0e1501 100644 --- a/src/test/ui/consts/const-if.stderr +++ b/src/test/ui/consts/const-if.stderr @@ -1,15 +1,37 @@ -error[E0019]: constant contains unimplemented expression type - --> $DIR/const-if.rs:1:20 +error[E0744]: `if` is not allowed in a `const` + --> $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 - --> $DIR/const-if.rs:1:17 +error[E0744]: `match` is not allowed in a `const` + --> $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`. diff --git a/src/test/ui/consts/const-loop.rs b/src/test/ui/consts/const-loop.rs index b94f3de4d47..383db24ad63 100644 --- a/src/test/ui/consts/const-loop.rs +++ b/src/test/ui/consts/const-loop.rs @@ -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() { - loop {} //~ ERROR loop is not allowed in a const fn + loop {} //~ ERROR `loop` is not allowed in a `const fn` } 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 () { - 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() { @@ -39,11 +39,11 @@ fn main() { const _: i32 = { 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; } - 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; } @@ -53,11 +53,11 @@ const _: i32 = { const _: i32 = { 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; } - 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; } @@ -67,16 +67,16 @@ const _: i32 = { const _: i32 = { let mut x = 0; - loop { //~ ERROR loop is not allowed in a const + loop { //~ ERROR `loop` is not allowed in a `const` 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; } } - loop { //~ ERROR loop is not allowed in a const + loop { //~ ERROR `loop` is not allowed in a `const` 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; } } @@ -86,7 +86,7 @@ const _: i32 = { const _: i32 = { 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 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 let` is not allowed in a `const` x }; diff --git a/src/test/ui/consts/const-loop.stderr b/src/test/ui/consts/const-loop.stderr index e6e4e2f5bb8..bfb953547d3 100644 --- a/src/test/ui/consts/const-loop.stderr +++ b/src/test/ui/consts/const-loop.stderr @@ -1,60 +1,140 @@ -error[E0019]: constant contains unimplemented expression type - --> $DIR/const-loop.rs:4:11 +error[E0744]: `loop` is not allowed in a `const` + --> $DIR/const-loop.rs:1:15 | -LL | while x < 4 { - | ^^^^^ +LL | const _: () = loop {}; + | ^^^^^^^ -error[E0019]: constant contains unimplemented expression type - --> $DIR/const-loop.rs:4:5 +error[E0744]: `loop` is not allowed in a `static` + --> $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 | | -LL | | LL | | x += 1; LL | | } | |_____^ -error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants - --> $DIR/const-loop.rs:20:14 +error[E0744]: `while` is not allowed in a `const` + --> $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 - --> $DIR/const-loop.rs:20:14 +error[E0744]: `for` is not allowed in a `const` + --> $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 - --> $DIR/const-loop.rs:20:14 +error[E0744]: `for` is not allowed in a `const` + --> $DIR/const-loop.rs:60:5 | -LL | for i in 0..4 { - | ^^^^ constants require immutable values +LL | / for i in 0..4 { +LL | | x += i; +LL | | } + | |_____^ -error[E0019]: constant contains unimplemented expression type - --> $DIR/const-loop.rs:20:9 +error[E0744]: `loop` is not allowed in a `const` + --> $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 - --> $DIR/const-loop.rs:41:12 - | -LL | if x == 4 { - | ^^^^^^ - -error[E0019]: constant contains unimplemented expression type - --> $DIR/const-loop.rs:41:9 +error[E0744]: `if` is not allowed in a `const` + --> $DIR/const-loop.rs:72:9 | LL | / if x == 4 { -LL | | -LL | | LL | | break; 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. -For more information about an error, try `rustc --explain E0015`. +error[E0744]: `if` is not allowed in a `const` + --> $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`. diff --git a/src/test/ui/consts/const-match-pattern-arm.rs b/src/test/ui/consts/const-match-pattern-arm.rs index 6ed3ac23562..0482f7f7dae 100644 --- a/src/test/ui/consts/const-match-pattern-arm.rs +++ b/src/test/ui/consts/const-match-pattern-arm.rs @@ -1,17 +1,13 @@ #![allow(warnings)] -const x: bool = match Some(true) { - //~^ ERROR: constant contains unimplemented expression type [E0019] +const x: bool = match Some(true) { //~ ERROR `match` is not allowed in a `const` Some(value) => true, - //~^ ERROR: constant contains unimplemented expression type [E0019] _ => false }; const y: bool = { - match Some(true) { - //~^ ERROR: constant contains unimplemented expression type [E0019] + match Some(true) { //~ ERROR `match` is not allowed in a `const` Some(value) => true, - //~^ ERROR: constant contains unimplemented expression type [E0019] _ => false } }; diff --git a/src/test/ui/consts/const-match-pattern-arm.stderr b/src/test/ui/consts/const-match-pattern-arm.stderr index 709b66b7bf0..57ef349a377 100644 --- a/src/test/ui/consts/const-match-pattern-arm.stderr +++ b/src/test/ui/consts/const-match-pattern-arm.stderr @@ -1,27 +1,22 @@ -error[E0019]: constant contains unimplemented expression type - --> $DIR/const-match-pattern-arm.rs:3:23 +error[E0744]: `match` is not allowed in a `const` + --> $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 - --> $DIR/const-match-pattern-arm.rs:5:5 +error[E0744]: `match` is not allowed in a `const` + --> $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 - --> $DIR/const-match-pattern-arm.rs:11:11 - | -LL | match Some(true) { - | ^^^^^^^^^^ +error: aborting due to 2 previous errors -error[E0019]: constant contains unimplemented expression type - --> $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`. +For more information about this error, try `rustc --explain E0744`. diff --git a/src/test/ui/consts/min_const_fn/loop_ice.rs b/src/test/ui/consts/min_const_fn/loop_ice.rs index 4278a8e2d00..754a1d7c2a3 100644 --- a/src/test/ui/consts/min_const_fn/loop_ice.rs +++ b/src/test/ui/consts/min_const_fn/loop_ice.rs @@ -1,5 +1,5 @@ const fn foo() { - loop {} //~ ERROR loops are not allowed in const fn + loop {} //~ ERROR `loop` is not allowed in a `const fn` } fn main() {} diff --git a/src/test/ui/consts/min_const_fn/loop_ice.stderr b/src/test/ui/consts/min_const_fn/loop_ice.stderr index edf983fc56b..87db65fbb7d 100644 --- a/src/test/ui/consts/min_const_fn/loop_ice.stderr +++ b/src/test/ui/consts/min_const_fn/loop_ice.stderr @@ -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 | 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 -For more information about this error, try `rustc --explain E0723`. +For more information about this error, try `rustc --explain E0744`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.stderr index 64b2ce83da2..5ce21e378cd 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.stderr @@ -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 error[E0723]: loops and conditional expressions are not stable in const fn - --> $DIR/min_const_fn.rs:100:38 - | -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 + --> $DIR/min_const_fn.rs:101:44 | 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 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 } | ^^^^^^ @@ -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 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 } | ^ @@ -206,7 +188,7 @@ LL | const fn inc(x: &mut i32) { *x += 1 } = help: add `#![feature(const_fn)]` to the crate attributes to enable 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 Foo { | ^ @@ -215,7 +197,7 @@ LL | impl Foo { = help: add `#![feature(const_fn)]` to the crate attributes to enable 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 Foo { | ^ @@ -224,7 +206,7 @@ LL | impl Foo { = help: add `#![feature(const_fn)]` to the crate attributes to enable 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 Foo { | ^ @@ -233,7 +215,7 @@ LL | impl Foo { = help: add `#![feature(const_fn)]` to the crate attributes to enable 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 { AlanTuring(0) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -242,7 +224,7 @@ LL | const fn no_rpit2() -> AlanTuring { AlanTuring(0) } = help: add `#![feature(const_fn)]` to the crate attributes to enable 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) {} | ^^^^^^^^^^^^^^^^^^^^ @@ -251,7 +233,7 @@ LL | const fn no_apit2(_x: AlanTuring) {} = help: add `#![feature(const_fn)]` to the crate attributes to enable 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) {} | ^^^^^^^^^^^^^^^^^^^^ @@ -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 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 {} | ^^^^^^^^^^^^^^^^^^^^ @@ -269,7 +251,7 @@ LL | const fn no_rpit() -> impl std::fmt::Debug {} = help: add `#![feature(const_fn)]` to the crate attributes to enable 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) {} | ^^ @@ -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 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 { &() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -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 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 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -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 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()) {} | ^^ @@ -305,7 +287,7 @@ LL | const fn no_fn_ptrs(_x: fn()) {} = help: add `#![feature(const_fn)]` to the crate attributes to enable 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 } | ^^^^ @@ -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 = 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. For more information about an error, try `rustc --explain E0493`. diff --git a/src/test/ui/consts/single_variant_match_ice.rs b/src/test/ui/consts/single_variant_match_ice.rs index 75793c90483..80a92c4c965 100644 --- a/src/test/ui/consts/single_variant_match_ice.rs +++ b/src/test/ui/consts/single_variant_match_ice.rs @@ -2,11 +2,11 @@ enum Foo { 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, }; -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, }; @@ -14,8 +14,7 @@ impl Foo { pub const fn as_val(&self) -> u8 { use self::Foo::*; - match *self { - //~^ ERROR loops and conditional expressions are not stable in const fn + match *self { //~ ERROR `match` is not allowed in a `const fn` Prob => 0x1, } } diff --git a/src/test/ui/consts/single_variant_match_ice.stderr b/src/test/ui/consts/single_variant_match_ice.stderr index 3f37a6c6450..780dd0dcddf 100644 --- a/src/test/ui/consts/single_variant_match_ice.stderr +++ b/src/test/ui/consts/single_variant_match_ice.stderr @@ -1,25 +1,29 @@ -error[E0019]: constant contains unimplemented expression type - --> $DIR/single_variant_match_ice.rs:5:24 +error[E0744]: `match` is not allowed in a `const` + --> $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 - --> $DIR/single_variant_match_ice.rs:9:24 +error[E0744]: `match` is not allowed in a `const` + --> $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 - --> $DIR/single_variant_match_ice.rs:17:15 +error[E0744]: `match` is not allowed in a `const fn` + --> $DIR/single_variant_match_ice.rs:17:9 | -LL | match *self { - | ^^^^^ - | - = 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 +LL | / match *self { +LL | | Prob => 0x1, +LL | | } + | |_________^ error: aborting due to 3 previous errors -Some errors have detailed explanations: E0019, E0723. -For more information about an error, try `rustc --explain E0019`. +For more information about this error, try `rustc --explain E0744`. diff --git a/src/test/ui/issues/issue-46843.rs b/src/test/ui/issues/issue-46843.rs index aa252efea46..e5b27136739 100644 --- a/src/test/ui/issues/issue-46843.rs +++ b/src/test/ui/issues/issue-46843.rs @@ -5,9 +5,8 @@ fn non_const() -> Thing { } pub const Q: i32 = match non_const() { - //~^ ERROR E0015 - //~^^ ERROR unimplemented expression type - Thing::This => 1, //~ ERROR unimplemented expression type + //~^ ERROR `match` is not allowed in a `const` + Thing::This => 1, Thing::That => 0 }; diff --git a/src/test/ui/issues/issue-46843.stderr b/src/test/ui/issues/issue-46843.stderr index 92ee154552c..9d533297864 100644 --- a/src/test/ui/issues/issue-46843.stderr +++ b/src/test/ui/issues/issue-46843.stderr @@ -1,22 +1,14 @@ -error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-46843.rs:7:26 +error[E0744]: `match` is not allowed in a `const` + --> $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 - --> $DIR/issue-46843.rs:7:26 - | -LL | pub const Q: i32 = match non_const() { - | ^^^^^^^^^^^ +error: aborting due to previous error -error[E0019]: constant contains unimplemented expression type - --> $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`. +For more information about this error, try `rustc --explain E0744`. diff --git a/src/test/ui/issues/issue-50577.rs b/src/test/ui/issues/issue-50577.rs index f0f1dc6c286..f3f680e7b8e 100644 --- a/src/test/ui/issues/issue-50577.rs +++ b/src/test/ui/issues/issue-50577.rs @@ -2,5 +2,8 @@ fn main() { enum Foo { Drop = assert_eq!(1, 1) //~^ 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` } } diff --git a/src/test/ui/issues/issue-50577.stderr b/src/test/ui/issues/issue-50577.stderr index 0c3ba2ea4f9..055a71f468d 100644 --- a/src/test/ui/issues/issue-50577.stderr +++ b/src/test/ui/issues/issue-50577.stderr @@ -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 --> $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 = 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`. diff --git a/src/test/ui/issues/issue-50582.rs b/src/test/ui/issues/issue-50582.rs index 1358e0bde4c..2d5c9358752 100644 --- a/src/test/ui/issues/issue-50582.rs +++ b/src/test/ui/issues/issue-50582.rs @@ -1,4 +1,5 @@ fn main() { Vec::<[(); 1 + for x in 0..1 {}]>::new(); //~^ ERROR cannot add + //~| ERROR `for` is not allowed in a `const` } diff --git a/src/test/ui/issues/issue-50582.stderr b/src/test/ui/issues/issue-50582.stderr index 226f5a3f0fe..13f6c4d7633 100644 --- a/src/test/ui/issues/issue-50582.stderr +++ b/src/test/ui/issues/issue-50582.stderr @@ -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}` --> $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}` -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`. diff --git a/src/test/ui/issues/issue-50585.rs b/src/test/ui/issues/issue-50585.rs index ca2ece8d53b..a2f11c98d5a 100644 --- a/src/test/ui/issues/issue-50585.rs +++ b/src/test/ui/issues/issue-50585.rs @@ -1,4 +1,5 @@ fn main() { |y: Vec<[(); for x in 0..2 {}]>| {}; //~^ ERROR mismatched types + //~| ERROR `for` is not allowed in a `const` } diff --git a/src/test/ui/issues/issue-50585.stderr b/src/test/ui/issues/issue-50585.stderr index 4c41da8fc33..8e57c9806e3 100644 --- a/src/test/ui/issues/issue-50585.stderr +++ b/src/test/ui/issues/issue-50585.stderr @@ -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 --> $DIR/issue-50585.rs:2:18 | @@ -7,6 +13,7 @@ LL | |y: Vec<[(); for x in 0..2 {}]>| {}; = note: expected type `usize` 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`. diff --git a/src/test/ui/issues/issue-51714.rs b/src/test/ui/issues/issue-51714.rs index 0dc588d75c6..e0fd7ff896c 100644 --- a/src/test/ui/issues/issue-51714.rs +++ b/src/test/ui/issues/issue-51714.rs @@ -10,4 +10,5 @@ fn main() { [(); return while let Some(n) = Some(0) {}]; //~^ ERROR return statement outside of function body + //~| ERROR `while let` is not allowed in a `const` } diff --git a/src/test/ui/issues/issue-51714.stderr b/src/test/ui/issues/issue-51714.stderr index 023d9013ab4..a3b20cf97f8 100644 --- a/src/test/ui/issues/issue-51714.stderr +++ b/src/test/ui/issues/issue-51714.stderr @@ -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 --> $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) {}]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -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`. diff --git a/src/test/ui/return/return-match-array-const.rs b/src/test/ui/return/return-match-array-const.rs index bbcd9600b22..9f3b9651642 100644 --- a/src/test/ui/return/return-match-array-const.rs +++ b/src/test/ui/return/return-match-array-const.rs @@ -1,7 +1,13 @@ 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` } diff --git a/src/test/ui/return/return-match-array-const.stderr b/src/test/ui/return/return-match-array-const.stderr index 6e8c9ed40bb..496e9208b61 100644 --- a/src/test/ui/return/return-match-array-const.stderr +++ b/src/test/ui/return/return-match-array-const.stderr @@ -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 --> $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 - --> $DIR/return-match-array-const.rs:4:10 + --> $DIR/return-match-array-const.rs:6:10 | LL | [(); return match 0 { 0 => 0 }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ 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 }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -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`. diff --git a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs index 7d1e5c3d64d..3baa19b5aed 100644 --- a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs +++ b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs @@ -218,18 +218,21 @@ fn inside_const_generic_arguments() { true && let 1 = 1 //~ ERROR `let` expressions are not supported here //~^ ERROR constant contains unimplemented expression type //~| ERROR constant contains unimplemented expression type + //~| 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 constant contains unimplemented expression type //~| ERROR constant contains unimplemented expression type + //~| ERROR `match` is not allowed in a `const` }>::O = 5 {} if A::<{ true && let 1 = 1 //~ ERROR `let` expressions are not supported here //~^ ERROR constant contains unimplemented expression type //~| ERROR constant contains unimplemented expression type + //~| ERROR `match` is not allowed in a `const` }>::O == 5 {} // In the cases above we have `ExprKind::Block` to help us out. diff --git a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr index 65de150b100..92cdead7856 100644 --- a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr +++ b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr @@ -1,5 +1,5 @@ error: expected one of `,` or `>`, found `&&` - --> $DIR/disallowed-positions.rs:242:14 + --> $DIR/disallowed-positions.rs:245: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:224:17 + --> $DIR/disallowed-positions.rs:225: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:230:17 + --> $DIR/disallowed-positions.rs:232:17 | 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. | ^^^^^^^^^^ +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 --> $DIR/disallowed-positions.rs:32:8 | @@ -966,30 +984,30 @@ LL | true && let 1 = 1 | ^ error[E0019]: constant contains unimplemented expression type - --> $DIR/disallowed-positions.rs:224:25 + --> $DIR/disallowed-positions.rs:225:25 | LL | true && let 1 = 1 | ^ error[E0019]: constant contains unimplemented expression type - --> $DIR/disallowed-positions.rs:224:21 + --> $DIR/disallowed-positions.rs:225:21 | LL | true && let 1 = 1 | ^ error[E0019]: constant contains unimplemented expression type - --> $DIR/disallowed-positions.rs:230:25 + --> $DIR/disallowed-positions.rs:232:25 | LL | true && let 1 = 1 | ^ error[E0019]: constant contains unimplemented expression type - --> $DIR/disallowed-positions.rs:230:21 + --> $DIR/disallowed-positions.rs:232:21 | 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`.