From aef6288d9ad2c5d9bba2525611ef1a3da703d4b5 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sun, 30 Dec 2018 19:20:53 +0100 Subject: [PATCH] const fn feature gate is not needed anymore in a lot of tests --- .../ctfe/const-block-non-item-statement-3.rs | 4 +++- .../ctfe/const-block-non-item-statement.rs | 5 ++++- src/test/run-pass/ctfe/locals-in-const-fn.rs | 2 -- src/test/ui/consts/const_let_assign2.rs | 2 -- src/test/ui/consts/const_let_assign3.rs | 9 ++++++-- src/test/ui/consts/const_let_assign3.stderr | 12 +++++------ src/test/ui/consts/const_let_eq.rs | 2 -- src/test/ui/issues/issue-32829-2.rs | 2 -- src/test/ui/issues/issue-32829-2.stderr | 6 +++--- src/test/ui/unsafe/ranged_ints2_const.rs | 6 +++--- src/test/ui/unsafe/ranged_ints2_const.stderr | 21 +++++++++---------- src/test/ui/unsafe/ranged_ints3_const.rs | 2 +- src/test/ui/unsafe/ranged_ints4_const.rs | 2 +- 13 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs b/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs index 54ed2efa50b..10a4c31f24e 100644 --- a/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs +++ b/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs @@ -3,4 +3,6 @@ type Array = [u32; { let x = 2; 5 }]; -pub fn main() {} +pub fn main() { + let _: Array = [0; 5]; +} diff --git a/src/test/run-pass/ctfe/const-block-non-item-statement.rs b/src/test/run-pass/ctfe/const-block-non-item-statement.rs index 92bf5ae7b97..a1b9b586ad0 100644 --- a/src/test/run-pass/ctfe/const-block-non-item-statement.rs +++ b/src/test/run-pass/ctfe/const-block-non-item-statement.rs @@ -1,8 +1,11 @@ // run-pass #![allow(dead_code)] +#[repr(u8)] enum Foo { Bar = { let x = 1; 3 } } -pub fn main() {} +pub fn main() { + assert_eq!(3, Foo::Bar as u8); +} diff --git a/src/test/run-pass/ctfe/locals-in-const-fn.rs b/src/test/run-pass/ctfe/locals-in-const-fn.rs index 27e93b913f8..95d50171a84 100644 --- a/src/test/run-pass/ctfe/locals-in-const-fn.rs +++ b/src/test/run-pass/ctfe/locals-in-const-fn.rs @@ -2,8 +2,6 @@ // https://github.com/rust-lang/rust/issues/48821 -#![feature(const_fn)] - const fn foo(i: usize) -> usize { let x = i; x diff --git a/src/test/ui/consts/const_let_assign2.rs b/src/test/ui/consts/const_let_assign2.rs index 7839aafe5ef..1c44237e49b 100644 --- a/src/test/ui/consts/const_let_assign2.rs +++ b/src/test/ui/consts/const_let_assign2.rs @@ -1,7 +1,5 @@ // compile-pass -#![feature(const_fn)] - pub struct AA { pub data: [u8; 10], } diff --git a/src/test/ui/consts/const_let_assign3.rs b/src/test/ui/consts/const_let_assign3.rs index dd0705edfe7..cbe73923e9c 100644 --- a/src/test/ui/consts/const_let_assign3.rs +++ b/src/test/ui/consts/const_let_assign3.rs @@ -17,9 +17,14 @@ const fn foo(&mut self, x: u32) { s }; -type Array = [u32; { let mut x = 2; let y = &mut x; *y = 42; *y}]; +type Array = [u32; { + let mut x = 2; + let y = &mut x; //~^ ERROR references in constants may only refer to immutable values -//~| ERROR constant contains unimplemented expression type + *y = 42; +//~^ ERROR constant contains unimplemented expression type + *y +}]; fn main() { assert_eq!(FOO.state, 3); diff --git a/src/test/ui/consts/const_let_assign3.stderr b/src/test/ui/consts/const_let_assign3.stderr index ecf6625151d..6649fb997cc 100644 --- a/src/test/ui/consts/const_let_assign3.stderr +++ b/src/test/ui/consts/const_let_assign3.stderr @@ -11,16 +11,16 @@ LL | s.foo(3); //~ ERROR references in constants may only refer to immutable | ^ constants require immutable values error[E0017]: references in constants may only refer to immutable values - --> $DIR/const_let_assign3.rs:20:45 + --> $DIR/const_let_assign3.rs:22:13 | -LL | type Array = [u32; { let mut x = 2; let y = &mut x; *y = 42; *y}]; - | ^^^^^^ constants require immutable values +LL | let y = &mut x; + | ^^^^^^ constants require immutable values error[E0019]: constant contains unimplemented expression type - --> $DIR/const_let_assign3.rs:20:53 + --> $DIR/const_let_assign3.rs:24:5 | -LL | type Array = [u32; { let mut x = 2; let y = &mut x; *y = 42; *y}]; - | ^^^^^^^ +LL | *y = 42; + | ^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/const_let_eq.rs b/src/test/ui/consts/const_let_eq.rs index 106a45ee1d4..a2364c392f2 100644 --- a/src/test/ui/consts/const_let_eq.rs +++ b/src/test/ui/consts/const_let_eq.rs @@ -1,5 +1,3 @@ -#![feature(const_fn)] - // run-pass struct Foo(T); diff --git a/src/test/ui/issues/issue-32829-2.rs b/src/test/ui/issues/issue-32829-2.rs index 379f1ee0f38..c93c84b5fb7 100644 --- a/src/test/ui/issues/issue-32829-2.rs +++ b/src/test/ui/issues/issue-32829-2.rs @@ -1,7 +1,5 @@ // ignore-tidy-linelength -#![feature(const_fn)] - const bad : u32 = { { 5; diff --git a/src/test/ui/issues/issue-32829-2.stderr b/src/test/ui/issues/issue-32829-2.stderr index 9b7fe71d9a7..8d7423f29ae 100644 --- a/src/test/ui/issues/issue-32829-2.stderr +++ b/src/test/ui/issues/issue-32829-2.stderr @@ -1,17 +1,17 @@ error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-32829-2.rs:14:9 + --> $DIR/issue-32829-2.rs:12:9 | LL | invalid(); | ^^^^^^^^^ error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-32829-2.rs:36:9 + --> $DIR/issue-32829-2.rs:34:9 | LL | invalid(); | ^^^^^^^^^ error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-32829-2.rs:58:9 + --> $DIR/issue-32829-2.rs:56:9 | LL | invalid(); | ^^^^^^^^^ diff --git a/src/test/ui/unsafe/ranged_ints2_const.rs b/src/test/ui/unsafe/ranged_ints2_const.rs index c404f259116..788f49f743c 100644 --- a/src/test/ui/unsafe/ranged_ints2_const.rs +++ b/src/test/ui/unsafe/ranged_ints2_const.rs @@ -1,4 +1,4 @@ -#![feature(rustc_attrs, const_fn)] +#![feature(rustc_attrs)] #[rustc_layout_scalar_valid_range_start(1)] #[repr(transparent)] @@ -8,13 +8,13 @@ fn main() { const fn foo() -> NonZero { let mut x = unsafe { NonZero(1) }; - let y = &mut x.0; //~ ERROR references in constant functions may only refer to immutable + let y = &mut x.0; //~ ERROR references in const fn are unstable //~^ ERROR mutation of layout constrained field is unsafe unsafe { NonZero(1) } } const fn bar() -> NonZero { let mut x = unsafe { NonZero(1) }; - let y = unsafe { &mut x.0 }; //~ ERROR references in constant functions may only refer to immut + let y = unsafe { &mut x.0 }; //~ ERROR mutable references in const fn are unstable unsafe { NonZero(1) } } diff --git a/src/test/ui/unsafe/ranged_ints2_const.stderr b/src/test/ui/unsafe/ranged_ints2_const.stderr index f79792ffba9..39a55190b17 100644 --- a/src/test/ui/unsafe/ranged_ints2_const.stderr +++ b/src/test/ui/unsafe/ranged_ints2_const.stderr @@ -1,24 +1,23 @@ -error[E0017]: references in constant functions may only refer to immutable values - --> $DIR/ranged_ints2_const.rs:11:13 +error: mutable references in const fn are unstable + --> $DIR/ranged_ints2_const.rs:11:9 | -LL | let y = &mut x.0; //~ ERROR references in constant functions may only refer to immutable - | ^^^^^^^^ constant functions require immutable values +LL | let y = &mut x.0; //~ ERROR references in const fn are unstable + | ^ -error[E0017]: references in constant functions may only refer to immutable values - --> $DIR/ranged_ints2_const.rs:18:22 +error: mutable references in const fn are unstable + --> $DIR/ranged_ints2_const.rs:18:9 | -LL | let y = unsafe { &mut x.0 }; //~ ERROR references in constant functions may only refer to immut - | ^^^^^^^^ constant functions require immutable values +LL | let y = unsafe { &mut x.0 }; //~ ERROR mutable references in const fn are unstable + | ^ error[E0133]: mutation of layout constrained field is unsafe and requires unsafe function or block --> $DIR/ranged_ints2_const.rs:11:13 | -LL | let y = &mut x.0; //~ ERROR references in constant functions may only refer to immutable +LL | let y = &mut x.0; //~ ERROR references in const fn are unstable | ^^^^^^^^ mutation of layout constrained field | = note: mutating layout constrained fields cannot statically be checked for valid values error: aborting due to 3 previous errors -Some errors occurred: E0017, E0133. -For more information about an error, try `rustc --explain E0017`. +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/unsafe/ranged_ints3_const.rs b/src/test/ui/unsafe/ranged_ints3_const.rs index f8ce81f0d1c..7b03d8eda93 100644 --- a/src/test/ui/unsafe/ranged_ints3_const.rs +++ b/src/test/ui/unsafe/ranged_ints3_const.rs @@ -1,4 +1,4 @@ -#![feature(rustc_attrs, const_fn)] +#![feature(rustc_attrs)] use std::cell::Cell; diff --git a/src/test/ui/unsafe/ranged_ints4_const.rs b/src/test/ui/unsafe/ranged_ints4_const.rs index 9bda1f69652..f09168c3d3f 100644 --- a/src/test/ui/unsafe/ranged_ints4_const.rs +++ b/src/test/ui/unsafe/ranged_ints4_const.rs @@ -1,4 +1,4 @@ -#![feature(rustc_attrs, const_fn)] +#![feature(rustc_attrs)] #[rustc_layout_scalar_valid_range_start(1)] #[repr(transparent)] -- 2.44.0