@@ -808,8 +808,16 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
808
808
& self . raw_proc_macros . unwrap ( ) [ pos]
809
809
}
810
810
811
+ fn opt_item_name ( self , item_index : DefIndex ) -> Option < Symbol > {
812
+ self . def_key ( item_index) . disambiguated_data . data . get_opt_name ( )
813
+ }
814
+
815
+ fn item_name ( self , item_index : DefIndex ) -> Symbol {
816
+ self . opt_item_name ( item_index) . expect ( "no encoded ident for item" )
817
+ }
818
+
811
819
fn opt_item_ident ( self , item_index : DefIndex , sess : & Session ) -> Option < Ident > {
812
- let name = self . def_key ( item_index) . disambiguated_data . data . get_opt_name ( ) ?;
820
+ let name = self . opt_item_name ( item_index) ?;
813
821
let span = match self . root . tables . def_ident_span . get ( self , item_index) {
814
822
Some ( lazy_span) => lazy_span. decode ( ( self , sess) ) ,
815
823
None => {
@@ -927,13 +935,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
927
935
}
928
936
}
929
937
930
- fn get_variant (
931
- self ,
932
- kind : & EntryKind ,
933
- index : DefIndex ,
934
- parent_did : DefId ,
935
- sess : & Session ,
936
- ) -> ty:: VariantDef {
938
+ fn get_variant ( self , kind : & EntryKind , index : DefIndex , parent_did : DefId ) -> ty:: VariantDef {
937
939
let data = match kind {
938
940
EntryKind :: Variant ( data) | EntryKind :: Struct ( data, _) | EntryKind :: Union ( data, _) => {
939
941
data. decode ( self )
@@ -953,7 +955,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
953
955
let ctor_did = data. ctor . map ( |index| self . local_def_id ( index) ) ;
954
956
955
957
ty:: VariantDef :: new (
956
- self . item_ident ( index, sess ) . name ,
958
+ self . item_name ( index) ,
957
959
variant_did,
958
960
ctor_did,
959
961
data. discr ,
@@ -965,7 +967,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
965
967
. decode ( self )
966
968
. map ( |index| ty:: FieldDef {
967
969
did : self . local_def_id ( index) ,
968
- name : self . item_ident ( index, sess ) . name ,
970
+ name : self . item_name ( index) ,
969
971
vis : self . get_visibility ( index) ,
970
972
} )
971
973
. collect ( ) ,
@@ -995,10 +997,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
995
997
. get ( self , item_id)
996
998
. unwrap_or_else ( Lazy :: empty)
997
999
. decode ( self )
998
- . map ( |index| self . get_variant ( & self . kind ( index) , index, did, tcx . sess ) )
1000
+ . map ( |index| self . get_variant ( & self . kind ( index) , index, did) )
999
1001
. collect ( )
1000
1002
} else {
1001
- std:: iter:: once ( self . get_variant ( & kind, item_id, did, tcx . sess ) ) . collect ( )
1003
+ std:: iter:: once ( self . get_variant ( & kind, item_id, did) ) . collect ( )
1002
1004
} ;
1003
1005
1004
1006
tcx. alloc_adt_def ( did, adt_kind, variants, repr)
@@ -1228,10 +1230,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1228
1230
}
1229
1231
}
1230
1232
1231
- fn get_associated_item ( self , id : DefIndex , sess : & Session ) -> ty:: AssocItem {
1233
+ fn get_associated_item ( self , id : DefIndex ) -> ty:: AssocItem {
1232
1234
let def_key = self . def_key ( id) ;
1233
1235
let parent = self . local_def_id ( def_key. parent . unwrap ( ) ) ;
1234
- let ident = self . item_ident ( id, sess ) ;
1236
+ let name = self . item_name ( id) ;
1235
1237
1236
1238
let ( kind, container, has_self) = match self . kind ( id) {
1237
1239
EntryKind :: AssocConst ( container, _, _) => ( ty:: AssocKind :: Const , container, false ) ,
@@ -1244,7 +1246,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1244
1246
} ;
1245
1247
1246
1248
ty:: AssocItem {
1247
- name : ident . name ,
1249
+ name,
1248
1250
kind,
1249
1251
vis : self . get_visibility ( id) ,
1250
1252
defaultness : container. defaultness ( ) ,
@@ -1301,7 +1303,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1301
1303
. get ( self , id)
1302
1304
. unwrap_or_else ( Lazy :: empty)
1303
1305
. decode ( self )
1304
- . map ( move |index| respan ( self . get_span ( index, sess) , self . item_ident ( index, sess ) . name ) )
1306
+ . map ( move |index| respan ( self . get_span ( index, sess) , self . item_name ( index) ) )
1305
1307
}
1306
1308
1307
1309
fn get_struct_field_visibilities ( self , id : DefIndex ) -> impl Iterator < Item = Visibility > + ' a {
0 commit comments