Auto merge of #84556 - RalfJung:const-fn-trait-bound, r=oli-obk

use correct feature flag for impl-block-level trait bounds on const fn

I am not sure what that special hack was needed for, but it doesn't seem needed any more...

This removes the last use of the `const_fn` feature flag -- Cc https://github.com/rust-lang/rust/issues/84510
r? `@oli-obk`
This commit is contained in:
bors 2021-04-29 17:38:37 +00:00
commit 18587b14d1
63 changed files with 85 additions and 133 deletions

View File

@ -426,7 +426,7 @@ impl Validator<'mir, 'tcx> {
ty::PredicateKind::Subtype(_) => {
bug!("subtype predicate on function: {:#?}", predicate)
}
ty::PredicateKind::Trait(pred, constness) => {
ty::PredicateKind::Trait(pred, _constness) => {
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
continue;
}
@ -440,16 +440,7 @@ impl Validator<'mir, 'tcx> {
// arguments when determining importance.
let kind = LocalKind::Arg;
if constness == hir::Constness::Const {
self.check_op_spanned(ops::ty::TraitBound(kind), span);
} else if !tcx.features().const_fn
|| self.ccx.is_const_stable_const_fn()
{
// HACK: We shouldn't need the conditional above, but trait
// bounds on containing impl blocks are wrongly being marked as
// "not-const".
self.check_op_spanned(ops::ty::TraitBound(kind), span);
}
self.check_op_spanned(ops::ty::TraitBound(kind), span);
}
// other kinds of bounds are either tautologies
// or cause errors in other passes

View File

@ -21,7 +21,8 @@
#![feature(rustc_allow_const_fn_unstable)]
#![feature(nll)]
#![feature(staged_api)]
#![feature(const_fn)]
#![cfg_attr(bootstrap, feature(const_fn))]
#![cfg_attr(not(bootstrap), feature(const_fn_trait_bound))]
#![feature(const_fn_fn_ptr_basics)]
#![feature(allow_internal_unstable)]
#![feature(decl_macro)]

View File

@ -2,8 +2,6 @@
// run-pass
#![feature(const_fn)]
#[derive(PartialEq, Debug, Clone)]
struct N(u8);

View File

@ -1,6 +1,6 @@
// #29924
#![feature(const_fn, associated_consts)]
#![feature(associated_consts)]
trait Trait {
const N: usize;

View File

@ -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")]

View File

@ -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 }

View File

@ -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)
| ^^^^

View File

@ -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 }

View File

@ -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
| ^^^^

View File

@ -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 {

View File

@ -1,11 +1,11 @@
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
@ -13,17 +13,17 @@ LL | assert_eq!(Z, 4);
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)
| ^^^^

View File

@ -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")]

View File

@ -1,5 +1,5 @@
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() }
| ^^^^^
@ -7,7 +7,7 @@ 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
@ -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
@ -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

View File

