@@ -12,7 +12,7 @@ use rustc_metadata::creader::{CStore, LoadedMacro};
12
12
use rustc_middle:: ty:: fast_reject:: SimplifiedType ;
13
13
use rustc_middle:: ty:: { self , TyCtxt } ;
14
14
use rustc_span:: def_id:: LOCAL_CRATE ;
15
- use rustc_span:: hygiene:: MacroKind ;
15
+ use rustc_span:: hygiene:: { MacroKind , MacroKinds } ;
16
16
use rustc_span:: symbol:: { Symbol , sym} ;
17
17
use thin_vec:: { ThinVec , thin_vec} ;
18
18
use tracing:: { debug, trace} ;
@@ -137,13 +137,16 @@ pub(crate) fn try_inline(
137
137
clean:: ConstantItem ( Box :: new ( ct) )
138
138
} )
139
139
}
140
- Res :: Def ( DefKind :: Macro ( kind) , did) => {
141
- let mac = build_macro ( cx, did, name, kind) ;
142
-
143
- let type_kind = match kind {
144
- MacroKind :: Bang => ItemType :: Macro ,
145
- MacroKind :: Attr => ItemType :: ProcAttribute ,
146
- MacroKind :: Derive => ItemType :: ProcDerive ,
140
+ Res :: Def ( DefKind :: Macro ( kinds) , did) => {
141
+ let mac = build_macro ( cx, did, name, kinds) ;
142
+
143
+ // FIXME: handle attributes and derives that aren't proc macros, and macros with
144
+ // multiple kinds
145
+ let type_kind = match kinds {
146
+ MacroKinds :: BANG => ItemType :: Macro ,
147
+ MacroKinds :: ATTR => ItemType :: ProcAttribute ,
148
+ MacroKinds :: DERIVE => ItemType :: ProcDerive ,
149
+ _ => todo ! ( "Handle macros with multiple kinds" ) ,
147
150
} ;
148
151
record_extern_fqn ( cx, did, type_kind) ;
149
152
mac
@@ -749,22 +752,36 @@ fn build_macro(
749
752
cx : & mut DocContext < ' _ > ,
750
753
def_id : DefId ,
751
754
name : Symbol ,
752
- macro_kind : MacroKind ,
755
+ macro_kinds : MacroKinds ,
753
756
) -> clean:: ItemKind {
754
757
match CStore :: from_tcx ( cx. tcx ) . load_macro_untracked ( def_id, cx. tcx ) {
755
- LoadedMacro :: MacroDef { def, .. } => match macro_kind {
756
- MacroKind :: Bang => clean:: MacroItem ( clean:: Macro {
758
+ // FIXME: handle attributes and derives that aren't proc macros, and macros with multiple
759
+ // kinds
760
+ LoadedMacro :: MacroDef { def, .. } => match macro_kinds {
761
+ MacroKinds :: BANG => clean:: MacroItem ( clean:: Macro {
757
762
source : utils:: display_macro_source ( cx, name, & def) ,
758
763
macro_rules : def. macro_rules ,
759
764
} ) ,
760
- MacroKind :: Derive | MacroKind :: Attr => {
761
- clean:: ProcMacroItem ( clean:: ProcMacro { kind : macro_kind, helpers : Vec :: new ( ) } )
762
- }
765
+ MacroKinds :: DERIVE => clean:: ProcMacroItem ( clean:: ProcMacro {
766
+ kind : MacroKind :: Derive ,
767
+ helpers : Vec :: new ( ) ,
768
+ } ) ,
769
+ MacroKinds :: ATTR => clean:: ProcMacroItem ( clean:: ProcMacro {
770
+ kind : MacroKind :: Attr ,
771
+ helpers : Vec :: new ( ) ,
772
+ } ) ,
773
+ _ => todo ! ( "Handle macros with multiple kinds" ) ,
763
774
} ,
764
- LoadedMacro :: ProcMacro ( ext) => clean:: ProcMacroItem ( clean:: ProcMacro {
765
- kind : ext. macro_kind ( ) ,
766
- helpers : ext. helper_attrs ,
767
- } ) ,
775
+ LoadedMacro :: ProcMacro ( ext) => {
776
+ // Proc macros can only have a single kind
777
+ let kind = match ext. macro_kinds ( ) {
778
+ MacroKinds :: BANG => MacroKind :: Bang ,
779
+ MacroKinds :: ATTR => MacroKind :: Attr ,
780
+ MacroKinds :: DERIVE => MacroKind :: Derive ,
781
+ _ => unreachable ! ( ) ,
782
+ } ;
783
+ clean:: ProcMacroItem ( clean:: ProcMacro { kind, helpers : ext. helper_attrs } )
784
+ }
768
785
}
769
786
}
770
787
0 commit comments