diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-24 17:44:51 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-24 17:44:51 -0500 |
| commit | 8d6d0e71a66355a9e2da366d22c7a4e355718fdf (patch) | |
| tree | 558187a61216c6e86efa56eeb7ee0676bf0ae23d /src | |
| parent | 6891388e661c2bbf965a330ff73bf8c08a7dbf7d (diff) | |
| download | rust-8d6d0e71a66355a9e2da366d22c7a4e355718fdf.tar.gz rust-8d6d0e71a66355a9e2da366d22c7a4e355718fdf.zip | |
Format librustc_feature
Use #[rustfmt::skip] on the tidy-parsed macro invocations
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_feature/accepted.rs | 3 | ||||
| -rw-r--r-- | src/librustc_feature/active.rs | 9 | ||||
| -rw-r--r-- | src/librustc_feature/builtin_attrs.rs | 37 | ||||
| -rw-r--r-- | src/librustc_feature/lib.rs | 21 | ||||
| -rw-r--r-- | src/librustc_feature/removed.rs | 4 |
5 files changed, 44 insertions, 30 deletions
diff --git a/src/librustc_feature/accepted.rs b/src/librustc_feature/accepted.rs index 3f294dc02ed..144a3faaba5 100644 --- a/src/librustc_feature/accepted.rs +++ b/src/librustc_feature/accepted.rs @@ -1,6 +1,6 @@ //! List of the accepted feature gates. -use super::{State, Feature}; +use super::{Feature, State}; use syntax_pos::symbol::sym; macro_rules! declare_features { @@ -23,6 +23,7 @@ macro_rules! declare_features { } } +#[rustfmt::skip] declare_features! ( // ------------------------------------------------------------------------- // feature-group-start: for testing purposes diff --git a/src/librustc_feature/active.rs b/src/librustc_feature/active.rs index 36664af8782..708e48fe6ad 100644 --- a/src/librustc_feature/active.rs +++ b/src/librustc_feature/active.rs @@ -1,10 +1,10 @@ //! List of the active feature gates. -use super::{State, Feature}; +use super::{Feature, State}; use syntax_pos::edition::Edition; +use syntax_pos::symbol::{sym, Symbol}; use syntax_pos::Span; -use syntax_pos::symbol::{Symbol, sym}; macro_rules! set { ($field: ident) => {{ @@ -12,7 +12,7 @@ macro_rules! set { features.$field = true; } f as fn(&mut Features, Span) - }} + }}; } macro_rules! declare_features { @@ -72,7 +72,7 @@ impl Feature { pub fn set(&self, features: &mut Features, span: Span) { match self.state { State::Active { set } => set(features, span), - _ => panic!("called `set` on feature `{}` which is not `active`", self.name) + _ => panic!("called `set` on feature `{}` which is not `active`", self.name), } } } @@ -91,6 +91,7 @@ impl Feature { // N.B., `tools/tidy/src/features.rs` parses this information directly out of the // source, so take care when modifying it. +#[rustfmt::skip] declare_features! ( // ------------------------------------------------------------------------- // feature-group-start: internal feature gates diff --git a/src/librustc_feature/builtin_attrs.rs b/src/librustc_feature/builtin_attrs.rs index 0a4fb8a224e..5ae87d9712d 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 syntax_pos::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 @@ const INTERNAL_UNSTABLE: &str = "this is an internal attribute that will never b 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: diff --git a/src/librustc_feature/lib.rs b/src/librustc_feature/lib.rs index c38bb3740af..b85feee040c 100644 --- a/src/librustc_feature/lib.rs +++ b/src/librustc_feature/lib.rs @@ -11,13 +11,13 @@ //! symbol to the `accepted` or `removed` modules respectively. mod accepted; -mod removed; mod active; mod builtin_attrs; +mod removed; use std::fmt; use std::num::NonZeroU32; -use syntax_pos::{Span, edition::Edition, symbol::Symbol}; +use syntax_pos::{edition::Edition, symbol::Symbol, Span}; #[derive(Clone, Copy)] pub enum State { @@ -43,7 +43,7 @@ pub struct Feature { pub state: State, pub name: Symbol, pub since: &'static str, - issue: Option<u32>, // FIXME: once #58732 is done make this an Option<NonZeroU32> + issue: Option<u32>, // FIXME: once #58732 is done make this an Option<NonZeroU32> pub edition: Option<Edition>, description: &'static str, } @@ -72,7 +72,7 @@ pub enum UnstableFeatures { /// during the build that feature-related lints are set to warn or above /// because the build turns on warnings-as-errors and uses lots of unstable /// features. As a result, this is always required for building Rust itself. - Cheat + Cheat, } impl UnstableFeatures { @@ -84,7 +84,7 @@ impl UnstableFeatures { match (disable_unstable_features, bootstrap) { (_, true) => UnstableFeatures::Cheat, (true, _) => UnstableFeatures::Disallow, - (false, _) => UnstableFeatures::Allow + (false, _) => UnstableFeatures::Allow, } } @@ -117,7 +117,7 @@ fn find_lang_feature_issue(feature: Symbol) -> Option<NonZeroU32> { pub enum GateIssue { Language, - Library(Option<NonZeroU32>) + Library(Option<NonZeroU32>), } pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZeroU32> { @@ -128,10 +128,9 @@ pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZeroU3 } pub use accepted::ACCEPTED_FEATURES; -pub use active::{ACTIVE_FEATURES, Features, INCOMPLETE_FEATURES}; -pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES}; +pub use active::{Features, ACTIVE_FEATURES, INCOMPLETE_FEATURES}; pub use builtin_attrs::{ - AttributeGate, AttributeTemplate, AttributeType, find_gated_cfg, GatedCfg, - BuiltinAttribute, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP, - deprecated_attributes, is_builtin_attr_name, + deprecated_attributes, find_gated_cfg, is_builtin_attr_name, AttributeGate, AttributeTemplate, + AttributeType, BuiltinAttribute, GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP, }; +pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES}; diff --git a/src/librustc_feature/removed.rs b/src/librustc_feature/removed.rs index 340bd32fb8a..5512e1247aa 100644 --- a/src/librustc_feature/removed.rs +++ b/src/librustc_feature/removed.rs @@ -1,6 +1,6 @@ //! List of the removed feature gates. -use super::{State, Feature}; +use super::{Feature, State}; use syntax_pos::symbol::sym; macro_rules! declare_features { @@ -41,6 +41,7 @@ macro_rules! declare_features { }; } +#[rustfmt::skip] declare_features! ( // ------------------------------------------------------------------------- // feature-group-start: removed features @@ -111,6 +112,7 @@ declare_features! ( // ------------------------------------------------------------------------- ); +#[rustfmt::skip] declare_features! ( (stable_removed, no_stack_check, "1.0.0", None, None), ); |
