Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_def/src/macro_expansion_tests/mbe.rs')
| -rw-r--r-- | crates/hir_def/src/macro_expansion_tests/mbe.rs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests/mbe.rs b/crates/hir_def/src/macro_expansion_tests/mbe.rs index c57e9cd838..8851028845 100644 --- a/crates/hir_def/src/macro_expansion_tests/mbe.rs +++ b/crates/hir_def/src/macro_expansion_tests/mbe.rs @@ -159,3 +159,66 @@ struct Bar; "##]], ); } + +#[test] +fn test_match_group_pattern_with_multiple_defs() { + check( + r#" +macro_rules! m { + ($ ($ i:ident),*) => ( impl Bar { $ ( fn $ i {} )*} ); +} +m! { foo, bar } +"#, + expect![[r#" +macro_rules! m { + ($ ($ i:ident),*) => ( impl Bar { $ ( fn $ i {} )*} ); +} +impl Bar { +fn foo {} +fn bar {} +} +"#]], + ); +} + +#[test] +fn test_match_group_pattern_with_multiple_statement() { + check( + r#" +macro_rules! m { + ($ ($ i:ident),*) => ( fn baz { $ ( $ i (); )*} ); +} +m! { foo, bar } +"#, + expect![[r#" +macro_rules! m { + ($ ($ i:ident),*) => ( fn baz { $ ( $ i (); )*} ); +} +fn baz { +foo(); +bar(); +} +"#]], + ) +} + +#[test] +fn test_match_group_pattern_with_multiple_statement_without_semi() { + check( + r#" +macro_rules! m { + ($ ($ i:ident),*) => ( fn baz { $ ( $i() );*} ); +} +m! { foo, bar } +"#, + expect![[r#" +macro_rules! m { + ($ ($ i:ident),*) => ( fn baz { $ ( $i() );*} ); +} +fn baz { +foo(); +bar() +} +"#]], + ) +} |