X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_feature%2Fbuiltin_attrs.rs;h=a38726e3de81fad8a3e7ff5173de7513600785e7;hb=e22ae2c096ed2b58ab0d6c029b8ae985a1749e1c;hp=0a4fb8a224eecc1cd8e74b7177eb3e7ffacb73fc;hpb=403bb097fce6f1d1fbb3b7b12d024f20ce845900;p=rust.git diff --git a/src/librustc_feature/builtin_attrs.rs b/src/librustc_feature/builtin_attrs.rs index 0a4fb8a224e..a38726e3de8 100644 --- a/src/librustc_feature/builtin_attrs.rs +++ b/src/librustc_feature/builtin_attrs.rs @@ -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: @@ -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 \