diff options
Diffstat (limited to 'crates/hir_ty/src/tests/macros.rs')
-rw-r--r-- | crates/hir_ty/src/tests/macros.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs index af4f8bb11..12951fb16 100644 --- a/crates/hir_ty/src/tests/macros.rs +++ b/crates/hir_ty/src/tests/macros.rs | |||
@@ -232,6 +232,28 @@ fn expr_macro_expanded_in_stmts() { | |||
232 | } | 232 | } |
233 | 233 | ||
234 | #[test] | 234 | #[test] |
235 | fn recursive_inner_item_macro_rules() { | ||
236 | check_infer( | ||
237 | r#" | ||
238 | macro_rules! mac { | ||
239 | () => { mac!($)}; | ||
240 | ($x:tt) => { macro_rules! blub { () => { 1 }; } }; | ||
241 | } | ||
242 | fn foo() { | ||
243 | mac!(); | ||
244 | let a = blub!(); | ||
245 | } | ||
246 | "#, | ||
247 | expect![[r#" | ||
248 | !0..1 '1': i32 | ||
249 | !0..7 'mac!($)': {unknown} | ||
250 | 107..143 '{ ...!(); }': () | ||
251 | 129..130 'a': i32 | ||
252 | "#]], | ||
253 | ); | ||
254 | } | ||
255 | |||
256 | #[test] | ||
235 | fn infer_type_value_macro_having_same_name() { | 257 | fn infer_type_value_macro_having_same_name() { |
236 | check_infer( | 258 | check_infer( |
237 | r#" | 259 | r#" |
@@ -585,6 +607,29 @@ fn bar() -> u32 {0} | |||
585 | } | 607 | } |
586 | 608 | ||
587 | #[test] | 609 | #[test] |
610 | fn infer_builtin_macros_include_child_mod() { | ||
611 | check_types( | ||
612 | r#" | ||
613 | //- /main.rs | ||
614 | #[rustc_builtin_macro] | ||
615 | macro_rules! include {() => {}} | ||
616 | |||
617 | include!("f/foo.rs"); | ||
618 | |||
619 | fn main() { | ||
620 | bar::bar(); | ||
621 | } //^ u32 | ||
622 | |||
623 | //- /f/foo.rs | ||
624 | pub mod bar; | ||
625 | |||
626 | //- /f/bar.rs | ||
627 | pub fn bar() -> u32 {0} | ||
628 | "#, | ||
629 | ); | ||
630 | } | ||
631 | |||
632 | #[test] | ||
588 | fn infer_builtin_macros_include_str() { | 633 | fn infer_builtin_macros_include_str() { |
589 | check_types( | 634 | check_types( |
590 | r#" | 635 | r#" |