Skip to content

Commit 18587b1

Browse files
committed
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 #84510 r? `@oli-obk`
2 parents 814a560 + 3c4c5eb commit 18587b1

File tree

63 files changed

+85
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+85
-133
lines changed

compiler/rustc_mir/src/transform/check_consts/validation.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl Validator<'mir, 'tcx> {
426426
ty::PredicateKind::Subtype(_) => {
427427
bug!("subtype predicate on function: {:#?}", predicate)
428428
}
429-
ty::PredicateKind::Trait(pred, constness) => {
429+
ty::PredicateKind::Trait(pred, _constness) => {
430430
if Some(pred.def_id()) == tcx.lang_items().sized_trait() {
431431
continue;
432432
}
@@ -440,16 +440,7 @@ impl Validator<'mir, 'tcx> {
440440
// arguments when determining importance.
441441
let kind = LocalKind::Arg;
442442

443-
if constness == hir::Constness::Const {
444-
self.check_op_spanned(ops::ty::TraitBound(kind), span);
445-
} else if !tcx.features().const_fn
446-
|| self.ccx.is_const_stable_const_fn()
447-
{
448-
// HACK: We shouldn't need the conditional above, but trait
449-
// bounds on containing impl blocks are wrongly being marked as
450-
// "not-const".
451-
self.check_op_spanned(ops::ty::TraitBound(kind), span);
452-
}
443+
self.check_op_spanned(ops::ty::TraitBound(kind), span);
453444
}
454445
// other kinds of bounds are either tautologies
455446
// or cause errors in other passes

library/proc_macro/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
#![feature(rustc_allow_const_fn_unstable)]
2222
#![feature(nll)]
2323
#![feature(staged_api)]
24-
#![feature(const_fn)]
24+
#![cfg_attr(bootstrap, feature(const_fn))]
25+
#![cfg_attr(not(bootstrap), feature(const_fn_trait_bound))]
2526
#![feature(const_fn_fn_ptr_basics)]
2627
#![feature(allow_internal_unstable)]
2728
#![feature(decl_macro)]

src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
// run-pass
44

5-
#![feature(const_fn)]
6-
75
#[derive(PartialEq, Debug, Clone)]
86
struct N(u8);
97

src/test/ui/associated-consts/associated-const-in-trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #29924
22

3-
#![feature(const_fn, associated_consts)]
3+
#![feature(associated_consts)]
44

55
trait Trait {
66
const N: usize;

src/test/ui/consts/const-eval/auxiliary/stability.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![crate_type="rlib"]
44
#![stable(feature = "rust1", since = "1.0.0")]
55

6-
#![feature(const_fn)]
76
#![feature(staged_api)]
87

98
#[stable(feature = "rust1", since = "1.0.0")]

src/test/ui/consts/const-eval/const_fn_ptr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// compile-flags: -Zunleash-the-miri-inside-of-you
3-
#![feature(const_fn)]
43

54
fn double(x: usize) -> usize { x * 2 }
65
const fn double_const(x: usize) -> usize { x * 2 }

src/test/ui/consts/const-eval/const_fn_ptr.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
warning: skipping const checks
22
|
33
help: skipping check that does not even have a feature gate
4-
--> $DIR/const_fn_ptr.rs:12:5
4+
--> $DIR/const_fn_ptr.rs:11:5
55
|
66
LL | X(x)
77
| ^^^^
88
help: skipping check that does not even have a feature gate
9-
--> $DIR/const_fn_ptr.rs:16:5
9+
--> $DIR/const_fn_ptr.rs:15:5
1010
|
1111
LL | X_CONST(x)
1212
| ^^^^^^^^^^
1313
help: skipping check for `const_fn_fn_ptr_basics` feature
14-
--> $DIR/const_fn_ptr.rs:19:14
14+
--> $DIR/const_fn_ptr.rs:18:14
1515
|
1616
LL | const fn foo(x: fn(usize) -> usize, y: usize) -> usize {
1717
| ^
1818
help: skipping check for `const_fn_fn_ptr_basics` feature
19-
--> $DIR/const_fn_ptr.rs:20:5
19+
--> $DIR/const_fn_ptr.rs:19:5
2020
|
2121
LL | x(y)
2222
| ^
2323
help: skipping check that does not even have a feature gate
24-
--> $DIR/const_fn_ptr.rs:20:5
24+
--> $DIR/const_fn_ptr.rs:19:5
2525
|
2626
LL | x(y)
2727
| ^^^^

src/test/ui/consts/const-eval/const_fn_ptr_fail.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// compile-flags: -Zunleash-the-miri-inside-of-you
3-
#![feature(const_fn)]
43
#![allow(unused)]
54

65
fn double(x: usize) -> usize { x * 2 }

src/test/ui/consts/const-eval/const_fn_ptr_fail.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
warning: skipping const checks
22
|
33
help: skipping check that does not even have a feature gate
4-
--> $DIR/const_fn_ptr_fail.rs:10:5
4+
--> $DIR/const_fn_ptr_fail.rs:9:5
55
|
66
LL | X(x) // FIXME: this should error someday
77
| ^^^^

src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// build-fail
22
// compile-flags: -Zunleash-the-miri-inside-of-you
33

4-
#![feature(const_fn)]
54
#![allow(const_err)]
65

76
fn double(x: usize) -> usize {

src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error[E0080]: evaluation of constant value failed
2-
--> $DIR/const_fn_ptr_fail2.rs:20:16
2+
--> $DIR/const_fn_ptr_fail2.rs:19:16
33
|
44
LL | assert_eq!(Y, 4);
55
| ^ referenced constant has errors
66

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

1313
warning: skipping const checks
1414
|
1515
help: skipping check for `const_fn_fn_ptr_basics` feature
16-
--> $DIR/const_fn_ptr_fail2.rs:12:14
16+
--> $DIR/const_fn_ptr_fail2.rs:11:14
1717
|
1818
LL | const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
1919
| ^
2020
help: skipping check for `const_fn_fn_ptr_basics` feature
21-
--> $DIR/const_fn_ptr_fail2.rs:13:5
21+
--> $DIR/const_fn_ptr_fail2.rs:12:5
2222
|
2323
LL | x(y)
2424
| ^
2525
help: skipping check that does not even have a feature gate
26-
--> $DIR/const_fn_ptr_fail2.rs:13:5
26+
--> $DIR/const_fn_ptr_fail2.rs:12:5
2727
|
2828
LL | x(y)
2929
| ^^^^

src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
we're apparently really bad at it",
44
issue = "none")]
55

6-
#![feature(const_fn)]
76
#![feature(staged_api)]
87

98
#[stable(feature = "rust1", since = "1.0.0")]

src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: `foo` is not yet stable as a const fn
2-
--> $DIR/dont_promote_unstable_const_fn.rs:15:25
2+
--> $DIR/dont_promote_unstable_const_fn.rs:14:25
33
|
44
LL | const fn bar() -> u32 { foo() }
55
| ^^^^^
66
|
77
= help: add `#![feature(foo)]` to the crate attributes to enable
88

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

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

3030
error[E0716]: temporary value dropped while borrowed
31-
--> $DIR/dont_promote_unstable_const_fn.rs:23:26
31+
--> $DIR/dont_promote_unstable_const_fn.rs:22:26
3232
|
3333
LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
3434
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use

src/test/ui/consts/const-eval/double_promotion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// check-pass
22

3-
#![feature(const_fn, rustc_attrs)]
3+
#![feature(rustc_attrs)]
44

55
#[rustc_args_required_const(0)]
66
pub const fn a(value: u8) -> u8 {

src/test/ui/consts/const-eval/feature-gate-const_fn_union.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(const_fn)]
2-
31
fn main() {}
42

53
#[repr(C)]

src/test/ui/consts/const-eval/feature-gate-const_fn_union.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: unions in const fn are unstable
2-
--> $DIR/feature-gate-const_fn_union.rs:12:5
2+
--> $DIR/feature-gate-const_fn_union.rs:10:5
33
|
44
LL | Foo { u }.i
55
| ^^^^^^^^^^^

src/test/ui/consts/const-eval/promoted_const_fn_fail.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(const_fn, const_fn_union)]
1+
#![feature(const_fn_union)]
22

33
#![allow(const_err)]
44

src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(const_fn, const_fn_union)]
1+
#![feature(const_fn_union)]
22

33
#![deny(const_err)]
44

src/test/ui/consts/const-eval/simd/insert_extract.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-pass
2-
#![feature(const_fn)]
32
#![feature(repr_simd)]
43
#![feature(platform_intrinsics)]
54
#![feature(staged_api)]

src/test/ui/consts/const-eval/union-const-eval-field.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// only-x86_64
2-
#![feature(const_fn)]
32

43
type Field1 = i32;
54
type Field2 = f32;

src/test/ui/consts/const-eval/union-const-eval-field.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: it is undefined behavior to use this value
2-
--> $DIR/union-const-eval-field.rs:29:5
2+
--> $DIR/union-const-eval-field.rs:28:5
33
|
44
LL | const FIELD3: Field3 = unsafe { UNION.field3 };
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes

src/test/ui/consts/const-eval/union-ice.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// only-x86_64
2-
#![feature(const_fn)]
32

43
type Field1 = i32;
54
type Field3 = i64;

src/test/ui/consts/const-eval/union-ice.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: it is undefined behavior to use this value
2-
--> $DIR/union-ice.rs:15:1
2+
--> $DIR/union-ice.rs:14:1
33
|
44
LL | const FIELD3: Field3 = unsafe { UNION.field3 };
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
@@ -10,7 +10,7 @@ LL | const FIELD3: Field3 = unsafe { UNION.field3 };
1010
}
1111

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

2626
error[E0080]: it is undefined behavior to use this value
27-
--> $DIR/union-ice.rs:27:1
27+
--> $DIR/union-ice.rs:26:1
2828
|
2929
LL | / const FIELD_PATH2: Struct2 = Struct2 {
3030
LL | | b: [

src/test/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
warning: any use of this value will cause an error
2-
--> $DIR/validate_uninhabited_zsts.rs:6:14
2+
--> $DIR/validate_uninhabited_zsts.rs:5:14
33
|
44
LL | unsafe { std::mem::transmute(()) }
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
| |
77
| transmuting to uninhabited type
8-
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:6:14
9-
| inside `FOO` at $DIR/validate_uninhabited_zsts.rs:16:26
8+
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14
9+
| inside `FOO` at $DIR/validate_uninhabited_zsts.rs:15:26
1010
...
1111
LL | const FOO: [Empty; 3] = [foo(); 3];
1212
| -----------------------------------
1313
|
1414
note: the lint level is defined here
15-
--> $DIR/validate_uninhabited_zsts.rs:15:8
15+
--> $DIR/validate_uninhabited_zsts.rs:14:8
1616
|
1717
LL | #[warn(const_err)]
1818
| ^^^^^^^^^
1919
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2020
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
2121

2222
error[E0080]: it is undefined behavior to use this value
23-
--> $DIR/validate_uninhabited_zsts.rs:19:1
23+
--> $DIR/validate_uninhabited_zsts.rs:18:1
2424
|
2525
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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];
2929
= note: the raw bytes of the constant (size: 0, align: 1) {}
3030

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

4343
warning: the type `Empty` does not permit zero-initialization
44-
--> $DIR/validate_uninhabited_zsts.rs:19:35
44+
--> $DIR/validate_uninhabited_zsts.rs:18:35
4545
|
4646
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
4747
| ^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
warning: any use of this value will cause an error
2-
--> $DIR/validate_uninhabited_zsts.rs:6:14
2+
--> $DIR/validate_uninhabited_zsts.rs:5:14
33
|
44
LL | unsafe { std::mem::transmute(()) }
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
| |
77
| transmuting to uninhabited type
8-
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:6:14
9-
| inside `FOO` at $DIR/validate_uninhabited_zsts.rs:16:26
8+
| inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14
9+
| inside `FOO` at $DIR/validate_uninhabited_zsts.rs:15:26
1010
...
1111
LL | const FOO: [Empty; 3] = [foo(); 3];
1212
| -----------------------------------
1313
|
1414
note: the lint level is defined here
15-
--> $DIR/validate_uninhabited_zsts.rs:15:8
15+
--> $DIR/validate_uninhabited_zsts.rs:14:8
1616
|
1717
LL | #[warn(const_err)]
1818
| ^^^^^^^^^
1919
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2020
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
2121

2222
error[E0080]: it is undefined behavior to use this value
23-
--> $DIR/validate_uninhabited_zsts.rs:19:1
23+
--> $DIR/validate_uninhabited_zsts.rs:18:1
2424
|
2525
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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];
2929
= note: the raw bytes of the constant (size: 0, align: 1) {}
3030

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

4343
warning: the type `Empty` does not permit zero-initialization
44-
--> $DIR/validate_uninhabited_zsts.rs:19:35
44+
--> $DIR/validate_uninhabited_zsts.rs:18:35
4545
|
4646
LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
4747
| ^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// stderr-per-bitwidth
2-
#![feature(const_fn)]
32
#![feature(const_fn_transmute)]
43

54
const fn foo() -> ! {

src/test/ui/consts/const-fn-error.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(const_fn)]
2-
31
const X : usize = 2;
42

53
const fn f(x: usize) -> usize {

0 commit comments

Comments
 (0)