1
Fork 0

Auto merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obk

further split up const_fn feature flag

This continues the work on splitting up `const_fn` into separate feature flags:
* `const_fn_trait_bound` for `const fn` with trait bounds
* `const_fn_unsize` for unsizing coercions in `const fn` (looks like only `dyn` unsizing is still guarded here)

I don't know if there are even any things left that `const_fn` guards... at least libcore and liballoc do not need it any more.

`@oli-obk` are you currently able to do reviews?
This commit is contained in:
bors 2021-04-24 23:16:03 +00:00
commit b56b175c6c
37 changed files with 176 additions and 114 deletions

View file

@ -10,7 +10,8 @@
)] )]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(const_fn)] // For the `transmute` in `P::new` #![cfg_attr(bootstrap, feature(const_fn))] // For the `transmute` in `P::new`
#![cfg_attr(not(bootstrap), feature(const_fn_unsize))] // For the `transmute` in `P::new`
#![feature(const_fn_transmute)] #![feature(const_fn_transmute)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]

View file

@ -416,7 +416,6 @@ E0716: include_str!("./error_codes/E0716.md"),
E0718: include_str!("./error_codes/E0718.md"), E0718: include_str!("./error_codes/E0718.md"),
E0719: include_str!("./error_codes/E0719.md"), E0719: include_str!("./error_codes/E0719.md"),
E0720: include_str!("./error_codes/E0720.md"), E0720: include_str!("./error_codes/E0720.md"),
E0723: include_str!("./error_codes/E0723.md"),
E0724: include_str!("./error_codes/E0724.md"), E0724: include_str!("./error_codes/E0724.md"),
E0725: include_str!("./error_codes/E0725.md"), E0725: include_str!("./error_codes/E0725.md"),
E0727: include_str!("./error_codes/E0727.md"), E0727: include_str!("./error_codes/E0727.md"),
@ -636,6 +635,7 @@ E0781: include_str!("./error_codes/E0781.md"),
E0717, // rustc_promotable without stability attribute E0717, // rustc_promotable without stability attribute
// E0721, // `await` keyword // E0721, // `await` keyword
E0722, // Malformed `#[optimize]` attribute E0722, // Malformed `#[optimize]` attribute
// E0723, unstable feature in `const` context
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`. // E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
E0757, // `#[ffi_const]` functions cannot be `#[ffi_pure]` E0757, // `#[ffi_const]` functions cannot be `#[ffi_pure]`

View file

@ -1,20 +0,0 @@
An unstable feature in `const` contexts was used.
Erroneous code example:
```compile_fail,E0723
const fn foo<T: Copy>(_: T) { // error!
// ...
}
```
To enable this feature on a nightly version of rustc, add the `const_fn`
feature flag:
```
#![feature(const_fn)]
const fn foo<T: Copy>(_: T) { // ok!
// ...
}
```

View file

@ -645,6 +645,12 @@ declare_features! (
/// Allows `extern "wasm" fn` /// Allows `extern "wasm" fn`
(active, wasm_abi, "1.53.0", Some(83788), None), (active, wasm_abi, "1.53.0", Some(83788), None),
/// Allows trait bounds in `const fn`.
(active, const_fn_trait_bound, "1.53.0", Some(57563), None),
/// Allows unsizing coercions in `const fn`.
(active, const_fn_unsize, "1.53.0", Some(64992), None),
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// feature-group-end: actual feature gates // feature-group-end: actual feature gates
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View file

@ -3,7 +3,6 @@
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(const_fn)] // For the unsizing cast on `&[]`
#![feature(const_panic)] #![feature(const_panic)]
#![feature(extended_key_value_attributes)] #![feature(extended_key_value_attributes)]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]

View file

@ -1,5 +1,4 @@
#![feature(allow_internal_unstable)] #![feature(allow_internal_unstable)]
#![feature(const_fn)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(extend_one)] #![feature(extend_one)]
#![feature(iter_zip)] #![feature(iter_zip)]

View file

@ -16,7 +16,6 @@
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(const_fn)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(extend_one)] #![feature(extend_one)]
#![feature(iter_zip)] #![feature(iter_zip)]

View file

@ -29,7 +29,6 @@
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(const_fn)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(discriminant_kind)] #![feature(discriminant_kind)]

View file

