Skip to content

Commit a2058dd

Browse files
committed
Review feedback: return empty iff !should_codegen, and use simpler unconditional logic otherwise.
1 parent 5881e5f commit a2058dd

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -1698,23 +1698,16 @@ fn exported_symbols_for_non_proc_macro(tcx: TyCtxt<'_>, crate_type: CrateType) -
16981698
}
16991699

17001700
fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<String> {
1701-
let mut symbols = Vec::new();
1701+
// `exported_symbols` will be empty when !should_codegen.
1702+
if !tcx.sess.opts.output_types.should_codegen() {
1703+
return Vec::new();
1704+
}
17021705

17031706
let stable_crate_id = tcx.sess.local_stable_crate_id();
17041707
let proc_macro_decls_name = tcx.sess.generate_proc_macro_decls_symbol(stable_crate_id);
17051708
let metadata_symbol_name = exported_symbols::metadata_symbol_name(tcx);
17061709

1707-
// You would think that both the two names would always be there, but in
1708-
// pnkfelix's local experiments that was not case. So instead we walk the
1709-
// list and only add them if they *are* there.
1710-
for_each_exported_symbols_include_dep(tcx, CrateType::ProcMacro, |symbol, _info, cnum| {
1711-
let name = symbol_export::symbol_name_for_instance_in_crate(tcx, symbol, cnum);
1712-
if name == proc_macro_decls_name || name == metadata_symbol_name {
1713-
symbols.push(name);
1714-
}
1715-
});
1716-
1717-
return symbols;
1710+
vec![proc_macro_decls_name, metadata_symbol_name]
17181711
}
17191712

17201713
pub(crate) fn linked_symbols(

0 commit comments

Comments
 (0)