@@ -654,7 +654,7 @@ impl<'a, 'tcx, T> Decodable<DecodeContext<'a, 'tcx>> for LazyValue<T> {
654
654
impl < ' a , ' tcx , T > Decodable < DecodeContext < ' a , ' tcx > > for LazyArray < T > {
655
655
fn decode ( decoder : & mut DecodeContext < ' a , ' tcx > ) -> Self {
656
656
let len = decoder. read_usize ( ) ;
657
- if len == 0 { LazyArray :: empty ( ) } else { decoder. read_lazy_array ( len) }
657
+ if len == 0 { LazyArray :: default ( ) } else { decoder. read_lazy_array ( len) }
658
658
}
659
659
}
660
660
@@ -864,7 +864,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
864
864
. tables
865
865
. children
866
866
. get ( self , index)
867
- . unwrap_or_else ( LazyArray :: empty )
867
+ . expect ( "fields are not encoded for a variant" )
868
868
. decode ( self )
869
869
. map ( |index| ty:: FieldDef {
870
870
did : self . local_def_id ( index) ,
@@ -896,7 +896,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
896
896
. tables
897
897
. children
898
898
. get ( self , item_id)
899
- . unwrap_or_else ( LazyArray :: empty )
899
+ . expect ( "variants are not encoded for an enum" )
900
900
. decode ( self )
901
901
. filter_map ( |index| {
902
902
let kind = self . def_kind ( index) ;
@@ -1045,7 +1045,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1045
1045
. tables
1046
1046
. fn_arg_names
1047
1047
. get ( self , id)
1048
- . unwrap_or_else ( LazyArray :: empty )
1048
+ . expect ( "argument names not encoded for a function" )
1049
1049
. decode ( ( self , sess) )
1050
1050
. nth ( 0 )
1051
1051
. map_or ( false , |ident| ident. name == kw:: SelfLower )
@@ -1060,21 +1060,20 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1060
1060
. tables
1061
1061
. children
1062
1062
. get ( self , id)
1063
- . unwrap_or_else ( LazyArray :: empty )
1063
+ . expect ( "associated items not encoded for an item" )
1064
1064
. decode ( ( self , sess) )
1065
1065
. map ( move |child_index| self . local_def_id ( child_index) )
1066
1066
}
1067
1067
1068
1068
fn get_associated_item ( self , id : DefIndex , sess : & ' a Session ) -> ty:: AssocItem {
1069
1069
let name = self . item_name ( id) ;
1070
1070
1071
- let kind = match self . def_kind ( id) {
1072
- DefKind :: AssocConst => ty:: AssocKind :: Const ,
1073
- DefKind :: AssocFn => ty:: AssocKind :: Fn ,
1074
- DefKind :: AssocTy => ty:: AssocKind :: Type ,
1071
+ let ( kind, has_self ) = match self . def_kind ( id) {
1072
+ DefKind :: AssocConst => ( ty:: AssocKind :: Const , false ) ,
1073
+ DefKind :: AssocFn => ( ty:: AssocKind :: Fn , self . get_fn_has_self_parameter ( id , sess ) ) ,
1074
+ DefKind :: AssocTy => ( ty:: AssocKind :: Type , false ) ,
1075
1075
_ => bug ! ( "cannot get associated-item of `{:?}`" , self . def_key( id) ) ,
1076
1076
} ;
1077
- let has_self = self . get_fn_has_self_parameter ( id, sess) ;
1078
1077
let container = self . root . tables . assoc_container . get ( self , id) . unwrap ( ) ;
1079
1078
1080
1079
ty:: AssocItem {
@@ -1131,7 +1130,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1131
1130
. tables
1132
1131
. children
1133
1132
. get ( self , id)
1134
- . unwrap_or_else ( LazyArray :: empty )
1133
+ . expect ( "fields not encoded for a struct" )
1135
1134
. decode ( self )
1136
1135
. map ( move |index| respan ( self . get_span ( index, sess) , self . item_name ( index) ) )
1137
1136
}
@@ -1144,7 +1143,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1144
1143
. tables
1145
1144
. children
1146
1145
. get ( self , id)
1147
- . unwrap_or_else ( LazyArray :: empty )
1146
+ . expect ( "fields not encoded for a struct" )
1148
1147
. decode ( self )
1149
1148
. map ( move |field_index| self . get_visibility ( field_index) )
1150
1149
}
@@ -1159,7 +1158,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1159
1158
. tables
1160
1159
. inherent_impls
1161
1160
. get ( self , id)
1162
- . unwrap_or_else ( LazyArray :: empty)
1163
1161
. decode ( self )
1164
1162
. map ( |index| self . local_def_id ( index) ) ,
1165
1163
)
@@ -1174,7 +1172,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1174
1172
. tables
1175
1173
. inherent_impls
1176
1174
. get ( self , ty_index)
1177
- . unwrap_or_else ( LazyArray :: empty)
1178
1175
. decode ( self )
1179
1176
. map ( move |impl_index| ( ty_def_id, self . local_def_id ( impl_index) ) )
1180
1177
} )
@@ -1322,7 +1319,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1322
1319
) -> DefPathHash {
1323
1320
* def_path_hashes
1324
1321
. entry ( index)
1325
- . or_insert_with ( || self . root . tables . def_path_hashes . get ( self , index) . unwrap ( ) )
1322
+ . or_insert_with ( || self . root . tables . def_path_hashes . get ( self , index) )
1326
1323
}
1327
1324
1328
1325
#[ inline]
0 commit comments