Skip to content

Commit 39f9d23

Browse files
committed
Add flag for rustc_std_internal_symbol attribute
Part of #47320
1 parent 6bc7f41 commit 39f9d23

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/librustc/hir/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,7 @@ bitflags! {
22282228
const RUSTC_ALLOCATOR_NOUNWIND = 0b0000_1000;
22292229
const NAKED = 0b0001_0000;
22302230
const NO_MANGLE = 0b0010_0000;
2231+
const RUSTC_STD_INTERNAL_SYMBOL = 0b0100_0000;
22312232
}
22322233
}
22332234

src/librustc_mir/monomorphize/collector.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
//! this is not implemented however: a mono item will be produced
189189
//! regardless of whether it is actually needed or not.
190190
191-
use rustc::hir;
191+
use rustc::hir::{self, TransFnAttrFlags};
192192
use rustc::hir::itemlikevisit::ItemLikeVisitor;
193193

194194
use rustc::hir::map as hir_map;
@@ -211,8 +211,6 @@ use monomorphize::item::{MonoItemExt, DefPathBasedNames, InstantiationMode};
211211

212212
use rustc_data_structures::bitvec::BitVector;
213213

214-
use syntax::attr;
215-
216214
use std::iter;
217215

218216
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
@@ -985,8 +983,8 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
985983
MonoItemCollectionMode::Lazy => {
986984
self.entry_fn == Some(def_id) ||
987985
self.tcx.is_reachable_non_generic(def_id) ||
988-
attr::contains_name(&self.tcx.get_attrs(def_id),
989-
"rustc_std_internal_symbol")
986+
self.tcx.trans_fn_attrs(def_id).flags.contains(
987+
TransFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)
990988
}
991989
}
992990
}

src/librustc_trans/back/symbol_export.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::sync::Arc;
1313

1414
use monomorphize::Instance;
1515
use rustc::hir;
16+
use rustc::hir::TransFnAttrFlags;
1617
use rustc::hir::def_id::CrateNum;
1718
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
1819
use rustc::middle::exported_symbols::{SymbolExportLevel, ExportedSymbol, metadata_symbol_name};
@@ -21,7 +22,6 @@ use rustc::ty::{TyCtxt, SymbolName};
2122
use rustc::ty::maps::Providers;
2223
use rustc::util::nodemap::{FxHashMap, DefIdSet};
2324
use rustc_allocator::ALLOCATOR_METHODS;
24-
use syntax::attr;
2525

2626
pub type ExportedSymbols = FxHashMap<
2727
CrateNum,
@@ -258,8 +258,8 @@ fn symbol_export_level_provider(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportL
258258
// are not considered for export
259259
let trans_fn_attrs = tcx.trans_fn_attrs(sym_def_id);
260260
let is_extern = trans_fn_attrs.contains_extern_indicator();
261-
let std_internal = attr::contains_name(&tcx.get_attrs(sym_def_id),
262-
"rustc_std_internal_symbol");
261+
let std_internal = trans_fn_attrs.flags.contains(TransFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
262+
263263
if is_extern && !std_internal {
264264
SymbolExportLevel::C
265265
} else {

src/librustc_typeck/collect.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,8 @@ fn trans_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> TransFnAt
17451745
trans_fn_attrs.flags |= TransFnAttrFlags::NAKED;
17461746
} else if attr.check_name("no_mangle") {
17471747
trans_fn_attrs.flags |= TransFnAttrFlags::NO_MANGLE;
1748+
} else if attr.check_name("rustc_std_internal_symbol") {
1749+
trans_fn_attrs.flags |= TransFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
17481750
} else if attr.check_name("inline") {
17491751
trans_fn_attrs.inline = attrs.iter().fold(InlineAttr::None, |ia, attr| {
17501752
if attr.path != "inline" {

0 commit comments

Comments
 (0)