diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2023-08-07 13:31:14 -0400 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2023-08-07 13:31:14 -0400 |
| commit | a2058ddbed82adda55ce39f0e0915996706cb2b9 (patch) | |
| tree | 1ccad08540b7365d920198601153ef20ff1b0aed /compiler/rustc_codegen_ssa | |
| parent | 5881e5f88d9245ef9259ca600b32af80d5972a7f (diff) | |
| download | rust-a2058ddbed82adda55ce39f0e0915996706cb2b9.tar.gz rust-a2058ddbed82adda55ce39f0e0915996706cb2b9.zip | |
Review feedback: return empty iff !should_codegen, and use simpler unconditional logic otherwise.
Diffstat (limited to 'compiler/rustc_codegen_ssa')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/linker.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 74b81733356..a1e322f4b31 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1698,23 +1698,16 @@ fn exported_symbols_for_non_proc_macro(tcx: TyCtxt<'_>, crate_type: CrateType) - } fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<String> { - let mut symbols = Vec::new(); + // `exported_symbols` will be empty when !should_codegen. + if !tcx.sess.opts.output_types.should_codegen() { + return Vec::new(); + } let stable_crate_id = tcx.sess.local_stable_crate_id(); let proc_macro_decls_name = tcx.sess.generate_proc_macro_decls_symbol(stable_crate_id); let metadata_symbol_name = exported_symbols::metadata_symbol_name(tcx); - // You would think that both the two names would always be there, but in - // pnkfelix's local experiments that was not case. So instead we walk the - // list and only add them if they *are* there. - for_each_exported_symbols_include_dep(tcx, CrateType::ProcMacro, |symbol, _info, cnum| { - let name = symbol_export::symbol_name_for_instance_in_crate(tcx, symbol, cnum); - if name == proc_macro_decls_name || name == metadata_symbol_name { - symbols.push(name); - } - }); - - return symbols; + vec![proc_macro_decls_name, metadata_symbol_name] } pub(crate) fn linked_symbols( |
