about summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-03-23 09:27:19 -0500
committerAlex Crichton <alex@alexcrichton.com>2018-03-23 10:16:09 -0700
commit4b31b5bda75ee7be63aa5aa146d75bbacb3faa4b (patch)
tree8d9dd13645c9c9ba1856c365de32002dfbe2452e /src/librustc_data_structures
parentf74d01cf29adc11b1bda3ca73537c49dcbb60c52 (diff)
parente09c2ff3f85b428cd8283a7f7d9b38843bbc95a9 (diff)
downloadrust-4b31b5bda75ee7be63aa5aa146d75bbacb3faa4b.tar.gz
rust-4b31b5bda75ee7be63aa5aa146d75bbacb3faa4b.zip
Rollup merge of #49030 - Zoxc:misc, r=michaelwoerister
Misc changes from my parallel rustc branch

r? @michaelwoerister
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/lib.rs8
-rw-r--r--src/librustc_data_structures/sync.rs37
2 files changed, 15 insertions, 30 deletions
diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs
index 81246aea1b5..bf0b3726bb3 100644
--- a/src/librustc_data_structures/lib.rs
+++ b/src/librustc_data_structures/lib.rs
@@ -76,6 +76,14 @@ pub mod flock;
 pub mod sync;
 pub mod owning_ref;
 
+pub struct OnDrop<F: Fn()>(pub F);
+
+impl<F: Fn()> Drop for OnDrop<F> {
+      fn drop(&mut self) {
+            (self.0)();
+      }
+}
+
 // See comments in src/librustc/lib.rs
 #[doc(hidden)]
 pub fn __noop_fix_for_27438() {}
diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs
index d7cd459e577..184ef136976 100644
--- a/src/librustc_data_structures/sync.rs
+++ b/src/librustc_data_structures/sync.rs
@@ -26,11 +26,6 @@
 //!
 //! `MTLock` is a mutex which disappears if cfg!(parallel_queries) is false.
 //!
-//! `rustc_global!` gives us a way to declare variables which are intended to be
-//! global for the current rustc session. This currently maps to thread-locals,
-//! since rustdoc uses the rustc libraries in multiple threads.
-//! These globals should eventually be moved into the `Session` structure.
-//!
 //! `rustc_erase_owner!` erases a OwningRef owner into Erased or Erased + Send + Sync
 //! depending on the value of cfg!(parallel_queries).
 
@@ -228,31 +223,6 @@ pub fn assert_sync<T: ?Sized + Sync>() {}
 pub fn assert_send_val<T: ?Sized + Send>(_t: &T) {}
 pub fn assert_send_sync_val<T: ?Sized + Sync + Send>(_t: &T) {}
 
-#[macro_export]
-#[allow_internal_unstable]
-macro_rules! rustc_global {
-    // empty (base case for the recursion)
-    () => {};
-
-    // process multiple declarations
-    ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
-        thread_local!($(#[$attr])* $vis static $name: $t = $init);
-        rustc_global!($($rest)*);
-    );
-
-    // handle a single declaration
-    ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => (
-        thread_local!($(#[$attr])* $vis static $name: $t = $init);
-    );
-}
-
-#[macro_export]
-macro_rules! rustc_access_global {
-    ($name:path, $callback:expr) => {
-        $name.with($callback)
-    }
-}
-
 impl<T: Copy + Debug> Debug for LockCell<T> {
     fn fmt(&self, f: &mut Formatter) -> fmt::Result {
         f.debug_struct("LockCell")
@@ -363,6 +333,13 @@ impl<T> Lock<T> {
     }
 }
 
+impl<T: Default> Default for Lock<T> {
+    #[inline]
+    fn default() -> Self {
+        Lock::new(T::default())
+    }
+}
+
 // FIXME: Probably a bad idea
 impl<T: Clone> Clone for Lock<T> {
     #[inline]