@@ -1033,45 +1033,33 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10331033
10341034 /// Iterates over all the stability attributes in the given crate.
10351035 fn get_lib_features ( self , tcx : TyCtxt < ' tcx > ) -> & ' tcx [ ( Symbol , Option < Symbol > ) ] {
1036- // FIXME: For a proc macro crate, not sure whether we should return the "host"
1037- // features or an empty Vec. Both don't cause ICEs.
10381036 tcx. arena . alloc_from_iter ( self . root . lib_features . decode ( self ) )
10391037 }
10401038
10411039 /// Iterates over the language items in the given crate.
10421040 fn get_lang_items ( self , tcx : TyCtxt < ' tcx > ) -> & ' tcx [ ( DefId , usize ) ] {
1043- if self . root . is_proc_macro_crate ( ) {
1044- // Proc macro crates do not export any lang-items to the target.
1045- & [ ]
1046- } else {
1047- tcx. arena . alloc_from_iter (
1048- self . root
1049- . lang_items
1050- . decode ( self )
1051- . map ( |( def_index, index) | ( self . local_def_id ( def_index) , index) ) ,
1052- )
1053- }
1041+ tcx. arena . alloc_from_iter (
1042+ self . root
1043+ . lang_items
1044+ . decode ( self )
1045+ . map ( |( def_index, index) | ( self . local_def_id ( def_index) , index) ) ,
1046+ )
10541047 }
10551048
10561049 /// Iterates over the diagnostic items in the given crate.
10571050 fn get_diagnostic_items ( self ) -> DiagnosticItems {
1058- if self . root . is_proc_macro_crate ( ) {
1059- // Proc macro crates do not export any diagnostic-items to the target.
1060- Default :: default ( )
1061- } else {
1062- let mut id_to_name = FxHashMap :: default ( ) ;
1063- let name_to_id = self
1064- . root
1065- . diagnostic_items
1066- . decode ( self )
1067- . map ( |( name, def_index) | {
1068- let id = self . local_def_id ( def_index) ;
1069- id_to_name. insert ( id, name) ;
1070- ( name, id)
1071- } )
1072- . collect ( ) ;
1073- DiagnosticItems { id_to_name, name_to_id }
1074- }
1051+ let mut id_to_name = FxHashMap :: default ( ) ;
1052+ let name_to_id = self
1053+ . root
1054+ . diagnostic_items
1055+ . decode ( self )
1056+ . map ( |( name, def_index) | {
1057+ let id = self . local_def_id ( def_index) ;
1058+ id_to_name. insert ( id, name) ;
1059+ ( name, id)
1060+ } )
1061+ . collect ( ) ;
1062+ DiagnosticItems { id_to_name, name_to_id }
10751063 }
10761064
10771065 /// Iterates over all named children of the given module,
@@ -1346,26 +1334,28 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
13461334 . decode ( ( self , sess) )
13471335 }
13481336
1349- fn get_struct_field_names ( self , id : DefIndex , sess : & Session ) -> Vec < Spanned < Symbol > > {
1337+ fn get_struct_field_names (
1338+ self ,
1339+ id : DefIndex ,
1340+ sess : & ' a Session ,
1341+ ) -> impl Iterator < Item = Spanned < Symbol > > + ' a {
13501342 self . root
13511343 . tables
13521344 . children
13531345 . get ( self , id)
13541346 . unwrap_or_else ( Lazy :: empty)
13551347 . decode ( self )
1356- . map ( |index| respan ( self . get_span ( index, sess) , self . item_ident ( index, sess) . name ) )
1357- . collect ( )
1348+ . map ( move |index| respan ( self . get_span ( index, sess) , self . item_ident ( index, sess) . name ) )
13581349 }
13591350
1360- fn get_struct_field_visibilities ( self , id : DefIndex ) -> Vec < Visibility > {
1351+ fn get_struct_field_visibilities ( self , id : DefIndex ) -> impl Iterator < Item = Visibility > + ' a {
13611352 self . root
13621353 . tables
13631354 . children
13641355 . get ( self , id)
13651356 . unwrap_or_else ( Lazy :: empty)
13661357 . decode ( self )
1367- . map ( |field_index| self . get_visibility ( field_index) )
1368- . collect ( )
1358+ . map ( move |field_index| self . get_visibility ( field_index) )
13691359 }
13701360
13711361 fn get_inherent_implementations_for_type (
@@ -1401,8 +1391,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14011391 tcx : TyCtxt < ' tcx > ,
14021392 trait_def_id : DefId ,
14031393 ) -> & ' tcx [ ( DefId , Option < SimplifiedType > ) ] {
1404- if self . root . is_proc_macro_crate ( ) {
1405- // proc-macro crates export no trait impls.
1394+ if self . trait_impls . is_empty ( ) {
14061395 return & [ ] ;
14071396 }
14081397
@@ -1437,13 +1426,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14371426 } )
14381427 }
14391428
1440- fn get_native_libraries ( self , sess : & Session ) -> Vec < NativeLib > {
1441- if self . root . is_proc_macro_crate ( ) {
1442- // Proc macro crates do not have any *target* native libraries.
1443- vec ! [ ]
1444- } else {
1445- self . root . native_libraries . decode ( ( self , sess) ) . collect ( )
1446- }
1429+ fn get_native_libraries ( self , sess : & ' a Session ) -> impl Iterator < Item = NativeLib > + ' a {
1430+ self . root . native_libraries . decode ( ( self , sess) )
14471431 }
14481432
14491433 fn get_proc_macro_quoted_span ( self , index : usize , sess : & Session ) -> Span {
@@ -1455,15 +1439,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14551439 . decode ( ( self , sess) )
14561440 }
14571441
1458- fn get_foreign_modules ( self , tcx : TyCtxt < ' tcx > ) -> Lrc < FxHashMap < DefId , ForeignModule > > {
1459- if self . root . is_proc_macro_crate ( ) {
1460- // Proc macro crates do not have any *target* foreign modules.
1461- Lrc :: new ( FxHashMap :: default ( ) )
1462- } else {
1463- let modules: FxHashMap < DefId , ForeignModule > =
1464- self . root . foreign_modules . decode ( ( self , tcx. sess ) ) . map ( |m| ( m. def_id , m) ) . collect ( ) ;
1465- Lrc :: new ( modules)
1466- }
1442+ fn get_foreign_modules ( self , sess : & ' a Session ) -> impl Iterator < Item = ForeignModule > + ' _ {
1443+ self . root . foreign_modules . decode ( ( self , sess) )
14671444 }
14681445
14691446 fn get_dylib_dependency_formats (
@@ -1479,12 +1456,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14791456 }
14801457
14811458 fn get_missing_lang_items ( self , tcx : TyCtxt < ' tcx > ) -> & ' tcx [ lang_items:: LangItem ] {
1482- if self . root . is_proc_macro_crate ( ) {
1483- // Proc macro crates do not depend on any target weak lang-items.
1484- & [ ]
1485- } else {
1486- tcx. arena . alloc_from_iter ( self . root . lang_items_missing . decode ( self ) )
1487- }
1459+ tcx. arena . alloc_from_iter ( self . root . lang_items_missing . decode ( self ) )
14881460 }
14891461
14901462 fn get_fn_param_names ( self , tcx : TyCtxt < ' tcx > , id : DefIndex ) -> & ' tcx [ Ident ] {
@@ -1500,13 +1472,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
15001472 self ,
15011473 tcx : TyCtxt < ' tcx > ,
15021474 ) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportLevel ) ] {
1503- if self . root . is_proc_macro_crate ( ) {
1504- // If this crate is a custom derive crate, then we're not even going to
1505- // link those in so we skip those crates.
1506- & [ ]
1507- } else {
1508- tcx. arena . alloc_from_iter ( self . root . exported_symbols . decode ( ( self , tcx) ) )
1509- }
1475+ tcx. arena . alloc_from_iter ( self . root . exported_symbols . decode ( ( self , tcx) ) )
15101476 }
15111477
15121478 fn get_rendered_const ( self , id : DefIndex ) -> String {
0 commit comments