From 8f1df30d06072f03407654b1cde11a1a067bdfad Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Fri, 10 Jan 2020 16:12:26 -0800 Subject: [PATCH 1/4] Only require `allow_internal_unstable` for stable `const fn` --- .../transform/qualify_min_const_fn.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs index fcdabb29cd0e2..74b21435eaee4 100644 --- a/src/librustc_mir/transform/qualify_min_const_fn.rs +++ b/src/librustc_mir/transform/qualify_min_const_fn.rs @@ -281,8 +281,21 @@ fn check_place( Ok(()) } -/// Returns whether `allow_internal_unstable(..., , ...)` is present. +/// Returns `true` if the given feature gate is allowed within the function with the given `DefId`. fn feature_allowed(tcx: TyCtxt<'tcx>, def_id: DefId, feature_gate: Symbol) -> bool { + // All features require that the corresponding gate be enabled. + if !tcx.features().enabled(feature_gate) { + return false; + } + + // If this crate is not using stability attributes, or this function is not claiming to be a + // stable `const fn`, that is all that is required. + if !tcx.features().staged_api || tcx.has_attr(def_id, sym::rustc_const_unstable) { + return true; + } + + // However, we cannot allow stable `const fn`s to use unstable features without an explicit + // opt-in via `allow_internal_unstable`. attr::allow_internal_unstable(&tcx.get_attrs(def_id), &tcx.sess.diagnostic()) .map_or(false, |mut features| features.any(|name| name == feature_gate)) } From 09b5c854de112120a6cf4298eb9c96549995b1b0 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Fri, 10 Jan 2020 17:40:57 -0800 Subject: [PATCH 2/4] Remove unnecessary `const_fn` feature gates This flag opts out of the min-const-fn checks entirely, which is usually not what we want. The few cases where the flag is still necessary have been annotated. --- src/libcore/lib.rs | 1 - src/libcore/tests/lib.rs | 1 - src/libproc_macro/lib.rs | 1 - src/librustc/lib.rs | 1 - src/librustc_hir/lib.rs | 2 +- src/librustc_mir/lib.rs | 1 - src/librustc_span/lib.rs | 1 - src/librustdoc/lib.rs | 1 - src/libsyntax/lib.rs | 2 +- .../consts/const-mut-refs/const_mut_refs.rs | 1 - .../exhaustive-c-like-enum-match.rs | 1 - ...eature-gate-const-if-match.if_match.stderr | 2 +- .../feature-gate-const-if-match.rs | 1 - .../feature-gate-const-if-match.stock.stderr | 50 +++++++++---------- .../consts/control-flow/short-circuit-let.rs | 1 - .../control-flow/single_variant_match_ice.rs | 2 +- 16 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 6f1d69821f56c..6c4956663841c 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -70,7 +70,6 @@ #![feature(bound_cloned)] #![feature(cfg_target_has_atomic)] #![feature(concat_idents)] -#![feature(const_fn)] #![feature(const_if_match)] #![feature(const_panic)] #![feature(const_fn_union)] diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 39f6133f2a689..1b9c7e35f416d 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -31,7 +31,6 @@ #![feature(slice_internals)] #![feature(slice_partition_dedup)] #![feature(int_error_matching)] -#![feature(const_fn)] #![feature(array_value_iter)] #![feature(iter_partition_in_place)] #![feature(iter_is_partitioned)] diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 0b74a104da44b..c51db695a5b15 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -21,7 +21,6 @@ #![feature(nll)] #![feature(staged_api)] #![feature(allow_internal_unstable)] -#![feature(const_fn)] #![feature(decl_macro)] #![feature(extern_types)] #![feature(in_band_lifetimes)] diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index cf424ffe7b293..3c0160a04527e 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -31,7 +31,6 @@ #![feature(bool_to_option)] #![feature(box_patterns)] #![feature(box_syntax)] -#![feature(const_fn)] #![feature(const_transmute)] #![feature(core_intrinsics)] #![feature(drain_filter)] diff --git a/src/librustc_hir/lib.rs b/src/librustc_hir/lib.rs index 66494d0fa736c..f54fa291bd6e8 100644 --- a/src/librustc_hir/lib.rs +++ b/src/librustc_hir/lib.rs @@ -3,7 +3,7 @@ //! [rustc guide]: https://rust-lang.github.io/rustc-guide/hir.html #![feature(crate_visibility_modifier)] -#![feature(const_fn)] +#![feature(const_fn)] // For the unsizing cast on `&[]` #![feature(in_band_lifetimes)] #![feature(specialization)] #![recursion_limit = "256"] diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 36c6568029d5f..d2565bf9c63d4 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -13,7 +13,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![feature(box_syntax)] #![feature(crate_visibility_modifier)] #![feature(core_intrinsics)] -#![feature(const_fn)] #![feature(decl_macro)] #![feature(drain_filter)] #![feature(exhaustive_patterns)] diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs index 8cca59df33846..1dc7fc5aa3ad1 100644 --- a/src/librustc_span/lib.rs +++ b/src/librustc_span/lib.rs @@ -5,7 +5,6 @@ //! This API is completely unstable and subject to change. #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] -#![feature(const_fn)] #![feature(crate_visibility_modifier)] #![feature(nll)] #![feature(optin_builtin_traits)] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 91150899877fe..22fcbde43663f 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -12,7 +12,6 @@ #![feature(test)] #![feature(ptr_offset_from)] #![feature(crate_visibility_modifier)] -#![feature(const_fn)] #![feature(drain_filter)] #![feature(never_type)] #![feature(unicode_internals)] diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index b197eab739427..d67a7ba3413f5 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -7,7 +7,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] #![feature(bool_to_option)] #![feature(box_syntax)] -#![feature(const_fn)] +#![feature(const_fn)] // For the `transmute` in `P::new` #![feature(const_transmute)] #![feature(crate_visibility_modifier)] #![feature(label_break_value)] diff --git a/src/test/ui/consts/const-mut-refs/const_mut_refs.rs b/src/test/ui/consts/const-mut-refs/const_mut_refs.rs index 33abfec02a87a..99006a20b1bcb 100644 --- a/src/test/ui/consts/const-mut-refs/const_mut_refs.rs +++ b/src/test/ui/consts/const-mut-refs/const_mut_refs.rs @@ -1,7 +1,6 @@ // run-pass #![feature(const_mut_refs)] -#![feature(const_fn)] struct Foo { x: usize diff --git a/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs b/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs index 7887fd12e5764..6bbbdd972a26c 100644 --- a/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs +++ b/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs @@ -3,7 +3,6 @@ // check-pass #![feature(const_if_match)] -#![feature(const_fn)] enum E { A, diff --git a/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr b/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr index 95096723b3c95..21e3f2af15ad6 100644 --- a/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr +++ b/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr @@ -1,5 +1,5 @@ error: fatal error triggered by #[rustc_error] - --> $DIR/feature-gate-const-if-match.rs:109:1 + --> $DIR/feature-gate-const-if-match.rs:108:1 | LL | / fn main() { LL | | let _ = [0; { diff --git a/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs b/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs index e4b65257531fd..00576d50ac66b 100644 --- a/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs +++ b/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs @@ -6,7 +6,6 @@ #![feature(rustc_attrs)] #![cfg_attr(if_match, feature(const_if_match))] -#![feature(const_fn)] const _: i32 = if true { //[stock]~ ERROR `if` is not allowed in a `const` 5 diff --git a/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr b/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr index e846ee4ab6a41..d3c6a51923ffb 100644 --- a/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr +++ b/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr @@ -1,5 +1,5 @@ error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:11:16 + --> $DIR/feature-gate-const-if-match.rs:10:16 | LL | const _: i32 = if true { | ________________^ @@ -13,7 +13,7 @@ LL | | }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:17:16 + --> $DIR/feature-gate-const-if-match.rs:16:16 | LL | const _: i32 = if let Some(true) = Some(false) { | ________________^ @@ -27,7 +27,7 @@ LL | | }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:23:16 + --> $DIR/feature-gate-const-if-match.rs:22:16 | LL | const _: i32 = match 1 { | ________________^ @@ -41,7 +41,7 @@ LL | | }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `static` - --> $DIR/feature-gate-const-if-match.rs:30:13 + --> $DIR/feature-gate-const-if-match.rs:29:13 | LL | let x = if true { 0 } else { 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | let x = if true { 0 } else { 1 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `static` - --> $DIR/feature-gate-const-if-match.rs:32:13 + --> $DIR/feature-gate-const-if-match.rs:31:13 | LL | let x = match x { 0 => 1, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | let x = match x { 0 => 1, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `static` - --> $DIR/feature-gate-const-if-match.rs:34:5 + --> $DIR/feature-gate-const-if-match.rs:33:5 | LL | if let Some(x) = Some(x) { x } else { 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | if let Some(x) = Some(x) { x } else { 1 } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `static mut` - --> $DIR/feature-gate-const-if-match.rs:39:13 + --> $DIR/feature-gate-const-if-match.rs:38:13 | LL | let x = if true { 0 } else { 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -77,7 +77,7 @@ LL | let x = if true { 0 } else { 1 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `static mut` - --> $DIR/feature-gate-const-if-match.rs:41:13 + --> $DIR/feature-gate-const-if-match.rs:40:13 | LL | let x = match x { 0 => 1, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -86,7 +86,7 @@ LL | let x = match x { 0 => 1, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `static mut` - --> $DIR/feature-gate-const-if-match.rs:43:5 + --> $DIR/feature-gate-const-if-match.rs:42:5 | LL | if let Some(x) = Some(x) { x } else { 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,7 +95,7 @@ LL | if let Some(x) = Some(x) { x } else { 1 } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:48:5 + --> $DIR/feature-gate-const-if-match.rs:47:5 | LL | if true { 5 } else { 6 } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -104,7 +104,7 @@ LL | if true { 5 } else { 6 } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:52:5 + --> $DIR/feature-gate-const-if-match.rs:51:5 | LL | / if let Some(true) = a { LL | | 0 @@ -117,7 +117,7 @@ LL | | } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:60:5 + --> $DIR/feature-gate-const-if-match.rs:59:5 | LL | / match i { LL | | i if i > 10 => i, @@ -130,7 +130,7 @@ LL | | } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:91:17 + --> $DIR/feature-gate-const-if-match.rs:90:17 | LL | let x = if y { 0 } else { 1 }; | ^^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL | let x = if y { 0 } else { 1 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:93:17 + --> $DIR/feature-gate-const-if-match.rs:92:17 | LL | let x = match x { 0 => 1, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -148,7 +148,7 @@ LL | let x = match x { 0 => 1, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:95:9 + --> $DIR/feature-gate-const-if-match.rs:94:9 | LL | if let Some(x) = Some(x) { x } else { 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | if let Some(x) = Some(x) { x } else { 1 } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:111:17 + --> $DIR/feature-gate-const-if-match.rs:110:17 | LL | let x = if false { 0 } else { 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | let x = if false { 0 } else { 1 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:113:17 + --> $DIR/feature-gate-const-if-match.rs:112:17 | LL | let x = match x { 0 => 1, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -175,7 +175,7 @@ LL | let x = match x { 0 => 1, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:115:9 + --> $DIR/feature-gate-const-if-match.rs:114:9 | LL | if let Some(x) = Some(x) { x } else { 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -184,7 +184,7 @@ LL | if let Some(x) = Some(x) { x } else { 1 } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:68:21 + --> $DIR/feature-gate-const-if-match.rs:67:21 | LL | const IF: i32 = if true { 5 } else { 6 }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL | const IF: i32 = if true { 5 } else { 6 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:71:25 + --> $DIR/feature-gate-const-if-match.rs:70:25 | LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -202,7 +202,7 @@ LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:74:24 + --> $DIR/feature-gate-const-if-match.rs:73:24 | LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -211,7 +211,7 @@ LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:79:21 + --> $DIR/feature-gate-const-if-match.rs:78:21 | LL | const IF: i32 = if true { 5 } else { 6 }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -220,7 +220,7 @@ LL | const IF: i32 = if true { 5 } else { 6 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:82:25 + --> $DIR/feature-gate-const-if-match.rs:81:25 | LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -229,7 +229,7 @@ LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:85:24 + --> $DIR/feature-gate-const-if-match.rs:84:24 | LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -238,7 +238,7 @@ LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0019]: constant contains unimplemented expression type - --> $DIR/feature-gate-const-if-match.rs:115:21 + --> $DIR/feature-gate-const-if-match.rs:114:21 | LL | if let Some(x) = Some(x) { x } else { 1 } | ^ diff --git a/src/test/ui/consts/control-flow/short-circuit-let.rs b/src/test/ui/consts/control-flow/short-circuit-let.rs index 4b20a2124c356..8cee2a54f56d3 100644 --- a/src/test/ui/consts/control-flow/short-circuit-let.rs +++ b/src/test/ui/consts/control-flow/short-circuit-let.rs @@ -4,7 +4,6 @@ #![feature(const_if_match)] #![feature(const_panic)] -#![feature(const_fn)] const X: i32 = { let mut x = 0; diff --git a/src/test/ui/consts/control-flow/single_variant_match_ice.rs b/src/test/ui/consts/control-flow/single_variant_match_ice.rs index bb0fce66c4d89..823605ff034f1 100644 --- a/src/test/ui/consts/control-flow/single_variant_match_ice.rs +++ b/src/test/ui/consts/control-flow/single_variant_match_ice.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(const_if_match, const_fn)] +#![feature(const_if_match)] enum Foo { Prob, From 1d418a11913888585d04a322178db28d01300840 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Fri, 10 Jan 2020 18:48:52 -0800 Subject: [PATCH 3/4] Test that stable `const fn` requires `allow_internal_unstable` --- src/test/ui/internal/internal-unstable-const.rs | 10 ++++++++++ src/test/ui/internal/internal-unstable-const.stderr | 12 ++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/test/ui/internal/internal-unstable-const.rs create mode 100644 src/test/ui/internal/internal-unstable-const.stderr diff --git a/src/test/ui/internal/internal-unstable-const.rs b/src/test/ui/internal/internal-unstable-const.rs new file mode 100644 index 0000000000000..ce306c845175a --- /dev/null +++ b/src/test/ui/internal/internal-unstable-const.rs @@ -0,0 +1,10 @@ +#![feature(staged_api)] +#![feature(const_if_match)] + +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_stable(feature = "rust1", since = "1.0.0")] +const fn foo() -> i32 { + if true { 4 } else { 5 } //~ loops and conditional expressions are not stable in const fn +} + +fn main() {} diff --git a/src/test/ui/internal/internal-unstable-const.stderr b/src/test/ui/internal/internal-unstable-const.stderr new file mode 100644 index 0000000000000..58bbe798b00b6 --- /dev/null +++ b/src/test/ui/internal/internal-unstable-const.stderr @@ -0,0 +1,12 @@ +error[E0723]: loops and conditional expressions are not stable in const fn + --> $DIR/internal-unstable-const.rs:7:5 + | +LL | if true { 4 } else { 5 } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 + = help: add `#![feature(const_fn)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0723`. From fc30825c8b22d93419a087fcec1817108d9b694b Mon Sep 17 00:00:00 2001 From: ecstatic-morse Date: Fri, 10 Jan 2020 19:29:16 -0800 Subject: [PATCH 4/4] Expand comment Co-Authored-By: Mazdak Farrokhzad --- src/librustc_mir/transform/qualify_min_const_fn.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs index 74b21435eaee4..c2c1625001d0f 100644 --- a/src/librustc_mir/transform/qualify_min_const_fn.rs +++ b/src/librustc_mir/transform/qualify_min_const_fn.rs @@ -283,7 +283,8 @@ fn check_place( /// Returns `true` if the given feature gate is allowed within the function with the given `DefId`. fn feature_allowed(tcx: TyCtxt<'tcx>, def_id: DefId, feature_gate: Symbol) -> bool { - // All features require that the corresponding gate be enabled. + // All features require that the corresponding gate be enabled, + // even if the function has `#[allow_internal_unstable(the_gate)]`. if !tcx.features().enabled(feature_gate) { return false; }