Skip to content

Commit 6bc7f41

Browse files
committed
Remove the contains_extern_indicator query
Part of #47320
1 parent 5460b88 commit 6bc7f41

File tree

11 files changed

+11
-16
lines changed

11 files changed

+11
-16
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ define_dep_nodes!( <'tcx>
627627
[input] AllCrateNums,
628628
[] ExportedSymbols(CrateNum),
629629
[eval_always] CollectAndPartitionTranslationItems,
630-
[] ContainsExternIndicator(DefId),
631630
[] IsTranslatedItem(DefId),
632631
[] CodegenUnit(InternedString),
633632
[] CompileCodegenUnit(InternedString),

src/librustc/hir/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,7 @@ bitflags! {
22272227
const UNWIND = 0b0000_0100;
22282228
const RUSTC_ALLOCATOR_NOUNWIND = 0b0000_1000;
22292229
const NAKED = 0b0001_0000;
2230+
const NO_MANGLE = 0b0010_0000;
22302231
}
22312232
}
22322233

@@ -2246,5 +2247,10 @@ impl TransFnAttrs {
22462247
InlineAttr::None | InlineAttr::Never => false,
22472248
}
22482249
}
2250+
2251+
/// True if `#[no_mangle]` or `#[export_name(...)]` is present.
2252+
pub fn contains_extern_indicator(&self) -> bool {
2253+
self.flags.contains(TransFnAttrFlags::NO_MANGLE) || self.export_name.is_some()
2254+
}
22492255
}
22502256

src/librustc/middle/reachable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
233233
false
234234
};
235235
let def_id = self.tcx.hir.local_def_id(item.id);
236-
let is_extern = self.tcx.contains_extern_indicator(def_id);
236+
let is_extern = self.tcx.trans_fn_attrs(def_id).contains_extern_indicator();
237237
if reachable || is_extern {
238238
self.reachable_symbols.insert(search_item);
239239
}

src/librustc/ty/maps/config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,6 @@ impl_disk_cacheable_query!(borrowck, |def_id| def_id.is_local());
687687
impl_disk_cacheable_query!(mir_borrowck, |def_id| def_id.is_local());
688688
impl_disk_cacheable_query!(mir_const_qualif, |def_id| def_id.is_local());
689689
impl_disk_cacheable_query!(check_match, |def_id| def_id.is_local());
690-
impl_disk_cacheable_query!(contains_extern_indicator, |_| true);
691690
impl_disk_cacheable_query!(def_symbol_name, |_| true);
692691
impl_disk_cacheable_query!(type_of, |def_id| def_id.is_local());
693692
impl_disk_cacheable_query!(predicates_of, |def_id| def_id.is_local());

src/librustc/ty/maps/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ define_maps! { <'tcx>
363363
[] fn collect_and_partition_translation_items:
364364
collect_and_partition_translation_items_node(CrateNum)
365365
-> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>),
366-
[] fn contains_extern_indicator: ContainsExternIndicator(DefId) -> bool,
367366
[] fn symbol_export_level: GetSymbolExportLevel(DefId) -> SymbolExportLevel,
368367
[] fn is_translated_item: IsTranslatedItem(DefId) -> bool,
369368
[] fn codegen_unit: CodegenUnit(InternedString) -> Arc<CodegenUnit<'tcx>>,

src/librustc/ty/maps/on_disk_cache.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ impl<'sess> OnDiskCache<'sess> {
217217
encode_query_results::<mir_const_qualif, _>(tcx, enc, qri)?;
218218
encode_query_results::<def_symbol_name, _>(tcx, enc, qri)?;
219219
encode_query_results::<const_is_rvalue_promotable_to_static, _>(tcx, enc, qri)?;
220-
encode_query_results::<contains_extern_indicator, _>(tcx, enc, qri)?;
221220
encode_query_results::<symbol_name, _>(tcx, enc, qri)?;
222221
encode_query_results::<check_match, _>(tcx, enc, qri)?;
223222
}

src/librustc/ty/maps/plumbing.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -926,9 +926,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
926926
DepKind::CollectAndPartitionTranslationItems => {
927927
force!(collect_and_partition_translation_items, LOCAL_CRATE);
928928
}
929-
DepKind::ContainsExternIndicator => {
930-
force!(contains_extern_indicator, def_id!());
931-
}
932929
DepKind::IsTranslatedItem => { force!(is_translated_item, def_id!()); }
933930
DepKind::OutputFilenames => { force!(output_filenames, LOCAL_CRATE); }
934931

@@ -997,7 +994,6 @@ impl_load_from_cache!(
997994
MirConstQualif => mir_const_qualif,
998995
SymbolName => def_symbol_name,
999996
ConstIsRvaluePromotableToStatic => const_is_rvalue_promotable_to_static,
1000-
ContainsExternIndicator => contains_extern_indicator,
1001997
CheckMatch => check_match,
1002998
TypeOfItem => type_of,
1003999
GenericsOfItem => generics_of,

src/librustc_trans/back/symbol_export.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ fn symbol_export_level_provider(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportL
256256
// special symbols in the standard library for various plumbing between
257257
// core/std/allocators/etc. For example symbols used to hook up allocation
258258
// are not considered for export
259-
let is_extern = tcx.contains_extern_indicator(sym_def_id);
259+
let trans_fn_attrs = tcx.trans_fn_attrs(sym_def_id);
260+
let is_extern = trans_fn_attrs.contains_extern_indicator();
260261
let std_internal = attr::contains_name(&tcx.get_attrs(sym_def_id),
261262
"rustc_std_internal_symbol");
262263
if is_extern && !std_internal {

src/librustc_trans_utils/symbol_names.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,6 @@ pub fn provide(providers: &mut Providers) {
120120
def_symbol_name,
121121
symbol_name,
122122

123-
contains_extern_indicator: |tcx, id| {
124-
attr::contains_name(&tcx.get_attrs(id), "no_mangle") ||
125-
tcx.trans_fn_attrs(id).export_name.is_some()
126-
},
127-
128123
..*providers
129124
};
130125
}

src/librustc_trans_utils/trans_crate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ impl TransCrate for MetadataOnlyTransCrate {
233233
MonoItem::Fn(inst) => {
234234
let def_id = inst.def_id();
235235
if def_id.is_local() {
236-
let _ = tcx.contains_extern_indicator(def_id);
237236
let _ = inst.def.is_inline(tcx);
238237
let _ = tcx.trans_fn_attrs(def_id);
239238
}

src/librustc_typeck/collect.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,8 @@ fn trans_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> TransFnAt
17431743
trans_fn_attrs.flags |= TransFnAttrFlags::RUSTC_ALLOCATOR_NOUNWIND;
17441744
} else if attr.check_name("naked") {
17451745
trans_fn_attrs.flags |= TransFnAttrFlags::NAKED;
1746+
} else if attr.check_name("no_mangle") {
1747+
trans_fn_attrs.flags |= TransFnAttrFlags::NO_MANGLE;
17461748
} else if attr.check_name("inline") {
17471749
trans_fn_attrs.inline = attrs.iter().fold(InlineAttr::None, |ia, attr| {
17481750
if attr.path != "inline" {

0 commit comments

Comments
 (0)