@@ -1145,6 +1145,23 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1145
1145
} ;
1146
1146
let no_builtins = attr:: contains_name ( & krate. attrs , "no_builtins" ) ;
1147
1147
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
+
1148
1165
// Run the translation item collector and partition the collected items into
1149
1166
// codegen units.
1150
1167
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>,
1181
1198
1182
1199
assert_module_sources:: assert_module_sources ( tcx, & modules) ;
1183
1200
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
-
1200
1201
// Instantiate translation items without filling out definitions yet...
1201
1202
for ccx in crate_context_list. iter_need_trans ( ) {
1202
1203
let cgu = ccx. codegen_unit ( ) ;
0 commit comments