@ -12,7 +12,6 @@ Rust MIR: a lowered representation of Rust.
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(const_fn)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(decl_macro)] #![feature(decl_macro)]

View file

@ -540,12 +540,17 @@ impl NonConstOp for UnionAccess {
pub struct UnsizingCast; pub struct UnsizingCast;
impl NonConstOp for UnsizingCast { impl NonConstOp for UnsizingCast {
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status { fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
mcf_status_in_item(ccx) if ccx.const_kind() != hir::ConstContext::ConstFn {
Status::Allowed
} else {
Status::Unstable(sym::const_fn_unsize)
}
} }
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
mcf_build_error( feature_err(
ccx, &ccx.tcx.sess.parse_sess,
sym::const_fn_unsize,
span, span,
"unsizing casts to types besides slices are not allowed in const fn", "unsizing casts to types besides slices are not allowed in const fn",
) )
@ -642,12 +647,17 @@ pub mod ty {
} }
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status { fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
mcf_status_in_item(ccx) if ccx.const_kind() != hir::ConstContext::ConstFn {
Status::Allowed
} else {
Status::Unstable(sym::const_fn_trait_bound)
}
} }
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
mcf_build_error( feature_err(
ccx, &ccx.tcx.sess.parse_sess,
sym::const_fn_trait_bound,
span, span,
"trait bounds other than `Sized` on const fn parameters are unstable", "trait bounds other than `Sized` on const fn parameters are unstable",
) )
@ -672,21 +682,3 @@ pub mod ty {
} }
} }
} }
fn mcf_status_in_item(ccx: &ConstCx<'_, '_>) -> Status {
if ccx.const_kind() != hir::ConstContext::ConstFn {
Status::Allowed
} else {
Status::Unstable(sym::const_fn)
}
}
fn mcf_build_error(ccx: &ConstCx<'_, 'tcx>, span: Span, msg: &str) -> DiagnosticBuilder<'tcx> {
let mut err = struct_span_err!(ccx.tcx.sess, span, E0723, "{}", msg);
err.note(
"see issue #57563 <https://github.com/rust-lang/rust/issues/57563> \
for more information",
);
err.help("add `#![feature(const_fn)]` to the crate attributes to enable");
err
}

View file

@ -1,6 +1,6 @@
//! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations. //! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorReported}; use rustc_errors::{Applicability, Diagnostic, ErrorReported};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::{self as hir, HirId, LangItem}; use rustc_hir::{self as hir, HirId, LangItem};
use rustc_index::bit_set::BitSet; use rustc_index::bit_set::BitSet;
@ -234,13 +234,11 @@ impl Validator<'mir, 'tcx> {
if self.is_const_stable_const_fn() { if self.is_const_stable_const_fn() {
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
if crate::const_eval::is_parent_const_impl_raw(tcx, hir_id) { if crate::const_eval::is_parent_const_impl_raw(tcx, hir_id) {
struct_span_err!( self.ccx
self.ccx.tcx.sess, .tcx
self.span, .sess
E0723, .struct_span_err(self.span, "trait methods cannot be stable const fn")
"trait methods cannot be stable const fn" .emit();
)
.emit();
} }
} }

View file

@ -4,7 +4,6 @@
#![feature(array_windows)] #![feature(array_windows)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(const_fn)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(control_flow_enum)] #![feature(control_flow_enum)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]

View file

@ -5,7 +5,6 @@
//! This API is completely unstable and subject to change. //! This API is completely unstable and subject to change.
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(const_fn)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]

View file

@ -1,5 +1,4 @@
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(const_fn)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(drain_filter)] #![feature(drain_filter)]

View file

@ -16,7 +16,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(array_windows)] #![feature(array_windows)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(const_fn)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(nll)] #![feature(nll)]

View file

@ -382,8 +382,10 @@ symbols! {
const_fn, const_fn,
const_fn_floating_point_arithmetic, const_fn_floating_point_arithmetic,
const_fn_fn_ptr_basics, const_fn_fn_ptr_basics,
const_fn_trait_bound,
const_fn_transmute, const_fn_transmute,
const_fn_union, const_fn_union,
const_fn_unsize,
const_generic_defaults, const_generic_defaults,
const_generics, const_generics,
const_generics_defaults, const_generics_defaults,

View file

@ -9,7 +9,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(const_fn)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(nll)] #![feature(nll)]
#![feature(never_type)] #![feature(never_type)]

