diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-04 01:28:24 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-09 22:17:44 +0300 |
| commit | 7aaf0de700d1bc242d270dcc7e2fee9e3533ea0a (patch) | |
| tree | 3fbd649aa1286fa7284d90ea0b4bdd276bc170de /src | |
| parent | b8ec4c4d11ede0fba333a0474ed473dbe82aacf1 (diff) | |
| download | rust-7aaf0de700d1bc242d270dcc7e2fee9e3533ea0a.tar.gz rust-7aaf0de700d1bc242d270dcc7e2fee9e3533ea0a.zip | |
Add a test for `$crate` inside macro invocation
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/proc-macro/dollar-crate-issue-62325.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/dollar-crate-issue-62325.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/dollar-crate-issue-62325.stdout | 61 |
3 files changed, 89 insertions, 0 deletions
diff --git a/src/test/ui/proc-macro/dollar-crate-issue-62325.rs b/src/test/ui/proc-macro/dollar-crate-issue-62325.rs new file mode 100644 index 00000000000..8e21ca87f92 --- /dev/null +++ b/src/test/ui/proc-macro/dollar-crate-issue-62325.rs @@ -0,0 +1,24 @@ +//~ ERROR expected type, found `$` + +// edition:2018 +// aux-build:test-macros.rs + +// Anonymize unstable non-dummy spans while still showing dummy spans `0..0`. +// normalize-stdout-test "bytes\([^0]\w*\.\.(\w+)\)" -> "bytes(LO..$1)" +// normalize-stdout-test "bytes\((\w+)\.\.[^0]\w*\)" -> "bytes($1..HI)" + +#![feature(proc_macro_hygiene)] + +#[macro_use] +extern crate test_macros; + +type S = u8; + +macro_rules! m { () => { + #[print_attr] + struct A(identity!($crate::S)); +}} + +m!(); + +fn main() {} diff --git a/src/test/ui/proc-macro/dollar-crate-issue-62325.stderr b/src/test/ui/proc-macro/dollar-crate-issue-62325.stderr new file mode 100644 index 00000000000..ecc0d3853e5 --- /dev/null +++ b/src/test/ui/proc-macro/dollar-crate-issue-62325.stderr @@ -0,0 +1,4 @@ +error: expected type, found `$` + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/dollar-crate-issue-62325.stdout b/src/test/ui/proc-macro/dollar-crate-issue-62325.stdout new file mode 100644 index 00000000000..e181a4ed54b --- /dev/null +++ b/src/test/ui/proc-macro/dollar-crate-issue-62325.stdout @@ -0,0 +1,61 @@ +PRINT-ATTR INPUT (DISPLAY): struct A(identity!($crate :: S)); +PRINT-ATTR RE-COLLECTED (DISPLAY): struct A ( identity ! ( $ crate :: S ) ) ; +PRINT-ATTR INPUT (DEBUG): TokenStream [ + Ident { + ident: "struct", + span: #0 bytes(0..0), + }, + Ident { + ident: "A", + span: #0 bytes(0..0), + }, + Group { + delimiter: Parenthesis, + stream: TokenStream [ + Ident { + ident: "identity", + span: #0 bytes(0..0), + }, + Punct { + ch: '!', + spacing: Alone, + span: #0 bytes(0..0), + }, + Group { + delimiter: Parenthesis, + stream: TokenStream [ + Punct { + ch: '$', + spacing: Alone, + span: #0 bytes(0..0), + }, + Ident { + ident: "crate", + span: #0 bytes(0..0), + }, + Punct { + ch: ':', + spacing: Joint, + span: #0 bytes(0..0), + }, + Punct { + ch: ':', + spacing: Alone, + span: #0 bytes(0..0), + }, + Ident { + ident: "S", + span: #0 bytes(0..0), + }, + ], + span: #0 bytes(0..0), + }, + ], + span: #0 bytes(0..0), + }, + Punct { + ch: ';', + spacing: Alone, + span: #0 bytes(0..0), + }, +] |
