From 6c1d29256902d16c520fe076ce06cb91d934b62f Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 8 Dec 2020 17:17:30 +0100 Subject: Add test for `$crate` in builtin macros Fixes #6716 --- crates/hir_def/src/body/tests.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index 6dba9817d..de77d5fc9 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs @@ -134,3 +134,31 @@ fn f() { "#, ); } + +#[test] +fn dollar_crate_in_builtin_macro() { + check_diagnostics( + r#" +#[macro_export] +#[rustc_builtin_macro] +macro_rules! format_args {} + +#[macro_export] +macro_rules! arg { + () => {} +} + +#[macro_export] +macro_rules! outer { + () => { + $crate::format_args!( "", $crate::arg!(1) ) + }; +} + +fn f() { + outer!(); + //^^^^^^^^ leftover tokens +} + "#, + ) +} -- cgit v1.2.3