about summary refs log tree commit diff
path: root/library/std/src/lazy.rs
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2020-08-19 10:28:22 +0200
committerAleksey Kladov <aleksey.kladov@gmail.com>2020-08-19 10:28:22 +0200
commit34e7eac1ca2d9c66f2ad3f723f18ecf4c5db934b (patch)
tree94b14d7299e4cde4ae399108305edf2a1d0e42c7 /library/std/src/lazy.rs
parentc03c213daf5fe3b52c768b4f145e45d8994d87ea (diff)
downloadrust-34e7eac1ca2d9c66f2ad3f723f18ecf4c5db934b.tar.gz
rust-34e7eac1ca2d9c66f2ad3f723f18ecf4c5db934b.zip
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 60eba96bcc0..bf801b3c8c7 100644
--- a/library/std/src/lazy.rs
+++ b/library/std/src/lazy.rs
@@ -516,6 +516,7 @@ mod tests {
             mpsc::channel,
             Mutex,
         },
+        thread,
     };
 
     #[test]
@@ -552,26 +553,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]
@@ -734,7 +717,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();
@@ -752,7 +734,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();
@@ -811,7 +792,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();
 
@@ -823,7 +803,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();
@@ -835,7 +815,7 @@ mod tests {
             });
         }
         for _ in 0..n_writers {
-            spawn(move || {
+            thread::spawn(move || {
                 let _ = ONCE_CELL.set(MSG.to_owned());
             });
         }