View file

@ -89,7 +89,8 @@
#![feature(cfg_target_has_atomic)] #![feature(cfg_target_has_atomic)]
#![feature(coerce_unsized)] #![feature(coerce_unsized)]
#![feature(const_btree_new)] #![feature(const_btree_new)]
#![feature(const_fn)] #![cfg_attr(bootstrap, feature(const_fn))]
#![cfg_attr(not(bootstrap), feature(const_fn_trait_bound))]
#![feature(cow_is_borrowed)] #![feature(cow_is_borrowed)]
#![feature(const_cow_is_borrowed)] #![feature(const_cow_is_borrowed)]
#![feature(destructuring_assignment)] #![feature(destructuring_assignment)]

View file

@ -81,11 +81,12 @@
#![feature(const_refs_to_cell)] #![feature(const_refs_to_cell)]
#![feature(const_panic)] #![feature(const_panic)]
#![feature(const_pin)] #![feature(const_pin)]
#![feature(const_fn)] #![cfg_attr(bootstrap, feature(const_fn))]
#![feature(const_fn_union)] #![feature(const_fn_union)]
#![feature(const_impl_trait)] #![feature(const_impl_trait)]
#![feature(const_fn_floating_point_arithmetic)] #![feature(const_fn_floating_point_arithmetic)]
#![feature(const_fn_fn_ptr_basics)] #![feature(const_fn_fn_ptr_basics)]
#![cfg_attr(not(bootstrap), feature(const_fn_trait_bound))]
#![feature(const_option)] #![feature(const_option)]
#![feature(const_precise_live_drops)] #![feature(const_precise_live_drops)]
#![feature(const_ptr_offset)] #![feature(const_ptr_offset)]

View file

