diff options
| author | Jana Dönszelmann <jana@donsz.nl> | 2025-08-25 18:52:57 +0200 |
|---|---|---|
| committer | Jana Dönszelmann <jana@donsz.nl> | 2025-08-26 13:05:51 +0200 |
| commit | d66ca530000af040a6f0a53c48e3ee35ae96f86b (patch) | |
| tree | 2b82cae0fffdf5b2242974055db4a5803a1d9f63 /compiler/rustc_passes/src | |
| parent | b779120cad2c93e53c0dfb7007c1214b2b275183 (diff) | |
| download | rust-d66ca530000af040a6f0a53c48e3ee35ae96f86b.tar.gz rust-d66ca530000af040a6f0a53c48e3ee35ae96f86b.zip | |
add a flag to codegen fn attrs for foreign items
Diffstat (limited to 'compiler/rustc_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/dead.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/reachable.rs | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 7aef60b7b91..dc9e7bce5e3 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -495,7 +495,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { { let attrs = self.tcx.codegen_fn_attrs(did); // Not checking naked as `#[inline]` is forbidden for naked functions anyways. - if attrs.contains_extern_indicator(self.tcx, did.into()) { + if attrs.contains_extern_indicator() { self.tcx.emit_node_span_lint( UNUSED_ATTRIBUTES, hir_id, diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 10cd9df4816..fc33405d455 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -706,7 +706,7 @@ fn has_allow_dead_code_or_lang_attr( // #[used], #[no_mangle], #[export_name], etc also keeps the item alive // forcefully, e.g., for placing it in a specific section. - cg_attrs.contains_extern_indicator(tcx, def_id.into()) + cg_attrs.contains_extern_indicator() || cg_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER) || cg_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) } diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs index 6cd8a54ecf4..d1a703fc5d8 100644 --- a/compiler/rustc_passes/src/reachable.rs +++ b/compiler/rustc_passes/src/reachable.rs @@ -183,7 +183,7 @@ impl<'tcx> ReachableContext<'tcx> { } else { CodegenFnAttrs::EMPTY }; - let is_extern = codegen_attrs.contains_extern_indicator(self.tcx, search_item.into()); + let is_extern = codegen_attrs.contains_extern_indicator(); if is_extern { self.reachable_symbols.insert(search_item); } @@ -425,7 +425,7 @@ fn has_custom_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { } let codegen_attrs = tcx.codegen_fn_attrs(def_id); - codegen_attrs.contains_extern_indicator(tcx, def_id.into()) + codegen_attrs.contains_extern_indicator() // FIXME(nbdd0121): `#[used]` are marked as reachable here so it's picked up by // `linked_symbols` in cg_ssa. They won't be exported in binary or cdylib due to their // `SymbolExportLevel::Rust` export level but may end up being exported in dylibs. |
