From 6a3f2ce76ca06c5541b3bdd8c626abedbc812685 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 1 Apr 2021 03:45:21 +0800 Subject: Fix block inner item defined in macro --- crates/hir_ty/src/tests/macros.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs index 3eb01dbd0..86e3d8b86 100644 --- a/crates/hir_ty/src/tests/macros.rs +++ b/crates/hir_ty/src/tests/macros.rs @@ -372,6 +372,32 @@ fn recursive_inner_item_macro_rules() { ); } +#[test] +fn infer_macro_defining_block_with_items() { + check_infer( + r#" + macro_rules! foo { + () => {{ + fn bar() -> usize { 0 } + bar() + }}; + } + fn main() { + let _a = foo!(); + } + "#, + expect![[r#" + !15..18 '{0}': usize + !16..17 '0': usize + !0..24 '{fnbar...bar()}': usize + !18..21 'bar': fn bar() -> usize + !18..23 'bar()': usize + 98..122 '{ ...!(); }': () + 108..110 '_a': usize + "#]], + ); +} + #[test] fn infer_type_value_macro_having_same_name() { check_infer( -- cgit v1.2.3