Skip to content

Commit 8d6d0e7

Browse files
committedDec 24, 2019
Format librustc_feature
Use #[rustfmt::skip] on the tidy-parsed macro invocations
1 parent 6891388 commit 8d6d0e7

File tree

6 files changed

+44
-34
lines changed

6 files changed

+44
-34
lines changed
 

‎rustfmt.toml

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ ignore = [
1010
# (and generally rustfmt can move around comments in UI-testing incompatible ways)
1111
"src/test",
1212

13-
# tidy issues (line length, etc.)
14-
# to be fixed shortly
15-
"src/librustc_feature",
16-
1713
# do not format submodules
1814
"src/doc/book",
1915
"src/doc/edition-guide",

‎src/librustc_feature/accepted.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! List of the accepted feature gates.
22
3-
use super::{State, Feature};
3+
use super::{Feature, State};
44
use syntax_pos::symbol::sym;
55

66
macro_rules! declare_features {
@@ -23,6 +23,7 @@ macro_rules! declare_features {
2323
}
2424
}
2525

26+
#[rustfmt::skip]
2627
declare_features! (
2728
// -------------------------------------------------------------------------
2829
// feature-group-start: for testing purposes

‎src/librustc_feature/active.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
//! List of the active feature gates.
22
3-
use super::{State, Feature};
3+
use super::{Feature, State};
44

55
use syntax_pos::edition::Edition;
6+
use syntax_pos::symbol::{sym, Symbol};
67
use syntax_pos::Span;
7-
use syntax_pos::symbol::{Symbol, sym};
88

99
macro_rules! set {
1010
($field: ident) => {{
1111
fn f(features: &mut Features, _: Span) {
1212
features.$field = true;
1313
}
1414
f as fn(&mut Features, Span)
15-
}}
15+
}};
1616
}
1717

