Skip to content

Commit

Permalink
Add a test case with $crate from other crate
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jul 9, 2019
1 parent 3997507 commit 4cb67c0
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/test/ui/proc-macro/auxiliary/dollar-crate-external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ macro_rules! external {
struct D($crate::S);
};
}

#[macro_export]
macro_rules! issue_62325 { () => {
#[print_attr]
struct B(identity!($crate::S));
}}
4 changes: 4 additions & 0 deletions src/test/ui/proc-macro/dollar-crate-issue-62325.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// check-pass
// edition:2018
// aux-build:test-macros.rs
// aux-build:dollar-crate-external.rs

// Anonymize unstable non-dummy spans while still showing dummy spans `0..0`.
// normalize-stdout-test "bytes\([^0]\w*\.\.(\w+)\)" -> "bytes(LO..$1)"
Expand All @@ -10,6 +11,7 @@

#[macro_use]
extern crate test_macros;
extern crate dollar_crate_external;

type S = u8;

Expand All @@ -20,4 +22,6 @@ macro_rules! m { () => {

m!();

dollar_crate_external::issue_62325!();

fn main() {}
56 changes: 56 additions & 0 deletions src/test/ui/proc-macro/dollar-crate-issue-62325.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,59 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
span: #2 bytes(LO..HI),
},
]
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 INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #7 bytes(LO..HI),
},
Ident {
ident: "B",
span: #7 bytes(LO..HI),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "identity",
span: #7 bytes(LO..HI),
},
Punct {
ch: '!',
spacing: Alone,
span: #7 bytes(LO..HI),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "$crate",
span: #7 bytes(LO..HI),
},
Punct {
ch: ':',
spacing: Joint,
span: #7 bytes(LO..HI),
},
Punct {
ch: ':',
spacing: Alone,
span: #7 bytes(LO..HI),
},
Ident {
ident: "S",
span: #7 bytes(LO..HI),
},
],
span: #7 bytes(LO..HI),
},
],
span: #7 bytes(LO..HI),
},
Punct {
ch: ';',
spacing: Alone,
span: #7 bytes(LO..HI),
},
]

0 comments on commit 4cb67c0

Please sign in to comment.