Skip to content

Commit

Permalink
remove const_fn feature gate from const tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Apr 29, 2021
1 parent 9a85277 commit 3752c6b
Show file tree
Hide file tree
Showing 51 changed files with 69 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

// run-pass

#![feature(const_fn)]

#[derive(PartialEq, Debug, Clone)]
struct N(u8);

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/associated-consts/associated-const-in-trait.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// #29924

#![feature(const_fn, associated_consts)]
#![feature(associated_consts)]

trait Trait {
const N: usize;
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/auxiliary/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![crate_type="rlib"]
#![stable(feature = "rust1", since = "1.0.0")]

#![feature(const_fn)]
#![feature(staged_api)]

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/const_fn_ptr.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// compile-flags: -Zunleash-the-miri-inside-of-you
#![feature(const_fn)]

fn double(x: usize) -> usize { x * 2 }
const fn double_const(x: usize) -> usize { x * 2 }
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/consts/const-eval/const_fn_ptr.stderr
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
warning: skipping const checks
|
help: skipping check that does not even have a feature gate
--> $DIR/const_fn_ptr.rs:12:5
--> $DIR/const_fn_ptr.rs:11:5
|
LL | X(x)
| ^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_fn_ptr.rs:16:5
--> $DIR/const_fn_ptr.rs:15:5
|
LL | X_CONST(x)
| ^^^^^^^^^^
help: skipping check for `const_fn_fn_ptr_basics` feature
--> $DIR/const_fn_ptr.rs:19:14
--> $DIR/const_fn_ptr.rs:18:14
|
LL | const fn foo(x: fn(usize) -> usize, y: usize) -> usize {
| ^
help: skipping check for `const_fn_fn_ptr_basics` feature
--> $DIR/const_fn_ptr.rs:20:5
--> $DIR/const_fn_ptr.rs:19:5
|
LL | x(y)
| ^
help: skipping check that does not even have a feature gate
--> $DIR/const_fn_ptr.rs:20:5
--> $DIR/const_fn_ptr.rs:19:5
|
LL | x(y)
| ^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/const_fn_ptr_fail.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// compile-flags: -Zunleash-the-miri-inside-of-you
#![feature(const_fn)]
#![allow(unused)]

fn double(x: usize) -> usize { x * 2 }
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
warning: skipping const checks
|
help: skipping check that does not even have a feature gate
--> $DIR/const_fn_ptr_fail.rs:10:5
--> $DIR/const_fn_ptr_fail.rs:9:5
|
LL | X(x) // FIXME: this should error someday
| ^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// build-fail
// compile-flags: -Zunleash-the-miri-inside-of-you

#![feature(const_fn)]
#![allow(const_err)]

fn double(x: usize) -> usize {
Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
error[E0080]: evaluation of constant value failed
--> $DIR/const_fn_ptr_fail2.rs:20:16
--> $DIR/const_fn_ptr_fail2.rs:19:16
|
LL | assert_eq!(Y, 4);
| ^ referenced constant has errors

error[E0080]: evaluation of constant value failed
--> $DIR/const_fn_ptr_fail2.rs:22:16
--> $DIR/const_fn_ptr_fail2.rs:21:16
|
LL | assert_eq!(Z, 4);
| ^ referenced constant has errors

warning: skipping const checks
|
help: skipping check for `const_fn_fn_ptr_basics` feature
--> $DIR/const_fn_ptr_fail2.rs:12:14
--> $DIR/const_fn_ptr_fail2.rs:11:14
|
LL | const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
| ^
help: skipping check for `const_fn_fn_ptr_basics` feature
--> $DIR/const_fn_ptr_fail2.rs:13:5
--> $DIR/const_fn_ptr_fail2.rs:12:5
|
LL | x(y)
| ^
help: skipping check that does not even have a feature gate
--> $DIR/const_fn_ptr_fail2.rs:13:5
--> $DIR/const_fn_ptr_fail2.rs:12:5
|
LL | x(y)
| ^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
we're apparently really bad at it",
issue = "none")]

#![feature(const_fn)]
#![feature(staged_api)]

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: `foo` is not yet stable as a const fn
--> $DIR/dont_promote_unstable_const_fn.rs:15:25
--> $DIR/dont_promote_unstable_const_fn.rs:14:25
|
LL | const fn bar() -> u32 { foo() }
| ^^^^^
|
= help: add `#![feature(foo)]` to the crate attributes to enable

error[E0716]: temporary value dropped while borrowed
--> $DIR/dont_promote_unstable_const_fn.rs:18:28
--> $DIR/dont_promote_unstable_const_fn.rs:17:28
|
LL | let _: &'static u32 = &foo();
| ------------ ^^^^^ creates a temporary which is freed while still in use
Expand All @@ -17,7 +17,7 @@ LL | }
| - temporary value is freed at the end of this statement

