]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_feature/builtin_attrs.rs
Rollup merge of #67313 - oli-obk:document_all_the_t̶h̶i̶n̶g̶s̶dataflow, r=ecstatic...
[rust.git] / src / librustc_feature / builtin_attrs.rs
index 4fa0198d8716d2463d49f9e1ca56f2cd58418040..a38726e3de81fad8a3e7ff5173de7513600785e7 100644 (file)
@@ -1,20 +1,20 @@
 //! Built-in attributes and `cfg` flag gating.
 
-use AttributeType::*;
 use AttributeGate::*;
+use AttributeType::*;
 
 use crate::{Features, Stability};
 
-use rustc_data_structures::fx::FxHashMap;
-use syntax_pos::symbol::{Symbol, sym};
 use lazy_static::lazy_static;
+use rustc_data_structures::fx::FxHashMap;
+use rustc_span::symbol::{sym, Symbol};
 
 type GateFn = fn(&Features) -> bool;
 
 macro_rules! cfg_fn {
     ($field: ident) => {
-        (|features| { features.$field }) as GateFn
-    }
+        (|features| features.$field) as GateFn
+    };
 }
 
 pub type GatedCfg = (Symbol, Symbol, GateFn);
@@ -66,9 +66,10 @@ pub enum AttributeGate {
 impl std::fmt::Debug for AttributeGate {
     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         match *self {
-            Self::Gated(ref stab, name, expl, _) =>
-                write!(fmt, "Gated({:?}, {}, {})", stab, name, expl),
-            Self::Ungated => write!(fmt, "Ungated")
+            Self::Gated(ref stab, name, expl, _) => {
+                write!(fmt, "Gated({:?}, {}, {})", stab, name, expl)
+            }
+            Self::Ungated => write!(fmt, "Ungated"),
         }
     }
 }
@@ -135,22 +136,31 @@ macro_rules! gated {
 macro_rules! rustc_attr {
     (TEST, $attr:ident, $typ:expr, $tpl:expr $(,)?) => {
         rustc_attr!(
-            $attr, $typ, $tpl,
-            concat!("the `#[", stringify!($attr), "]` attribute is just used for rustc unit tests \
+            $attr,
+            $typ,
+            $tpl,
+            concat!(
+                "the `#[",
+                stringify!($attr),
+                "]` attribute is just used for rustc unit tests \
                 and will never be stable",
             ),
         )
     };
     ($attr:ident, $typ:expr, $tpl:expr, $msg:expr $(,)?) => {
-        (sym::$attr, $typ, $tpl,
-         Gated(Stability::Unstable, sym::rustc_attrs, $msg, cfg_fn!(rustc_attrs)))
+        (
+            sym::$attr,
+            $typ,
+            $tpl,
+            Gated(Stability::Unstable, sym::rustc_attrs, $msg, cfg_fn!(rustc_attrs)),
+        )
     };
 }
 
 macro_rules! experimental {
     ($attr:ident) => {
         concat!("the `#[", stringify!($attr), "]` attribute is an experimental feature")
-    }
+    };
 }
 
 const IMPL_DETAIL: &str = "internal implementation detail";
@@ -159,6 +169,7 @@ macro_rules! experimental {
 pub type BuiltinAttribute = (Symbol, AttributeType, AttributeTemplate, AttributeGate);
 
 /// Attributes that have a special meaning to rustc or rustdoc.
+#[rustfmt::skip]
 pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
     // ==========================================================================
     // Stable attributes:
@@ -344,10 +355,10 @@ macro_rules! experimental {
         unstable, Whitelisted,
         template!(List: r#"feature = "name", reason = "...", issue = "N""#),
     ),
-    gated!(
-        rustc_const_unstable, Normal, template!(List: r#"feature = "name""#),
-        "the `#[rustc_const_unstable]` attribute is an internal feature",
-    ),
+    // FIXME(#14407)
+    ungated!(rustc_const_unstable, Whitelisted, template!(List: r#"feature = "name""#)),
+    // FIXME(#14407)
+    ungated!(rustc_const_stable, Whitelisted, template!(List: r#"feature = "name""#)),
     gated!(
         allow_internal_unstable, Normal, template!(Word, List: "feat1, feat2, ..."),
         "allow_internal_unstable side-steps feature gating and stability checks",
@@ -398,11 +409,6 @@ macro_rules! experimental {
         "the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \
         which contains compiler-rt intrinsics and will never be stable",
     ),
-    gated!(
-        sanitizer_runtime, Whitelisted, template!(Word),
-        "the `#[sanitizer_runtime]` attribute is used to identify crates that contain the runtime \
-        of a sanitizer and will never be stable",
-    ),
     gated!(
         profiler_runtime, Whitelisted, template!(Word),
         "the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \