about summary refs log tree commit diff
path: root/library/std/src/lazy.rs
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2020-08-19 11:12:25 -0700
committerGitHub <noreply@github.com>2020-08-19 11:12:25 -0700
commitad3db41182a6f256fb6d44d4b8e67cd2ab6e7922 (patch)
treed3005c84ee82e922dc2d27aa7a2426c9de49571d /library/std/src/lazy.rs
parent0fdc8c06dd36b2ee52b32f2b7431ee5952427f28 (diff)
parent34e7eac1ca2d9c66f2ad3f723f18ecf4c5db934b (diff)
downloadrust-ad3db41182a6f256fb6d44d4b8e67cd2ab6e7922.tar.gz
rust-ad3db41182a6f256fb6d44d4b8e67cd2ab6e7922.zip
Rollup merge of #75696 - matklad:mirit, r=RalfJung
Remove `#[cfg(miri)]` from OnceCell tests

They were carried over from once_cell crate, but they are not entirely
correct (as miri now supports more things), and we don't run miri
tests for std, so let's just remove them.

Maybe one day we'll run miri in std, but then we can just re-install
these attributes.
Diffstat (limited to 'library/std/src/lazy.rs')
-rw-r--r--library/std/src/lazy.rs28
1 files changed, 4 insertions, 24 deletions
diff --git a/library/std/src/lazy.rs b/library/std/src/lazy.rs
index c1d05213e11..f0548582d2f 100644
--- a/library/std/src/lazy.rs
+++ b/library/std/src/lazy.rs
@@ -517,6 +517,7 @@ mod tests {
             mpsc::channel,
             Mutex,
         },
+        thread,
     };
 
     #[test]
@@ -553,26 +554,8 @@ mod tests {
         }
     }
 
-    // miri doesn't support threads
-    #[cfg(not(miri))]
     fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
-        crate::thread::spawn(f).join().unwrap()
-    }
-
-    #[cfg(not(miri))]
-    fn spawn(f: impl FnOnce() + Send + 'static) {
-        let _ = crate::thread::spawn(f);
-    }
-
-    // "stub threads" for Miri
-    #[cfg(miri)]
-    fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
-        f(())
-    }
-
-    #[cfg(miri)]
-    fn spawn(f: impl FnOnce() + Send + 'static) {
-        f(())
+        thread::spawn(f).join().unwrap()
     }
 
     #[test]
@@ -735,7 +718,6 @@ mod tests {
     }
 
     #[test]
-    #[cfg_attr(miri, ignore)] // leaks memory
     fn static_sync_lazy() {
         static XS: SyncLazy<Vec<i32>> = SyncLazy::new(|| {
             let mut xs = Vec::new();
@@ -753,7 +735,6 @@ mod tests {
     }
 
     #[test]
-    #[cfg_attr(miri, ignore)] // leaks memory
     fn static_sync_lazy_via_fn() {
         fn xs() -> &'static Vec<i32> {
             static XS: SyncOnceCell<Vec<i32>> = SyncOnceCell::new();
@@ -812,7 +793,6 @@ mod tests {
     }
 
     #[test]
-    #[cfg_attr(miri, ignore)] // deadlocks without real threads
     fn sync_once_cell_does_not_leak_partially_constructed_boxes() {
         static ONCE_CELL: SyncOnceCell<String> = SyncOnceCell::new();
 
@@ -824,7 +804,7 @@ mod tests {
 
         for _ in 0..n_readers {
             let tx = tx.clone();
-            spawn(move || {
+            thread::spawn(move || {
                 loop {
                     if let Some(msg) = ONCE_CELL.get() {
                         tx.send(msg).unwrap();
@@ -836,7 +816,7 @@ mod tests {
             });
         }
         for _ in 0..n_writers {
-            spawn(move || {
+            thread::spawn(move || {
                 let _ = ONCE_CELL.set(MSG.to_owned());
             });
         }