File tree 2 files changed +37
-8
lines changed
2 files changed +37
-8
lines changed Original file line number Diff line number Diff line change @@ -2330,14 +2330,26 @@ impl Clean<Item> for (&hir::MacroDef<'_>, Option<Ident>) {
2330
2330
. collect:: <String >( ) ,
2331
2331
)
2332
2332
} else {
2333
- // This code currently assumes that there will only be one or zero matchers, as syntax
2334
- // for multiple is not currently defined.
2335
- format ! (
2336
- "{}macro {}{} {{\n \t ...\n }}" ,
2337
- item. vis. clean( cx) . print_with_space( ) ,
2338
- name,
2339
- matchers. iter( ) . map( |span| span. to_src( cx) ) . collect:: <String >( ) ,
2340
- )
2333
+ let vis = item. vis . clean ( cx) ;
2334
+
2335
+ if matchers. len ( ) <= 1 {
2336
+ format ! (
2337
+ "{}macro {}{} {{\n ...\n }}" ,
2338
+ vis. print_with_space( ) ,
2339
+ name,
2340
+ matchers. iter( ) . map( |span| span. to_src( cx) ) . collect:: <String >( ) ,
2341
+ )
2342
+ } else {
2343
+ format ! (
2344
+ "{}macro {} {{\n {}}}" ,
2345
+ vis. print_with_space( ) ,
2346
+ name,
2347
+ matchers
2348
+ . iter( )
2349
+ . map( |span| { format!( " {} => {{ ... }},\n " , span. to_src( cx) ) } )
2350
+ . collect:: <String >( ) ,
2351
+ )
2352
+ }
2341
2353
} ;
2342
2354
2343
2355
Item :: from_hir_id_and_parts (
Original file line number Diff line number Diff line change @@ -13,3 +13,20 @@ pub macro my_macro() {
13
13
pub macro my_macro_2( $( $tok: tt) * ) {
14
14
15
15
}
16
+
17
+ // @has decl_macro/macro.my_macro_multi.html //pre 'pub macro my_macro_multi {'
18
+ // @has - //pre '(_) => { ... },'
19
+ // @has - //pre '($foo:ident . $bar:expr) => { ... },'
20
+ // @has - //pre '($($foo:literal),+) => { ... }'
21
+ // @has - //pre '}'
22
+ pub macro my_macro_multi {
23
+ ( _) => {
24
+
25
+ } ,
26
+ ( $foo: ident . $bar: expr) => {
27
+
28
+ } ,
29
+ ( $( $foo: literal) , +) => {
30
+
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments