Skip to content

Commit ee94fbb

Browse files
committed
Make allocator_kind a query.
1 parent e1e6949 commit ee94fbb

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

compiler/rustc_ast/src/expand/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_span::symbol::{sym, Symbol};
22

3-
#[derive(Clone, Copy)]
3+
#[derive(Clone, Debug, Copy, HashStable_Generic)]
44
pub enum AllocatorKind {
55
Global,
66
Default,

compiler/rustc_codegen_cranelift/src/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) fn codegen(
1919
});
2020
if any_dynamic_crate {
2121
false
22-
} else if let Some(kind) = tcx.allocator_kind() {
22+
} else if let Some(kind) = tcx.allocator_kind(()) {
2323
codegen_inner(module, unwind_context, kind);
2424
true
2525
} else {

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn exported_symbols_provider_local(
180180
symbols.push((exported_symbol, SymbolExportLevel::C));
181181
}
182182

183-
if tcx.allocator_kind().is_some() {
183+
if tcx.allocator_kind(()).is_some() {
184184
for method in ALLOCATOR_METHODS {
185185
let symbol_name = format!("__rust_{}", method.name);
186186
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name));

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
517517
});
518518
let allocator_module = if any_dynamic_crate {
519519
None
520-
} else if let Some(kind) = tcx.allocator_kind() {
520+
} else if let Some(kind) = tcx.allocator_kind(()) {
521521
let llmod_id =
522522
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
523523
let mut modules = backend.new_metadata(tcx, &llmod_id);

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub type DepNode = rustc_query_system::dep_graph::DepNode<DepKind>;
285285
// required that their size stay the same, but we don't want to change
286286
// it inadvertently. This assert just ensures we're aware of any change.
287287
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
288-
static_assert_size!(DepNode, 17);
288+
static_assert_size!(DepNode, 18);
289289

290290
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
291291
static_assert_size!(DepNode, 24);

compiler/rustc_middle/src/query/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,9 @@ rustc_queries! {
14121412
eval_always
14131413
desc { "generating a postorder list of CrateNums" }
14141414
}
1415+
query allocator_kind(_: ()) -> Option<AllocatorKind> {
1416+
desc { "allocator kind for the current crate" }
1417+
}
14151418

14161419
query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
14171420
desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) }

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use crate::ty::{
2525
TraitObjectVisitor, Ty, TyKind, TyS, TyVar, TyVid, TypeAndMut, UintTy,
2626
};
2727
use rustc_ast as ast;
28-
use rustc_ast::expand::allocator::AllocatorKind;
2928
use rustc_attr as attr;
3029
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
3130
use rustc_data_structures::profiling::SelfProfilerRef;
@@ -1207,10 +1206,6 @@ impl<'tcx> TyCtxt<'tcx> {
12071206
self.all_crate_nums(())
12081207
}
12091208

1210-
pub fn allocator_kind(self) -> Option<AllocatorKind> {
1211-
self.untracked_resolutions.cstore.allocator_kind()
1212-
}
1213-
12141209
pub fn features(self) -> &'tcx rustc_feature::Features {
12151210
self.features_query(())
12161211
}
@@ -2817,4 +2812,5 @@ pub fn provide(providers: &mut ty::query::Providers) {
28172812
// We want to check if the panic handler was defined in this crate
28182813
tcx.lang_items().panic_impl().map_or(false, |did| did.is_local())
28192814
};
2815+
providers.allocator_kind = |tcx, ()| tcx.resolutions(()).cstore.allocator_kind();
28202816
}

compiler/rustc_middle/src/ty/query/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use crate::traits::{self, ImplSource};
3333
use crate::ty::subst::{GenericArg, SubstsRef};
3434
use crate::ty::util::AlwaysRequiresDrop;
3535
use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
36+
use rustc_ast::expand::allocator::AllocatorKind;
3637
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
3738
use rustc_data_structures::steal::Steal;
3839
use rustc_data_structures::svh::Svh;

0 commit comments

Comments
 (0)