Skip to content

Commit ccec777

Browse files
committed
Cargo fmt and update tests
1 parent 6115dcd commit ccec777

File tree

7 files changed

+49
-50
lines changed

7 files changed

+49
-50
lines changed

src/cargo-fmt/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn execute() -> i32 {
9797
}
9898

9999
macro_rules! print_usage {
100-
($print: ident, $opts: ident, $reason: expr) => {{
100+
($print:ident, $opts:ident, $reason:expr) => {{
101101
let msg = format!("{}\nusage: cargo fmt [options]", $reason);
102102
$print!(
103103
"{}\nThis utility formats all bin and lib files of the current crate using rustfmt. \

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Rewrite for MacroArg {
103103

104104
fn parse_macro_arg(parser: &mut Parser) -> Option<MacroArg> {
105105
macro_rules! parse_macro_arg {
106-
($macro_arg: ident, $parser: ident) => {
106+
($macro_arg:ident, $parser:ident) => {
107107
let mut cloned_parser = (*parser).clone();
108108
match cloned_parser.$parser() {
109109
Ok(x) => {

src/spanned.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub trait Spanned {
2020
}
2121

2222
macro_rules! span_with_attrs_lo_hi {
23-
($this: ident, $lo: expr, $hi: expr) => {{
23+
($this:ident, $lo:expr, $hi:expr) => {{
2424
let attrs = outer_attributes(&$this.attrs);
2525
if attrs.is_empty() {
2626
mk_sp($lo, $hi)
@@ -31,13 +31,13 @@ macro_rules! span_with_attrs_lo_hi {
3131
}
3232

3333
macro_rules! span_with_attrs {
34-
($this: ident) => {
34+
($this:ident) => {
3535
span_with_attrs_lo_hi!($this, $this.span.lo(), $this.span.hi())
3636
};
3737
}
3838

3939
macro_rules! implement_spanned {
40-
($this: ty) => {
40+
($this:ty) => {
4141
impl Spanned for $this {
4242
fn span(&self) -> Span {
4343
span_with_attrs!(self)

src/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ macro_rules! msg {
266266
// For format_missing and last_pos, need to use the source callsite (if applicable).
267267
// Required as generated code spans aren't guaranteed to follow on from the last span.
268268
macro_rules! source {
269-
($this: ident, $sp: expr) => {
269+
($this:ident, $sp:expr) => {
270270
$sp.source_callsite()
271271
};
272272
}
@@ -277,7 +277,7 @@ pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
277277

278278
// Return true if the given span does not intersect with file lines.
279279
macro_rules! out_of_file_lines_range {
280-
($self: ident, $span: expr) => {
280+
($self:ident, $span:expr) => {
281281
!$self.config.file_lines().is_all()
282282
&& !$self
283283
.config
@@ -287,15 +287,15 @@ macro_rules! out_of_file_lines_range {
287287
}
288288

289289
macro_rules! skip_out_of_file_lines_range {
290-
($self: ident, $span: expr) => {
290+
($self:ident, $span:expr) => {
291291
if out_of_file_lines_range!($self, $span) {
292292
return None;
293293
}
294294
};
295295
}
296296

297297
macro_rules! skip_out_of_file_lines_range_visitor {
298-
($self: ident, $span: expr) => {
298+
($self:ident, $span:expr) => {
299299
if out_of_file_lines_range!($self, $span) {
300300
$self.push_rewrite($span, None);
301301
return;

tests/target/macro_not_expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
macro_rules! test {
2-
($($t: tt)*) => {};
2+
($($t:tt)*) => {};
33
}
44

55
fn main() {

tests/target/macro_rules.rs

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@
22

33
macro_rules! m {
44
() => {};
5-
($x: ident) => {};
6-
($m1: ident, $m2: ident, $x: ident) => {};
7-
($($beginning: ident),*; $middle: ident; $($end: ident),*) => {};
5+
($x:ident) => {};
6+
($m1:ident, $m2:ident, $x:ident) => {};
7+
($($beginning:ident),*; $middle:ident; $($end:ident),*) => {};
88
(
9-
$($beginning: ident),*;
10-
$middle: ident;
11-
$($end: ident),*;
12-
$($beginning: ident),*;
13-
$middle: ident;
14-
$($end: ident),*
9+
$($beginning:ident),*;
10+
$middle:ident;
11+
$($end:ident),*;
12+
$($beginning:ident),*;
13+
$middle:ident;
14+
$($end:ident),*
1515
) => {};
16-
($name: ident($($dol: tt $var: ident)*) $($body: tt)*) => {};
16+
($name:ident($($dol:tt $var:ident)*) $($body:tt)*) => {};
1717
(
18-
$($i: ident : $ty: ty, $def: expr, $stb: expr, $($dstring: tt),+);+ $(;)*
19-
$($i: ident : $ty: ty, $def: expr, $stb: expr, $($dstring: tt),+);+ $(;)*
18+
$($i:ident : $ty:ty, $def:expr, $stb:expr, $($dstring:tt),+);+ $(;)*
19+
$($i:ident : $ty:ty, $def:expr, $stb:expr, $($dstring:tt),+);+ $(;)*
2020
) => {};
21-
($foo: tt foo[$attr: meta] $name: ident) => {};
22-
($foo: tt[$attr: meta] $name: ident) => {};
23-
($foo: tt &'a[$attr: meta] $name: ident) => {};
24-
($foo: tt foo #[$attr: meta] $name: ident) => {};
25-
($foo: tt #[$attr: meta] $name: ident) => {};
26-
($foo: tt &'a #[$attr: meta] $name: ident) => {};
27-
($x: tt foo bar foo bar foo bar $y: tt => x * y * z $z: tt, $($a: tt),*) => {};
21+
($foo:tt foo[$attr:meta] $name:ident) => {};
22+
($foo:tt[$attr:meta] $name:ident) => {};
23+
($foo:tt &'a[$attr:meta] $name:ident) => {};
24+
($foo:tt foo #[$attr:meta] $name:ident) => {};
25+
($foo:tt #[$attr:meta] $name:ident) => {};
26+
($foo:tt &'a #[$attr:meta] $name:ident) => {};
27+
($x:tt foo bar foo bar foo bar $y:tt => x * y * z $z:tt, $($a:tt),*) => {};
2828
}
2929

3030
macro_rules! impl_a_method {
31-
($n: ident($a: ident : $ta: ty) -> $ret: ty { $body: expr }) => {
31+
($n:ident($a:ident : $ta:ty) -> $ret:ty { $body:expr }) => {
3232
fn $n($a: $ta) -> $ret {
3333
$body
3434
}
@@ -38,7 +38,7 @@ macro_rules! impl_a_method {
3838
};
3939
}
4040
};
41-
($n: ident($a: ident : $ta: ty, $b: ident : $tb: ty) -> $ret: ty { $body: expr }) => {
41+
($n:ident($a:ident : $ta:ty, $b:ident : $tb:ty) -> $ret:ty { $body:expr }) => {
4242
fn $n($a: $ta, $b: $tb) -> $ret {
4343
$body
4444
}
@@ -49,8 +49,7 @@ macro_rules! impl_a_method {
4949
}
5050
};
5151
(
52-
$n: ident($a: ident : $ta: ty, $b: ident : $tb: ty, $c: ident : $tc: ty) ->
53-
$ret: ty { $body: expr }
52+
$n:ident($a:ident : $ta:ty, $b:ident : $tb:ty, $c:ident : $tc:ty) -> $ret:ty { $body:expr }
5453
) => {
5554
fn $n($a: $ta, $b: $tb, $c: $tc) -> $ret {
5655
$body
@@ -62,8 +61,8 @@ macro_rules! impl_a_method {
6261
}
6362
};
6463
(
65-
$n: ident($a: ident : $ta: ty, $b: ident : $tb: ty, $c: ident : $tc: ty, $d: ident : $td: ty) ->
66-
$ret: ty { $body: expr }
64+
$n:ident($a:ident : $ta:ty, $b:ident : $tb:ty, $c:ident : $tc:ty, $d:ident : $td:ty) ->
65+
$ret:ty { $body:expr }
6766
) => {
6867
fn $n($a: $ta, $b: $tb, $c: $tc, $d: $td) -> $ret {
6968
$body
@@ -78,7 +77,7 @@ macro_rules! impl_a_method {
7877

7978
macro_rules! m {
8079
// a
81-
($expr: expr, $($func: ident)*) => {{
80+
($expr:expr, $($func:ident)*) => {{
8281
let x = $expr;
8382
$func(x)
8483
}};
@@ -91,7 +90,7 @@ macro_rules! m {
9190
(@tag) => {};
9291

9392
// d
94-
($item: ident) => {
93+
($item:ident) => {
9594
mod macro_item {
9695
struct $item;
9796
}
@@ -100,7 +99,7 @@ macro_rules! m {
10099

101100
macro m2 {
102101
// a
103-
($expr: expr, $($func: ident)*) => {{
102+
($expr:expr, $($func:ident)*) => {{
104103
let x = $expr;
105104
$func(x)
106105
}}
@@ -113,7 +112,7 @@ macro m2 {
113112
(@tag) => {}
114113

115114
// d
116-
($item: ident) => {
115+
($item:ident) => {
117116
mod macro_item {
118117
struct $item;
119118
}
@@ -156,10 +155,10 @@ macro_rules! m {
156155
// #2439
157156
macro_rules! m {
158157
(
159-
$line0_xxxxxxxxxxxxxxxxx: expr,
160-
$line1_xxxxxxxxxxxxxxxxx: expr,
161-
$line2_xxxxxxxxxxxxxxxxx: expr,
162-
$line3_xxxxxxxxxxxxxxxxx: expr,
158+
$line0_xxxxxxxxxxxxxxxxx:expr,
159+
$line1_xxxxxxxxxxxxxxxxx:expr,
160+
$line2_xxxxxxxxxxxxxxxxx:expr,
161+
$line3_xxxxxxxxxxxxxxxxx:expr,
163162
) => {};
164163
}
165164

@@ -173,7 +172,7 @@ macro_rules! m [
173172
];
174173

175174
// #2470
176-
macro foo($type_name: ident, $docs: expr) {
175+
macro foo($type_name:ident, $docs:expr) {
177176
#[allow(non_camel_case_types)]
178177
#[doc=$docs]
179178
#[derive(Debug, Clone, Copy)]
@@ -182,13 +181,13 @@ macro foo($type_name: ident, $docs: expr) {
182181

183182
// #2534
184183
macro_rules! foo {
185-
($a: ident : $b: ty) => {};
186-
($a: ident $b: ident $c: ident) => {};
184+
($a:ident : $b:ty) => {};
185+
($a:ident $b:ident $c:ident) => {};
187186
}
188187

189188
// #2538
190189
macro_rules! add_message_to_notes {
191-
($msg: expr) => {{
190+
($msg:expr) => {{
192191
let mut lines = message.lines();
193192
notes.push_str(&format!("\n{}: {}", level, lines.next().unwrap()));
194193
for line in lines {

tests/target/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn issue_1555() {
141141

142142
fn issue1178() {
143143
macro_rules! foo {
144-
(#[$attr: meta] $name: ident) => {};
144+
(#[$attr:meta] $name:ident) => {};
145145
}
146146

147147
foo!(
@@ -246,7 +246,7 @@ fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() {
246246

247247
// #878
248248
macro_rules! try_opt {
249-
($expr: expr) => {
249+
($expr:expr) => {
250250
match $expr {
251251
Some(val) => val,
252252

@@ -891,7 +891,7 @@ fn macro_in_pattern_position() {
891891

892892
macro foo() {}
893893

894-
pub macro bar($x: ident + $y: expr;) {
894+
pub macro bar($x:ident + $y:expr;) {
895895
fn foo($x: Foo) {
896896
long_function(
897897
a_long_argument_to_a_long_function_is_what_this_is(AAAAAAAAAAAAAAAAAAAAAAAAAAAA),

0 commit comments

Comments
 (0)