File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
Expand file tree Collapse file tree 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(
379379 }
380380}
381381
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+
382399pub ( crate ) fn rewrite_macro_def (
383400 context : & RewriteContext < ' _ > ,
384401 shape : Shape ,
@@ -419,6 +436,13 @@ pub(crate) fn rewrite_macro_def(
419436 shape
420437 } ;
421438
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+
422446 let branch_items = itemize_list (
423447 context. snippet_provider ,
424448 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