File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- 546c826f0ccaab36e897860205281f490db274e6
1+ 1f34da9ec8a85b6f86c5fa1c121ab6f88f2f4966
Original file line number Diff line number Diff line change 1- // compile-flags: -Zmiri-disable-isolation
1+ // We want to control preemption here.
2+ // compile-flags: -Zmiri-disable-isolation -Zmiri-preemption-rate=0
23// ignore-windows: Concurrency on Windows is not supported yet.
34use std:: sync:: Arc ;
45use std:: sync:: atomic:: { AtomicUsize , Ordering , fence} ;
Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ LL | const VOID: ! = panic!();
66 |
77 = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
88
9- error: post-monomorphization error: encountered constants with type errors, stopping evaluation
9+ error: post-monomorphization error: referenced constant has errors
1010 --> $DIR/erroneous_const.rs:LL:CC
1111 |
1212LL | let _ = PrintName::<T>::VOID;
13- | ^^^^^^^^^^^^^^^^^^^^ encountered constants with type errors, stopping evaluation
13+ | ^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
1414 |
1515 = note: inside `no_codegen::<i32>` at $DIR/erroneous_const.rs:LL:CC
1616note: inside `main` at $DIR/erroneous_const.rs:LL:CC
Original file line number Diff line number Diff line change @@ -9,20 +9,23 @@ use std::thread;
99/// The test taken from the Rust documentation.
1010fn simple_send ( ) {
1111 let ( tx, rx) = channel ( ) ;
12- thread:: spawn ( move || {
12+ let t = thread:: spawn ( move || {
1313 tx. send ( 10 ) . unwrap ( ) ;
1414 } ) ;
1515 assert_eq ! ( rx. recv( ) . unwrap( ) , 10 ) ;
16+ t. join ( ) . unwrap ( ) ;
1617}
1718
1819/// The test taken from the Rust documentation.
1920fn multiple_send ( ) {
2021 let ( tx, rx) = channel ( ) ;
22+ let mut threads = vec ! [ ] ;
2123 for i in 0 ..10 {
2224 let tx = tx. clone ( ) ;
23- thread:: spawn ( move || {
25+ let t = thread:: spawn ( move || {
2426 tx. send ( i) . unwrap ( ) ;
2527 } ) ;
28+ threads. push ( t) ;
2629 }
2730
2831 let mut sum = 0 ;
@@ -32,6 +35,10 @@ fn multiple_send() {
3235 sum += j;
3336 }
3437 assert_eq ! ( sum, 45 ) ;
38+
39+ for t in threads {
40+ t. join ( ) . unwrap ( ) ;
41+ }
3542}
3643
3744/// The test taken from the Rust documentation.
@@ -41,13 +48,15 @@ fn send_on_sync() {
4148 // this returns immediately
4249 sender. send ( 1 ) . unwrap ( ) ;
4350
44- thread:: spawn ( move || {
51+ let t = thread:: spawn ( move || {
4552 // this will block until the previous message has been received
4653 sender. send ( 2 ) . unwrap ( ) ;
4754 } ) ;
4855
4956 assert_eq ! ( receiver. recv( ) . unwrap( ) , 1 ) ;
5057 assert_eq ! ( receiver. recv( ) . unwrap( ) , 2 ) ;
58+
59+ t. join ( ) . unwrap ( ) ;
5160}
5261
5362fn main ( ) {
Original file line number Diff line number Diff line change 11// ignore-windows: Concurrency on Windows is not supported yet.
2- // compile-flags: -Zmiri-ignore-leaks
2+ // FIXME: disallow preemption to work around https://github.com/rust-lang/rust/issues/55005
3+ // compile-flags: -Zmiri-ignore-leaks -Zmiri-preemption-rate=0
34
45//! Test that leaking threads works, and that their destructors are not executed.
56
You can’t perform that action at this time.
0 commit comments