@ -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 {

View File

@ -1,5 +1,3 @@
#![feature(const_fn)]
fn main() {}
#[repr(C)]

View File

@ -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
| ^^^^^^^^^^^

View File

@ -1,4 +1,4 @@
#![feature(const_fn, const_fn_union)]
#![feature(const_fn_union)]
#![allow(const_err)]

View File

@ -1,4 +1,4 @@
#![feature(const_fn, const_fn_union)]
#![feature(const_fn_union)]
#![deny(const_err)]

View File

@ -1,5 +1,4 @@
// run-pass
#![feature(const_fn)]
#![feature(repr_simd)]
#![feature(platform_intrinsics)]
#![feature(staged_api)]

View File

@ -1,5 +1,4 @@
// only-x86_64
#![feature(const_fn)]
type Field1 = i32;
type Field2 = f32;

View File

@ -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

View File

@ -1,5 +1,4 @@
// only-x86_64
#![feature(const_fn)]
type Field1 = i32;
type Field3 = i64;

View File

@ -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
@ -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,
@ -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: [

View File

@ -1,18 +1,18 @@
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)]
| ^^^^^^^^^
@ -20,7 +20,7 @@ LL | #[warn(const_err)]
= 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]
@ -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(()) }
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -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];
| ^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,18 +1,18 @@
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)]
| ^^^^^^^^^
@ -20,7 +20,7 @@ LL | #[warn(const_err)]
= 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]
@ -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(()) }
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -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];
| ^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,4 @@
// stderr-per-bitwidth
#![feature(const_fn)]
#![feature(const_fn_transmute)]
const fn foo() -> ! {

View File

@ -1,5 +1,3 @@
#![feature(const_fn)]
const X : usize = 2;
const fn f(x: usize) -> usize {

View File

@ -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 | |
@ -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 {
| ^^^^
@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,6 +1,6 @@
// Test that we can't call random fns in a const fn or do other bad things.
#![feature(const_fn, const_fn_transmute)]
#![feature(const_fn_transmute)]
use std::mem::transmute;

View File

@ -1,6 +1,5 @@
// run-pass
#![feature(const_fn)]
#![feature(const_type_name)]
#![allow(dead_code)]

View File

@ -1,7 +1,6 @@
// run-pass
#![feature(core_intrinsics)]
#![feature(const_fn)]
#![feature(const_type_name)]
#![allow(dead_code)]

View File

@ -1,6 +1,5 @@
// check-pass
#![feature(const_mut_refs)]
#![feature(const_fn)]
#![feature(raw_ref_op)]
struct Foo {

View File

@ -1,5 +1,4 @@
#![feature(const_mut_refs)]
#![feature(const_fn)]
#![feature(raw_ref_op)]
#![feature(const_raw_ptr_deref)]

View File

@ -1,11 +1,11 @@
error[E0764]: mutable references are not allowed in the final value of constants
--> $DIR/mut_ref_in_final.rs:12:21
--> $DIR/mut_ref_in_final.rs:11:21
|
LL | const B: *mut i32 = &mut 4;
| ^^^^^^
error[E0716]: temporary value dropped while borrowed
--> $DIR/mut_ref_in_final.rs:18:40
--> $DIR/mut_ref_in_final.rs:17:40
|
LL | const B3: Option<&mut i32> = Some(&mut 42);
| ----------^^-
@ -15,7 +15,7 @@ LL | const B3: Option<&mut i32> = Some(&mut 42);
| using this value as a constant requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed
--> $DIR/mut_ref_in_final.rs:21:42
--> $DIR/mut_ref_in_final.rs:20:42
|
LL | const B4: Option<&mut i32> = helper(&mut 42);
| ------------^^-
@ -25,7 +25,7 @@ LL | const B4: Option<&mut i32> = helper(&mut 42);
| using this value as a constant requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed
--> $DIR/mut_ref_in_final.rs:36:65
--> $DIR/mut_ref_in_final.rs:35:65
|
LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
| -------------------------------^^--
@ -35,7 +35,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
| using this value as a constant requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed
--> $DIR/mut_ref_in_final.rs:39:67
--> $DIR/mut_ref_in_final.rs:38:67
|
LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
| -------------------------------^^--
@ -45,7 +45,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
| using this value as a static requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed
--> $DIR/mut_ref_in_final.rs:42:71
--> $DIR/mut_ref_in_final.rs:41:71
|
LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
| -------------------------------^^--

View File

@ -1,5 +1,4 @@
#![feature(const_mut_refs)]
#![feature(const_fn)]
#![feature(raw_ref_op)]
#![feature(const_raw_ptr_deref)]

View File

@ -1,12 +1,12 @@
error: any use of this value will cause an error
--> $DIR/mut_ref_in_final_dynamic_check.rs:15:10
--> $DIR/mut_ref_in_final_dynamic_check.rs:14:10
|
LL | Some(&mut *(42 as *mut i32))
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| unable to turn bytes into a pointer
| inside `helper` at $DIR/mut_ref_in_final_dynamic_check.rs:15:10
| inside `A` at $DIR/mut_ref_in_final_dynamic_check.rs:20:29
| inside `helper` at $DIR/mut_ref_in_final_dynamic_check.rs:14:10
| inside `A` at $DIR/mut_ref_in_final_dynamic_check.rs:19:29
...
LL | const A: Option<&mut i32> = helper();
| -------------------------------------
@ -16,7 +16,7 @@ LL | const A: Option<&mut i32> = helper();
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: encountered dangling pointer in final constant
--> $DIR/mut_ref_in_final_dynamic_check.rs:27:1
--> $DIR/mut_ref_in_final_dynamic_check.rs:26:1
|
LL | const B: Option<&mut i32> = helper2();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,11 +1,7 @@
// Test that constructors are considered to be const fns with the required feature.
// Test that constructors are considered to be const fns
// run-pass
// revisions: min_const_fn const_fn
#![cfg_attr(const_fn, feature(const_fn))]
// Ctor(..) is transformed to Ctor { 0: ... } in THIR lowering, so directly
// calling constructors doesn't require them to be const.

View File

@ -1,8 +1,5 @@
// revisions: min_const_fn const_fn
// run-pass
#![cfg_attr(const_fn, feature(const_fn))]
trait ConstDefault {
const DEFAULT: Self;
}

View File

@ -1,5 +1,3 @@
#![feature(const_fn)]
struct S {
state: u32,
}

View File

@ -1,5 +1,5 @@
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/const_let_assign3.rs:8:18
--> $DIR/const_let_assign3.rs:6:18
|
LL | const fn foo(&mut self, x: u32) {
| ^^^^^^^^^
@ -8,7 +8,7 @@ LL | const fn foo(&mut self, x: u32) {
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0658]: mutable references are not allowed in constants
--> $DIR/const_let_assign3.rs:16:5
--> $DIR/const_let_assign3.rs:14:5
|
LL | s.foo(3);
| ^
@ -17,7 +17,7 @@ LL | s.foo(3);
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0658]: mutable references are not allowed in constants
--> $DIR/const_let_assign3.rs:22:13
--> $DIR/const_let_assign3.rs:20:13
|
LL | let y = &mut x;
| ^^^^^^

View File

@ -1,6 +1,5 @@
// run-pass
#![feature(const_fn)]
#![feature(const_unreachable_unchecked)]
const unsafe fn foo(x: bool) -> bool {

View File

@ -1,6 +1,5 @@
// build-fail
#![feature(const_fn)]
#![feature(const_unreachable_unchecked)]
const unsafe fn foo(x: bool) -> bool {

View File

@ -6,16 +6,16 @@ LL | unsafe { intrinsics::unreachable() }
| |
| entering unreachable code
| inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL
| inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:9:18
| inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:14:28
| inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:8:18
| inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:13:28
|
::: $DIR/const_unsafe_unreachable_ub.rs:14:1
::: $DIR/const_unsafe_unreachable_ub.rs:13:1
|
LL | const BAR: bool = unsafe { foo(false) };
| ----------------------------------------
|
note: the lint level is defined here
--> $DIR/const_unsafe_unreachable_ub.rs:13:8
--> $DIR/const_unsafe_unreachable_ub.rs:12:8
|
LL | #[warn(const_err)]
| ^^^^^^^^^
@ -23,13 +23,13 @@ LL | #[warn(const_err)]
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error[E0080]: evaluation of constant value failed
--> $DIR/const_unsafe_unreachable_ub.rs:17:14
--> $DIR/const_unsafe_unreachable_ub.rs:16:14
|
LL | assert_eq!(BAR, true);
| ^^^ referenced constant has errors
error: erroneous constant used
--> $DIR/const_unsafe_unreachable_ub.rs:17:3
--> $DIR/const_unsafe_unreachable_ub.rs:16:3
|
LL | assert_eq!(BAR, true);
| ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors

View File

@ -3,7 +3,6 @@
// run-pass
#![feature(const_panic)]
#![feature(const_fn)]
const X: u32 = 4;
const Y: u32 = 5;

View File

@ -3,7 +3,7 @@
we're apparently really bad at it",
issue = "none")]
#![feature(const_fn, const_fn_floating_point_arithmetic, foo, foo2)]
#![feature(const_fn_floating_point_arithmetic, foo, foo2)]
#![feature(staged_api)]
#[stable(feature = "rust1", since = "1.0.0")]

View File

@ -3,7 +3,7 @@
we're apparently really bad at it",
issue = "none")]
#![feature(const_fn, const_fn_floating_point_arithmetic, foo, foo2)]
#![feature(const_fn_floating_point_arithmetic, foo, foo2)]
#![feature(staged_api)]
#[stable(feature = "rust1", since = "1.0.0")]
@ -25,7 +25,7 @@ const unsafe fn bar2() -> u32 { unsafe { foo2() } } //~ ERROR not yet stable as
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")]
// conformity is required, even with `const_fn` feature gate
// conformity is required
const unsafe fn bar3() -> u32 { (5f32 + 6f32) as u32 }
//~^ ERROR const-stable function cannot use `#[feature(const_fn_floating_point_arithmetic)]`

View File

@ -3,7 +3,7 @@
we're apparently really bad at it",
issue = "none")]
#![feature(const_fn, foo, foo2)]
#![feature(foo, foo2)]
#![feature(staged_api)]
#[stable(feature = "rust1", since = "1.0.0")]

