Skip to content
Permalink
Browse files

pretty-print: Do not lose the `$crate` printing flag in `print_tt`

  • Loading branch information...
petrochenkov committed Jul 10, 2019
1 parent 6907005 commit da50d598816c0ba367e330309707cb94637cce2e
@@ -689,7 +689,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
TokenTree::Delimited(_, delim, tts) => {
self.word(token_kind_to_string(&token::OpenDelim(delim)));
self.space();
self.print_tts(tts);
self.print_tts(tts, convert_dollar_crate);
self.space();
self.word(token_kind_to_string(&token::CloseDelim(delim)))
},
@@ -0,0 +1,10 @@
pub type S = u8;

macro_rules! generate_exported { () => {
#[macro_export]
macro_rules! exported {
() => ($crate::S)
}
}}

generate_exported!();
@@ -0,0 +1,8 @@
// check-pass
// aux-build:dollar-crate-nested-encoding.rs

extern crate dollar_crate_nested_encoding;

type A = dollar_crate_nested_encoding::exported!();

fn main() {}
@@ -1,4 +1,4 @@
PRINT-BANG INPUT (DISPLAY): struct M ( crate :: S ) ;
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
PRINT-BANG INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
@@ -39,7 +39,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
},
]
PRINT-ATTR INPUT (DISPLAY): struct A(crate::S);
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( crate :: S ) ;
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
@@ -1,5 +1,5 @@
PRINT-ATTR INPUT (DISPLAY): struct A(identity!(crate :: S));
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( identity ! ( crate :: S ) ) ;
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( identity ! ( $crate :: S ) ) ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
@@ -55,7 +55,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
},
]
PRINT-ATTR INPUT (DISPLAY): struct B(identity!(::dollar_crate_external :: S));
PRINT-ATTR RE-COLLECTED (DISPLAY): struct B ( identity ! ( ::dollar_crate_external :: S ) ) ;
PRINT-ATTR RE-COLLECTED (DISPLAY): struct B ( identity ! ( $crate :: S ) ) ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
@@ -1,4 +1,4 @@
PRINT-BANG INPUT (DISPLAY): struct M ( crate :: S ) ;
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
PRINT-BANG INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
@@ -39,7 +39,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
},
]
PRINT-ATTR INPUT (DISPLAY): struct A(crate::S);
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( crate :: S ) ;
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
@@ -80,7 +80,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
},
]
PRINT-DERIVE INPUT (DISPLAY): struct D(crate::S);
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( crate :: S ) ;
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( $crate :: S ) ;
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
@@ -120,7 +120,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
span: #2 bytes(LO..HI),
},
]
PRINT-BANG INPUT (DISPLAY): struct M ( ::dollar_crate_external :: S ) ;
PRINT-BANG INPUT (DISPLAY): struct M ( $crate :: S ) ;
PRINT-BANG INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
@@ -161,7 +161,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
},
]
PRINT-ATTR INPUT (DISPLAY): struct A(::dollar_crate_external::S);
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( ::dollar_crate_external :: S ) ;
PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( $crate :: S ) ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
@@ -202,7 +202,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
},
]
PRINT-DERIVE INPUT (DISPLAY): struct D(::dollar_crate_external::S);
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( ::dollar_crate_external :: S ) ;
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct D ( $crate :: S ) ;
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",

0 comments on commit da50d59

Please sign in to comment.
You can’t perform that action at this time.