File tree 3 files changed +38
-0
lines changed
3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -379,6 +379,23 @@ fn handle_vec_semi(
379
379
}
380
380
}
381
381
382
+ fn rewrite_empty_macro_def_body (
383
+ context : & RewriteContext < ' _ > ,
384
+ span : Span ,
385
+ shape : Shape ,
386
+ ) -> Option < String > {
387
+ // Create an empty, dummy `ast::Block` representing an empty macro body
388
+ let block = ast:: Block {
389
+ stmts : vec ! [ ] . into ( ) ,
390
+ id : rustc_ast:: node_id:: DUMMY_NODE_ID ,
391
+ rules : ast:: BlockCheckMode :: Default ,
392
+ span : span,
393
+ tokens : None ,
394
+ could_be_bare_literal : false ,
395
+ } ;
396
+ block. rewrite ( context, shape)
397
+ }
398
+
382
399
pub ( crate ) fn rewrite_macro_def (
383
400
context : & RewriteContext < ' _ > ,
384
401
shape : Shape ,
@@ -419,6 +436,13 @@ pub(crate) fn rewrite_macro_def(
419
436
shape
420
437
} ;
421
438
439
+ if parsed_def. branches . len ( ) == 0 {
440
+ let lo = context. snippet_provider . span_before ( span, "{" ) ;
441
+ result += " " ;
442
+ result += & rewrite_empty_macro_def_body ( context, span. with_lo ( lo) , shape) ?;
443
+ return Some ( result) ;
444
+ }
445
+
422
446
let branch_items = itemize_list (
423
447
context. snippet_provider ,
424
448
parsed_def. branches . iter ( ) ,
Original file line number Diff line number Diff line change
1
+ macro_rules! foo{ }
2
+ macro_rules! bar{ /*comment*/ }
3
+ macro_rules! baz{ //comment
4
+ }
5
+ macro_rules! foobar{
6
+ //comment
7
+ }
Original file line number Diff line number Diff line change
1
+ macro_rules! foo { }
2
+ macro_rules! bar { /*comment*/ }
3
+ macro_rules! baz { //comment
4
+ }
5
+ macro_rules! foobar {
6
+ //comment
7
+ }
You can’t perform that action at this time.
0 commit comments