@@ -14,7 +14,6 @@ use rustc_data_structures::sync::{Lock, LockGuard, Lrc, OnceCell};
14
14
use rustc_data_structures:: unhash:: UnhashMap ;
15
15
use rustc_expand:: base:: { SyntaxExtension , SyntaxExtensionKind } ;
16
16
use rustc_expand:: proc_macro:: { AttrProcMacro , BangProcMacro , ProcMacroDerive } ;
17
- use rustc_hir as hir;
18
17
use rustc_hir:: def:: { CtorKind , CtorOf , DefKind , Res } ;
19
18
use rustc_hir:: def_id:: { CrateNum , DefId , DefIndex , CRATE_DEF_INDEX , LOCAL_CRATE } ;
20
19
use rustc_hir:: definitions:: { DefKey , DefPath , DefPathData , DefPathHash } ;
@@ -909,40 +908,9 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
909
908
)
910
909
}
911
910
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
-
943
911
fn get_variant ( self , kind : & EntryKind , index : DefIndex , parent_did : DefId ) -> ty:: VariantDef {
944
912
let data = match kind {
945
- EntryKind :: Variant ( data) | EntryKind :: Struct ( data, _ ) | EntryKind :: Union ( data, _ ) => {
913
+ EntryKind :: Variant ( data) | EntryKind :: Struct ( data) | EntryKind :: Union ( data) => {
946
914
data. decode ( self )
947
915
}
948
916
_ => bug ! ( ) ,
@@ -988,12 +956,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
988
956
let kind = self . kind ( item_id) ;
989
957
let did = self . local_def_id ( item_id) ;
990
958
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 ,
995
963
_ => bug ! ( "get_adt_def called on a non-ADT {:?}" , did) ,
996
964
} ;
965
+ let repr = self . root . tables . repr_options . get ( self , item_id) . unwrap ( ) . decode ( self ) ;
997
966
998
967
let variants = if let ty:: AdtKind :: Enum = adt_kind {
999
968
self . root
@@ -1171,7 +1140,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1171
1140
callback ( exp) ;
1172
1141
}
1173
1142
}
1174
- EntryKind :: Enum ( .. ) | EntryKind :: Trait ( .. ) => { }
1143
+ EntryKind :: Enum | EntryKind :: Trait => { }
1175
1144
_ => bug ! ( "`for_each_module_child` is called on a non-module: {:?}" , self . def_kind( id) ) ,
1176
1145
}
1177
1146
}
@@ -1186,7 +1155,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1186
1155
1187
1156
fn module_expansion ( self , id : DefIndex , sess : & Session ) -> ExpnId {
1188
1157
match self . kind ( id) {
1189
- EntryKind :: Mod ( _) | EntryKind :: Enum ( _ ) | EntryKind :: Trait ( _ ) => {
1158
+ EntryKind :: Mod ( _) | EntryKind :: Enum | EntryKind :: Trait => {
1190
1159
self . get_expn_that_defined ( id, sess)
1191
1160
}
1192
1161
_ => panic ! ( "Expected module, found {:?}" , self . local_def_id( id) ) ,
@@ -1239,7 +1208,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1239
1208
1240
1209
fn get_ctor_def_id_and_kind ( self , node_id : DefIndex ) -> Option < ( DefId , CtorKind ) > {
1241
1210
match self . kind ( node_id) {
1242
- EntryKind :: Struct ( data, _ ) | EntryKind :: Variant ( data) => {
1211
+ EntryKind :: Struct ( data) | EntryKind :: Variant ( data) => {
1243
1212
let vdata = data. decode ( self ) ;
1244
1213
vdata. ctor . map ( |index| ( self . local_def_id ( index) , vdata. ctor_kind ) )
1245
1214
}
@@ -1395,7 +1364,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1395
1364
_ => return None ,
1396
1365
}
1397
1366
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) ) ,
1399
1368
_ => None ,
1400
1369
} )
1401
1370
}
@@ -1449,22 +1418,9 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1449
1418
}
1450
1419
}
1451
1420
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
-
1465
1421
fn is_foreign_item ( self , id : DefIndex ) -> bool {
1466
1422
match self . kind ( id) {
1467
- EntryKind :: ForeignStatic | EntryKind :: ForeignFn ( _ ) => true ,
1423
+ EntryKind :: ForeignStatic | EntryKind :: ForeignFn => true ,
1468
1424
_ => false ,
1469
1425
}
1470
1426
}
0 commit comments