Skip to content

Commit 34e7eac

Browse files
committed
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.
1 parent c03c213 commit 34e7eac

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

library/std/src/lazy.rs

+4-24
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ mod tests {
516516
mpsc::channel,
517517
Mutex,
518518
},
519+
thread,
519520
};
520521

521522
#[test]
@@ -552,26 +553,8 @@ mod tests {
552553
}
553554
}
554555

555-
// miri doesn't support threads
556-
#[cfg(not(miri))]
557556
fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
558-
crate::thread::spawn(f).join().unwrap()
559-
}
560-
561-
#[cfg(not(miri))]
562-
fn spawn(f: impl FnOnce() + Send + 'static) {
563-
let _ = crate::thread::spawn(f);
564-
}
565-
566-
// "stub threads" for Miri
567-
#[cfg(miri)]
568-
fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
569-
f(())
570-
}
571-
572-
#[cfg(miri)]
573-
fn spawn(f: impl FnOnce() + Send + 'static) {
574-
f(())
557+
thread::spawn(f).join().unwrap()
575558
}
576559

577560
#[test]
@@ -734,7 +717,6 @@ mod tests {
734717
}
735718

736719
#[test]
737-
#[cfg_attr(miri, ignore)] // leaks memory
738720
fn static_sync_lazy() {
739721
static XS: SyncLazy<Vec<i32>> = SyncLazy::new(|| {
740722
let mut xs = Vec::new();
@@ -752,7 +734,6 @@ mod tests {
752734
}
753735

754736
#[test]
755-
#[cfg_attr(miri, ignore)] // leaks memory
756737
fn static_sync_lazy_via_fn() {
757738
fn xs() -> &'static Vec<i32> {
758739
static XS: SyncOnceCell<Vec<i32>> = SyncOnceCell::new();
@@ -811,7 +792,6 @@ mod tests {
811792
}
812793

813794
#[test]
814-
#[cfg_attr(miri, ignore)] // deadlocks without real threads
815795
fn sync_once_cell_does_not_leak_partially_constructed_boxes() {
816796
static ONCE_CELL: SyncOnceCell<String> = SyncOnceCell::new();
817797

@@ -823,7 +803,7 @@ mod tests {
823803

824804
for _ in 0..n_readers {
825805
let tx = tx.clone();
826-
spawn(move || {
806+
thread::spawn(move || {
827807
loop {
828808
if let Some(msg) = ONCE_CELL.get() {
829809
tx.send(msg).unwrap();
@@ -835,7 +815,7 @@ mod tests {
835815
});
836816
}
837817
for _ in 0..n_writers {
838-
spawn(move || {
818+
thread::spawn(move || {
839819
let _ = ONCE_CELL.set(MSG.to_owned());
840820
});
841821
}

0 commit comments

Comments
 (0)