diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index c73e950bed408..45e47a571b6ee 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1836,11 +1836,6 @@ fn exported_symbols_for_non_proc_macro( } fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, SymbolExportKind)> { - // `exported_symbols` will be empty when !should_codegen. - if !tcx.sess.opts.output_types.should_codegen() { - return Vec::new(); - } - let stable_crate_id = tcx.stable_crate_id(LOCAL_CRATE); let proc_macro_decls_name = tcx.sess.generate_proc_macro_decls_symbol(stable_crate_id); diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index a80976fad02a4..a1ead7ac6b458 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -47,10 +47,6 @@ pub fn crates_export_threshold(crate_types: &[CrateType]) -> SymbolExportLevel { } fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap { - if !tcx.sess.opts.output_types.should_codegen() && !tcx.is_sdylib_interface_build() { - return Default::default(); - } - let is_compiler_builtins = tcx.is_compiler_builtins(LOCAL_CRATE); let mut reachable_non_generics: DefIdMap<_> = tcx @@ -166,10 +162,6 @@ fn exported_non_generic_symbols_provider_local<'tcx>( tcx: TyCtxt<'tcx>, _: LocalCrate, ) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] { - if !tcx.sess.opts.output_types.should_codegen() && !tcx.is_sdylib_interface_build() { - return &[]; - } - // FIXME: Sorting this is unnecessary since we are sorting later anyway. // Can we skip the later sorting? let sorted = tcx.with_stable_hashing_context(|hcx| { @@ -221,10 +213,6 @@ fn exported_generic_symbols_provider_local<'tcx>( tcx: TyCtxt<'tcx>, _: LocalCrate, ) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] { - if !tcx.sess.opts.output_types.should_codegen() && !tcx.is_sdylib_interface_build() { - return &[]; - } - let mut symbols: Vec<_> = vec![]; if tcx.local_crate_exports_generics() { diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index ddfec9f886a6a..78c7e6de600ef 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -1114,9 +1114,7 @@ fn run_required_analyses(tcx: TyCtxt<'_>) { // If we need to codegen, ensure that we emit all errors from // `mir_drops_elaborated_and_const_checked` now, to avoid discovering // them later during codegen. - if tcx.sess.opts.output_types.should_codegen() - || tcx.hir_body_const_context(def_id).is_some() - { + if tcx.hir_body_const_context(def_id).is_some() { tcx.ensure_ok().mir_drops_elaborated_and_const_checked(def_id); } if tcx.is_coroutine(def_id.to_def_id()) { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 9fac68039f52c..636055a3454e5 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1111,11 +1111,7 @@ fn should_encode_mir( ) -> (bool, bool) { match tcx.def_kind(def_id) { // Constructors - DefKind::Ctor(_, _) => { - let mir_opt_base = tcx.sess.opts.output_types.should_codegen() - || tcx.sess.opts.unstable_opts.always_encode_mir; - (true, mir_opt_base) - } + DefKind::Ctor(_, _) => (true, true), // Constants DefKind::AnonConst | DefKind::InlineConst | DefKind::AssocConst | DefKind::Const => { (true, false) @@ -1127,8 +1123,7 @@ fn should_encode_mir( DefKind::AssocFn | DefKind::Fn | DefKind::Closure => { let generics = tcx.generics_of(def_id); let opt = tcx.sess.opts.unstable_opts.always_encode_mir - || (tcx.sess.opts.output_types.should_codegen() - && reachable_set.contains(&def_id) + || (reachable_set.contains(&def_id) && (generics.requires_monomorphization(tcx) || tcx.cross_crate_inlinable(def_id))); // The function has a `const` modifier or is in a `const trait`. @@ -1858,10 +1853,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { // Encode all the deduced parameter attributes for everything that has MIR, even for items // that can't be inlined. But don't if we aren't optimizing in non-incremental mode, to // save the query traffic. - if tcx.sess.opts.output_types.should_codegen() - && tcx.sess.opts.optimize != OptLevel::No - && tcx.sess.opts.incremental.is_none() - { + if tcx.sess.opts.optimize != OptLevel::No && tcx.sess.opts.incremental.is_none() { for &local_def_id in tcx.mir_keys(()) { if let DefKind::AssocFn | DefKind::Fn = tcx.def_kind(local_def_id) { record_array!(self.tables.deduced_param_attrs[local_def_id.to_def_id()] <- @@ -2263,11 +2255,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { /// Used to prefetch queries which will be needed later by metadata encoding. /// Only a subset of the queries are actually prefetched to keep this code smaller. fn prefetch_mir(tcx: TyCtxt<'_>) { - if !tcx.sess.opts.output_types.should_codegen() { - // We won't emit MIR, so don't prefetch it. - return; - } - let reachable_set = tcx.reachable_set(()); par_for_each_in(tcx.mir_keys(()), |&&def_id| { if tcx.is_trivial_const(def_id) {