@@ -14,7 +14,6 @@ use rustc_data_structures::sync::{Lock, LockGuard, Lrc, OnceCell};
1414use rustc_data_structures:: unhash:: UnhashMap ;
1515use rustc_expand:: base:: { SyntaxExtension , SyntaxExtensionKind } ;
1616use rustc_expand:: proc_macro:: { AttrProcMacro , BangProcMacro , ProcMacroDerive } ;
17- use rustc_hir as hir;
1817use rustc_hir:: def:: { CtorKind , CtorOf , DefKind , Res } ;
1918use rustc_hir:: def_id:: { CrateNum , DefId , DefIndex , CRATE_DEF_INDEX , LOCAL_CRATE } ;
2019use rustc_hir:: definitions:: { DefKey , DefPath , DefPathData , DefPathHash } ;
@@ -909,40 +908,9 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
909908 )
910909 }
911910
912- fn get_trait_def ( self , item_id : DefIndex , sess : & Session ) -> ty:: TraitDef {
913- match self . kind ( item_id) {
914- EntryKind :: Trait ( data) => {
915- let data = data. decode ( ( self , sess) ) ;
916- ty:: TraitDef :: new (
917- self . local_def_id ( item_id) ,
918- data. unsafety ,
919- data. paren_sugar ,
920- data. has_auto_impl ,
921- data. is_marker ,
922- data. skip_array_during_method_dispatch ,
923- data. specialization_kind ,
924- self . def_path_hash ( item_id) ,
925- data. must_implement_one_of ,
926- )
927- }
928- EntryKind :: TraitAlias => ty:: TraitDef :: new (
929- self . local_def_id ( item_id) ,
930- hir:: Unsafety :: Normal ,
931- false ,
932- false ,
933- false ,
934- false ,
935- ty:: trait_def:: TraitSpecializationKind :: None ,
936- self . def_path_hash ( item_id) ,
937- None ,
938- ) ,
939- _ => bug ! ( "def-index does not refer to trait or trait alias" ) ,
940- }
941- }
942-
943911 fn get_variant ( self , kind : & EntryKind , index : DefIndex , parent_did : DefId ) -> ty:: VariantDef {
944912 let data = match kind {
945- EntryKind :: Variant ( data) | EntryKind :: Struct ( data, _ ) | EntryKind :: Union ( data, _ ) => {
913+ EntryKind :: Variant ( data) | EntryKind :: Struct ( data) | EntryKind :: Union ( data) => {
946914 data. decode ( self )
947915 }
948916 _ => bug ! ( ) ,
@@ -988,12 +956,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
988956 let kind = self . kind ( item_id) ;
989957 let did = self . local_def_id ( item_id) ;
990958
991- let ( adt_kind, repr ) = match kind {
992- EntryKind :: Enum ( repr ) => ( ty:: AdtKind :: Enum , repr ) ,
993- EntryKind :: Struct ( _, repr ) => ( ty:: AdtKind :: Struct , repr ) ,
994- EntryKind :: Union ( _, repr ) => ( ty:: AdtKind :: Union , repr ) ,
959+ let adt_kind = match kind {
960+ EntryKind :: Enum => ty:: AdtKind :: Enum ,
961+ EntryKind :: Struct ( _) => ty:: AdtKind :: Struct ,
962+ EntryKind :: Union ( _) => ty:: AdtKind :: Union ,
995963 _ => bug ! ( "get_adt_def called on a non-ADT {:?}" , did) ,
996964 } ;
965+ let repr = self . root . tables . repr_options . get ( self , item_id) . unwrap ( ) . decode ( self ) ;
997966
998967 let variants = if let ty:: AdtKind :: Enum = adt_kind {
999968 self . root
@@ -1171,7 +1140,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11711140 callback ( exp) ;
11721141 }
11731142 }
1174- EntryKind :: Enum ( .. ) | EntryKind :: Trait ( .. ) => { }
1143+ EntryKind :: Enum | EntryKind :: Trait => { }
11751144 _ => bug ! ( "`for_each_module_child` is called on a non-module: {:?}" , self . def_kind( id) ) ,
11761145 }
11771146 }
@@ -1186,7 +1155,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11861155
11871156 fn module_expansion ( self , id : DefIndex , sess : & Session ) -> ExpnId {
11881157 match self . kind ( id) {
1189- EntryKind :: Mod ( _) | EntryKind :: Enum ( _ ) | EntryKind :: Trait ( _ ) => {
1158+ EntryKind :: Mod ( _) | EntryKind :: Enum | EntryKind :: Trait => {
11901159 self . get_expn_that_defined ( id, sess)
11911160 }
11921161 _ => panic ! ( "Expected module, found {:?}" , self . local_def_id( id) ) ,
@@ -1239,7 +1208,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12391208
12401209 fn get_ctor_def_id_and_kind ( self , node_id : DefIndex ) -> Option < ( DefId , CtorKind ) > {
12411210 match self . kind ( node_id) {
1242- EntryKind :: Struct ( data, _ ) | EntryKind :: Variant ( data) => {
1211+ EntryKind :: Struct ( data) | EntryKind :: Variant ( data) => {
12431212 let vdata = data. decode ( self ) ;
12441213 vdata. ctor . map ( |index| ( self . local_def_id ( index) , vdata. ctor_kind ) )
12451214 }
@@ -1395,7 +1364,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13951364 _ => return None ,
13961365 }
13971366 def_key. parent . and_then ( |parent_index| match self . kind ( parent_index) {
1398- EntryKind :: Trait ( _ ) | EntryKind :: TraitAlias => Some ( self . local_def_id ( parent_index) ) ,
1367+ EntryKind :: Trait | EntryKind :: TraitAlias => Some ( self . local_def_id ( parent_index) ) ,
13991368 _ => None ,
14001369 } )
14011370 }
@@ -1449,22 +1418,9 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14491418 }
14501419 }
14511420
1452- // This replicates some of the logic of the crate-local `is_const_fn_raw` query, because we
1453- // don't serialize constness for tuple variant and tuple struct constructors.
1454- fn is_const_fn_raw ( self , id : DefIndex ) -> bool {
1455- let constness = match self . kind ( id) {
1456- EntryKind :: AssocFn ( data) => data. decode ( self ) . fn_data . constness ,
1457- EntryKind :: Fn ( data) => data. decode ( self ) . constness ,
1458- EntryKind :: ForeignFn ( data) => data. decode ( self ) . constness ,
1459- EntryKind :: Variant ( ..) | EntryKind :: Struct ( ..) => hir:: Constness :: Const ,
1460- _ => hir:: Constness :: NotConst ,
1461- } ;
1462- constness == hir:: Constness :: Const
1463- }
1464-
14651421 fn is_foreign_item ( self , id : DefIndex ) -> bool {
14661422 match self . kind ( id) {
1467- EntryKind :: ForeignStatic | EntryKind :: ForeignFn ( _ ) => true ,
1423+ EntryKind :: ForeignStatic | EntryKind :: ForeignFn => true ,
14681424 _ => false ,
14691425 }
14701426 }
0 commit comments