From 76f2b9d2ef797fb995f1bd2706a7e609d014a67a Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Mon, 4 Jan 2021 10:53:31 +0800 Subject: Proper handling $crate Take 2 --- crates/hir_ty/src/tests/macros.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'crates/hir_ty/src') diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs index 1953da7be..c64f0b5b5 100644 --- a/crates/hir_ty/src/tests/macros.rs +++ b/crates/hir_ty/src/tests/macros.rs @@ -370,6 +370,37 @@ expand!(); ); } +#[test] +fn infer_macro_with_dollar_crate_in_def_site() { + check_types( + r#" +//- /main.rs crate:main deps:foo +use foo::expand; + +macro_rules! list { + ($($tt:tt)*) => { $($tt)* } +} + +fn test() { + let r = expand!(); + r; + //^ u128 +} + +//- /lib.rs crate:foo +#[macro_export] +macro_rules! expand { + () => { list!($crate::m!()) }; +} + +#[macro_export] +macro_rules! m { + () => { 0u128 }; +} +"#, + ); +} + #[test] fn infer_type_value_non_legacy_macro_use_as() { check_infer( -- cgit v1.2.3