]> git.lizzy.rs Git - rust.git/commitdiff
Remove `rustc_allow_const_fn_ptr`
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Thu, 24 Sep 2020 23:15:41 +0000 (16:15 -0700)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Sun, 27 Sep 2020 17:46:41 +0000 (10:46 -0700)
This was a hack to work around the lack of an escape hatch for the "min
`const fn`" checks in const-stable functions. Now that we have co-opted
`allow_internal_unstable` for this purpose, we no longer need the
bespoke attribute.

compiler/rustc_attr/src/builtin.rs
compiler/rustc_feature/src/builtin_attrs.rs
compiler/rustc_middle/src/query/mod.rs
compiler/rustc_mir/src/const_eval/fn_queries.rs
compiler/rustc_span/src/symbol.rs
library/core/src/task/wake.rs

index 03dbcc450246f742fbca3d6859f346790b0219db..94e2a40e1fe368ca2da564cb0d568d6d711426e5 100644 (file)
@@ -145,8 +145,6 @@ pub struct ConstStability {
     pub feature: Symbol,
     /// whether the function has a `#[rustc_promotable]` attribute
     pub promotable: bool,
-    /// whether the function has a `#[rustc_allow_const_fn_ptr]` attribute
-    pub allow_const_fn_ptr: bool,
 }
 
 /// The available stability levels.
@@ -190,7 +188,6 @@ fn find_stability_generic<'a, I>(
     let mut stab: Option<Stability> = None;
     let mut const_stab: Option<ConstStability> = None;
     let mut promotable = false;
-    let mut allow_const_fn_ptr = false;
     let diagnostic = &sess.parse_sess.span_diagnostic;
 
     'outer: for attr in attrs_iter {
@@ -200,7 +197,6 @@ fn find_stability_generic<'a, I>(
             sym::unstable,
             sym::stable,
             sym::rustc_promotable,
-            sym::rustc_allow_const_fn_ptr,
         ]
         .iter()
         .any(|&s| attr.has_name(s))
@@ -215,9 +211,6 @@ fn find_stability_generic<'a, I>(
         if attr.has_name(sym::rustc_promotable) {
             promotable = true;
         }
-        if attr.has_name(sym::rustc_allow_const_fn_ptr) {
-            allow_const_fn_ptr = true;
-        }
         // attributes with data
         else if let Some(MetaItem { kind: MetaItemKind::List(ref metas), .. }) = meta {
             let meta = meta.as_ref().unwrap();
@@ -360,12 +353,8 @@ fn find_stability_generic<'a, I>(
                             if sym::unstable == meta_name {
                                 stab = Some(Stability { level, feature });
                             } else {
-                                const_stab = Some(ConstStability {
-                                    level,
-                                    feature,
-                                    promotable: false,
-                                    allow_const_fn_ptr: false,
-                                });
+                                const_stab =
+                                    Some(ConstStability { level, feature, promotable: false });
                             }
                         }
                         (None, _, _) => {
@@ -440,12 +429,8 @@ fn find_stability_generic<'a, I>(
                             if sym::stable == meta_name {
                                 stab = Some(Stability { level, feature });
                             } else {
-                                const_stab = Some(ConstStability {
-                                    level,
-                                    feature,
-                                    promotable: false,
-                                    allow_const_fn_ptr: false,
-                                });
+                                const_stab =
+                                    Some(ConstStability { level, feature, promotable: false });
                             }
                         }
                         (None, _) => {
@@ -464,18 +449,16 @@ fn find_stability_generic<'a, I>(
     }
 
     // Merge the const-unstable info into the stability info
