Skip to content

Commit ad3db41

Browse files
authored
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.
2 parents 0fdc8c0 + 34e7eac commit ad3db41

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
@@ -517,6 +517,7 @@ mod tests {
517517
mpsc::channel,
518518
Mutex,
519519
},
520+
thread,
520521
};
521522

522523
#[test]
@@ -553,26 +554,8 @@ mod tests {
553554
}
554555
}
555556

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

578561
#[test]
@@ -735,7 +718,6 @@ mod tests {
735718
}
736719

737720
#[test]
738-
#[cfg_attr(miri, ignore)] // leaks memory
739721
fn static_sync_lazy() {
740722
static XS: SyncLazy<Vec<i32>> = SyncLazy::new(|| {
741723
let mut xs = Vec::new();
@@ -753,7 +735,6 @@ mod tests {
753735
}
754736

755737
#[test]
756-
#[cfg_attr(miri, ignore)] // leaks memory
757738
fn static_sync_lazy_via_fn() {
758739
fn xs() -> &'static Vec<i32> {
759740
static XS: SyncOnceCell<Vec<i32>> = SyncOnceCell::new();
@@ -812,7 +793,6 @@ mod tests {
812793
}
813794

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

@@ -824,7 +804,7 @@ mod tests {
824804

825805
for _ in 0..n_readers {
826806
let tx = tx.clone();
827-
spawn(move || {
807+
thread::spawn(move || {
828808
loop {
829809
if let Some(msg) = ONCE_CELL.get() {
830810
tx.send(msg).unwrap();
@@ -836,7 +816,7 @@ mod tests {
836816
});
837817
}
838818
for _ in 0..n_writers {
839-
spawn(move || {
819+
thread::spawn(move || {
840820
let _ = ONCE_CELL.set(MSG.to_owned());
841821
});
842822
}

0 commit comments

Comments
 (0)