From 2df637f41900e50bbe47d2628554f7ffd167749a Mon Sep 17 00:00:00 2001 From: Brandon Date: Sat, 13 Mar 2021 21:28:10 -0800 Subject: Fix incorrect diagnositics for failing built in eager macros --- crates/hir_def/src/nameres/tests/diagnostics.rs | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'crates/hir_def/src/nameres/tests') diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs index d5ef8ceb5..bfc1ab13f 100644 --- a/crates/hir_def/src/nameres/tests/diagnostics.rs +++ b/crates/hir_def/src/nameres/tests/diagnostics.rs @@ -152,3 +152,48 @@ fn inactive_via_cfg_attr() { "#, ); } + +#[test] +fn unresolved_legacy_scope_macro() { + check_diagnostics( + r#" + //- /lib.rs + macro_rules! m { () => {} } + + m!(); + m2!(); + //^^^^^^ unresolved macro call + "#, + ); +} + +#[test] +fn unresolved_module_scope_macro() { + check_diagnostics( + r#" + //- /lib.rs + mod mac { + #[macro_export] + macro_rules! m { () => {} } + } + + self::m!(); + self::m2!(); + //^^^^^^^^^^^^ unresolved macro call + "#, + ); +} + +#[test] +fn builtin_macro_fails_expansion() { + check_diagnostics( + r#" + //- /lib.rs + #[rustc_builtin_macro] + macro_rules! include { () => {} } + + include!("doesntexist"); + //^^^^^^^^^^^^^^^^^^^^^^^^ could not convert tokens + "#, + ); +} -- cgit v1.2.3