-    if promotable || allow_const_fn_ptr {
+    if promotable {
         if let Some(ref mut stab) = const_stab {
             stab.promotable = promotable;
-            stab.allow_const_fn_ptr = allow_const_fn_ptr;
         } else {
             struct_span_err!(
                 diagnostic,
                 item_sp,
                 E0717,
-                "rustc_promotable and rustc_allow_const_fn_ptr attributes \
-                      must be paired with either a rustc_const_unstable or a rustc_const_stable \
-                      attribute"
+                "`rustc_promotable` attribute must be paired with either a `rustc_const_unstable` \
+                or a `rustc_const_stable` attribute"
             )
             .emit();
         }
index 8b7fd59cd874ae57c665d559af0de011bad64126..22c1ca2f289d3b23e33c25edf3e511bf612b2a37 100644 (file)
@@ -464,7 +464,6 @@ macro_rules! experimental {
     // ==========================================================================
 
     rustc_attr!(rustc_promotable, AssumedUsed, template!(Word), IMPL_DETAIL),
-    rustc_attr!(rustc_allow_const_fn_ptr, AssumedUsed, template!(Word), IMPL_DETAIL),
     rustc_attr!(rustc_args_required_const, AssumedUsed, template!(List: "N"), INTERNAL_UNSTABLE),
 
     // ==========================================================================
index 784d6c3b2cee4e1557c03ce398dfcb58e4dd7a25..d5b99ea4d288dc66a65bfe4b9fc304ade09eef5a 100644 (file)
@@ -457,10 +457,6 @@ fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
             desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) }
         }
 
-        query const_fn_is_allowed_fn_ptr(key: DefId) -> bool {
-            desc { |tcx| "checking if const fn allows `fn()` types: `{}`", tcx.def_path_str(key) }
-        }
-
         /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
         query is_foreign_item(key: DefId) -> bool {
             desc { |tcx| "checking if `{}` is a foreign item", tcx.def_path_str(key) }
index 9ef63b3322dd54900aea201995ee63a6bbc1d51e..b20d89b6e835c1bd0f1462d9275787f049eadb67 100644 (file)
@@ -151,17 +151,11 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
         }
 }
 
-fn const_fn_is_allowed_fn_ptr(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
-    is_const_fn(tcx, def_id)
-        && tcx.lookup_const_stability(def_id).map(|stab| stab.allow_const_fn_ptr).unwrap_or(false)
-}
-
 pub fn provide(providers: &mut Providers) {
     *providers = Providers {
         is_const_fn_raw,
         is_const_impl_raw: |tcx, def_id| is_const_impl_raw(tcx, def_id.expect_local()),
         is_promotable_const_fn,
-        const_fn_is_allowed_fn_ptr,
         ..*providers
     };
 }
index 7332a7ea3317c2370395dfbffbe4119510fe225e..4234aef33590652b17bf282905a5e774eedc165a 100644 (file)
         rustc,
         rustc_allocator,
         rustc_allocator_nounwind,
-        rustc_allow_const_fn_ptr,
         rustc_args_required_const,
         rustc_attrs,
         rustc_builtin_macro,
index 109dbfda105e3f5899dbded1fd72ea81a2f131dd..ba3fb35caaf9d2a3b8743cc6550b011f711b15bd 100644 (file)
@@ -129,14 +129,9 @@ impl RawWakerVTable {
     /// associated task.
     #[rustc_promotable]
     #[stable(feature = "futures_api", since = "1.36.0")]
-    // `rustc_allow_const_fn_ptr` is a hack that should not be used anywhere else
-    // without first consulting with T-Lang.
-    //
-    // FIXME: remove whenever we have a stable way to accept fn pointers from const fn
-    // (see https://github.com/rust-rfcs/const-eval/issues/19#issuecomment-472799062)
-    #[rustc_allow_const_fn_ptr]
     #[rustc_const_stable(feature = "futures_api", since = "1.36.0")]
     #[cfg_attr(not(bootstrap), allow_internal_unstable(const_fn_fn_ptr_basics))]
+    #[cfg_attr(bootstrap, rustc_allow_const_fn_ptr)]
     pub const fn new(
         clone: unsafe fn(*const ()) -> RawWaker,
         wake: unsafe fn(*const ()),