From 5cd1b5dd7972e465bb7d7f6fbfecae6b6f6c299d Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Tue, 14 Jul 2020 23:21:59 -0400 Subject: [PATCH] Add test for use of $crate in nested foreign macro_rules! --- .../ui/hygiene/auxiliary/nested-dollar-crate.rs | 14 ++++++++++++++ src/test/ui/hygiene/nested-dollar-crate.rs | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/test/ui/hygiene/auxiliary/nested-dollar-crate.rs create mode 100644 src/test/ui/hygiene/nested-dollar-crate.rs diff --git a/src/test/ui/hygiene/auxiliary/nested-dollar-crate.rs b/src/test/ui/hygiene/auxiliary/nested-dollar-crate.rs new file mode 100644 index 00000000000..e5caa0f9cf8 --- /dev/null +++ b/src/test/ui/hygiene/auxiliary/nested-dollar-crate.rs @@ -0,0 +1,14 @@ +pub const IN_DEF_CRATE: &str = "In def crate!"; + +macro_rules! make_it { + () => { + #[macro_export] + macro_rules! inner { + () => { + $crate::IN_DEF_CRATE + } + } + } +} + +make_it!(); diff --git a/src/test/ui/hygiene/nested-dollar-crate.rs b/src/test/ui/hygiene/nested-dollar-crate.rs new file mode 100644 index 00000000000..e8703bc77ee --- /dev/null +++ b/src/test/ui/hygiene/nested-dollar-crate.rs @@ -0,0 +1,9 @@ +// aux-build:nested-dollar-crate.rs +// edition:2018 +// run-pass + +extern crate nested_dollar_crate; + +fn main() { + assert_eq!(nested_dollar_crate::inner!(), "In def crate!"); +}