Skip to content

Commit b46e42f

Browse files
committed
Clean up macro argument matches so they satisfy tidy checks
1 parent 4e496de commit b46e42f

File tree

2 files changed

+53
-15
lines changed

2 files changed

+53
-15
lines changed

src/librustc/hir/def_id.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ newtype_index!(CrateNum nopub
2323
const LOCAL_CRATE = 0,
2424

2525
/// Virtual crate for builtin macros
26-
// FIXME(jseyfried): this is also used for custom derives until proc-macro crates get `CrateNum`s.
26+
// FIXME(jseyfried): this is also used for custom derives until proc-macro crates get
27+
// `CrateNum`s.
2728
const BUILTIN_MACROS_CRATE = u32::MAX,
2829

2930
/// A CrateNum value that indicates that something is wrong.

src/librustc_data_structures/indexed_vec.rs

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ macro_rules! newtype_index {
8686
// ---- private rules ----
8787

8888
// Base case, user-defined constants (if any) have already been defined
89-
(@derives[$($derives:ident),*] @type[$type:ident] @pub[$($pub:tt)*] @max[$max:expr] @debug_name[$debug_name:expr]) => (
89+
(@derives [$($derives:ident),*]
90+
@type [$type:ident]
91+
@pub [$($pub:tt)*]
92+
@max [$max:expr]
93+
@debug_name [$debug_name:expr]) => (
9094
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, $($derives),*)]
9195
pub struct $type($($pub)* u32);
9296

@@ -110,8 +114,12 @@ macro_rules! newtype_index {
110114

111115
// By not including the @derives marker in this list nor in the default args, we can force it
112116
// to come first if it exists
113-
(@type[$type:ident] @pub[$($pub:tt)*] @max[$max:expr] @debug_name[$debug_name:expr]
114-
derive [$($derives:ident),+] $($tokens:tt)*) => (
117+
(@type [$type:ident]
118+
@pub [$($pub:tt)*]
119+
@max [$max:expr]
120+
@debug_name [$debug_name:expr]
121+
derive [$($derives:ident),+]
122+
$($tokens:tt)*) => (
115123
newtype_index!(
116124
@derives [$($derives),+]
117125
@type [$type]
@@ -122,7 +130,11 @@ macro_rules! newtype_index {
122130
);
123131

124132
// The case where no derives are added
125-
(@type[$type:ident] @pub[$($pub:tt)*] @max[$max:expr] @debug_name[$debug_name:expr] $($tokens:tt)*) => (
133+
(@type [$type:ident]
134+
@pub [$($pub:tt)*]
135+
@max [$max:expr]
136+
@debug_name [$debug_name:expr]
137+
$($tokens:tt)*) => (
126138
newtype_index!(
127139
@derives []
128140
@type [$type]
@@ -133,8 +145,12 @@ macro_rules! newtype_index {
133145
);
134146

135147
// Rewrite final without comma to one that includes comma
136-
(@derives[$($derives:ident),*] @type[$type:ident] @pub[$($pub:tt)*] @max[$max:expr] @debug_name[$debug_name:expr]
137-
$name:ident = $constant:expr) => (
148+
(@derives [$($derives:ident),*]
149+
@type [$type:ident]
150+
@pub [$($pub:tt)*]
151+
@max [$max:expr]
152+
@debug_name [$debug_name:expr]
153+
$name:ident = $constant:expr) => (
138154
newtype_index!(
139155
@derives [$($derives),*]
140156
@type [$type]
@@ -145,8 +161,13 @@ macro_rules! newtype_index {
145161
);
146162

147163
// Rewrite final const without comma to one that includes comma
148-
(@derives[$($derives:ident),*] @type[$type:ident] @pub[$($pub:tt)*] @max[$_max:expr] @debug_name[$debug_name:expr]
149-
$(#[doc = $doc:expr])* const $name:ident = $constant:expr) => (
164+
(@derives [$($derives:ident),*]
165+
@type [$type:ident]
166+
@pub [$($pub:tt)*]
167+
@max [$_max:expr]
168+
@debug_name [$debug_name:expr]
169+
$(#[doc = $doc:expr])*
170+
const $name:ident = $constant:expr) => (
150171
newtype_index!(
151172
@derives [$($derives),*]
152173
@type [$type]
@@ -157,8 +178,13 @@ macro_rules! newtype_index {
157178
);
158179

159180
// Replace existing default for max
160-
(@derives[$($derives:ident),*] @type[$type:ident] @pub[$($pub:tt)*] @max[$_max:expr] @debug_name[$debug_name:expr]
161-
MAX = $max:expr, $($tokens:tt)*) => (
181+
(@derives [$($derives:ident),*]
182+
@type [$type:ident]
183+
@pub [$($pub:tt)*]
184+
@max [$_max:expr]
185+
@debug_name [$debug_name:expr]
186+
MAX = $max:expr,
187+
$($tokens:tt)*) => (
162188
newtype_index!(
163189
@derives [$($derives),*]
164190
@type [$type]
@@ -169,8 +195,13 @@ macro_rules! newtype_index {
169195
);
170196

171197
// Replace existing default for debug_name
172-
(@derives[$($derives:ident),*] @type[$type:ident] @pub[$($pub:tt)*] @max[$max:expr] @debug_name[$_debug_name:expr]
173-
DEBUG_NAME = $debug_name:expr, $($tokens:tt)*) => (
198+
(@derives [$($derives:ident),*]
199+
@type [$type:ident]
200+
@pub [$($pub:tt)*]
201+
@max [$max:expr]
202+
@debug_name [$_debug_name:expr]
203+
DEBUG_NAME = $debug_name:expr,
204+
$($tokens:tt)*) => (
174205
newtype_index!(
175206
@derives [$($derives),*]
176207
@type [$type]
@@ -181,8 +212,14 @@ macro_rules! newtype_index {
181212
);
182213

183214
// Assign a user-defined constant
184-
(@derives[$($derives:ident),*] @type[$type:ident] @pub[$($pub:tt)*] @max[$max:expr] @debug_name[$debug_name:expr]
185-
$(#[doc = $doc:expr])* const $name:ident = $constant:expr, $($tokens:tt)*) => (
215+
(@derives [$($derives:ident),*]
216+
@type [$type:ident]
217+
@pub [$($pub:tt)*]
218+
@max [$max:expr]
219+
@debug_name [$debug_name:expr]
220+
$(#[doc = $doc:expr])*
221+
const $name:ident = $constant:expr,
222+
$($tokens:tt)*) => (
186223
$(#[doc = $doc])*
187224
pub const $name: $type = $type($constant);
188225
newtype_index!(

0 commit comments

Comments
 (0)