File tree 5 files changed +19
-8
lines changed
5 files changed +19
-8
lines changed 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
2
3
// ignore-windows: Concurrency on Windows is not supported yet.
3
4
use std:: sync:: Arc ;
4
5
use std:: sync:: atomic:: { AtomicUsize , Ordering , fence} ;
Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ LL | const VOID: ! = panic!();
6
6
|
7
7
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
8
8
9
- error: post-monomorphization error: encountered constants with type errors, stopping evaluation
9
+ error: post-monomorphization error: referenced constant has errors
10
10
--> $DIR/erroneous_const.rs:LL:CC
11
11
|
12
12
LL | let _ = PrintName::<T>::VOID;
13
- | ^^^^^^^^^^^^^^^^^^^^ encountered constants with type errors, stopping evaluation
13
+ | ^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
14
14
|
15
15
= note: inside `no_codegen::<i32>` at $DIR/erroneous_const.rs:LL:CC
16
16
note: 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;
9
9
/// The test taken from the Rust documentation.
10
10
fn simple_send ( ) {
11
11
let ( tx, rx) = channel ( ) ;
12
- thread:: spawn ( move || {
12
+ let t = thread:: spawn ( move || {
13
13
tx. send ( 10 ) . unwrap ( ) ;
14
14
} ) ;
15
15
assert_eq ! ( rx. recv( ) . unwrap( ) , 10 ) ;
16
+ t. join ( ) . unwrap ( ) ;
16
17
}
17
18
18
19
/// The test taken from the Rust documentation.
19
20
fn multiple_send ( ) {
20
21
let ( tx, rx) = channel ( ) ;
22
+ let mut threads = vec ! [ ] ;
21
23
for i in 0 ..10 {
22
24
let tx = tx. clone ( ) ;
23
- thread:: spawn ( move || {
25
+ let t = thread:: spawn ( move || {
24
26
tx. send ( i) . unwrap ( ) ;
25
27
} ) ;
28
+ threads. push ( t) ;
26
29
}
27
30
28
31
let mut sum = 0 ;
@@ -32,6 +35,10 @@ fn multiple_send() {
32
35
sum += j;
33
36
}
34
37
assert_eq ! ( sum, 45 ) ;
38
+
39
+ for t in threads {
40
+ t. join ( ) . unwrap ( ) ;
41
+ }
35
42
}
36
43
37
44
/// The test taken from the Rust documentation.
@@ -41,13 +48,15 @@ fn send_on_sync() {
41
48
// this returns immediately
42
49
sender. send ( 1 ) . unwrap ( ) ;
43
50
44
- thread:: spawn ( move || {
51
+ let t = thread:: spawn ( move || {
45
52
// this will block until the previous message has been received
46
53
sender. send ( 2 ) . unwrap ( ) ;
47
54
} ) ;
48
55
49
56
assert_eq ! ( receiver. recv( ) . unwrap( ) , 1 ) ;
50
57
assert_eq ! ( receiver. recv( ) . unwrap( ) , 2 ) ;
58
+
59
+ t. join ( ) . unwrap ( ) ;
51
60
}
52
61
53
62
fn main ( ) {
Original file line number Diff line number Diff line change 1
1
// 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
3
4
4
5
//! Test that leaking threads works, and that their destructors are not executed.
5
6
You can’t perform that action at this time.
0 commit comments