Skip to content

Commit

Permalink
Merge #111
Browse files Browse the repository at this point in the history
111: Miri supports threads now
 r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
  • Loading branch information
bors[bot] and matklad committed Aug 19, 2020
2 parents d6b9907 + 2efe657 commit f479161
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,32 +202,9 @@ mod unsync {
mod sync {
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};

use once_cell::sync::{Lazy, OnceCell};

#[cfg(not(miri))] // miri doesn't support threads
mod scope {
pub(super) use crossbeam_utils::thread::scope;
}
use crossbeam_utils::thread::scope;

#[cfg(miri)] // "stub threads" for Miri
mod scope {
pub(super) struct Scope;

#[cfg(miri)]
impl Scope {
pub(super) fn spawn<R>(&self, f: impl FnOnce(()) -> R) -> R {
f(())
}
}

#[cfg(miri)]
pub(super) fn scope(f: impl FnOnce(&Scope)) -> Result<(), ()> {
f(&Scope);
Ok(())
}
}

use scope::scope;
use once_cell::sync::{Lazy, OnceCell};

#[test]
fn once_cell() {
Expand Down

0 comments on commit f479161

Please sign in to comment.