Skip to content

Commit 8cf990c

Browse files
committed
Auto merge of rust-lang#84920 - Aaron1011:pretty-print-rental, r=petrochenkov
Remove some unncessary spaces from pretty-printed tokenstream output In addition to making the output look nicer for all crates, this also aligns the pretty-printing output with what the `rental` crate expects. This will allow us to eventually disable a backwards-compat hack in a follow-up PR. See rust-lang#84428 for some background information about why we want to make this change. Note that this change would be desirable (but not particularly necessary) even if `rental` didn't exist, so we're not adding any crate-specific hacks into the compiler.
2 parents 50f2bf6 + 357c013 commit 8cf990c

25 files changed

+176
-53
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,15 @@ pub fn print_crate<'a>(
140140
// and also addresses some specific regressions described in #63896 and #73345.
141141
fn tt_prepend_space(tt: &TokenTree, prev: &TokenTree) -> bool {
142142
if let TokenTree::Token(token) = prev {
143+
if matches!(token.kind, token::Dot) {
144+
return false;
145+
}
143146
if let token::DocComment(comment_kind, ..) = token.kind {
144147
return comment_kind != CommentKind::Line;
145148
}
146149
}
147150
match tt {
148-
TokenTree::Token(token) => token.kind != token::Comma,
151+
TokenTree::Token(token) => !matches!(token.kind, token::Comma | token::Not | token::Dot),
149152
TokenTree::Delimited(_, DelimToken::Paren, _) => {
150153
!matches!(prev, TokenTree::Token(Token { kind: token::Ident(..), .. }))
151154
}

src/test/pretty/ast-stmt-expr-attr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ fn syntax() {
114114
let _ = #[attr] continue ;
115115
let _ = #[attr] return;
116116
let _ = #[attr] foo!();
117-
let _ = #[attr] foo!(# ! [attr]);
117+
let _ = #[attr] foo!(#! [attr]);
118118
let _ = #[attr] foo![];
119-
let _ = #[attr] foo![# ! [attr]];
119+
let _ = #[attr] foo![#! [attr]];
120120
let _ = #[attr] foo! { };
121-
let _ = #[attr] foo! { # ! [attr] };
121+
let _ = #[attr] foo! { #! [attr] };
122122
let _ = #[attr] Foo{bar: baz,};
123123
let _ = #[attr] Foo{..foo};
124124
let _ = #[attr] Foo{bar: baz, ..foo};

src/test/pretty/delimited-token-groups.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mac! {
99
{
1010
fn clone() -> S
1111
{
12-
panic ! () ;
12+
panic! () ;
1313

1414
}
1515
}

src/test/ui/macros/trace-macro.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ LL | println!("Hello, World!");
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: expanding `println! { "Hello, World!" }`
8-
= note: to `{ $crate :: io :: _print($crate :: format_args_nl ! ("Hello, World!")) ; }`
8+
= note: to `{ $crate :: io :: _print($crate :: format_args_nl! ("Hello, World!")) ; }`
99

src/test/ui/macros/trace_faulty_macros.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ LL | my_faulty_macro!();
1919
| ^^^^^^^^^^^^^^^^^^^
2020
|
2121
= note: expanding `my_faulty_macro! { }`
22-
= note: to `my_faulty_macro ! (bcd) ;`
22+
= note: to `my_faulty_macro! (bcd) ;`
2323
= note: expanding `my_faulty_macro! { bcd }`
2424

2525
error: recursion limit reached while expanding `my_recursive_macro!`
@@ -41,13 +41,13 @@ LL | my_recursive_macro!();
4141
| ^^^^^^^^^^^^^^^^^^^^^^
4242
|
4343
= note: expanding `my_recursive_macro! { }`
44-
= note: to `my_recursive_macro ! () ;`
44+
= note: to `my_recursive_macro! () ;`
4545
= note: expanding `my_recursive_macro! { }`
46-
= note: to `my_recursive_macro ! () ;`
46+
= note: to `my_recursive_macro! () ;`
4747
= note: expanding `my_recursive_macro! { }`
48-
= note: to `my_recursive_macro ! () ;`
48+
= note: to `my_recursive_macro! () ;`
4949
= note: expanding `my_recursive_macro! { }`
50-
= note: to `my_recursive_macro ! () ;`
50+
= note: to `my_recursive_macro! () ;`
5151

5252
error: expected expression, found `A { a: a, b: 0, c: _, .. }`
5353
--> $DIR/trace_faulty_macros.rs:16:9
@@ -73,7 +73,7 @@ LL | let a = pat_macro!();
7373
| ^^^^^^^^^^^^
7474
|
7575
= note: expanding `pat_macro! { }`
76-
= note: to `pat_macro ! (A { a : a, b : 0, c : _, .. }) ;`
76+
= note: to `pat_macro! (A { a : a, b : 0, c : _, .. }) ;`
7777
= note: expanding `pat_macro! { A { a : a, b : 0, c : _, .. } }`
7878
= note: to `A { a: a, b: 0, c: _, .. }`
7979

src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
8787
span: $DIR/allowed-attr-stmt-expr.rs:57:33: 57:34 (#0),
8888
},
8989
]
90-
PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro ! ("{}", string) ;
90+
PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro! ("{}", string) ;
9191
PRINT-ATTR INPUT (DEBUG): TokenStream [
9292
Punct {
9393
ch: '#',
@@ -140,7 +140,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
140140
span: $DIR/allowed-attr-stmt-expr.rs:61:28: 61:29 (#0),
141141
},
142142
]
143-
PRINT-ATTR INPUT (DISPLAY): second_make_stmt ! (#[allow(dead_code)] struct Bar { }) ;
143+
PRINT-ATTR INPUT (DISPLAY): second_make_stmt! (#[allow(dead_code)] struct Bar { }) ;
144144
PRINT-ATTR INPUT (DEBUG): TokenStream [
145145
Ident {
146146
ident: "second_make_stmt",

src/test/ui/proc-macro/attr-complex-fn.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
7676
span: $DIR/attr-complex-fn.rs:19:42: 19:44 (#0),
7777
},
7878
]
79-
PRINT-ATTR INPUT (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { # ! [rustc_dummy] }
79+
PRINT-ATTR INPUT (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { #! [rustc_dummy] }
8080
PRINT-ATTR INPUT (DEBUG): TokenStream [
8181
Ident {
8282
ident: "impl",

src/test/ui/proc-macro/attr-stmt-expr.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
7171
span: $DIR/attr-stmt-expr.rs:49:33: 49:34 (#0),
7272
},
7373
]
74-
PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro ! ("{}", string) ;
74+
PRINT-ATTR INPUT (DISPLAY): #[expect_my_macro_stmt] my_macro! ("{}", string) ;
7575
PRINT-ATTR INPUT (DEBUG): TokenStream [
7676
Punct {
7777
ch: '#',
@@ -124,7 +124,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
124124
span: $DIR/attr-stmt-expr.rs:53:28: 53:29 (#0),
125125
},
126126
]
127-
PRINT-ATTR INPUT (DISPLAY): second_make_stmt ! (#[allow(dead_code)] struct Bar { }) ;
127+
PRINT-ATTR INPUT (DISPLAY): second_make_stmt! (#[allow(dead_code)] struct Bar { }) ;
128128
PRINT-ATTR INPUT (DEBUG): TokenStream [
129129
Ident {
130130
ident: "second_make_stmt",

src/test/ui/proc-macro/auxiliary/attr-stmt-expr-rpass.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream {
1717
#[proc_macro_attribute]
1818
pub fn expect_print_stmt(attr: TokenStream, item: TokenStream) -> TokenStream {
1919
assert!(attr.to_string().is_empty());
20-
assert_eq!(item.to_string(), "println ! (\"{}\", string) ;");
20+
assert_eq!(item.to_string(), "println! (\"{}\", string) ;");
2121
item
2222
}
2323

@@ -31,7 +31,7 @@ pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
3131
#[proc_macro_attribute]
3232
pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
3333
assert!(attr.to_string().is_empty());
34-
assert_eq!(item.to_string(), "println ! (\"{}\", string)");
34+
assert_eq!(item.to_string(), "println! (\"{}\", string)");
3535
item
3636
}
3737

src/test/ui/proc-macro/auxiliary/attr-stmt-expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream {
1717
#[proc_macro_attribute]
1818
pub fn expect_my_macro_stmt(attr: TokenStream, item: TokenStream) -> TokenStream {
1919
assert!(attr.to_string().is_empty());
20-
assert_eq!(item.to_string(), "my_macro ! (\"{}\", string) ;");
20+
assert_eq!(item.to_string(), "my_macro! (\"{}\", string) ;");
2121
item
2222
}
2323

@@ -31,7 +31,7 @@ pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
3131
#[proc_macro_attribute]
3232
pub fn expect_my_macro_expr(attr: TokenStream, item: TokenStream) -> TokenStream {
3333
assert!(attr.to_string().is_empty());
34-
assert_eq!(item.to_string(), "my_macro ! (\"{}\", string)");
34+
assert_eq!(item.to_string(), "my_macro! (\"{}\", string)");
3535
item
3636
}
3737

src/test/ui/proc-macro/cfg-eval-inner.stdout

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
PRINT-ATTR INPUT (DISPLAY): impl Foo <
22
[u8 ;
33
{
4-
# ! [rustc_dummy(cursed_inner)] # ! [allow(unused)] struct Inner
5-
{ field : [u8 ; { # ! [rustc_dummy(another_cursed_inner)] 1 }] } 0
6-
}] > { # ! [rustc_dummy(evaluated_attr)] fn bar() { } }
4+
#! [rustc_dummy(cursed_inner)] #! [allow(unused)] struct Inner
5+
{ field : [u8 ; { #! [rustc_dummy(another_cursed_inner)] 1 }] } 0
6+
}] > { #! [rustc_dummy(evaluated_attr)] fn bar() { } }
77
PRINT-ATTR INPUT (DEBUG): TokenStream [
88
Ident {
99
ident: "impl",

src/test/ui/proc-macro/dollar-crate-issue-62325.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PRINT-ATTR INPUT (DISPLAY): struct A(identity ! ($crate :: S)) ;
1+
PRINT-ATTR INPUT (DISPLAY): struct A(identity! ($crate :: S)) ;
22
PRINT-ATTR INPUT (DEBUG): TokenStream [
33
Ident {
44
ident: "struct",
@@ -53,7 +53,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
5353
span: $DIR/dollar-crate-issue-62325.rs:19:35: 19:36 (#4),
5454
},
5555
]
56-
PRINT-ATTR INPUT (DISPLAY): struct B(identity ! ($crate :: S)) ;
56+
PRINT-ATTR INPUT (DISPLAY): struct B(identity! ($crate :: S)) ;
5757
PRINT-ATTR INPUT (DEBUG): TokenStream [
5858
Ident {
5959
ident: "struct",

src/test/ui/proc-macro/inner-attr-non-inline-mod.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PRINT-ATTR INPUT (DISPLAY): #[deny(unused_attributes)] mod module_with_attrs { # ! [rustfmt :: skip] }
1+
PRINT-ATTR INPUT (DISPLAY): #[deny(unused_attributes)] mod module_with_attrs { #! [rustfmt :: skip] }
22
PRINT-ATTR INPUT (DEBUG): TokenStream [
33
Punct {
44
ch: '#',

src/test/ui/proc-macro/inner-attrs.stdout

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
66
},
77
]
88
PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(second)] fn foo()
9-
{ # ! [print_target_and_args(third)] # ! [print_target_and_args(fourth)] }
9+
{ #! [print_target_and_args(third)] #! [print_target_and_args(fourth)] }
1010
PRINT-ATTR INPUT (DEBUG): TokenStream [
1111
Punct {
1212
ch: '#',
@@ -121,7 +121,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
121121
},
122122
]
123123
PRINT-ATTR INPUT (DISPLAY): fn foo()
124-
{ # ! [print_target_and_args(third)] # ! [print_target_and_args(fourth)] }
124+
{ #! [print_target_and_args(third)] #! [print_target_and_args(fourth)] }
125125
PRINT-ATTR INPUT (DEBUG): TokenStream [
126126
Ident {
127127
ident: "fn",
@@ -210,7 +210,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
210210
span: $DIR/inner-attrs.rs:19:30: 19:35 (#0),
211211
},
212212
]
213-
PRINT-ATTR INPUT (DISPLAY): fn foo() { # ! [print_target_and_args(fourth)] }
213+
PRINT-ATTR INPUT (DISPLAY): fn foo() { #! [print_target_and_args(fourth)] }
214214
PRINT-ATTR INPUT (DEBUG): TokenStream [
215215
Ident {
216216
ident: "fn",
@@ -299,7 +299,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
299299
]
300300
PRINT-ATTR INPUT (DISPLAY): #[print_target_and_args(mod_second)] mod inline_mod
301301
{
302-
# ! [print_target_and_args(mod_third)] # !
302+
#! [print_target_and_args(mod_third)] #!
303303
[print_target_and_args(mod_fourth)]
304304
}
305305
PRINT-ATTR INPUT (DEBUG): TokenStream [
@@ -412,7 +412,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
412412
]
413413
PRINT-ATTR INPUT (DISPLAY): mod inline_mod
414414
{
415-
# ! [print_target_and_args(mod_third)] # !
415+
#! [print_target_and_args(mod_third)] #!
416416
[print_target_and_args(mod_fourth)]
417417
}
418418
PRINT-ATTR INPUT (DEBUG): TokenStream [
@@ -498,7 +498,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
498498
span: $DIR/inner-attrs.rs:26:30: 26:39 (#0),
499499
},
500500
]
501-
PRINT-ATTR INPUT (DISPLAY): mod inline_mod { # ! [print_target_and_args(mod_fourth)] }
501+
PRINT-ATTR INPUT (DISPLAY): mod inline_mod { #! [print_target_and_args(mod_fourth)] }
502502
PRINT-ATTR INPUT (DEBUG): TokenStream [
503503
Ident {
504504
ident: "mod",
@@ -571,7 +571,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
571571
PRINT-DERIVE INPUT (DISPLAY): struct MyDerivePrint
572572
{
573573
field :
574-
[u8 ; { match true { _ => { # ! [rustc_dummy(third)] true } } ; 0 }]
574+
[u8 ; { match true { _ => { #! [rustc_dummy(third)] true } } ; 0 }]
575575
}
576576
PRINT-DERIVE INPUT (DEBUG): TokenStream [
577577
Ident {
@@ -705,7 +705,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
705705
span: $DIR/inner-attrs.rs:48:29: 48:40 (#0),
706706
},
707707
]
708-
PRINT-ATTR INPUT (DISPLAY): (3, 4, { # ! [cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }) ;
708+
PRINT-ATTR INPUT (DISPLAY): (3, 4, { #! [cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }) ;
709709
PRINT-ATTR INPUT (DEBUG): TokenStream [
710710
Group {
711711
delimiter: Parenthesis,
@@ -819,7 +819,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
819819
span: $DIR/inner-attrs.rs:55:29: 55:40 (#0),
820820
},
821821
]
822-
PRINT-ATTR INPUT (DISPLAY): (3, 4, { # ! [cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }) ;
822+
PRINT-ATTR INPUT (DISPLAY): (3, 4, { #! [cfg_attr(not(FALSE), rustc_dummy(innermost))] 5 }) ;
823823
PRINT-ATTR INPUT (DEBUG): TokenStream [
824824
Group {
825825
delimiter: Parenthesis,

src/test/ui/proc-macro/issue-75734-pp-paren.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PRINT-ATTR INPUT (DISPLAY): fn main() { & | _ : u8 | { } ; mul_2 ! (1 + 1) ; }
1+
PRINT-ATTR INPUT (DISPLAY): fn main() { & | _ : u8 | { } ; mul_2! (1 + 1) ; }
22
PRINT-ATTR INPUT (DEBUG): TokenStream [
33
Ident {
44
ident: "fn",

src/test/ui/proc-macro/issue-75930-derive-cfg.stdout

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ struct Foo < #[cfg(FALSE)] A, B >
1111
#[cfg(FALSE)] true => { },
1212
#[cfg_attr(not(FALSE), allow(warnings))] false => { }, _ => { }
1313
} ; #[print_helper(should_be_removed)] fn removed_fn()
14-
{ # ! [cfg(FALSE)] } #[print_helper(c)] #[cfg(not(FALSE))] fn
15-
kept_fn() { # ! [cfg(not(FALSE))] let my_val = true ; } enum
16-
TupleEnum
14+
{ #! [cfg(FALSE)] } #[print_helper(c)] #[cfg(not(FALSE))] fn
15+
kept_fn() { #! [cfg(not(FALSE))] let my_val = true ; } enum TupleEnum
1716
{
1817
Foo(#[cfg(FALSE)] u8, #[cfg(FALSE)] bool, #[cfg(not(FALSE))] i32,
1918
#[cfg(FALSE)] String, u8)
2019
} struct
2120
TupleStruct(#[cfg(FALSE)] String, #[cfg(not(FALSE))] i32,
2221
#[cfg(FALSE)] bool, u8) ; fn plain_removed_fn()
23-
{ # ! [cfg_attr(not(FALSE), cfg(FALSE))] } 0
22+
{ #! [cfg_attr(not(FALSE), cfg(FALSE))] } 0
2423
}], #[print_helper(d)] fourth : B
2524
}
2625
PRINT-ATTR INPUT (DEBUG): TokenStream [
@@ -1281,7 +1280,7 @@ PRINT-DERIVE INPUT (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[print_hel
12811280
#[cfg(not(FALSE))] struct Inner ; match true
12821281
{ #[allow(warnings)] false => { }, _ => { } } ; #[print_helper(c)]
12831282
#[cfg(not(FALSE))] fn kept_fn()
1284-
{ # ! [cfg(not(FALSE))] let my_val = true ; } enum TupleEnum
1283+
{ #! [cfg(not(FALSE))] let my_val = true ; } enum TupleEnum
12851284
{ Foo(#[cfg(not(FALSE))] i32, u8) } struct
12861285
TupleStruct(#[cfg(not(FALSE))] i32, u8) ; 0
12871286
}], #[print_helper(d)] fourth : B

src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
PRINT-BANG INPUT (DISPLAY): foo ! { #[fake_attr] mod bar {
1+
PRINT-BANG INPUT (DISPLAY): foo! { #[fake_attr] mod bar {
22
#![doc = r" Foo"]
33
} }
4-
PRINT-BANG DEEP-RE-COLLECTED (DISPLAY): foo ! { #[fake_attr] mod bar { # ! [doc = r" Foo"] } }
4+
PRINT-BANG DEEP-RE-COLLECTED (DISPLAY): foo! { #[fake_attr] mod bar { #! [doc = r" Foo"] } }
55
PRINT-BANG INPUT (DEBUG): TokenStream [
66
Ident {
77
ident: "foo",

src/test/ui/proc-macro/macro-rules-derive-cfg.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PRINT-DERIVE INPUT (DISPLAY): struct Foo
44
[bool ;
55
{
66
let a = #[rustc_dummy(first)] #[rustc_dummy(second)]
7-
{ # ! [allow(unused)] 30 } ; 0
7+
{ #! [allow(unused)] 30 } ; 0
88
}]
99
}
1010
PRINT-DERIVE INPUT (DEBUG): TokenStream [

src/test/ui/proc-macro/meta-macro-hygiene.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ macro_rules! produce_it
3030
*/ {
3131
() =>
3232
{
33-
meta_macro :: print_def_site ! ($ crate :: dummy ! ()) ;
33+
meta_macro :: print_def_site! ($ crate :: dummy! ()) ;
3434
// `print_def_site!` will respan the `$crate` identifier
3535
// with `Span::def_site()`. This should cause it to resolve
3636
// relative to `meta_macro`, *not* `make_macro` (despite

src/test/ui/proc-macro/nodelim-groups.stdout

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
7171
},
7272
]
7373
PRINT-BANG INPUT (DISPLAY): "hi" "hello".len() + "world".len() (1 + 1)
74-
PRINT-BANG DEEP-RE-COLLECTED (DISPLAY): "hi" "hello" . len() + "world" . len() (1 + 1)
7574
PRINT-BANG INPUT (DEBUG): TokenStream [
7675
Literal {
7776
kind: Str,

src/test/ui/proc-macro/nonterminal-expansion.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PRINT-ATTR_ARGS INPUT (DISPLAY): a, line!(), b
2-
PRINT-ATTR_ARGS RE-COLLECTED (DISPLAY): a, line ! (), b
2+
PRINT-ATTR_ARGS RE-COLLECTED (DISPLAY): a, line! (), b
33
PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [
44
Ident {
55
ident: "a",

src/test/ui/proc-macro/nonterminal-token-hygiene.stdout

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ macro_rules! outer
5252
*/ {
5353
($ item : item) =>
5454
{
55-
macro inner() { print_bang ! { $ item } } inner ! () ;
55+
macro inner() { print_bang! { $ item } } inner! () ;
5656

5757
} ;
5858
}
5959

6060
struct S /* 0#0 */;
61-
macro inner /* 0#4 */ { () => { print_bang ! { struct S; } } }
61+
macro inner /* 0#4 */ { () => { print_bang! { struct S; } } }
6262

6363
struct S /* 0#5 */;
6464
// OK, not a duplicate definition of `S`
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// check-pass
2+
// aux-build:test-macros.rs
3+
// compile-flags: -Z span-debug
4+
5+
#![feature(rustc_attrs)]
6+
7+
#![no_std] // Don't load unnecessary hygiene information from std
8+
extern crate std;
9+
10+
#[macro_use]
11+
extern crate test_macros;
12+
13+
// Tests the pretty-printing behavior of various (unparsed) tokens
14+
print_bang_consume!({
15+
#![rustc_dummy]
16+
let a = "hello".len();
17+
matches!(a, 5);
18+
});
19+
20+
fn main() {}

0 commit comments

Comments
 (0)