@@ -654,7 +654,7 @@ impl<'a, 'tcx, T> Decodable<DecodeContext<'a, 'tcx>> for LazyValue<T> {
654654impl < ' a , ' tcx , T > Decodable < DecodeContext < ' a , ' tcx > > for LazyArray < T > {
655655 fn decode ( decoder : & mut DecodeContext < ' a , ' tcx > ) -> Self {
656656 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) }
658658 }
659659}
660660
@@ -864,7 +864,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
864864 . tables
865865 . children
866866 . get ( self , index)
867- . unwrap_or_else ( LazyArray :: empty )
867+ . expect ( "fields are not encoded for a variant" )
868868 . decode ( self )
869869 . map ( |index| ty:: FieldDef {
870870 did : self . local_def_id ( index) ,
@@ -896,7 +896,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
896896 . tables
897897 . children
898898 . get ( self , item_id)
899- . unwrap_or_else ( LazyArray :: empty )
899+ . expect ( "variants are not encoded for an enum" )
900900 . decode ( self )
901901 . filter_map ( |index| {
902902 let kind = self . def_kind ( index) ;
@@ -1045,7 +1045,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10451045 . tables
10461046 . fn_arg_names
10471047 . get ( self , id)
1048- . unwrap_or_else ( LazyArray :: empty )
1048+ . expect ( "argument names not encoded for a function" )
10491049 . decode ( ( self , sess) )
10501050 . nth ( 0 )
10511051 . map_or ( false , |ident| ident. name == kw:: SelfLower )
@@ -1060,21 +1060,20 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10601060 . tables
10611061 . children
10621062 . get ( self , id)
1063- . unwrap_or_else ( LazyArray :: empty )
1063+ . expect ( "associated items not encoded for an item" )
10641064 . decode ( ( self , sess) )
10651065 . map ( move |child_index| self . local_def_id ( child_index) )
10661066 }
10671067
10681068 fn get_associated_item ( self , id : DefIndex , sess : & ' a Session ) -> ty:: AssocItem {
10691069 let name = self . item_name ( id) ;
10701070
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 ) ,
10751075 _ => bug ! ( "cannot get associated-item of `{:?}`" , self . def_key( id) ) ,
10761076 } ;
1077- let has_self = self . get_fn_has_self_parameter ( id, sess) ;
10781077 let container = self . root . tables . assoc_container . get ( self , id) . unwrap ( ) ;
10791078
10801079 ty:: AssocItem {
@@ -1131,7 +1130,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11311130 . tables
11321131 . children
11331132 . get ( self , id)
1134- . unwrap_or_else ( LazyArray :: empty )
1133+ . expect ( "fields not encoded for a struct" )
11351134 . decode ( self )
11361135 . map ( move |index| respan ( self . get_span ( index, sess) , self . item_name ( index) ) )
11371136 }
@@ -1144,7 +1143,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11441143 . tables
11451144 . children
11461145 . get ( self , id)
1147- . unwrap_or_else ( LazyArray :: empty )
1146+ . expect ( "fields not encoded for a struct" )
11481147 . decode ( self )
11491148 . map ( move |field_index| self . get_visibility ( field_index) )
11501149 }
@@ -1159,7 +1158,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11591158 . tables
11601159 . inherent_impls
11611160 . get ( self , id)
1162- . unwrap_or_else ( LazyArray :: empty)
11631161 . decode ( self )
11641162 . map ( |index| self . local_def_id ( index) ) ,
11651163 )
@@ -1174,7 +1172,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11741172 . tables
11751173 . inherent_impls
11761174 . get ( self , ty_index)
1177- . unwrap_or_else ( LazyArray :: empty)
11781175 . decode ( self )
11791176 . map ( move |impl_index| ( ty_def_id, self . local_def_id ( impl_index) ) )
11801177 } )
@@ -1322,7 +1319,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13221319 ) -> DefPathHash {
13231320 * def_path_hashes
13241321 . 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) )
13261323 }
13271324
13281325 #[ inline]
0 commit comments