diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2023-08-07 13:31:14 -0400 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2023-08-11 18:52:37 -0700 |
| commit | a94c607997d4b4389c53b5198e4fe5f3f0a093ed (patch) | |
| tree | 13583142a53ec2fdff9b5c0d4c6243d1e0404b91 /compiler/rustc_codegen_ssa/src | |
| parent | fecb6b277c99f250654fa2cff204df2e773ade08 (diff) | |
Review feedback: return empty iff !should_codegen, and use simpler unconditional logic otherwise.
(cherry picked from commit a2058ddbed82adda55ce39f0e0915996706cb2b9)
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -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 f622ed32c38..8ac86fa4b26 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( |