error[E0716]: temporary value dropped while borrowed
--> $DIR/dont_promote_unstable_const_fn.rs:22:28
--> $DIR/dont_promote_unstable_const_fn.rs:21:28
|
LL | let _: &'static u32 = &meh();
| ------------ ^^^^^ creates a temporary which is freed while still in use
Expand All @@ -28,7 +28,7 @@ LL | }
| - temporary value is freed at the end of this statement

error[E0716]: temporary value dropped while borrowed
--> $DIR/dont_promote_unstable_const_fn.rs:23:26
--> $DIR/dont_promote_unstable_const_fn.rs:22:26
|
LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-eval/double_promotion.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// check-pass

#![feature(const_fn, rustc_attrs)]
#![feature(rustc_attrs)]

#[rustc_args_required_const(0)]
pub const fn a(value: u8) -> u8 {
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/consts/const-eval/feature-gate-const_fn_union.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(const_fn)]

fn main() {}

#[repr(C)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: unions in const fn are unstable
--> $DIR/feature-gate-const_fn_union.rs:12:5
--> $DIR/feature-gate-const_fn_union.rs:10:5
|
LL | Foo { u }.i
| ^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-eval/promoted_const_fn_fail.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(const_fn, const_fn_union)]
#![feature(const_fn_union)]

#![allow(const_err)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(const_fn, const_fn_union)]
#![feature(const_fn_union)]

#![deny(const_err)]

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/simd/insert_extract.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-pass
#![feature(const_fn)]
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#![feature(staged_api)]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/union-const-eval-field.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// only-x86_64
#![feature(const_fn)]

