Skip to content

Commit da50d59

Browse files
committed
pretty-print: Do not lose the $crate printing flag in print_tt
1 parent 6907005 commit da50d59

6 files changed

+29
-11
lines changed

src/libsyntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
689689
TokenTree::Delimited(_, delim, tts) => {
690690
self.word(token_kind_to_string(&token::OpenDelim(delim)));
691691
self.space();
692-
self.print_tts(tts);
692+
self.print_tts(tts, convert_dollar_crate);
693693
self.space();
694694
self.word(token_kind_to_string(&token::CloseDelim(delim)))
695695
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pub type S = u8;
2+
3+
macro_rules! generate_exported { () => {
4+
#[macro_export]
5+
macro_rules! exported {
6+
() => ($crate::S)
7+
}
8+
}}
9+
10+
generate_exported!();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// check-pass
2+
// aux-build:dollar-crate-nested-encoding.rs
3+
4+
extern crate dollar_crate_nested_encoding;
5+
6+
type A = dollar_crate_nested_encoding::exported!();
7+
8+
fn main() {}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PRINT-BANG INPUT (DISPLAY): struct M ( crate :: S ) ;
1+
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
22
PRINT-BANG INPUT (DEBUG): TokenStream [
33
Ident {
44
ident: "struct",
@@ -39,7 +39,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
3939
},
4040
]
4141
PRINT-ATTR INPUT (DISPLAY): struct A(crate::S);
42-
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( crate :: S ) ;
42+
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
4343
PRINT-ATTR INPUT (DEBUG): TokenStream [
4444
Ident {
4545
ident: "struct",

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PRINT-ATTR INPUT (DISPLAY): struct A(identity!(crate :: S));
2-
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( identity ! ( crate :: S ) ) ;
2+
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( identity ! ( $crate :: S ) ) ;
33
PRINT-ATTR INPUT (DEBUG): TokenStream [
44
Ident {
55
ident: "struct",
@@ -55,7 +55,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
5555
},
5656
]
5757
PRINT-ATTR INPUT (DISPLAY): struct B(identity!(::dollar_crate_external :: S));
58-
PRINT-ATTR RE-COLLECTED (DISPLAY): struct B ( identity ! ( ::dollar_crate_external :: S ) ) ;
58+
PRINT-ATTR RE-COLLECTED (DISPLAY): struct B ( identity ! ( $crate :: S ) ) ;
5959
PRINT-ATTR INPUT (DEBUG): TokenStream [
6060
Ident {
6161
ident: "struct",

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PRINT-BANG INPUT (DISPLAY): struct M ( crate :: S ) ;
1+
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
22
PRINT-BANG INPUT (DEBUG): TokenStream [
33
Ident {
44
ident: "struct",
@@ -39,7 +39,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
3939
},
4040
]
4141
PRINT-ATTR INPUT (DISPLAY): struct A(crate::S);
42-
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( crate :: S ) ;
42+
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
4343
PRINT-ATTR INPUT (DEBUG): TokenStream [
4444
Ident {
4545
ident: "struct",
@@ -80,7 +80,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
8080
},
8181
]
8282
PRINT-DERIVE INPUT (DISPLAY): struct D(crate::S);
83-
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( crate :: S ) ;
83+
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( $crate :: S ) ;
8484
PRINT-DERIVE INPUT (DEBUG): TokenStream [
8585
Ident {
8686
ident: "struct",
@@ -120,7 +120,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
120120
span: #2 bytes(LO..HI),
121121
},
122122
]
123-
PRINT-BANG INPUT (DISPLAY): struct M ( ::dollar_crate_external :: S ) ;
123+
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
124124
PRINT-BANG INPUT (DEBUG): TokenStream [
125125
Ident {
126126
ident: "struct",
@@ -161,7 +161,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
161161
},
162162
]
163163
PRINT-ATTR INPUT (DISPLAY): struct A(::dollar_crate_external::S);
164-
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( ::dollar_crate_external :: S ) ;
164+
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
165165
PRINT-ATTR INPUT (DEBUG): TokenStream [
166166
Ident {
167167
ident: "struct",
@@ -202,7 +202,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
202202
},
203203
]
204204
PRINT-DERIVE INPUT (DISPLAY): struct D(::dollar_crate_external::S);
205-
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( ::dollar_crate_external :: S ) ;
205+
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( $crate :: S ) ;
206206
PRINT-DERIVE INPUT (DEBUG): TokenStream [
207207
Ident {
208208
ident: "struct",

0 commit comments

Comments
 (0)