From 4cb67c0f1c429a1a1e2ec8c3e02714557feeb60d Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 9 Jul 2019 22:21:55 +0300 Subject: [PATCH] Add a test case with `$crate` from other crate --- .../auxiliary/dollar-crate-external.rs | 6 ++ .../ui/proc-macro/dollar-crate-issue-62325.rs | 4 ++ .../dollar-crate-issue-62325.stdout | 56 +++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/src/test/ui/proc-macro/auxiliary/dollar-crate-external.rs b/src/test/ui/proc-macro/auxiliary/dollar-crate-external.rs index d5d393b5a6457..bdcdb7922ca57 100644 --- a/src/test/ui/proc-macro/auxiliary/dollar-crate-external.rs +++ b/src/test/ui/proc-macro/auxiliary/dollar-crate-external.rs @@ -14,3 +14,9 @@ macro_rules! external { struct D($crate::S); }; } + +#[macro_export] +macro_rules! issue_62325 { () => { + #[print_attr] + struct B(identity!($crate::S)); +}} diff --git a/src/test/ui/proc-macro/dollar-crate-issue-62325.rs b/src/test/ui/proc-macro/dollar-crate-issue-62325.rs index 35c61b2bc69e0..b7b152e669213 100644 --- a/src/test/ui/proc-macro/dollar-crate-issue-62325.rs +++ b/src/test/ui/proc-macro/dollar-crate-issue-62325.rs @@ -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)" @@ -10,6 +11,7 @@ #[macro_use] extern crate test_macros; +extern crate dollar_crate_external; type S = u8; @@ -20,4 +22,6 @@ macro_rules! m { () => { m!(); +dollar_crate_external::issue_62325!(); + fn main() {} diff --git a/src/test/ui/proc-macro/dollar-crate-issue-62325.stdout b/src/test/ui/proc-macro/dollar-crate-issue-62325.stdout index 033699d8d86ae..17ad1a7af7046 100644 --- a/src/test/ui/proc-macro/dollar-crate-issue-62325.stdout +++ b/src/test/ui/proc-macro/dollar-crate-issue-62325.stdout @@ -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), + }, +]