diff options
Diffstat (limited to 'src/test')
96 files changed, 232 insertions, 1498 deletions
diff --git a/src/test/compile-fail/issue-52443.rs b/src/test/compile-fail/issue-52443.rs index 00aca1d14ba..21bd6252219 100644 --- a/src/test/compile-fail/issue-52443.rs +++ b/src/test/compile-fail/issue-52443.rs @@ -1,11 +1,11 @@ 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 `while` is not allowed in a `const` - //~| WARN denote infinite loops with + //~^ WARN denote infinite loops with + [(); { for _ in 0usize.. {}; 0}]; //~^ ERROR `for` is not allowed in a `const` //~| ERROR calls in constants are limited to constant functions diff --git a/src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs b/src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs index 69c33921868..d8a9ae6ca20 100644 --- a/src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs +++ b/src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs @@ -2,7 +2,8 @@ // run-pass -#![feature(const_fn, const_if_match)] +#![feature(const_fn)] + #[derive(PartialEq, Debug, Clone)] struct N(u8); diff --git a/src/test/ui/async-await/issue-70594.rs b/src/test/ui/async-await/issue-70594.rs index 34d12db8806..9e7c5847b3b 100644 --- a/src/test/ui/async-await/issue-70594.rs +++ b/src/test/ui/async-await/issue-70594.rs @@ -4,7 +4,6 @@ async fn fun() { [1; ().await]; //~^ error: `await` is only allowed inside `async` functions and blocks //~| error: `.await` is not allowed in a `const` - //~| error: `loop` is not allowed in a `const` //~| error: `.await` is not allowed in a `const` //~| error: `()` is not a future } diff --git a/src/test/ui/async-await/issue-70594.stderr b/src/test/ui/async-await/issue-70594.stderr index 1b7abe31722..badb7ae9f6f 100644 --- a/src/test/ui/async-await/issue-70594.stderr +++ b/src/test/ui/async-await/issue-70594.stderr @@ -12,15 +12,6 @@ error[E0744]: `.await` is not allowed in a `const` LL | [1; ().await]; | ^^^^^^^^ -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/issue-70594.rs:4:9 - | -LL | [1; ().await]; - | ^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - error[E0744]: `.await` is not allowed in a `const` --> $DIR/issue-70594.rs:4:9 | @@ -36,7 +27,7 @@ LL | [1; ().await]; = help: the trait `std::future::Future` is not implemented for `()` = note: required by `std::future::Future::poll` -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0277, E0658, E0728, E0744. +Some errors have detailed explanations: E0277, E0728, E0744. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/borrowck/issue-64453.rs b/src/test/ui/borrowck/issue-64453.rs index 8a405edb046..3e803f3b6d8 100644 --- a/src/test/ui/borrowck/issue-64453.rs +++ b/src/test/ui/borrowck/issue-64453.rs @@ -2,7 +2,8 @@ struct Project; struct Value; static settings_dir: String = format!(""); -//~^ ERROR `match` is not allowed in a `static` +//~^ ERROR calls in statics are limited to constant functions +//~| ERROR calls in statics are limited to constant functions fn from_string(_: String) -> Value { Value @@ -11,6 +12,7 @@ fn set_editor(_: Value) {} fn main() { let settings_data = from_string(settings_dir); + //~^ ERROR cannot move out of static item let args: i32 = 0; match args { diff --git a/src/test/ui/borrowck/issue-64453.stderr b/src/test/ui/borrowck/issue-64453.stderr index 48859fb6763..081ccd37861 100644 --- a/src/test/ui/borrowck/issue-64453.stderr +++ b/src/test/ui/borrowck/issue-64453.stderr @@ -1,13 +1,26 @@ -error[E0658]: `match` is not allowed in a `static` +error[E0507]: cannot move out of static item `settings_dir` + --> $DIR/issue-64453.rs:14:37 + | +LL | let settings_data = from_string(settings_dir); + | ^^^^^^^^^^^^ move occurs because `settings_dir` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants + --> $DIR/issue-64453.rs:4:31 + | +LL | static settings_dir: String = format!(""); + | ^^^^^^^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z 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: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0015, E0507. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/closures/issue-52437.rs b/src/test/ui/closures/issue-52437.rs index 634638e1335..f79a0bd3548 100644 --- a/src/test/ui/closures/issue-52437.rs +++ b/src/test/ui/closures/issue-52437.rs @@ -1,7 +1,6 @@ fn main() { [(); &(&'static: loop { |x| {}; }) as *const _ as usize] //~^ ERROR: invalid label name `'static` - //~| ERROR: `loop` is not allowed in a `const` //~| ERROR: type annotations needed //~| ERROR mismatched types } diff --git a/src/test/ui/closures/issue-52437.stderr b/src/test/ui/closures/issue-52437.stderr index acb59c7b02d..54825cb746d 100644 --- a/src/test/ui/closures/issue-52437.stderr +++ b/src/test/ui/closures/issue-52437.stderr @@ -4,15 +4,6 @@ error: invalid label name `'static` LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] | ^^^^^^^ -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/issue-52437.rs:2:13 - | -LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - error[E0282]: type annotations needed --> $DIR/issue-52437.rs:2:30 | @@ -27,7 +18,7 @@ LL | fn main() { LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[(); _]` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0282, E0308, E0658. +Some errors have detailed explanations: E0282, E0308. For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/consts/const-eval/infinite_loop.rs b/src/test/ui/consts/const-eval/infinite_loop.rs index c8de259354e..14a573ccf5a 100644 --- a/src/test/ui/consts/const-eval/infinite_loop.rs +++ b/src/test/ui/consts/const-eval/infinite_loop.rs @@ -4,10 +4,8 @@ fn main() { let _ = [(); { let mut n = 113383; // #20 in https://oeis.org/A006884 while n != 0 { - //~^ ERROR `while` is not allowed in a `const` n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; //~^ ERROR evaluation of constant value failed - //~| 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 3386e6e588e..d01376e5959 100644 --- a/src/test/ui/consts/const-eval/infinite_loop.stderr +++ b/src/test/ui/consts/const-eval/infinite_loop.stderr @@ -1,34 +1,9 @@ -error[E0658]: `while` is not allowed in a `const` - --> $DIR/infinite_loop.rs:6:9 - | -LL | / while n != 0 { -LL | | -LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; -LL | | -LL | | -LL | | } - | |_________^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/infinite_loop.rs:8:17 - | -LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - error[E0080]: evaluation of constant value failed - --> $DIR/infinite_loop.rs:8:17 + --> $DIR/infinite_loop.rs:7:17 | LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0080, E0658. -For more information about an error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/issue-52442.rs b/src/test/ui/consts/const-eval/issue-52442.rs index 07fb491015a..ea24578c7dd 100644 --- a/src/test/ui/consts/const-eval/issue-52442.rs +++ b/src/test/ui/consts/const-eval/issue-52442.rs @@ -1,6 +1,5 @@ fn main() { [(); { &loop { break } as *const _ as usize } ]; - //~^ ERROR `loop` is not allowed in a `const` - //~| ERROR casting pointers to integers in constants is unstable + //~^ ERROR casting pointers to integers in constants is unstable //~| ERROR evaluation of constant value failed } diff --git a/src/test/ui/consts/const-eval/issue-52442.stderr b/src/test/ui/consts/const-eval/issue-52442.stderr index eda2dbf0b6b..53a87837e16 100644 --- a/src/test/ui/consts/const-eval/issue-52442.stderr +++ b/src/test/ui/consts/const-eval/issue-52442.stderr @@ -1,12 +1,3 @@ -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/issue-52442.rs:2:14 - | -LL | [(); { &loop { break } as *const _ as usize } ]; - | ^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - error[E0658]: casting pointers to integers in constants is unstable --> $DIR/issue-52442.rs:2:13 | @@ -22,7 +13,7 @@ error[E0080]: evaluation of constant value failed LL | [(); { &loop { break } as *const _ as usize } ]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0080, E0658. For more information about an error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/issue-52475.rs b/src/test/ui/consts/const-eval/issue-52475.rs index 869f0b981af..ce65407bbab 100644 --- a/src/test/ui/consts/const-eval/issue-52475.rs +++ b/src/test/ui/consts/const-eval/issue-52475.rs @@ -3,7 +3,6 @@ fn main() { let mut x = &0; let mut n = 0; while n < 5 { - //~^ ERROR `while` is not allowed in a `const` n = (n + 1) % 5; //~ ERROR evaluation of constant value failed x = &0; // Materialize a new AllocId } diff --git a/src/test/ui/consts/const-eval/issue-52475.stderr b/src/test/ui/consts/const-eval/issue-52475.stderr index b069537ead9..8536ff02c6d 100644 --- a/src/test/ui/consts/const-eval/issue-52475.stderr +++ b/src/test/ui/consts/const-eval/issue-52475.stderr @@ -1,24 +1,9 @@ -error[E0658]: `while` is not allowed in a `const` - --> $DIR/issue-52475.rs:5:9 - | -LL | / while n < 5 { -LL | | -LL | | n = (n + 1) % 5; -LL | | x = &0; // Materialize a new AllocId -LL | | } - | |_________^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - error[E0080]: evaluation of constant value failed - --> $DIR/issue-52475.rs:7:17 + --> $DIR/issue-52475.rs:6:17 | LL | n = (n + 1) % 5; | ^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0080, E0658. -For more information about an error, try `rustc --explain E0080`. +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/issue-62272.rs b/src/test/ui/consts/const-eval/issue-62272.rs deleted file mode 100644 index 19abd91252d..00000000000 --- a/src/test/ui/consts/const-eval/issue-62272.rs +++ /dev/null @@ -1,11 +0,0 @@ -// `loop`s unconditionally-broken-from used to be allowed in constants, but are now forbidden by -// the HIR const-checker. -// -// See https://github.com/rust-lang/rust/pull/66170 and -// https://github.com/rust-lang/rust/issues/62272. - -const FOO: () = loop { break; }; //~ ERROR `loop` is not allowed in a `const` - -fn main() { - [FOO; { let x; loop { x = 5; break; } x }]; //~ ERROR `loop` is not allowed in a `const` -} diff --git a/src/test/ui/consts/const-eval/issue-62272.stderr b/src/test/ui/consts/const-eval/issue-62272.stderr deleted file mode 100644 index 380f68bee09..00000000000 --- a/src/test/ui/consts/const-eval/issue-62272.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/issue-62272.rs:7:17 - | -LL | const FOO: () = loop { break; }; - | ^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/issue-62272.rs:10:20 - | -LL | [FOO; { let x; loop { x = 5; break; } x }]; - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const-eval/issue-70723.rs b/src/test/ui/consts/const-eval/issue-70723.rs index 8b79d5d53c5..3c81afa67a6 100644 --- a/src/test/ui/consts/const-eval/issue-70723.rs +++ b/src/test/ui/consts/const-eval/issue-70723.rs @@ -1,5 +1,3 @@ -#![feature(const_loop)] - static _X: () = loop {}; //~ ERROR could not evaluate static initializer fn main() {} diff --git a/src/test/ui/consts/const-eval/issue-70723.stderr b/src/test/ui/consts/const-eval/issue-70723.stderr index 687d6565a71..09fb3e060dc 100644 --- a/src/test/ui/consts/const-eval/issue-70723.stderr +++ b/src/test/ui/consts/const-eval/issue-70723.stderr @@ -1,5 +1,5 @@ error[E0080]: could not evaluate static initializer - --> $DIR/issue-70723.rs:3:17 + --> $DIR/issue-70723.rs:1:17 | LL | static _X: () = loop {}; | ^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) diff --git a/src/test/ui/consts/const-eval/livedrop.rs b/src/test/ui/consts/const-eval/livedrop.rs index f00d1c70659..66b7d058080 100644 --- a/src/test/ui/consts/const-eval/livedrop.rs +++ b/src/test/ui/consts/const-eval/livedrop.rs @@ -1,6 +1,3 @@ -#![feature(const_if_match)] -#![feature(const_loop)] - const _: Option<Vec<i32>> = { let mut never_returned = Some(Vec::new()); let mut always_returned = None; //~ ERROR destructors cannot be evaluated at compile-time diff --git a/src/test/ui/consts/const-eval/livedrop.stderr b/src/test/ui/consts/const-eval/livedrop.stderr index b802d23d9a8..1e8b4230c6f 100644 --- a/src/test/ui/consts/const-eval/livedrop.stderr +++ b/src/test/ui/consts/const-eval/livedrop.stderr @@ -1,5 +1,5 @@ error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/livedrop.rs:6:9 + --> $DIR/livedrop.rs:3:9 | LL | let mut always_returned = None; | ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors 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 80494d16629..f6b5ad005a8 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,7 +5,6 @@ fn main() { let _: [u8; 0] = [4; { match &1 as *const i32 as usize { //~^ ERROR casting pointers to integers in constants - //~| ERROR `match` is not allowed in a `const` //~| ERROR evaluation of constant value failed 0 => 42, n => n, 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 b47f6d5f845..48dbe661492 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,18 +1,3 @@ -error[E0658]: `match` is not allowed in a `const` - --> $DIR/match-test-ptr-null.rs:6:9 - | -LL | / match &1 as *const i32 as usize { -LL | | -LL | | -LL | | -LL | | 0 => 42, -LL | | n => n, -LL | | } - | |_________^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - error[E0658]: casting pointers to integers in constants is unstable --> $DIR/match-test-ptr-null.rs:6:15 | @@ -28,7 +13,7 @@ error[E0080]: evaluation of constant value failed LL | match &1 as *const i32 as usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0080, E0658. For more information about an error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-labeled-break.rs b/src/test/ui/consts/const-labeled-break.rs index 45e3cf43888..6864f7247ad 100644 --- a/src/test/ui/consts/const-labeled-break.rs +++ b/src/test/ui/consts/const-labeled-break.rs @@ -1,12 +1,11 @@ +// run-pass + // Using labeled break in a while loop has caused an illegal instruction being // generated, and an ICE later. // // See https://github.com/rust-lang/rust/issues/51350 for more information. -// -// It is now forbidden by the HIR const-checker. -// -// See https://github.com/rust-lang/rust/pull/66170. -const CRASH: () = 'a: while break 'a {}; //~ ERROR `while` is not allowed in a `const` +#[allow(unreachable_code)] +const _: () = 'a: while break 'a {}; fn main() {} diff --git a/src/test/ui/consts/const-labeled-break.stderr b/src/test/ui/consts/const-labeled-break.stderr deleted file mode 100644 index ac845df227c..00000000000 --- a/src/test/ui/consts/const-labeled-break.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: `while` is not allowed in a `const` - --> $DIR/const-labeled-break.rs:10:19 - | -LL | const CRASH: () = 'a: while break 'a {}; - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const-match-pattern-arm.rs b/src/test/ui/consts/const-match-pattern-arm.rs index 0482f7f7dae..90680c0194c 100644 --- a/src/test/ui/consts/const-match-pattern-arm.rs +++ b/src/test/ui/consts/const-match-pattern-arm.rs @@ -1,12 +1,12 @@ -#![allow(warnings)] +// check-pass -const x: bool = match Some(true) { //~ ERROR `match` is not allowed in a `const` +const _: bool = match Some(true) { Some(value) => true, _ => false }; -const y: bool = { - match Some(true) { //~ ERROR `match` is not allowed in a `const` +const _: bool = { + match Some(true) { Some(value) => true, _ => false } diff --git a/src/test/ui/consts/const-match-pattern-arm.stderr b/src/test/ui/consts/const-match-pattern-arm.stderr deleted file mode 100644 index 412e1609ccf..00000000000 --- a/src/test/ui/consts/const-match-pattern-arm.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0658]: `match` is not allowed in a `const` - --> $DIR/const-match-pattern-arm.rs:3:17 - | -LL | const x: bool = match Some(true) { - | _________________^ -LL | | Some(value) => true, -LL | | _ => false -LL | | }; - | |_^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const` - --> $DIR/const-match-pattern-arm.rs:9:5 - | -LL | / match Some(true) { -LL | | Some(value) => true, -LL | | _ => false -LL | | } - | |_____^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const_in_pattern/custom-eq-branch-pass.rs b/src/test/ui/consts/const_in_pattern/custom-eq-branch-pass.rs index 81a2024a81b..a38731ceb8a 100644 --- a/src/test/ui/consts/const_in_pattern/custom-eq-branch-pass.rs +++ b/src/test/ui/consts/const_in_pattern/custom-eq-branch-pass.rs @@ -1,6 +1,5 @@ // run-pass -#![feature(const_if_match)] #![warn(indirect_structural_match)] struct CustomEq; diff --git a/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.rs b/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.rs index 21c4de6fbb1..a1f9838ca08 100644 --- a/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.rs +++ b/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.rs @@ -1,6 +1,5 @@ // check-pass -#![feature(const_if_match)] #![warn(indirect_structural_match)] //~^ NOTE lint level is defined here diff --git a/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr b/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr index 06ec2a7fdd3..0be1cca806e 100644 --- a/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr +++ b/src/test/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr @@ -1,11 +1,11 @@ warning: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/custom-eq-branch-warn.rs:33:9 + --> $DIR/custom-eq-branch-warn.rs:32:9 | LL | BAR_BAZ => panic!(), | ^^^^^^^ | note: the lint level is defined here - --> $DIR/custom-eq-branch-warn.rs:4:9 + --> $DIR/custom-eq-branch-warn.rs:3:9 | LL | #![warn(indirect_structural_match)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs b/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs index 28b3fbb9525..c7f02c615a0 100644 --- a/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs +++ b/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs @@ -1,4 +1,3 @@ -#![feature(const_if_match)] #![warn(indirect_structural_match)] struct NoEq; diff --git a/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.stderr b/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.stderr index cb870ec7dbc..ee78c6f5c3e 100644 --- a/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.stderr +++ b/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.stderr @@ -1,11 +1,11 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/no-eq-branch-fail.rs:22:9 + --> $DIR/no-eq-branch-fail.rs:21:9 | LL | BAR_BAZ => panic!(), | ^^^^^^^ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/no-eq-branch-fail.rs:22:9 + --> $DIR/no-eq-branch-fail.rs:21:9 | LL | BAR_BAZ => panic!(), | ^^^^^^^ diff --git a/src/test/ui/consts/const_let_refutable.rs b/src/test/ui/consts/const_let_refutable.rs index e49d4767391..efb134d2eef 100644 --- a/src/test/ui/consts/const_let_refutable.rs +++ b/src/test/ui/consts/const_let_refutable.rs @@ -2,6 +2,5 @@ fn main() {} const fn slice(&[a, b]: &[i32]) -> i32 { //~^ ERROR refutable pattern in function argument - //~| ERROR loops and conditional expressions are not stable in const fn a + b } diff --git a/src/test/ui/consts/const_let_refutable.stderr b/src/test/ui/consts/const_let_refutable.stderr index 02296e6de75..d7e8c048f7d 100644 --- a/src/test/ui/consts/const_let_refutable.stderr +++ b/src/test/ui/consts/const_let_refutable.stderr @@ -6,16 +6,6 @@ LL | const fn slice(&[a, b]: &[i32]) -> i32 { | = note: the matched value is of type `&[i32]` -error[E0723]: loops and conditional expressions are not stable in const fn - --> $DIR/const_let_refutable.rs:3:17 - | -LL | const fn slice(&[a, b]: &[i32]) -> i32 { - | ^^^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0005, E0723. -For more information about an error, try `rustc --explain E0005`. +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/consts/const_limit/const_eval_limit_not_reached.rs b/src/test/ui/consts/const_limit/const_eval_limit_not_reached.rs index 34abcdf08da..629d1f02a30 100644 --- a/src/test/ui/consts/const_limit/const_eval_limit_not_reached.rs +++ b/src/test/ui/consts/const_limit/const_eval_limit_not_reached.rs @@ -1,7 +1,6 @@ // check-pass #![feature(const_eval_limit)] -#![feature(const_loop, const_if_match)] // This needs to be higher than the number of loop iterations since each pass through the loop may // hit more than one terminator. diff --git a/src/test/ui/consts/const_limit/const_eval_limit_reached.rs b/src/test/ui/consts/const_limit/const_eval_limit_reached.rs index b45aca0b13e..069dac00c9a 100644 --- a/src/test/ui/consts/const_limit/const_eval_limit_reached.rs +++ b/src/test/ui/consts/const_limit/const_eval_limit_reached.rs @@ -1,7 +1,5 @@ #![feature(const_eval_limit)] -#![feature(const_loop, const_if_match)] - -#![const_eval_limit="500"] +#![const_eval_limit = "500"] const X: usize = { let mut x = 0; diff --git a/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr b/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr index 8c2190b4e59..8785c9e54b9 100644 --- a/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr +++ b/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr @@ -1,5 +1,5 @@ error: any use of this value will cause an error - --> $DIR/const_eval_limit_reached.rs:8:5 + --> $DIR/const_eval_limit_reached.rs:6:5 | LL | / const X: usize = { LL | | let mut x = 0; diff --git a/src/test/ui/consts/const_short_circuit.rs b/src/test/ui/consts/const_short_circuit.rs index 87b14a11178..6403fbb17dd 100644 --- a/src/test/ui/consts/const_short_circuit.rs +++ b/src/test/ui/consts/const_short_circuit.rs @@ -1,13 +1,13 @@ +// check-pass + const _: bool = false && false; const _: bool = true && false; const _: bool = { let mut x = true && false; - //~^ ERROR new features like let bindings are not permitted x }; const _: bool = { let x = true && false; - //~^ ERROR new features like let bindings are not permitted x }; diff --git a/src/test/ui/consts/const_short_circuit.stderr b/src/test/ui/consts/const_short_circuit.stderr deleted file mode 100644 index b020382af07..00000000000 --- a/src/test/ui/consts/const_short_circuit.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: new features like let bindings are not permitted in constants which also use short circuiting operators - --> $DIR/const_short_circuit.rs:4:9 - | -LL | let mut x = true && false; - | ^^^^^ - | -note: use of `&&` operator here does not actually short circuit due to the const evaluator presently not being able to do control flow. See issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information. - --> $DIR/const_short_circuit.rs:4:22 - | -LL | let mut x = true && false; - | ^^ - -error: new features like let bindings are not permitted in constants which also use short circuiting operators - --> $DIR/const_short_circuit.rs:9:9 - | -LL | let x = true && false; - | ^ - | -note: use of `&&` operator here does not actually short circuit due to the const evaluator presently not being able to do control flow. See issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information. - --> $DIR/const_short_circuit.rs:9:18 - | -LL | let x = true && false; - | ^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/consts/control-flow/assert.both.stderr b/src/test/ui/consts/control-flow/assert.both.stderr deleted file mode 100644 index 7dd60cfb545..00000000000 --- a/src/test/ui/consts/control-flow/assert.both.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: any use of this value will cause an error - --> $DIR/assert.rs:12:15 - | -LL | const _: () = assert!(false); - | --------------^^^^^^^^^^^^^^- - | | - | the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:12:15 - | - = note: `#[deny(const_err)]` on by default - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error - diff --git a/src/test/ui/consts/control-flow/assert.if_match.stderr b/src/test/ui/consts/control-flow/assert.if_match.stderr deleted file mode 100644 index 466fb7c3ec5..00000000000 --- a/src/test/ui/consts/control-flow/assert.if_match.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: panicking in constants is unstable - --> $DIR/assert.rs:8:15 - | -LL | const _: () = assert!(true); - | ^^^^^^^^^^^^^ - | - = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information - = help: add `#![feature(const_panic)]` to the crate attributes to enable - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0658]: panicking in constants is unstable - --> $DIR/assert.rs:12:15 - | -LL | const _: () = assert!(false); - | ^^^^^^^^^^^^^^ - | - = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information - = help: add `#![feature(const_panic)]` to the crate attributes to enable - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/control-flow/assert.panic.stderr b/src/test/ui/consts/control-flow/assert.panic.stderr index eafbdd84cc8..03662a35209 100644 --- a/src/test/ui/consts/control-flow/assert.panic.stderr +++ b/src/test/ui/consts/control-flow/assert.panic.stderr @@ -1,23 +1,13 @@ -error[E0658]: `if` is not allowed in a `const` - --> $DIR/assert.rs:8:15 - | -LL | const _: () = assert!(true); - | ^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/assert.rs:12:15 +error: any use of this value will cause an error + --> $DIR/assert.rs:10:15 | LL | const _: () = assert!(false); - | ^^^^^^^^^^^^^^ + | --------------^^^^^^^^^^^^^^- + | | + | the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:10:15 | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable + = note: `#[deny(const_err)]` on by default = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/control-flow/assert.rs b/src/test/ui/consts/control-flow/assert.rs index 2da42d5084b..30cd31ee8a7 100644 --- a/src/test/ui/consts/control-flow/assert.rs +++ b/src/test/ui/consts/control-flow/assert.rs @@ -1,17 +1,14 @@ -// Test that `assert` works only when both `const_if_match` and `const_panic` are enabled. +// Test that `assert` works when `const_panic` is enabled. -// revisions: stock if_match panic both +// revisions: stock panic -#![cfg_attr(any(both, if_match), feature(const_if_match))] -#![cfg_attr(any(both, panic), feature(const_panic))] +#![cfg_attr(panic, feature(const_panic))] const _: () = assert!(true); -//[stock,panic]~^ ERROR `if` is not allowed in a `const` -//[if_match]~^^ ERROR panicking in constants is unstable +//[stock]~^ ERROR panicking in constants is unstable const _: () = assert!(false); -//[stock,panic]~^ ERROR `if` is not allowed in a `const` -//[if_match]~^^ ERROR panicking in constants is unstable -//[both]~^^^ ERROR any use of this value will cause an error +//[stock]~^ ERROR panicking in constants is unstable +//[panic]~^^ ERROR any use of this value will cause an error fn main() {} diff --git a/src/test/ui/consts/control-flow/assert.stock.stderr b/src/test/ui/consts/control-flow/assert.stock.stderr index eafbdd84cc8..fd344533ce1 100644 --- a/src/test/ui/consts/control-flow/assert.stock.stderr +++ b/src/test/ui/consts/control-flow/assert.stock.stderr @@ -1,21 +1,21 @@ -error[E0658]: `if` is not allowed in a `const` - --> $DIR/assert.rs:8:15 +error[E0658]: panicking in constants is unstable + --> $DIR/assert.rs:7:15 | LL | const _: () = assert!(true); | ^^^^^^^^^^^^^ | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable + = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information + = help: add `#![feature(const_panic)]` to the crate attributes to enable = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0658]: `if` is not allowed in a `const` - --> $DIR/assert.rs:12:15 +error[E0658]: panicking in constants is unstable + --> $DIR/assert.rs:10:15 | LL | const _: () = assert!(false); | ^^^^^^^^^^^^^^ | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable + = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information + = help: add `#![feature(const_panic)]` to the crate attributes to enable = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/control-flow/basics.rs b/src/test/ui/consts/control-flow/basics.rs index a53293743d5..6dd6192941d 100644 --- a/src/test/ui/consts/control-flow/basics.rs +++ b/src/test/ui/consts/control-flow/basics.rs @@ -3,8 +3,6 @@ // run-pass #![feature(const_panic)] -#![feature(const_if_match)] -#![feature(const_loop)] #![feature(const_fn)] const X: u32 = 4; diff --git a/src/test/ui/consts/control-flow/drop-fail.precise.stderr b/src/test/ui/consts/control-flow/drop-fail.precise.stderr index b4b6be8a1e5..0b0b2443a4a 100644 --- a/src/test/ui/consts/control-flow/drop-fail.precise.stderr +++ b/src/test/ui/consts/control-flow/drop-fail.precise.stderr @@ -1,11 +1,11 @@ error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:10:9 + --> $DIR/drop-fail.rs:8:9 | LL | let x = Some(Vec::new()); | ^ constants cannot evaluate destructors error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:41:9 + --> $DIR/drop-fail.rs:39:9 | LL | let mut tmp = None; | ^^^^^^^ constants cannot evaluate destructors diff --git a/src/test/ui/consts/control-flow/drop-fail.rs b/src/test/ui/consts/control-flow/drop-fail.rs index 7bd36726cea..efa5a11c941 100644 --- a/src/test/ui/consts/control-flow/drop-fail.rs +++ b/src/test/ui/consts/control-flow/drop-fail.rs @@ -1,7 +1,5 @@ // revisions: stock precise -#![feature(const_if_match)] -#![feature(const_loop)] #![cfg_attr(precise, feature(const_precise_live_drops))] // `x` is *not* always moved into the final value and may be dropped inside the initializer. diff --git a/src/test/ui/consts/control-flow/drop-fail.stock.stderr b/src/test/ui/consts/control-flow/drop-fail.stock.stderr index 6a9ea91d20e..72ca4fa08bc 100644 --- a/src/test/ui/consts/control-flow/drop-fail.stock.stderr +++ b/src/test/ui/consts/control-flow/drop-fail.stock.stderr @@ -1,5 +1,5 @@ error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:10:9 + --> $DIR/drop-fail.rs:8:9 | LL | let x = Some(Vec::new()); | ^ constants cannot evaluate destructors @@ -8,7 +8,7 @@ LL | }; | - value is dropped here error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:23:9 + --> $DIR/drop-fail.rs:21:9 | LL | let vec_tuple = (Vec::new(),); | ^^^^^^^^^ constants cannot evaluate destructors @@ -17,7 +17,7 @@ LL | }; | - value is dropped here error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:31:9 + --> $DIR/drop-fail.rs:29:9 | LL | let x: Result<_, Vec<i32>> = Ok(Vec::new()); | ^ constants cannot evaluate destructors @@ -26,7 +26,7 @@ LL | }; | - value is dropped here error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/drop-fail.rs:41:9 + --> $DIR/drop-fail.rs:39:9 | LL | let mut tmp = None; | ^^^^^^^ constants cannot evaluate destructors diff --git a/src/test/ui/consts/control-flow/drop-pass.rs b/src/test/ui/consts/control-flow/drop-pass.rs index b0afd76c4e6..95f954a59a8 100644 --- a/src/test/ui/consts/control-flow/drop-pass.rs +++ b/src/test/ui/consts/control-flow/drop-pass.rs @@ -1,8 +1,6 @@ // run-pass // revisions: stock precise -#![feature(const_if_match)] -#![feature(const_loop)] #![cfg_attr(precise, feature(const_precise_live_drops))] // `x` is always moved into the final value and is not dropped inside the initializer. diff --git a/src/test/ui/consts/control-flow/drop-precise.rs b/src/test/ui/consts/control-flow/drop-precise.rs index 95df76d9905..4ecc5ef78dd 100644 --- a/src/test/ui/consts/control-flow/drop-precise.rs +++ b/src/test/ui/consts/control-flow/drop-precise.rs @@ -1,8 +1,6 @@ // run-pass // gate-test-const_precise_live_drops -#![feature(const_if_match)] -#![feature(const_loop)] #![feature(const_precise_live_drops)] const _: Vec<i32> = { diff --git a/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs b/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs index 6bbbdd972a2..4320133dfdb 100644 --- a/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs +++ b/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs @@ -2,8 +2,6 @@ // check-pass -#![feature(const_if_match)] - enum E { A, B, diff --git a/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr b/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr deleted file mode 100644 index 21e3f2af15a..00000000000 --- a/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/feature-gate-const-if-match.rs:108:1 - | -LL | / fn main() { -LL | | let _ = [0; { -LL | | let x = if false { 0 } else { 1 }; -LL | | -... | -LL | | }]; -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs b/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs index c49dd830a12..cb66bc75309 100644 --- a/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs +++ b/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs @@ -1,25 +1,10 @@ -// Ensure that `if`, `if let` and `match` are only allowed in the various const contexts when -// `#![feature(const_if_match)]` is enabled. When the feature gate is removed, the `#[rustc_error]` -// on `main` should be removed and this test converted to `check-pass`. +// check-pass -// revisions: stock if_match +const _: i32 = if true { 5 } else { 6 }; -#![feature(rustc_attrs)] -#![cfg_attr(if_match, feature(const_if_match))] +const _: i32 = if let Some(true) = Some(false) { 0 } else { 1 }; -const _: i32 = if true { //[stock]~ ERROR `if` is not allowed in a `const` - 5 -} else { - 6 -}; - -const _: i32 = if let Some(true) = Some(false) { //[stock]~ ERROR `if` is not allowed in a `const` - 0 -} else { - 1 -}; - -const _: i32 = match 1 { //[stock]~ ERROR `match` is not allowed in a `const` +const _: i32 = match 1 { 2 => 3, 4 => 5, _ => 0, @@ -27,91 +12,85 @@ const _: i32 = match 1 { //[stock]~ ERROR `match` is not allowed in a `const` static FOO: i32 = { let x = if true { 0 } else { 1 }; - //[stock]~^ ERROR `if` is not allowed in a `static` - let x = match x { 0 => 1, _ => 0 }; - //[stock]~^ ERROR `match` is not allowed in a `static` + let x = match x { + 0 => 1, + _ => 0, + }; if let Some(x) = Some(x) { x } else { 1 } - //[stock]~^ ERROR `if` is not allowed in a `static` }; static mut BAR: i32 = { let x = if true { 0 } else { 1 }; - //[stock]~^ ERROR `if` is not allowed in a `static mut` - let x = match x { 0 => 1, _ => 0 }; - //[stock]~^ ERROR `match` is not allowed in a `static mut` + let x = match x { + 0 => 1, + _ => 0, + }; if let Some(x) = Some(x) { x } else { 1 } - //[stock]~^ ERROR `if` is not allowed in a `static mut` }; const fn if_() -> i32 { - if true { 5 } else { 6 } //[stock]~ ERROR `if` is not allowed in a `const fn` + if true { 5 } else { 6 } } const fn if_let(a: Option<bool>) -> i32 { - if let Some(true) = a { //[stock]~ ERROR `if` is not allowed in a `const fn` - 0 - } else { - 1 - } + if let Some(true) = a { 0 } else { 1 } } const fn match_(i: i32) -> i32 { - match i { //[stock]~ ERROR `match` is not allowed in a `const fn` + match i { i if i > 10 => i, 1 => 2, - _ => 0 + _ => 0, } } pub trait Foo { const IF: i32 = if true { 5 } else { 6 }; - //[stock]~^ ERROR `if` is not allowed in a `const` - const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; - //[stock]~^ ERROR `if` is not allowed in a `const` - - const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; - //[stock]~^ ERROR `match` is not allowed in a `const` + const MATCH: i32 = match 0 { + 1 => 2, + _ => 0, + }; } impl Foo for () { const IF: i32 = if true { 5 } else { 6 }; - //[stock]~^ ERROR `if` is not allowed in a `const` - const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; - //[stock]~^ ERROR `if` is not allowed in a `const` - - const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; - //[stock]~^ ERROR `match` is not allowed in a `const` + const MATCH: i32 = match 0 { + 1 => 2, + _ => 0, + }; } fn non_const_outside() { const fn const_inside(y: bool) -> i32 { let x = if y { 0 } else { 1 }; - //[stock]~^ ERROR `if` is not allowed in a `const fn` - let x = match x { 0 => 1, _ => 0 }; - //[stock]~^ ERROR `match` is not allowed in a `const fn` + let x = match x { + 0 => 1, + _ => 0, + }; if let Some(x) = Some(x) { x } else { 1 } - //[stock]~^ ERROR `if` is not allowed in a `const fn` } } const fn const_outside() { fn non_const_inside(y: bool) -> i32 { let x = if y { 0 } else { 1 }; - let x = match x { 0 => 1, _ => 0 }; + let x = match x { + 0 => 1, + _ => 0, + }; if let Some(x) = Some(x) { x } else { 1 } } } -#[rustc_error] -fn main() { //[if_match]~ ERROR fatal error triggered by #[rustc_error] +fn main() { let _ = [0; { let x = if false { 0 } else { 1 }; - //[stock]~^ ERROR `if` is not allowed in a `const` - let x = match x { 0 => 1, _ => 0 }; - //[stock]~^ ERROR `match` is not allowed in a `const` + let x = match x { + 0 => 1, + _ => 0, + }; if let Some(x) = Some(x) { x } else { 1 } - //[stock]~^ ERROR `if` is not allowed in a `const` }]; } diff --git a/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr b/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr deleted file mode 100644 index b27971dccac..00000000000 --- a/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr +++ /dev/null @@ -1,242 +0,0 @@ -error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:10:16 - | -LL | const _: i32 = if true { - | ________________^ -LL | | 5 -LL | | } else { -LL | | 6 -LL | | }; - | |_^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:16:16 - | -LL | const _: i32 = if let Some(true) = Some(false) { - | ________________^ -LL | | 0 -LL | | } else { -LL | | 1 -LL | | }; - | |_^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:22:16 - | -LL | const _: i32 = match 1 { - | ________________^ -LL | | 2 => 3, -LL | | 4 => 5, -LL | | _ => 0, -LL | | }; - | |_^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `static` - --> $DIR/feature-gate-const-if-match.rs:29:13 - | -LL | let x = if true { 0 } else { 1 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `static` - --> $DIR/feature-gate-const-if-match.rs:31:13 - | -LL | let x = match x { 0 => 1, _ => 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `static` - --> $DIR/feature-gate-const-if-match.rs:33:5 - | -LL | if let Some(x) = Some(x) { x } else { 1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `static mut` - --> $DIR/feature-gate-const-if-match.rs:38:13 - | -LL | let x = if true { 0 } else { 1 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `static mut` - --> $DIR/feature-gate-const-if-match.rs:40:13 - | -LL | let x = match x { 0 => 1, _ => 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `static mut` - --> $DIR/feature-gate-const-if-match.rs:42:5 - | -LL | if let Some(x) = Some(x) { x } else { 1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:47:5 - | -LL | if true { 5 } else { 6 } - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:51:5 - | -LL | / if let Some(true) = a { -LL | | 0 -LL | | } else { -LL | | 1 -LL | | } - | |_____^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:59:5 - | -LL | / match i { -LL | | i if i > 10 => i, -LL | | 1 => 2, -LL | | _ => 0 -LL | | } - | |_____^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:90:17 - | -LL | let x = if y { 0 } else { 1 }; - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:92:17 - | -LL | let x = match x { 0 => 1, _ => 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:94:9 - | -LL | if let Some(x) = Some(x) { x } else { 1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:110:17 - | -LL | let x = if false { 0 } else { 1 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:112:17 - | -LL | let x = match x { 0 => 1, _ => 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:114:9 - | -LL | if let Some(x) = Some(x) { x } else { 1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:67:21 - | -LL | const IF: i32 = if true { 5 } else { 6 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:70:25 - | -LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:73:24 - | -LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:78:21 - | -LL | const IF: i32 = if true { 5 } else { 6 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:81:25 - | -LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:84:24 - | -LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error: aborting due to 24 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/control-flow/interior-mutability.rs b/src/test/ui/consts/control-flow/interior-mutability.rs index c2439f4a7bf..a6d44237b0d 100644 --- a/src/test/ui/consts/control-flow/interior-mutability.rs +++ b/src/test/ui/consts/control-flow/interior-mutability.rs @@ -1,9 +1,6 @@ // Ensure that *any* assignment to the return place of a value with interior mutability // disqualifies it from promotion. -#![feature(const_if_match)] -#![feature(const_loop)] - use std::cell::Cell; const X: Option<Cell<i32>> = { @@ -39,7 +36,6 @@ const Z: Option<Cell<i32>> = { z }; - fn main() { let x: &'static _ = &X; //~ ERROR temporary value dropped while borrowed let y: &'static _ = &Y; //~ ERROR temporary value dropped while borrowed diff --git a/src/test/ui/consts/control-flow/interior-mutability.stderr b/src/test/ui/consts/control-flow/interior-mutability.stderr index 0977c84d12d..4f9c7d34c35 100644 --- a/src/test/ui/consts/control-flow/interior-mutability.stderr +++ b/src/test/ui/consts/control-flow/interior-mutability.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/interior-mutability.rs:44:26 + --> $DIR/interior-mutability.rs:40:26 | LL | let x: &'static _ = &X; | ---------- ^ creates a temporary which is freed while still in use @@ -10,7 +10,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/interior-mutability.rs:45:26 + --> $DIR/interior-mutability.rs:41:26 | LL | let y: &'static _ = &Y; | ---------- ^ creates a temporary which is freed while still in use @@ -21,7 +21,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/interior-mutability.rs:46:26 + --> $DIR/interior-mutability.rs:42:26 | LL | let z: &'static _ = &Z; | ---------- ^ creates a temporary which is freed while still in use diff --git a/src/test/ui/consts/control-flow/issue-46843.rs b/src/test/ui/consts/control-flow/issue-46843.rs index 1fc91015ffa..edf62f23266 100644 --- a/src/test/ui/consts/control-flow/issue-46843.rs +++ b/src/test/ui/consts/control-flow/issue-46843.rs @@ -1,16 +1,14 @@ -// revisions: stock if_match - -#![cfg_attr(if_match, feature(const_if_match))] - -enum Thing { This, That } +enum Thing { + This, + That, +} fn non_const() -> Thing { Thing::This } pub const Q: i32 = match non_const() { - //[stock]~^ ERROR `match` is not allowed in a `const` - //[if_match]~^^ ERROR calls in constants are limited to constant functions + //~^ ERROR calls in constants are limited to constant functions Thing::This => 1, Thing::That => 0 }; diff --git a/src/test/ui/consts/control-flow/issue-46843.if_match.stderr b/src/test/ui/consts/control-flow/issue-46843.stderr index 4c64d7dee8c..ea9ea25f9e1 100644 --- a/src/test/ui/consts/control-flow/issue-46843.if_match.stderr +++ b/src/test/ui/consts/control-flow/issue-46843.stderr @@ -1,5 +1,5 @@ error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-46843.rs:11:26 + --> $DIR/issue-46843.rs:10:26 | LL | pub const Q: i32 = match non_const() { | ^^^^^^^^^^^ diff --git a/src/test/ui/consts/control-flow/issue-46843.stock.stderr b/src/test/ui/consts/control-flow/issue-46843.stock.stderr deleted file mode 100644 index e4650da2075..00000000000 --- a/src/test/ui/consts/control-flow/issue-46843.stock.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0658]: `match` is not allowed in a `const` - --> $DIR/issue-46843.rs:11:20 - | -LL | pub const Q: i32 = match non_const() { - | ____________________^ -LL | | -LL | | -LL | | Thing::This => 1, -LL | | Thing::That => 0 -LL | | }; - | |_^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/control-flow/issue-50577.rs b/src/test/ui/consts/control-flow/issue-50577.rs index 9600f8b6aee..beb9a44fca5 100644 --- a/src/test/ui/consts/control-flow/issue-50577.rs +++ b/src/test/ui/consts/control-flow/issue-50577.rs @@ -1,13 +1,6 @@ -// revisions: stock if_match - -#![cfg_attr(if_match, feature(const_if_match))] - fn main() { enum Foo { - Drop = assert_eq!(1, 1) - //[stock,if_match]~^ ERROR `if` may be missing an `else` clause - //[stock]~^^ ERROR `match` is not allowed in a `const` - //[stock]~| ERROR `match` is not allowed in a `const` - //[stock]~| ERROR `if` is not allowed in a `const` + Drop = assert_eq!(1, 1), + //~^ ERROR `if` may be missing an `else` clause } } diff --git a/src/test/ui/consts/control-flow/issue-50577.if_match.stderr b/src/test/ui/consts/control-flow/issue-50577.stderr index 831360d5652..b7b4c3a30d1 100644 --- a/src/test/ui/consts/control-flow/issue-50577.if_match.stderr +++ b/src/test/ui/consts/control-flow/issue-50577.stderr @@ -1,7 +1,7 @@ error[E0317]: `if` may be missing an `else` clause - --> $DIR/issue-50577.rs:7:16 + --> $DIR/issue-50577.rs:3:16 | -LL | Drop = assert_eq!(1, 1) +LL | Drop = assert_eq!(1, 1), | ^^^^^^^^^^^^^^^^ | | | expected `()`, found `isize` diff --git a/src/test/ui/consts/control-flow/issue-50577.stock.stderr b/src/test/ui/consts/control-flow/issue-50577.stock.stderr deleted file mode 100644 index 9d0d2831d9a..00000000000 --- a/src/test/ui/consts/control-flow/issue-50577.stock.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0658]: `match` is not allowed in a `const` - --> $DIR/issue-50577.rs:7:16 - | -LL | Drop = assert_eq!(1, 1) - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/issue-50577.rs:7:16 - | -LL | Drop = assert_eq!(1, 1) - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0658]: `match` is not allowed in a `const` - --> $DIR/issue-50577.rs:7:16 - | -LL | Drop = assert_eq!(1, 1) - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0317]: `if` may be missing an `else` clause - --> $DIR/issue-50577.rs:7:16 - | -LL | Drop = assert_eq!(1, 1) - | ^^^^^^^^^^^^^^^^ - | | - | expected `()`, found `isize` - | found here - | - = note: `if` expressions without `else` evaluate to `()` - = help: consider adding an `else` block that evaluates to the expected type - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0317, E0658. -For more information about an error, try `rustc --explain E0317`. diff --git a/src/test/ui/consts/control-flow/loop.if_match.stderr b/src/test/ui/consts/control-flow/loop.if_match.stderr deleted file mode 100644 index e8ff3624b77..00000000000 --- a/src/test/ui/consts/control-flow/loop.if_match.stderr +++ /dev/null @@ -1,151 +0,0 @@ -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/loop.rs:10:15 - | -LL | const _: () = loop {}; - | ^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `static` - --> $DIR/loop.rs:12:19 - | -LL | static FOO: i32 = loop { break 4; }; - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const fn` - --> $DIR/loop.rs:15:5 - | -LL | loop {} - | ^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const fn` - --> $DIR/loop.rs:28:9 - | -LL | loop {} - | ^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:40:9 - | -LL | while false {} - | ^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:49:5 - | -LL | / while x < 4 { -LL | | x += 1; -LL | | } - | |_____^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:53:5 - | -LL | / while x < 8 { -LL | | x += 1; -LL | | } - | |_____^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0744]: `for` is not allowed in a `const` - --> $DIR/loop.rs:63:5 - | -LL | / for i in 0..4 { -LL | | x += i; -LL | | } - | |_____^ - -error[E0744]: `for` is not allowed in a `const` - --> $DIR/loop.rs:67:5 - | -LL | / for i in 0..4 { -LL | | x += i; -LL | | } - | |_____^ - -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/loop.rs:77:5 - | -LL | / loop { -LL | | x += 1; -LL | | if x == 4 { -LL | | break; -LL | | } -LL | | } - | |_____^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/loop.rs:84:5 - | -LL | / loop { -LL | | x += 1; -LL | | if x == 8 { -LL | | break; -LL | | } -LL | | } - | |_____^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:96:5 - | -LL | while let None = Some(x) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:97:5 - | -LL | while let None = Some(x) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/loop.rs:19:22 - | -LL | const BAR: i32 = loop { break 4; }; - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/loop.rs:23:22 - | -LL | const BAR: i32 = loop { break 4; }; - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error: aborting due to 15 previous errors - -Some errors have detailed explanations: E0658, E0744. -For more information about an error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/control-flow/loop.loop_.stderr b/src/test/ui/consts/control-flow/loop.loop_.stderr deleted file mode 100644 index 3d739f4d2b4..00000000000 --- a/src/test/ui/consts/control-flow/loop.loop_.stderr +++ /dev/null @@ -1,96 +0,0 @@ -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:40:9 - | -LL | while false {} - | ^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - = note: `#![feature(const_loop)]` alone is not sufficient, since this loop expression contains an implicit conditional - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:49:5 - | -LL | / while x < 4 { -LL | | x += 1; -LL | | } - | |_____^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - = note: `#![feature(const_loop)]` alone is not sufficient, since this loop expression contains an implicit conditional - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:53:5 - | -LL | / while x < 8 { -LL | | x += 1; -LL | | } - | |_____^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - = note: `#![feature(const_loop)]` alone is not sufficient, since this loop expression contains an implicit conditional - -error[E0744]: `for` is not allowed in a `const` - --> $DIR/loop.rs:63:5 - | -LL | / for i in 0..4 { -LL | | x += i; -LL | | } - | |_____^ - -error[E0744]: `for` is not allowed in a `const` - --> $DIR/loop.rs:67:5 - | -LL | / for i in 0..4 { -LL | | x += i; -LL | | } - | |_____^ - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/loop.rs:79:9 - | -LL | / if x == 4 { -LL | | break; -LL | | } - | |_________^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/loop.rs:86:9 - | -LL | / if x == 8 { -LL | | break; -LL | | } - | |_________^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:96:5 - | -LL | while let None = Some(x) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - = note: `#![feature(const_loop)]` alone is not sufficient, since this loop expression contains an implicit conditional - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:97:5 - | -LL | while let None = Some(x) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - = note: `#![feature(const_loop)]` alone is not sufficient, since this loop expression contains an implicit conditional - -error: aborting due to 9 previous errors - -Some errors have detailed explanations: E0658, E0744. -For more information about an error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/control-flow/loop.rs b/src/test/ui/consts/control-flow/loop.rs index bc57f7568a7..2b8561a2644 100644 --- a/src/test/ui/consts/control-flow/loop.rs +++ b/src/test/ui/consts/control-flow/loop.rs @@ -1,31 +1,22 @@ -// Ensure that loops are forbidden in a const context unless `#![feature(const_loop)]` is enabled. -// `while` loops require `#![feature(const_if_match)]` to be enabled as well. +const _: () = loop { break (); }; -// gate-test-const_loop -// revisions: stock if_match loop_ both - -#![cfg_attr(any(both, if_match), feature(const_if_match))] -#![cfg_attr(any(both, loop_), feature(const_loop))] - -const _: () = loop {}; //[stock,if_match]~ ERROR `loop` is not allowed in a `const` - -static FOO: i32 = loop { break 4; }; //[stock,if_match]~ ERROR `loop` is not allowed in a `static` +static FOO: i32 = loop { break 4; }; const fn foo() { - loop {} //[stock,if_match]~ ERROR `loop` is not allowed in a `const fn` + loop {} } pub trait Foo { - const BAR: i32 = loop { break 4; }; //[stock,if_match]~ ERROR `loop` is not allowed in a `const` + const BAR: i32 = loop { break 4; }; } impl Foo for () { - const BAR: i32 = loop { break 4; }; //[stock,if_match]~ ERROR `loop` is not allowed in a `const` + const BAR: i32 = loop { break 4; }; } fn non_const_outside() { const fn const_inside() { - loop {} //[stock,if_match]~ ERROR `loop` is not allowed in a `const fn` + loop {} } } @@ -38,7 +29,6 @@ const fn const_outside() { fn main() { let x = [0; { while false {} - //[stock,if_match,loop_]~^ ERROR `while` is not allowed in a `const` 4 }]; } @@ -46,11 +36,11 @@ fn main() { const _: i32 = { let mut x = 0; - while x < 4 { //[stock,if_match,loop_]~ ERROR `while` is not allowed in a `const` + while x < 4 { x += 1; } - while x < 8 { //[stock,if_match,loop_]~ ERROR `while` is not allowed in a `const` + while x < 8 { x += 1; } @@ -60,11 +50,11 @@ const _: i32 = { const _: i32 = { let mut x = 0; - for i in 0..4 { //[stock,if_match,loop_,both]~ ERROR `for` is not allowed in a `const` + for i in 0..4 { //~ ERROR `for` is not allowed in a `const` x += i; } - for i in 0..4 { //[stock,if_match,loop_,both]~ ERROR `for` is not allowed in a `const` + for i in 0..4 { //~ ERROR `for` is not allowed in a `const` x += i; } @@ -74,16 +64,16 @@ const _: i32 = { const _: i32 = { let mut x = 0; - loop { //[stock,if_match]~ ERROR `loop` is not allowed in a `const` + loop { x += 1; - if x == 4 { //[stock,loop_]~ ERROR `if` is not allowed in a `const` + if x == 4 { break; } } - loop { //[stock,if_match]~ ERROR `loop` is not allowed in a `const` + loop { x += 1; - if x == 8 { //[stock,loop_]~ ERROR `if` is not allowed in a `const` + if x == 8 { break; } } @@ -93,7 +83,7 @@ const _: i32 = { const _: i32 = { let mut x = 0; - while let None = Some(x) { } //[stock,if_match,loop_]~ ERROR `while` is not allowed in a `const` - while let None = Some(x) { } //[stock,if_match,loop_]~ ERROR `while` is not allowed in a `const` + while let None = Some(x) { } + while let None = Some(x) { } x }; diff --git a/src/test/ui/consts/control-flow/loop.both.stderr b/src/test/ui/consts/control-flow/loop.stderr index 71d96b216f9..7b99fa4fe46 100644 --- a/src/test/ui/consts/control-flow/loop.both.stderr +++ b/src/test/ui/consts/control-flow/loop.stderr @@ -1,5 +1,5 @@ error[E0744]: `for` is not allowed in a `const` - --> $DIR/loop.rs:63:5 + --> $DIR/loop.rs:53:5 | LL | / for i in 0..4 { LL | | x += i; @@ -7,7 +7,7 @@ LL | | } | |_____^ error[E0744]: `for` is not allowed in a `const` - --> $DIR/loop.rs:67:5 + --> $DIR/loop.rs:57:5 | LL | / for i in 0..4 { LL | | x += i; diff --git a/src/test/ui/consts/control-flow/loop.stock.stderr b/src/test/ui/consts/control-flow/loop.stock.stderr deleted file mode 100644 index 987ced96551..00000000000 --- a/src/test/ui/consts/control-flow/loop.stock.stderr +++ /dev/null @@ -1,178 +0,0 @@ -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/loop.rs:10:15 - | -LL | const _: () = loop {}; - | ^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `static` - --> $DIR/loop.rs:12:19 - | -LL | static FOO: i32 = loop { break 4; }; - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const fn` - --> $DIR/loop.rs:15:5 - | -LL | loop {} - | ^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const fn` - --> $DIR/loop.rs:28:9 - | -LL | loop {} - | ^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:40:9 - | -LL | while false {} - | ^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:49:5 - | -LL | / while x < 4 { -LL | | x += 1; -LL | | } - | |_____^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:53:5 - | -LL | / while x < 8 { -LL | | x += 1; -LL | | } - | |_____^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0744]: `for` is not allowed in a `const` - --> $DIR/loop.rs:63:5 - | -LL | / for i in 0..4 { -LL | | x += i; -LL | | } - | |_____^ - -error[E0744]: `for` is not allowed in a `const` - --> $DIR/loop.rs:67:5 - | -LL | / for i in 0..4 { -LL | | x += i; -LL | | } - | |_____^ - -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/loop.rs:77:5 - | -LL | / loop { -LL | | x += 1; -LL | | if x == 4 { -LL | | break; -LL | | } -LL | | } - | |_____^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/loop.rs:79:9 - | -LL | / if x == 4 { -LL | | break; -LL | | } - | |_________^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/loop.rs:84:5 - | -LL | / loop { -LL | | x += 1; -LL | | if x == 8 { -LL | | break; -LL | | } -LL | | } - | |_____^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `if` is not allowed in a `const` - --> $DIR/loop.rs:86:9 - | -LL | / if x == 8 { -LL | | break; -LL | | } - | |_________^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:96:5 - | -LL | while let None = Some(x) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `while` is not allowed in a `const` - --> $DIR/loop.rs:97:5 - | -LL | while let None = Some(x) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/loop.rs:19:22 - | -LL | const BAR: i32 = loop { break 4; }; - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error[E0658]: `loop` is not allowed in a `const` - --> $DIR/loop.rs:23:22 - | -LL | const BAR: i32 = loop { break 4; }; - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error: aborting due to 17 previous errors - -Some errors have detailed explanations: E0658, E0744. -For more information about an error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/control-flow/short-circuit-let.rs b/src/test/ui/consts/control-flow/short-circuit-let.rs index 8cee2a54f56..4dfa22b8eba 100644 --- a/src/test/ui/consts/control-flow/short-circuit-let.rs +++ b/src/test/ui/consts/control-flow/short-circuit-let.rs @@ -2,7 +2,6 @@ // run-pass -#![feature(const_if_match)] #![feature(const_panic)] const X: i32 = { diff --git a/src/test/ui/consts/control-flow/short-circuit.if_match.stderr b/src/test/ui/consts/control-flow/short-circuit.if_match.stderr deleted file mode 100644 index f6ba28e7b72..00000000000 --- a/src/test/ui/consts/control-flow/short-circuit.if_match.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/short-circuit.rs:14:1 - | -LL | fn main() {} - | ^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/consts/control-flow/short-circuit.rs b/src/test/ui/consts/control-flow/short-circuit.rs index f5e54a69d4a..f6a0f03a4a6 100644 --- a/src/test/ui/consts/control-flow/short-circuit.rs +++ b/src/test/ui/consts/control-flow/short-circuit.rs @@ -1,14 +1,14 @@ -// Test that both `&&` and `||` actually short-circuit when the `const_if_match` feature flag is -// enabled. Without the feature flag, both sides are evaluated unconditionally. +// run-pass -// revisions: stock if_match +// Test that both `&&` and `||` actually short-circuit. +// Formerly, both sides were evaluated unconditionally -#![feature(rustc_attrs)] #![feature(const_panic)] -#![cfg_attr(if_match, feature(const_if_match))] -const _: bool = true || panic!(); //[stock]~ ERROR any use of this value will cause an error -const _: bool = false && panic!(); //[stock]~ ERROR any use of this value will cause an error +const TRUE: bool = true || panic!(); +const FALSE: bool = false && panic!(); -#[rustc_error] -fn main() {} //[if_match]~ ERROR fatal error triggered by #[rustc_error] +fn main() { + assert!(TRUE); + assert!(!FALSE); +} diff --git a/src/test/ui/consts/control-flow/short-circuit.stock.stderr b/src/test/ui/consts/control-flow/short-circuit.stock.stderr deleted file mode 100644 index f32f248af45..00000000000 --- a/src/test/ui/consts/control-flow/short-circuit.stock.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error: any use of this value will cause an error - --> $DIR/short-circuit.rs:10:25 - | -LL | const _: bool = true || panic!(); - | ------------------------^^^^^^^^- - | | - | the evaluated program panicked at 'explicit panic', $DIR/short-circuit.rs:10:25 - | - = note: `#[deny(const_err)]` on by default - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: any use of this value will cause an error - --> $DIR/short-circuit.rs:11:26 - | -LL | const _: bool = false && panic!(); - | -------------------------^^^^^^^^- - | | - | the evaluated program panicked at 'explicit panic', $DIR/short-circuit.rs:11:26 - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/consts/control-flow/single_variant_match_ice.rs b/src/test/ui/consts/control-flow/single_variant_match_ice.rs index 823605ff034..b59be00ffb7 100644 --- a/src/test/ui/consts/control-flow/single_variant_match_ice.rs +++ b/src/test/ui/consts/control-flow/single_variant_match_ice.rs @@ -1,7 +1,5 @@ // check-pass -#![feature(const_if_match)] - enum Foo { Prob, } diff --git a/src/test/ui/consts/control-flow/try.rs b/src/test/ui/consts/control-flow/try.rs index 31fe09d4f69..7d85a412b47 100644 --- a/src/test/ui/consts/control-flow/try.rs +++ b/src/test/ui/consts/control-flow/try.rs @@ -1,8 +1,6 @@ // The `?` operator is still not const-evaluatable because it calls `From::from` on the error // variant. -#![feature(const_if_match)] - const fn opt() -> Option<i32> { let x = Some(2); x?; //~ ERROR `?` is not allowed in a `const fn` diff --git a/src/test/ui/consts/control-flow/try.stderr b/src/test/ui/consts/control-flow/try.stderr index 60a386ef6c8..35075a3e60b 100644 --- a/src/test/ui/consts/control-flow/try.stderr +++ b/src/test/ui/consts/control-flow/try.stderr @@ -1,5 +1,5 @@ error[E0744]: `?` is not allowed in a `const fn` - --> $DIR/try.rs:8:5 + --> $DIR/try.rs:6:5 | LL | x?; | ^^ diff --git a/src/test/ui/consts/min_const_fn/loop_ice.rs b/src/test/ui/consts/min_const_fn/loop_ice.rs deleted file mode 100644 index 754a1d7c2a3..00000000000 --- a/src/test/ui/consts/min_const_fn/loop_ice.rs +++ /dev/null @@ -1,5 +0,0 @@ -const fn foo() { - 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 deleted file mode 100644 index f48b7396e77..00000000000 --- a/src/test/ui/consts/min_const_fn/loop_ice.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: `loop` is not allowed in a `const fn` - --> $DIR/loop_ice.rs:2:5 - | -LL | loop {} - | ^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.rs b/src/test/ui/consts/min_const_fn/min_const_fn.rs index 557439f3949..2ebd9dd10c5 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn.rs @@ -98,13 +98,13 @@ const fn foo30_2(x: *mut u32) -> usize { x as usize } const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } } //~^ ERROR casting pointers to ints is unstable const fn foo30_6() -> bool { let x = true; x } -const fn foo36(a: bool, b: bool) -> bool { a && b } -//~^ ERROR loops and conditional expressions are not stable in const fn -const fn foo37(a: bool, b: bool) -> bool { a || b } -//~^ ERROR loops and conditional expressions are not stable in const fn const fn inc(x: &mut i32) { *x += 1 } //~^ ERROR mutable references in const fn are unstable +// ok +const fn foo36(a: bool, b: bool) -> bool { a && b } +const fn foo37(a: bool, b: bool) -> bool { a || b } + fn main() {} impl<T: std::fmt::Debug> Foo<T> { 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 4b0401ebf9d..9b55b6c6f3b 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 @@ -166,26 +166,8 @@ LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = help: add `#![feature(const_fn)]` to the crate attributes to enable -error[E0723]: loops and conditional expressions are not stable in const fn - --> $DIR/min_const_fn.rs:101:44 - | -LL | const fn foo36(a: bool, b: bool) -> bool { a && b } - | ^^^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn)]` to the crate attributes to enable - -error[E0723]: loops and conditional expressions are not stable in const fn - --> $DIR/min_const_fn.rs:103:44 - | -LL | const fn foo37(a: bool, b: bool) -> bool { a || b } - | ^^^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn)]` to the crate attributes to enable - error[E0723]: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:105:14 + --> $DIR/min_const_fn.rs:101:14 | LL | const fn inc(x: &mut i32) { *x += 1 } | ^ @@ -283,7 +265,7 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = help: add `#![feature(const_fn)]` to the crate attributes to enable -error: aborting due to 32 previous errors +error: aborting due to 30 previous errors Some errors have detailed explanations: E0493, E0723. For more information about an error, try `rustc --explain E0493`. diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index 52f6536b5ea..08d68b039be 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -2,8 +2,7 @@ // aux-build:static_cross_crate.rs #![allow(const_err)] -// `const_if_match` is a HIR check and thus needed even when unleashed. -#![feature(exclusive_range_pattern, half_open_range_patterns, const_if_match)] +#![feature(exclusive_range_pattern, half_open_range_patterns)] extern crate static_cross_crate; diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr index 9d1e88a811f..52662ef9eaf 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:12:1 + --> $DIR/const_refers_to_static_cross_crate.rs:11:1 | LL | / const SLICE_MUT: &[u8; 1] = { LL | | @@ -11,13 +11,13 @@ LL | | }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:40:9 + --> $DIR/const_refers_to_static_cross_crate.rs:39:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:18:1 + --> $DIR/const_refers_to_static_cross_crate.rs:17:1 | LL | / const U8_MUT: &u8 = { LL | | @@ -29,13 +29,13 @@ LL | | }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:49:9 + --> $DIR/const_refers_to_static_cross_crate.rs:48:9 | LL | U8_MUT => true, | ^^^^^^ warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:27:14 + --> $DIR/const_refers_to_static_cross_crate.rs:26:14 | LL | / const U8_MUT2: &u8 = { LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] } @@ -46,19 +46,19 @@ LL | | }; | |__- | note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:25:8 + --> $DIR/const_refers_to_static_cross_crate.rs:24:8 | LL | #[warn(const_err)] | ^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + --> $DIR/const_refers_to_static_cross_crate.rs:59:9 | LL | U8_MUT2 => true, | ^^^^^^^ warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:33:51 + --> $DIR/const_refers_to_static_cross_crate.rs:32:51 | LL | / const U8_MUT3: &u8 = { LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } @@ -69,37 +69,37 @@ LL | | }; | |__- | note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:31:8 + --> $DIR/const_refers_to_static_cross_crate.rs:30:8 | LL | #[warn(const_err)] | ^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:68:9 + --> $DIR/const_refers_to_static_cross_crate.rs:67:9 | LL | U8_MUT3 => true, | ^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:40:9 + --> $DIR/const_refers_to_static_cross_crate.rs:39:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:49:9 + --> $DIR/const_refers_to_static_cross_crate.rs:48:9 | LL | U8_MUT => true, | ^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + --> $DIR/const_refers_to_static_cross_crate.rs:59:9 | LL | U8_MUT2 => true, | ^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:68:9 + --> $DIR/const_refers_to_static_cross_crate.rs:67:9 | LL | U8_MUT3 => true, | ^^^^^^^ @@ -107,57 +107,52 @@ LL | U8_MUT3 => true, warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:15:15 + --> $DIR/const_refers_to_static_cross_crate.rs:14:15 | LL | unsafe { &static_cross_crate::ZERO } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:15:15 + --> $DIR/const_refers_to_static_cross_crate.rs:14:15 | LL | unsafe { &static_cross_crate::ZERO } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:21:15 + --> $DIR/const_refers_to_static_cross_crate.rs:20:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:21:15 + --> $DIR/const_refers_to_static_cross_crate.rs:20:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:21:15 + --> $DIR/const_refers_to_static_cross_crate.rs:20:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:27:17 + --> $DIR/const_refers_to_static_cross_crate.rs:26:17 | LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:33:20 + --> $DIR/const_refers_to_static_cross_crate.rs:32:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:33:20 - | -LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:33:20 + --> $DIR/const_refers_to_static_cross_crate.rs:32:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check for `const_panic` feature - --> $DIR/const_refers_to_static_cross_crate.rs:33:77 + --> $DIR/const_refers_to_static_cross_crate.rs:32:77 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:33:20 + --> $DIR/const_refers_to_static_cross_crate.rs:32:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/unstable-const-fn-in-libcore.rs b/src/test/ui/consts/unstable-const-fn-in-libcore.rs index 0b64786ccce..29d3dc18fa7 100644 --- a/src/test/ui/consts/unstable-const-fn-in-libcore.rs +++ b/src/test/ui/consts/unstable-const-fn-in-libcore.rs @@ -4,7 +4,6 @@ // gate was not enabled in libcore. #![stable(feature = "core", since = "1.6.0")] -#![feature(const_if_match)] #![feature(rustc_const_unstable)] #![feature(staged_api)] diff --git a/src/test/ui/consts/unstable-const-fn-in-libcore.stderr b/src/test/ui/consts/unstable-const-fn-in-libcore.stderr index 928605356a1..be797cae7ca 100644 --- a/src/test/ui/consts/unstable-const-fn-in-libcore.stderr +++ b/src/test/ui/consts/unstable-const-fn-in-libcore.stderr @@ -1,11 +1,11 @@ error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants - --> $DIR/unstable-const-fn-in-libcore.rs:24:26 + --> $DIR/unstable-const-fn-in-libcore.rs:23:26 | LL | Opt::None => f(), | ^^^ error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/unstable-const-fn-in-libcore.rs:19:53 + --> $DIR/unstable-const-fn-in-libcore.rs:18:53 | LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T { | ^ constant functions cannot evaluate destructors @@ -14,7 +14,7 @@ LL | } | - value is dropped here error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/unstable-const-fn-in-libcore.rs:19:47 + --> $DIR/unstable-const-fn-in-libcore.rs:18:47 | LL | const fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T { | ^^^^ constant functions cannot evaluate destructors diff --git a/src/test/ui/enum-discriminant/niche.rs b/src/test/ui/enum-discriminant/niche.rs index 8d2cdf34f37..b3694bb4216 100644 --- a/src/test/ui/enum-discriminant/niche.rs +++ b/src/test/ui/enum-discriminant/niche.rs @@ -1,7 +1,6 @@ // run-pass #![feature(const_panic)] -#![feature(const_if_match)] //! Make sure that we read and write enum discriminants correctly for corner cases caused //! by layout optimizations. diff --git a/src/test/ui/internal/internal-unstable-const.rs b/src/test/ui/internal/internal-unstable-const.rs index ce306c84517..3b3a2950942 100644 --- a/src/test/ui/internal/internal-unstable-const.rs +++ b/src/test/ui/internal/internal-unstable-const.rs @@ -1,10 +1,14 @@ +// Don't allow unstable features in stable functions without `allow_internal_unstable`. + +#![stable(feature = "rust1", since = "1.0.0")] + #![feature(staged_api)] -#![feature(const_if_match)] +#![feature(const_transmute, const_fn)] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "rust1", since = "1.0.0")] -const fn foo() -> i32 { - if true { 4 } else { 5 } //~ loops and conditional expressions are not stable in const fn +pub const fn foo() -> i32 { + unsafe { std::mem::transmute(4u32) } //~ ERROR is not stable as `const fn` } fn main() {} diff --git a/src/test/ui/internal/internal-unstable-const.stderr b/src/test/ui/internal/internal-unstable-const.stderr index b2d97b981ba..5a2c58f3928 100644 --- a/src/test/ui/internal/internal-unstable-const.stderr +++ b/src/test/ui/internal/internal-unstable-const.stderr @@ -1,8 +1,8 @@ -error[E0723]: loops and conditional expressions are not stable in const fn - --> $DIR/internal-unstable-const.rs:7:5 +error[E0723]: can only call other `const fn` within a `const fn`, but `const std::intrinsics::transmute::<u32, i32>` is not stable as `const fn` + --> $DIR/internal-unstable-const.rs:11:14 | -LL | if true { 4 } else { 5 } - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | unsafe { std::mem::transmute(4u32) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = help: add `#![feature(const_fn)]` to the crate attributes to enable diff --git a/src/test/ui/issues/issue-51714.rs b/src/test/ui/issues/issue-51714.rs index 782037a1fe5..0dc588d75c6 100644 --- a/src/test/ui/issues/issue-51714.rs +++ b/src/test/ui/issues/issue-51714.rs @@ -10,5 +10,4 @@ fn main() { [(); return while let Some(n) = Some(0) {}]; //~^ ERROR return statement outside of function body - //~| ERROR `while` is not allowed in a `const` } diff --git a/src/test/ui/issues/issue-51714.stderr b/src/test/ui/issues/issue-51714.stderr index 69603085043..023d9013ab4 100644 --- a/src/test/ui/issues/issue-51714.stderr +++ b/src/test/ui/issues/issue-51714.stderr @@ -1,13 +1,3 @@ -error[E0658]: `while` is not allowed in a `const` - --> $DIR/issue-51714.rs:11:17 - | -LL | [(); return while let Some(n) = Some(0) {}]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information - = help: add `#![feature(const_loop)]` to the crate attributes to enable - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - error[E0572]: return statement outside of function body --> $DIR/issue-51714.rs:2:14 | @@ -32,7 +22,6 @@ error[E0572]: return statement outside of function body LL | [(); return while let Some(n) = Some(0) {}]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0572, E0658. -For more information about an error, try `rustc --explain E0572`. +For more information about this error, try `rustc --explain E0572`. diff --git a/src/test/ui/issues/issue-66706.rs b/src/test/ui/issues/issue-66706.rs index 02305191f6e..4585bcc8cd5 100644 --- a/src/test/ui/issues/issue-66706.rs +++ b/src/test/ui/issues/issue-66706.rs @@ -19,7 +19,6 @@ fn c() { fn d() { [0; match [|f @ &ref _| () ] {} ] //~^ ERROR expected identifier, found reserved identifier `_` - //~| ERROR `match` is not allowed in a `const` //~| ERROR mismatched types } diff --git a/src/test/ui/issues/issue-66706.stderr b/src/test/ui/issues/issue-66706.stderr index ea461cc5d03..f0b93ac9111 100644 --- a/src/test/ui/issues/issue-66706.stderr +++ b/src/test/ui/issues/issue-66706.stderr @@ -26,15 +26,6 @@ error: expected identifier, found reserved identifier `_` LL | [0; match [|f @ &ref _| () ] {} ] | ^ expected identifier, found reserved identifier -error[E0658]: `match` is not allowed in a `const` - --> $DIR/issue-66706.rs:20:9 - | -LL | [0; match [|f @ &ref _| () ] {} ] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - error[E0282]: type annotations needed --> $DIR/issue-66706.rs:2:11 | @@ -65,7 +56,7 @@ LL | fn d() { LL | [0; match [|f @ &ref _| () ] {} ] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[{integer}; _]` -error: aborting due to 9 previous errors +error: aborting due to 8 previous errors -Some errors have detailed explanations: E0282, E0308, E0658. +Some errors have detailed explanations: E0282, E0308. For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/or-patterns/feature-gate-const-fn.rs b/src/test/ui/or-patterns/const-fn.rs index d21cf3dc72c..f4af2f0d2dd 100644 --- a/src/test/ui/or-patterns/feature-gate-const-fn.rs +++ b/src/test/ui/or-patterns/const-fn.rs @@ -1,35 +1,30 @@ +// check-pass #![feature(or_patterns)] const fn foo((Ok(a) | Err(a)): Result<i32, i32>) { - //~^ ERROR or-pattern is not allowed in a `const fn` let x = Ok(3); let Ok(y) | Err(y) = x; - //~^ ERROR or-pattern is not allowed in a `const fn` } const X: () = { let x = Ok(3); let Ok(y) | Err(y) = x; - //~^ ERROR or-pattern is not allowed in a `const` }; static Y: () = { let x = Ok(3); let Ok(y) | Err(y) = x; - //~^ ERROR or-pattern is not allowed in a `static` }; static mut Z: () = { let x = Ok(3); let Ok(y) | Err(y) = x; - //~^ ERROR or-pattern is not allowed in a `static mut` }; fn main() { let _: [(); { let x = Ok(3); let Ok(y) | Err(y) = x; - //~^ ERROR or-pattern is not allowed in a `const` 2 }]; } diff --git a/src/test/ui/or-patterns/feature-gate-const-fn.stderr b/src/test/ui/or-patterns/feature-gate-const-fn.stderr deleted file mode 100644 index 345d6c70981..00000000000 --- a/src/test/ui/or-patterns/feature-gate-const-fn.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0658]: or-pattern is not allowed in a `const fn` - --> $DIR/feature-gate-const-fn.rs:3:15 - | -LL | const fn foo((Ok(a) | Err(a)): Result<i32, i32>) { - | ^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: or-pattern is not allowed in a `const fn` - --> $DIR/feature-gate-const-fn.rs:6:9 - | -LL | let Ok(y) | Err(y) = x; - | ^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: or-pattern is not allowed in a `const` - --> $DIR/feature-gate-const-fn.rs:12:9 - | -LL | let Ok(y) | Err(y) = x; - | ^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: or-pattern is not allowed in a `static` - --> $DIR/feature-gate-const-fn.rs:18:9 - | -LL | let Ok(y) | Err(y) = x; - | ^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: or-pattern is not allowed in a `static mut` - --> $DIR/feature-gate-const-fn.rs:24:9 - | -LL | let Ok(y) | Err(y) = x; - | ^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: or-pattern is not allowed in a `const` - --> $DIR/feature-gate-const-fn.rs:31:13 - | -LL | let Ok(y) | Err(y) = x; - | ^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/return/return-match-array-const.rs b/src/test/ui/return/return-match-array-const.rs index 9f3b9651642..f21eac37c17 100644 --- a/src/test/ui/return/return-match-array-const.rs +++ b/src/test/ui/return/return-match-array-const.rs @@ -1,13 +1,10 @@ fn main() { [(); return match 0 { n => n }]; //~^ ERROR: return statement outside of function body - //~| ERROR: `match` is not allowed in a `const` [(); return match 0 { 0 => 0 }]; //~^ ERROR: return statement outside of function body - //~| ERROR: `match` is not allowed in a `const` [(); return match () { 'a' => 0, _ => 0 }]; //~^ ERROR: return statement outside of function body - //~| ERROR: `match` is not allowed in a `const` } diff --git a/src/test/ui/return/return-match-array-const.stderr b/src/test/ui/return/return-match-array-const.stderr index c475c7de438..8e801e3fbb7 100644 --- a/src/test/ui/return/return-match-array-const.stderr +++ b/src/test/ui/return/return-match-array-const.stderr @@ -1,30 +1,3 @@ -error[E0658]: `match` is not allowed in a `const` - --> $DIR/return-match-array-const.rs:2:17 - | -LL | [(); return match 0 { n => n }]; - | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const` - --> $DIR/return-match-array-const.rs:6:17 - | -LL | [(); return match 0 { 0 => 0 }]; - | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const` - --> $DIR/return-match-array-const.rs:10:17 - | -LL | [(); return match () { 'a' => 0, _ => 0 }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - error[E0572]: return statement outside of function body --> $DIR/return-match-array-const.rs:2:10 | @@ -32,18 +5,17 @@ LL | [(); return match 0 { n => n }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0572]: return statement outside of function body - --> $DIR/return-match-array-const.rs:6:10 + --> $DIR/return-match-array-const.rs:5:10 | LL | [(); return match 0 { 0 => 0 }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0572]: return statement outside of function body - --> $DIR/return-match-array-const.rs:10:10 + --> $DIR/return-match-array-const.rs:8:10 | LL | [(); return match () { 'a' => 0, _ => 0 }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0572, E0658. -For more information about an error, try `rustc --explain E0572`. +For more information about this error, try `rustc --explain E0572`. 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 d5756737f17..71af704c69f 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 @@ -216,17 +216,14 @@ fn inside_const_generic_arguments() { if let A::<{ true && let 1 = 1 //~ ERROR `let` expressions are not supported here - //~| ERROR `match` is not allowed in a `const` }>::O = 5 {} while let A::<{ true && let 1 = 1 //~ ERROR `let` expressions are not supported here - //~| ERROR `match` is not allowed in a `const` }>::O = 5 {} if A::<{ true && let 1 = 1 //~ ERROR `let` expressions are not supported here - //~| ERROR `match` is not allowed in a `const` }>::O == 5 {} // In the cases above we have `ExprKind::Block` to help us out. 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 4c3a00e5f35..7f343d1a853 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:239:14 + --> $DIR/disallowed-positions.rs:236:14 | LL | true && let 1 = 1 | ^^ expected one of `,` or `>` @@ -482,7 +482,7 @@ LL | true && let 1 = 1 = note: as well as when nested within `&&` and parenthesis in those conditions error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:223:17 + --> $DIR/disallowed-positions.rs:222:17 | LL | true && let 1 = 1 | ^^^^^^^^^ @@ -491,7 +491,7 @@ LL | true && let 1 = 1 = note: as well as when nested within `&&` and parenthesis in those conditions error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:228:17 + --> $DIR/disallowed-positions.rs:226:17 | LL | true && let 1 = 1 | ^^^^^^^^^ @@ -516,33 +516,6 @@ LL | #![feature(let_chains)] // Avoid inflating `.stderr` with overzealous gates | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information -error[E0658]: `match` is not allowed in a `const` - --> $DIR/disallowed-positions.rs:218:17 - | -LL | true && let 1 = 1 - | ^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const` - --> $DIR/disallowed-positions.rs:223:17 - | -LL | true && let 1 = 1 - | ^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - -error[E0658]: `match` is not allowed in a `const` - --> $DIR/disallowed-positions.rs:228:17 - | -LL | true && let 1 = 1 - | ^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable - error[E0308]: mismatched types --> $DIR/disallowed-positions.rs:32:8 | @@ -983,7 +956,7 @@ LL | let 0 = 0?; = help: the trait `std::ops::Try` is not implemented for `{integer}` = note: required by `std::ops::Try::into_result` -error: aborting due to 106 previous errors; 2 warnings emitted +error: aborting due to 103 previous errors; 2 warnings emitted -Some errors have detailed explanations: E0277, E0308, E0600, E0614, E0658. +Some errors have detailed explanations: E0277, E0308, E0600, E0614. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs index f7af1b506f0..655d4d7400b 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs @@ -4,12 +4,13 @@ #![allow(incomplete_features)] pub trait MyTrait { - fn method(&self); + fn method(&self) -> Option<()>; } impl const MyTrait for () { - fn method(&self) { - match *self {} //~ ERROR `match` is not allowed in a `const fn` + fn method(&self) -> Option<()> { + Some(())?; //~ ERROR `?` is not allowed in a `const fn` + None } } diff --git a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr index 563a9afe5bb..8c76d7eb597 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr +++ b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr @@ -1,12 +1,9 @@ -error[E0658]: `match` is not allowed in a `const fn` +error[E0744]: `?` is not allowed in a `const fn` --> $DIR/hir-const-check.rs:12:9 | -LL | match *self {} - | ^^^^^^^^^^^^^^ - | - = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information - = help: add `#![feature(const_if_match)]` to the crate attributes to enable +LL | Some(())?; + | ^^^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0744`. |
