@@ -618,43 +618,6 @@ impl MetadataBlob {
618618 }
619619}
620620
621- impl EntryKind {
622- fn def_kind ( & self ) -> DefKind {
623- match * self {
624- EntryKind :: AnonConst ( ..) => DefKind :: AnonConst ,
625- EntryKind :: Const ( ..) => DefKind :: Const ,
626- EntryKind :: AssocConst ( ..) => DefKind :: AssocConst ,
627- EntryKind :: ImmStatic
628- | EntryKind :: MutStatic
629- | EntryKind :: ForeignImmStatic
630- | EntryKind :: ForeignMutStatic => DefKind :: Static ,
631- EntryKind :: Struct ( _, _) => DefKind :: Struct ,
632- EntryKind :: Union ( _, _) => DefKind :: Union ,
633- EntryKind :: Fn ( _) | EntryKind :: ForeignFn ( _) => DefKind :: Fn ,
634- EntryKind :: AssocFn ( _) => DefKind :: AssocFn ,
635- EntryKind :: Type => DefKind :: TyAlias ,
636- EntryKind :: TypeParam => DefKind :: TyParam ,
637- EntryKind :: ConstParam => DefKind :: ConstParam ,
638- EntryKind :: OpaqueTy => DefKind :: OpaqueTy ,
639- EntryKind :: AssocType ( _) => DefKind :: AssocTy ,
640- EntryKind :: Mod ( _) => DefKind :: Mod ,
641- EntryKind :: Variant ( _) => DefKind :: Variant ,
642- EntryKind :: Trait ( _) => DefKind :: Trait ,
643- EntryKind :: TraitAlias => DefKind :: TraitAlias ,
644- EntryKind :: Enum ( ..) => DefKind :: Enum ,
645- EntryKind :: MacroDef ( _) => DefKind :: Macro ( MacroKind :: Bang ) ,
646- EntryKind :: ProcMacro ( kind) => DefKind :: Macro ( kind) ,
647- EntryKind :: ForeignType => DefKind :: ForeignTy ,
648- EntryKind :: Impl ( _) => DefKind :: Impl ,
649- EntryKind :: Closure => DefKind :: Closure ,
650- EntryKind :: ForeignMod => DefKind :: ForeignMod ,
651- EntryKind :: GlobalAsm => DefKind :: GlobalAsm ,
652- EntryKind :: Field => DefKind :: Field ,
653- EntryKind :: Generator ( _) => DefKind :: Generator ,
654- }
655- }
656- }
657-
658621impl CrateRoot < ' _ > {
659622 crate fn is_proc_macro_crate ( & self ) -> bool {
660623 self . proc_macro_data . is_some ( )
@@ -685,21 +648,6 @@ impl CrateRoot<'_> {
685648}
686649
687650impl < ' a , ' tcx > CrateMetadataRef < ' a > {
688- fn maybe_kind ( & self , item_id : DefIndex ) -> Option < EntryKind > {
689- self . root . tables . kind . get ( self , item_id) . map ( |k| k. decode ( self ) )
690- }
691-
692- fn kind ( & self , item_id : DefIndex ) -> EntryKind {
693- self . maybe_kind ( item_id) . unwrap_or_else ( || {
694- bug ! (
695- "CrateMetadata::kind({:?}): id not found, in crate {:?} with number {}" ,
696- item_id,
697- self . root. name,
698- self . cnum,
699- )
700- } )
701- }
702-
703651 fn raw_proc_macro ( & self , id : DefIndex ) -> & ProcMacro {
704652 // DefIndex's in root.proc_macro_data have a one-to-one correspondence
705653 // with items in 'raw_proc_macros'.
@@ -736,8 +684,30 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
736684 self . try_item_ident ( item_index, sess) . unwrap ( )
737685 }
738686
739- fn def_kind ( & self , index : DefIndex ) -> DefKind {
740- self . kind ( index) . def_kind ( )
687+ fn maybe_kind ( & self , item_id : DefIndex ) -> Option < EntryKind > {
688+ self . root . tables . kind . get ( self , item_id) . map ( |k| k. decode ( self ) )
689+ }
690+
691+ fn kind ( & self , item_id : DefIndex ) -> EntryKind {
692+ self . maybe_kind ( item_id) . unwrap_or_else ( || {
693+ bug ! (
694+ "CrateMetadata::kind({:?}): id not found, in crate {:?} with number {}" ,
695+ item_id,
696+ self . root. name,
697+ self . cnum,
698+ )
699+ } )
700+ }
701+
702+ fn def_kind ( & self , item_id : DefIndex ) -> DefKind {
703+ self . root . tables . def_kind . get ( self , item_id) . map ( |k| k. decode ( self ) ) . unwrap_or_else ( || {
704+ bug ! (
705+ "CrateMetadata::def_kind({:?}): id not found, in crate {:?} with number {}" ,
706+ item_id,
707+ self . root. name,
708+ self . cnum,
709+ )
710+ } )
741711 }
742712
743713 fn get_span ( & self , index : DefIndex , sess : & Session ) -> Span {
0 commit comments