diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-11-24 14:37:46 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-11-28 20:59:57 +0300 |
| commit | 9be526e8ebfd318ecc5c6d5a6c40886dffb1be95 (patch) | |
| tree | 4112dff7b4997c7eb5480c31f9c027337a1ce10b /src/librustc | |
| parent | 4c8105e8b743ce1742a91a07dca3b5a23f72178b (diff) | |
| download | rust-9be526e8ebfd318ecc5c6d5a6c40886dffb1be95.tar.gz rust-9be526e8ebfd318ecc5c6d5a6c40886dffb1be95.zip | |
rustc_metadata: Move `has_global_allocator` from session to cstore
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/middle/cstore.rs | 1 | ||||
| -rw-r--r-- | src/librustc/session/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustc/ty/context.rs | 4 |
3 files changed, 5 insertions, 4 deletions
diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 53548fa40f2..51282701480 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -237,6 +237,7 @@ pub trait CrateStore { fn metadata_encoding_version(&self) -> &[u8]; fn injected_panic_runtime(&self) -> Option<CrateNum>; fn allocator_kind(&self) -> Option<AllocatorKind>; + fn has_global_allocator(&self) -> bool; } pub type CrateStoreDyn = dyn CrateStore + sync::Sync; diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index af6522df61e..0b9d04ca6a3 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -133,9 +133,6 @@ pub struct Session { /// false positives about a job server in our environment. pub jobserver: Client, - /// Metadata about the allocators for the current crate being compiled. - pub has_global_allocator: Once<bool>, - /// Cap lint level specified by a driver specifically. pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>, @@ -1180,7 +1177,6 @@ fn build_session_( print_fuel_crate, print_fuel, jobserver: jobserver::client(), - has_global_allocator: Once::new(), driver_lint_caps, trait_methods_not_found: Lock::new(Default::default()), confused_type_with_std_module: Lock::new(Default::default()), diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 95456581169..0f3441267f5 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -3028,4 +3028,8 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { // We want to check if the panic handler was defined in this crate tcx.lang_items().panic_impl().map_or(false, |did| did.is_local()) }; + providers.has_global_allocator = |tcx, cnum| { + assert_eq!(cnum, LOCAL_CRATE); + tcx.cstore.has_global_allocator() + }; } |
