File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -395,3 +395,25 @@ fn foo() {
395
395
"# ] ] ,
396
396
)
397
397
}
398
+
399
+ #[ test]
400
+ fn trailing_expr_macro_expands_stmts ( ) {
401
+ check_at (
402
+ r#"
403
+ macro_rules! foo {
404
+ () => { const FOO: u32 = 0;const BAR: u32 = 0; };
405
+ }
406
+ fn f() {$0
407
+ foo!{}
408
+ };
409
+ "# ,
410
+ expect ! [ [ r#"
411
+ block scope
412
+ BAR: v
413
+ FOO: v
414
+
415
+ crate
416
+ f: v
417
+ "# ] ] ,
418
+ )
419
+ }
Original file line number Diff line number Diff line change @@ -90,6 +90,13 @@ impl<'a> Ctx<'a> {
90
90
_ => None ,
91
91
} )
92
92
. collect ( ) ;
93
+ if let Some ( ast:: Expr :: MacroExpr ( expr) ) = block. tail_expr ( ) {
94
+ if let Some ( call) = expr. macro_call ( ) {
95
+ if let Some ( mod_item) = self . lower_mod_item ( & call. into ( ) ) {
96
+ self . tree . top_level . push ( mod_item) ;
97
+ }
98
+ }
99
+ }
93
100
94
101
self . tree
95
102
}
You can’t perform that action at this time.
0 commit comments