type Field1 = i32;
type Field2 = f32;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/union-const-eval-field.rs:29:5
--> $DIR/union-const-eval-field.rs:28:5
|
LL | const FIELD3: Field3 = unsafe { UNION.field3 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/union-ice.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// only-x86_64
#![feature(const_fn)]

type Field1 = i32;
type Field3 = i64;
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/consts/const-eval/union-ice.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/union-ice.rs:15:1
--> $DIR/union-ice.rs:14:1
|
LL | const FIELD3: Field3 = unsafe { UNION.field3 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
Expand All @@ -10,7 +10,7 @@ LL | const FIELD3: Field3 = unsafe { UNION.field3 };
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/union-ice.rs:17:1
--> $DIR/union-ice.rs:16:1
|
LL | / const FIELD_PATH: Struct = Struct {
LL | | a: 42,
Expand All @@ -24,7 +24,7 @@ LL | | };
}

error[E0080]: it is undefined behavior to use this value
--> $DIR/union-ice.rs:27:1
--> $DIR/union-ice.rs:26:1
|
LL | / const FIELD_PATH2: Struct2 = Struct2 {
LL | | b: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
warning: any use of this value will cause an error
--> $DIR/validate_uninhabited_zsts.rs:6:14
--> $DIR/validate_uninhabited_zsts.rs:5:14
|
LL | unsafe { std::mem::transmute(()) }
| ^^^^^^^^^^^^^^^^^^^^^^^
| |
| transmuting to uninhabited type
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:6:14
| inside `FOO` at $DIR/validate_uninhabited_zsts.rs:16:26
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14
| inside `FOO` at $DIR/validate_uninhabited_zsts.rs:15:26
...
LL | const FOO: [Empty; 3] = [foo(); 3];
| -----------------------------------
|
note: the lint level is defined here
--> $DIR/validate_uninhabited_zsts.rs:15:8
--> $DIR/validate_uninhabited_zsts.rs:14:8
|
LL | #[warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error[E0080]: it is undefined behavior to use this value
--> $DIR/validate_uninhabited_zsts.rs:19:1
--> $DIR/validate_uninhabited_zsts.rs:18:1
|
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Empty at [0]
Expand All @@ -29,7 +29,7 @@ LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
= note: the raw bytes of the constant (size: 0, align: 1) {}

warning: the type `!` does not permit zero-initialization
--> $DIR/validate_uninhabited_zsts.rs:6:14
--> $DIR/validate_uninhabited_zsts.rs:5:14
|
LL | unsafe { std::mem::transmute(()) }
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -41,7 +41,7 @@ LL | unsafe { std::mem::transmute(()) }
= note: the `!` type has no valid value

warning: the type `Empty` does not permit zero-initialization
--> $DIR/validate_uninhabited_zsts.rs:19:35
--> $DIR/validate_uninhabited_zsts.rs:18:35
|
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// stderr-per-bitwidth
#![feature(const_fn)]
#![feature(const_fn_transmute)]

const fn foo() -> ! {
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/consts/const-fn-error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(const_fn)]

const X : usize = 2;

const fn f(x: usize) -> usize {
Expand Down
14 changes: 7 additions & 7 deletions src/test/ui/consts/const-fn-error.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0744]: `for` is not allowed in a `const fn`
--> $DIR/const-fn-error.rs:7:5
--> $DIR/const-fn-error.rs:5:5
|
LL | / for i in 0..x {
LL | |
Expand All @@ -11,13 +11,13 @@ LL | | }
| |_____^

error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/const-fn-error.rs:7:14
--> $DIR/const-fn-error.rs:5:14
|
LL | for i in 0..x {
| ^^^^

error[E0658]: mutable references are not allowed in constant functions
--> $DIR/const-fn-error.rs:7:14
--> $DIR/const-fn-error.rs:5:14
|
LL | for i in 0..x {
| ^^^^
Expand All @@ -26,22 +26,22 @@ LL | for i in 0..x {
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/const-fn-error.rs:7:14
--> $DIR/const-fn-error.rs:5:14
|
LL | for i in 0..x {
| ^^^^

error[E0080]: evaluation of constant value failed
--> $DIR/const-fn-error.rs:7:14
--> $DIR/const-fn-error.rs:5:14
|
LL | for i in 0..x {
| ^^^^
| |
| calling non-const function `<std::ops::Range<usize> as IntoIterator>::into_iter`
| inside `f` at $DIR/const-fn-error.rs:7:14
| inside `f` at $DIR/const-fn-error.rs:5:14
...
LL | let a : [i32; f(X)];
| ---- inside `main::{constant#0}` at $DIR/const-fn-error.rs:20:19
| ---- inside `main::{constant#0}` at $DIR/const-fn-error.rs:18:19

error: aborting due to 5 previous errors

Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/consts/const-fn-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// it if the trait fn is const (but right now no trait fns can be
// const).

#![feature(const_fn)]

trait Foo {
fn f() -> u32;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-fn-mismatch.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0379]: functions in traits cannot be declared const
--> $DIR/const-fn-mismatch.rs:13:5
--> $DIR/const-fn-mismatch.rs:11:5
|
LL | const fn f() -> u32 {
| ^^^^^ functions in traits cannot be const
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/consts/const-fn-not-in-trait.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Test that const fn is illegal in a trait declaration, whether or
// not a default is provided, and even with the feature gate.

#![feature(const_fn)]

trait Foo {
const fn f() -> u32;
//~^ ERROR functions in traits cannot be declared const
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/const-fn-not-in-trait.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0379]: functions in traits cannot be declared const
--> $DIR/const-fn-not-in-trait.rs:7:5
--> $DIR/const-fn-not-in-trait.rs:5:5
|
LL | const fn f() -> u32;
| ^^^^^ functions in traits cannot be const

error[E0379]: functions in traits cannot be declared const
--> $DIR/const-fn-not-in-trait.rs:9:5
--> $DIR/const-fn-not-in-trait.rs:7:5
|
LL | const fn g() -> u32 {
| ^^^^^ functions in traits cannot be const
Expand Down
Loading

0 comments on commit 3752c6b

Please sign in to comment.