@ -12,7 +12,7 @@ RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST/stage2/bin/rustc --edition=2018 \
# Download and build a single-file stress test benchmark on perf.rust-lang.org. # Download and build a single-file stress test benchmark on perf.rust-lang.org.
function pgo_perf_benchmark { function pgo_perf_benchmark {
local PERF=e095f5021bf01cf3800f50b3a9f14a9683eb3e4e local PERF=9442def56a39d742bf27ebcc3e0614cf117e1bc2
local github_prefix=https://raw.githubusercontent.com/rust-lang/rustc-perf/$PERF local github_prefix=https://raw.githubusercontent.com/rust-lang/rustc-perf/$PERF
local name=$1 local name=$1
curl -o /tmp/$name.rs $github_prefix/collector/benchmarks/$name/src/lib.rs curl -o /tmp/$name.rs $github_prefix/collector/benchmarks/$name/src/lib.rs

View file

@ -1,7 +1,7 @@
// issue-49296: Unsafe shenigans in constants can result in missing errors // issue-49296: Unsafe shenigans in constants can result in missing errors
#![feature(const_fn)]
#![feature(const_fn_union)] #![feature(const_fn_union)]
#![feature(const_fn_trait_bound)]
const unsafe fn transmute<T: Copy, U: Copy>(t: T) -> U { const unsafe fn transmute<T: Copy, U: Copy>(t: T) -> U {
#[repr(C)] #[repr(C)]

View file

@ -3,7 +3,8 @@
// A very basic test of const fn functionality. // A very basic test of const fn functionality.
#![feature(const_fn, const_indexing)] #![feature(const_indexing)]
#![feature(const_fn_trait_bound)]
const fn add(x: u32, y: u32) -> u32 { const fn add(x: u32, y: u32) -> u32 {
x + y x + y

View file

@ -0,0 +1,8 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/const_fn_trait_bound.rs:17:1
|
LL | fn main() {}
| ^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,17 @@
// gate-test-const_fn_trait_bound
// revisions: stock gated
#![feature(rustc_attrs)]
#![cfg_attr(gated, feature(const_fn_trait_bound))]
const fn test1<T: std::ops::Add>() {}
//[stock]~^ trait bounds
const fn test2(_x: &dyn Send) {}
//[stock]~^ trait bounds
const fn test3() -> &'static dyn Send { loop {} }
//[stock]~^ trait bounds
#[rustc_error]
fn main() {} //[gated]~ fatal error triggered by #[rustc_error]

View file

@ -0,0 +1,30 @@
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/const_fn_trait_bound.rs:8:16
|
LL | const fn test1<T: std::ops::Add>() {}
| ^
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/const_fn_trait_bound.rs:10:16
|
LL | const fn test2(_x: &dyn Send) {}
| ^^
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/const_fn_trait_bound.rs:12:21
|
LL | const fn test3() -> &'static dyn Send { loop {} }
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -0,0 +1,8 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/const_fn_unsize.rs:16:1
|
LL | fn main() {}
| ^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,16 @@
// gate-test-const_fn_unsize
// revisions: stock gated
#![feature(rustc_attrs)]
#![cfg_attr(gated, feature(const_fn_unsize))]
use std::ptr::NonNull;
const fn test() {
let _x = NonNull::<[i32; 0]>::dangling() as NonNull<[i32]>;
//[stock]~^ unsizing cast
}
#[rustc_error]
fn main() {} //[gated]~ fatal error triggered by #[rustc_error]

View file

@ -0,0 +1,12 @@
error[E0658]: unsizing casts to types besides slices are not allowed in const fn
--> $DIR/const_fn_unsize.rs:11:14
|
LL | let _x = NonNull::<[i32; 0]>::dangling() as NonNull<[i32]>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #64992 <https://github.com/rust-lang/rust/issues/64992> for more information
= help: add `#![feature(const_fn_unsize)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View file

@ -130,23 +130,23 @@ LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 }
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:84:16 --> $DIR/min_const_fn.rs:84:16
| |
LL | const fn foo11<T: std::fmt::Display>(t: T) -> T { t } LL | const fn foo11<T: std::fmt::Display>(t: T) -> T { t }
| ^ | ^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = 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 = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:86:18 --> $DIR/min_const_fn.rs:86:18
| |
LL | const fn foo11_2<T: Send>(t: T) -> T { t } LL | const fn foo11_2<T: Send>(t: T) -> T { t }
| ^ | ^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = 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 = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0013]: constant functions cannot refer to statics error[E0013]: constant functions cannot refer to statics
--> $DIR/min_const_fn.rs:90:27 --> $DIR/min_const_fn.rs:90:27
@ -209,41 +209,41 @@ LL | const fn inc(x: &mut i32) { *x += 1 }
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:110:6 --> $DIR/min_const_fn.rs:110:6
| |
LL | impl<T: std::fmt::Debug> Foo<T> { LL | impl<T: std::fmt::Debug> Foo<T> {
| ^ | ^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = 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 = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:115:6 --> $DIR/min_const_fn.rs:115:6
| |
LL | impl<T: std::fmt::Debug + Sized> Foo<T> { LL | impl<T: std::fmt::Debug + Sized> Foo<T> {
| ^ | ^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = 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 = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:120:6 --> $DIR/min_const_fn.rs:120:6
| |
LL | impl<T: Sync + Sized> Foo<T> { LL | impl<T: Sync + Sized> Foo<T> {
| ^ | ^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = 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 = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:126:34 --> $DIR/min_const_fn.rs:126:34
| |
LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {} LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = 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 = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/min_const_fn.rs:126:19 --> $DIR/min_const_fn.rs:126:19
@ -253,14 +253,14 @@ LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {}
| | | |
| constant functions cannot evaluate destructors | constant functions cannot evaluate destructors
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:129:22 --> $DIR/min_const_fn.rs:129:22
| |
LL | const fn no_apit(_x: impl std::fmt::Debug) {} LL | const fn no_apit(_x: impl std::fmt::Debug) {}
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = 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 = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/min_const_fn.rs:129:18 --> $DIR/min_const_fn.rs:129:18
@ -270,50 +270,50 @@ LL | const fn no_apit(_x: impl std::fmt::Debug) {}
| | | |
| constant functions cannot evaluate destructors | constant functions cannot evaluate destructors
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:132:23 --> $DIR/min_const_fn.rs:132:23
| |
LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {}
| ^^ | ^^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = 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 = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:134:32 --> $DIR/min_const_fn.rs:134:32
| |
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = 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 = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0723]: unsizing casts to types besides slices are not allowed in const fn error[E0658]: unsizing casts to types besides slices are not allowed in const fn
--> $DIR/min_const_fn.rs:134:63 --> $DIR/min_const_fn.rs:134:63
| |
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| ^^^ | ^^^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = note: see issue #64992 <https://github.com/rust-lang/rust/issues/64992> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn_unsize)]` to the crate attributes to enable
error[E0723]: unsizing casts to types besides slices are not allowed in const fn error[E0658]: unsizing casts to types besides slices are not allowed in const fn
--> $DIR/min_const_fn.rs:134:63 --> $DIR/min_const_fn.rs:134:63
| |
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| ^^^ | ^^^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = note: see issue #64992 <https://github.com/rust-lang/rust/issues/64992> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn_unsize)]` to the crate attributes to enable
error[E0723]: unsizing casts to types besides slices are not allowed in const fn error[E0658]: unsizing casts to types besides slices are not allowed in const fn
--> $DIR/min_const_fn.rs:141:42 --> $DIR/min_const_fn.rs:141:42
| |
LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 }
| ^^^ | ^^^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = note: see issue #64992 <https://github.com/rust-lang/rust/issues/64992> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn_unsize)]` to the crate attributes to enable
error[E0658]: function pointers cannot appear in constant functions error[E0658]: function pointers cannot appear in constant functions
--> $DIR/min_const_fn.rs:144:21 --> $DIR/min_const_fn.rs:144:21
@ -344,5 +344,5 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
error: aborting due to 39 previous errors error: aborting due to 39 previous errors
Some errors have detailed explanations: E0013, E0493, E0658, E0723. Some errors have detailed explanations: E0013, E0493, E0658.
For more information about an error, try `rustc --explain E0013`. For more information about an error, try `rustc --explain E0013`.

View file

@ -1,21 +1,21 @@
error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn_dyn.rs:9:5 --> $DIR/min_const_fn_dyn.rs:9:5
| |
LL | x.0.field; LL | x.0.field;
| ^^^^^^^^^ | ^^^^^^^^^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = 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 = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0723]: unsizing casts to types besides slices are not allowed in const fn error[E0658]: unsizing casts to types besides slices are not allowed in const fn
--> $DIR/min_const_fn_dyn.rs:12:66 --> $DIR/min_const_fn_dyn.rs:12:66
| |
LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
| ^^ | ^^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = note: see issue #64992 <https://github.com/rust-lang/rust/issues/64992> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn_unsize)]` to the crate attributes to enable
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0723`. For more information about this error, try `rustc --explain E0658`.

View file

@ -1,12 +1,12 @@
error[E0723]: unsizing casts to types besides slices are not allowed in const fn error[E0658]: unsizing casts to types besides slices are not allowed in const fn
--> $DIR/unsizing-cast-non-null.rs:6:5 --> $DIR/unsizing-cast-non-null.rs:6:5
| |
LL | NonNull::<[T; 0]>::dangling() LL | NonNull::<[T; 0]>::dangling()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = note: see issue #64992 <https://github.com/rust-lang/rust/issues/64992> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable = help: add `#![feature(const_fn_unsize)]` to the crate attributes to enable
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0723`. For more information about this error, try `rustc --explain E0658`.

View file

@ -6,7 +6,7 @@
#![stable(feature = "core", since = "1.6.0")] #![stable(feature = "core", since = "1.6.0")]
#![feature(rustc_const_unstable)] #![feature(rustc_const_unstable)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(const_fn)] #![feature(const_fn_trait_bound)]
enum Opt<T> { enum Opt<T> {
Some(T), Some(T),

View file

@ -2,8 +2,8 @@
// check-pass // check-pass
#![feature(const_fn)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#![feature(const_fn_trait_bound)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
struct S; struct S;

View file

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

View file

@ -2,8 +2,8 @@
// check-pass // check-pass
#![feature(const_fn)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#![feature(const_fn_trait_bound)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
struct S; struct S;

View file

@ -2,7 +2,7 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
#![feature(const_trait_impl)] #![feature(const_trait_impl)]
#![feature(const_fn)] #![feature(const_fn_trait_bound)]
use std::marker::PhantomData; use std::marker::PhantomData;

View file

@ -1,4 +1,4 @@
error[E0723]: trait methods cannot be stable const fn error: trait methods cannot be stable const fn
--> $DIR/stability.rs:14:5 --> $DIR/stability.rs:14:5
| |
LL | / fn sub(self, rhs: Self) -> Self { LL | / fn sub(self, rhs: Self) -> Self {
@ -17,4 +17,3 @@ LL | Int(1i32) + Int(2i32)
error: aborting due to 2 previous errors error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0723`.