1818
macro_rules! declare_features {
@@ -72,7 +72,7 @@ impl Feature {
7272
pub fn set(&self, features: &mut Features, span: Span) {
7373
match self.state {
7474
State::Active { set } => set(features, span),
75-
_ => panic!("called `set` on feature `{}` which is not `active`", self.name)
75+
_ => panic!("called `set` on feature `{}` which is not `active`", self.name),
7676
}
7777
}
7878
}
@@ -91,6 +91,7 @@ impl Feature {
9191
// N.B., `tools/tidy/src/features.rs` parses this information directly out of the
9292
// source, so take care when modifying it.
9393

94+
#[rustfmt::skip]
9495
declare_features! (
9596
// -------------------------------------------------------------------------
9697
// feature-group-start: internal feature gates

‎src/librustc_feature/builtin_attrs.rs

+24-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
//! Built-in attributes and `cfg` flag gating.
22
3-
use AttributeType::*;
43
use AttributeGate::*;
4+
use AttributeType::*;
55

66
use crate::{Features, Stability};
77

8-
use rustc_data_structures::fx::FxHashMap;
9-
use syntax_pos::symbol::{Symbol, sym};
108
use lazy_static::lazy_static;
9+
use rustc_data_structures::fx::FxHashMap;
10+
use syntax_pos::symbol::{sym, Symbol};
1111

1212
type GateFn = fn(&Features) -> bool;
1313

1414
macro_rules! cfg_fn {
1515
($field: ident) => {
16-
(|features| { features.$field }) as GateFn
17-
}
16+
(|features| features.$field) as GateFn
17+
};
1818
}
1919

2020
pub type GatedCfg = (Symbol, Symbol, GateFn);
@@ -66,9 +66,10 @@ pub enum AttributeGate {
6666
impl std::fmt::Debug for AttributeGate {
6767
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6868
match *self {
69-
Self::Gated(ref stab, name, expl, _) =>
70-
write!(fmt, "Gated({:?}, {}, {})", stab, name, expl),
71-
Self::Ungated => write!(fmt, "Ungated")
69+
Self::Gated(ref stab, name, expl, _) => {
70+
write!(fmt, "Gated({:?}, {}, {})", stab, name, expl)
71+
}
72+
Self::Ungated => write!(fmt, "Ungated"),
7273
}
7374
}
7475
}
@@ -135,22 +136,31 @@ macro_rules! gated {
135136
macro_rules! rustc_attr {
136137
(TEST, $attr:ident, $typ:expr, $tpl:expr $(,)?) => {
137138
rustc_attr!(
138-
$attr, $typ, $tpl,
139-
concat!("the `#[", stringify!($attr), "]` attribute is just used for rustc unit tests \
139+
$attr,
140+
$typ,
141+
$tpl,
142+
concat!(
143+
"the `#[",
144+
stringify!($attr),
145+
"]` attribute is just used for rustc unit tests \
140146
and will never be stable",
141147
),
142148
)
143149
};
144150
($attr:ident, $typ:expr, $tpl:expr, $msg:expr $(,)?) => {
145-
(sym::$attr, $typ, $tpl,
146-
Gated(Stability::Unstable, sym::rustc_attrs, $msg, cfg_fn!(rustc_attrs)))
151+
(
152+
sym::$attr,
153+
$typ,
154+
$tpl,
155+
Gated(Stability::Unstable, sym::rustc_attrs, $msg, cfg_fn!(rustc_attrs)),
156+
)
147157
};
148158
}
149159

150160
macro_rules! experimental {
151161
($attr:ident) => {
152162
concat!("the `#[", stringify!($attr), "]` attribute is an experimental feature")
153-
}
163+
};
154164
}
155165

156166
const IMPL_DETAIL: &str = "internal implementation detail";
@@ -159,6 +169,7 @@ const INTERNAL_UNSTABLE: &str = "this is an internal attribute that will never b
159169
pub type BuiltinAttribute = (Symbol, AttributeType, AttributeTemplate, AttributeGate);
160170

161171
/// Attributes that have a special meaning to rustc or rustdoc.
172+
#[rustfmt::skip]
162173
pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
163174
// ==========================================================================
164175
// Stable attributes:

‎src/librustc_feature/lib.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
//! symbol to the `accepted` or `removed` modules respectively.
1212
1313
mod accepted;
14-
mod removed;
1514
mod active;
1615
mod builtin_attrs;
16+
mod removed;
1717

1818
use std::fmt;
1919
use std::num::NonZeroU32;
20-
use syntax_pos::{Span, edition::Edition, symbol::Symbol};
20+
use syntax_pos::{edition::Edition, symbol::Symbol, Span};
2121

2222
#[derive(Clone, Copy)]
2323
pub enum State {
@@ -43,7 +43,7 @@ pub struct Feature {
4343
pub state: State,
4444
pub name: Symbol,
4545
pub since: &'static str,
46-
issue: Option<u32>, // FIXME: once #58732 is done make this an Option<NonZeroU32>
46+
issue: Option<u32>, // FIXME: once #58732 is done make this an Option<NonZeroU32>
4747
pub edition: Option<Edition>,
4848
description: &'static str,
4949
}
@@ -72,7 +72,7 @@ pub enum UnstableFeatures {
7272
/// during the build that feature-related lints are set to warn or above
7373
/// because the build turns on warnings-as-errors and uses lots of unstable
7474
/// features. As a result, this is always required for building Rust itself.
75-
Cheat
75+
Cheat,
7676
}
7777

7878
impl UnstableFeatures {
@@ -84,7 +84,7 @@ impl UnstableFeatures {
8484
match (disable_unstable_features, bootstrap) {
8585
(_, true) => UnstableFeatures::Cheat,
8686
(true, _) => UnstableFeatures::Disallow,
87-
(false, _) => UnstableFeatures::Allow
87+
(false, _) => UnstableFeatures::Allow,
8888
}
8989
}
9090

@@ -117,7 +117,7 @@ fn find_lang_feature_issue(feature: Symbol) -> Option<NonZeroU32> {
117117

118118
pub enum GateIssue {
119119
Language,
120-
Library(Option<NonZeroU32>)
120+
Library(Option<NonZeroU32>),
121121
}
122122

123123
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
128128
}
129129

130130
pub use accepted::ACCEPTED_FEATURES;
131-
pub use active::{ACTIVE_FEATURES, Features, INCOMPLETE_FEATURES};
132-
pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES};
131+
pub use active::{Features, ACTIVE_FEATURES, INCOMPLETE_FEATURES};
133132
pub use builtin_attrs::{
134-
AttributeGate, AttributeTemplate, AttributeType, find_gated_cfg, GatedCfg,
135-
BuiltinAttribute, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
136-
deprecated_attributes, is_builtin_attr_name,
133+
deprecated_attributes, find_gated_cfg, is_builtin_attr_name, AttributeGate, AttributeTemplate,
134+
AttributeType, BuiltinAttribute, GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
137135
};
136+
pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES};

‎src/librustc_feature/removed.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! List of the removed feature gates.
22
3-
use super::{State, Feature};
3+
use super::{Feature, State};
44
use syntax_pos::symbol::sym;
55

66
macro_rules! declare_features {
@@ -41,6 +41,7 @@ macro_rules! declare_features {
4141
};
4242
}
4343

44+
#[rustfmt::skip]
4445
declare_features! (
4546
// -------------------------------------------------------------------------
4647
// feature-group-start: removed features
@@ -111,6 +112,7 @@ declare_features! (
111112
// -------------------------------------------------------------------------
112113
);
113114

115+
#[rustfmt::skip]
114116
declare_features! (
115117
(stable_removed, no_stack_check, "1.0.0", None, None),
116118
);

0 commit comments

Comments
 (0)
Please sign in to comment.