@@ -546,17 +546,35 @@ fn build_static(cx: &mut DocContext<'_>, did: DefId, mutable: bool) -> clean::St
546546fn build_macro ( cx : & mut DocContext < ' _ > , did : DefId , name : Symbol ) -> clean:: ItemKind {
547547 let imported_from = cx. tcx . crate_name ( did. krate ) ;
548548 match cx. enter_resolver ( |r| r. cstore ( ) . load_macro_untracked ( did, cx. sess ( ) ) ) {
549- LoadedMacro :: MacroDef ( def , _) => {
550- if let ast:: ItemKind :: MacroDef ( ref def) = def . kind {
549+ LoadedMacro :: MacroDef ( item_def , _) => {
550+ if let ast:: ItemKind :: MacroDef ( ref def) = item_def . kind {
551551 let tts: Vec < _ > = def. body . inner_tokens ( ) . into_trees ( ) . collect ( ) ;
552552 let matchers = tts. chunks ( 4 ) . map ( |arm| & arm[ 0 ] ) ;
553-
554- let source = format ! (
555- "macro_rules! {} {{\n {}}}" ,
556- name,
557- utils:: render_macro_arms( matchers, ";" )
558- ) ;
559-
553+ let source = if def. macro_rules {
554+ format ! (
555+ "macro_rules! {} {{\n {}}}" ,
556+ name,
557+ utils:: render_macro_arms( matchers, ";" )
558+ )
559+ } else {
560+ let vis = item_def. vis . clean ( cx) ;
561+
562+ if matchers. len ( ) <= 1 {
563+ format ! (
564+ "{}macro {}{} {{\n ...\n }}" ,
565+ vis. to_src_with_space( cx. tcx, did) ,
566+ name,
567+ matchers. map( utils:: render_macro_matcher) . collect:: <String >( ) ,
568+ )
569+ } else {
570+ format ! (
571+ "{}macro {} {{\n {}}}" ,
572+ vis. to_src_with_space( cx. tcx, did) ,
573+ name,
574+ utils:: render_macro_arms( matchers, ";" ) ,
575+ )
576+ }
577+ } ;
560578 clean:: MacroItem ( clean:: Macro { source, imported_from : Some ( imported_from) } )
561579 } else {
562580 unreachable ! ( )
0 commit comments