View File

@ -1,7 +1,7 @@
// ignore-tidy-linelength
// Test various things that we do not want to promote.
#![allow(unconditional_panic, const_err)]
#![feature(const_fn, const_fn_union)]
#![feature(const_fn_union)]
use std::cell::Cell;

View File

@ -1,4 +1,4 @@
#![feature(rustc_attrs, const_fn)]
#![feature(rustc_attrs)]
#[rustc_args_required_const(0)]
fn foo(_a: i32) {

View File

@ -1,6 +1,6 @@
#![stable(feature = "core", since = "1.6.0")]
#![feature(staged_api)]
#![feature(const_precise_live_drops, const_fn)]
#![feature(const_precise_live_drops)]
enum Either<T, S> {
Left(T),

View File

@ -5,7 +5,6 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl)]
#![feature(const_fn)]
struct NonConstAdd(i32);

View File

@ -1,6 +1,5 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl)]
#![feature(const_fn)]
pub trait Plus {
fn plus(self, rhs: Self) -> Self;

View File

@ -1,5 +1,5 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
--> $DIR/call-const-trait-method-fail.rs:26:5
--> $DIR/call-const-trait-method-fail.rs:25:5
|
LL | a.plus(b)
| ^^^^^^^^^

View File

@ -2,7 +2,6 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl)]
#![feature(const_fn)]
struct Int(i32);

View File

@ -1,4 +1,4 @@
#![feature(const_fn)]
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]
#![feature(const_trait_bound_opt_out)]
#![allow(incomplete_features)]

View File

@ -1,6 +1,6 @@
// check-pass
#![feature(const_fn)]
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]
#![feature(const_trait_bound_opt_out)]
#![allow(incomplete_features)]

View File

@ -1,7 +1,6 @@
// FIXME(jschievink): this is not rejected correctly (only when the non-const impl is actually used)
// ignore-test
#![feature(const_fn)]
#![feature(const_trait_impl)]
#![allow(incomplete_features)]

View File

@ -4,7 +4,7 @@
#![cfg_attr(gated, feature(const_trait_bound_opt_out))]
#![allow(incomplete_features)]
#![feature(rustc_attrs)]
#![feature(const_fn)]
#![feature(const_fn_trait_bound)]
trait T {
const CONST: i32;

View File

@ -1,6 +1,6 @@
// Regression test for #69615.
#![feature(const_trait_impl, const_fn)]
#![feature(const_trait_impl)]
#![allow(incomplete_features)]
pub trait MyTrait {