diff options
| author | bors <bors@rust-lang.org> | 2018-04-12 16:22:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-04-12 16:22:36 +0000 |
| commit | 6c537493d01694cc6e0a614dff12c475055aa2b4 (patch) | |
| tree | d656ca53d1f26ce7bdd653864a65cf2d83157f35 /src/librustc_metadata | |
| parent | 9afed646451175e24964cc76688293cb87ed718c (diff) | |
| parent | 006f9b2f5616ad970cb0f5102ec50e02ef2dd379 (diff) | |
| download | rust-6c537493d01694cc6e0a614dff12c475055aa2b4.tar.gz rust-6c537493d01694cc6e0a614dff12c475055aa2b4.zip | |
Auto merge of #49558 - Zoxc:sync-misc, r=michaelwoerister
Even more thread-safety changes r? @michaelwoerister
Diffstat (limited to 'src/librustc_metadata')
| -rw-r--r-- | src/librustc_metadata/creader.rs | 14 | ||||
| -rw-r--r-- | src/librustc_metadata/encoder.rs | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 86f495c5fac..34d9f47bac3 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -614,6 +614,7 @@ impl<'a> CrateLoader<'a> { }); if !any_non_rlib { info!("panic runtime injection skipped, only generating rlib"); + self.sess.injected_panic_runtime.set(None); return } @@ -646,6 +647,7 @@ impl<'a> CrateLoader<'a> { // we just don't need one at all, then we're done here and there's // nothing else to do. if !needs_panic_runtime || runtime_found { + self.sess.injected_panic_runtime.set(None); return } @@ -812,9 +814,7 @@ impl<'a> CrateLoader<'a> { fn inject_allocator_crate(&mut self, krate: &ast::Crate) { let has_global_allocator = has_global_allocator(krate); - if has_global_allocator { - self.sess.has_global_allocator.set(true); - } + self.sess.has_global_allocator.set(has_global_allocator); // Check to see if we actually need an allocator. This desire comes // about through the `#![needs_allocator]` attribute and is typically @@ -825,6 +825,8 @@ impl<'a> CrateLoader<'a> { needs_allocator = needs_allocator || data.needs_allocator(self.sess); }); if !needs_allocator { + self.sess.injected_allocator.set(None); + self.sess.allocator_kind.set(None); return } @@ -844,6 +846,8 @@ impl<'a> CrateLoader<'a> { } } if !need_lib_alloc && !need_exe_alloc { + self.sess.injected_allocator.set(None); + self.sess.allocator_kind.set(None); return } @@ -881,6 +885,7 @@ impl<'a> CrateLoader<'a> { }); if global_allocator.is_some() { self.sess.allocator_kind.set(Some(AllocatorKind::Global)); + self.sess.injected_allocator.set(None); return } @@ -924,6 +929,9 @@ impl<'a> CrateLoader<'a> { }; let allocation_crate_data = exe_allocation_crate_data.or_else(|| { + // No allocator was injected + self.sess.injected_allocator.set(None); + if attr::contains_name(&krate.attrs, "default_lib_allocator") { // Prefer self as the allocator if there's a collision return None; diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index e40a3057a95..22b440eea60 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -459,7 +459,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeProcMacro); let has_default_lib_allocator = attr::contains_name(tcx.hir.krate_attrs(), "default_lib_allocator"); - let has_global_allocator = tcx.sess.has_global_allocator.get(); + let has_global_allocator = *tcx.sess.has_global_allocator.get(); let root = self.lazy(&CrateRoot { name: tcx.crate_name(LOCAL_CRATE), extra_filename: tcx.sess.opts.cg.extra_filename.clone(), |
