@@ -1145,6 +1145,23 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11451145 } ;
11461146 let no_builtins = attr:: contains_name ( & krate. attrs , "no_builtins" ) ;
11471147
1148+ // Skip crate items and just output metadata in -Z no-trans mode.
1149+ if tcx. sess . opts . debugging_opts . no_trans ||
1150+ !tcx. sess . opts . output_types . should_trans ( ) {
1151+ let empty_exported_symbols = ExportedSymbols :: empty ( ) ;
1152+ let linker_info = LinkerInfo :: new ( & shared_ccx, & empty_exported_symbols) ;
1153+ return CrateTranslation {
1154+ modules : vec ! [ ] ,
1155+ metadata_module : metadata_module,
1156+ link : link_meta,
1157+ metadata : metadata,
1158+ exported_symbols : empty_exported_symbols,
1159+ no_builtins : no_builtins,
1160+ linker_info : linker_info,
1161+ windows_subsystem : None ,
1162+ } ;
1163+ }
1164+
11481165 // Run the translation item collector and partition the collected items into
11491166 // codegen units.
11501167 let ( codegen_units, symbol_map) = collect_and_partition_translation_items ( & shared_ccx) ;
@@ -1181,22 +1198,6 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11811198
11821199 assert_module_sources:: assert_module_sources ( tcx, & modules) ;
11831200
1184- // Skip crate items and just output metadata in -Z no-trans mode.
1185- if tcx. sess . opts . debugging_opts . no_trans ||
1186- tcx. sess . opts . output_types . contains_key ( & config:: OutputType :: Metadata ) {
1187- let linker_info = LinkerInfo :: new ( & shared_ccx, & ExportedSymbols :: empty ( ) ) ;
1188- return CrateTranslation {
1189- modules : modules,
1190- metadata_module : metadata_module,
1191- link : link_meta,
1192- metadata : metadata,
1193- exported_symbols : ExportedSymbols :: empty ( ) ,
1194- no_builtins : no_builtins,
1195- linker_info : linker_info,
1196- windows_subsystem : None ,
1197- } ;
1198- }
1199-
12001201 // Instantiate translation items without filling out definitions yet...
12011202 for ccx in crate_context_list. iter_need_trans ( ) {
12021203 let cgu = ccx. codegen_unit ( ) ;
0 commit comments