Skip to content

Commit f248395

Browse files
committed
bless tests
1 parent d8ff397 commit f248395

12 files changed

+190
-129
lines changed

tests/crashes/137916.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/crashes/138274.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/ui/async-await/issue-70818.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
use std::future::Future;
44
fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
5-
//~^ ERROR future cannot be sent between threads safely
5+
//~^ ERROR: future cannot be sent between threads safely
66
async { (ty, ty1) }
7-
//~^ ERROR future cannot be sent between threads safely
87
}
98

109
fn main() {}
Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,3 @@
1-
error: future cannot be sent between threads safely
2-
--> $DIR/issue-70818.rs:6:5
3-
|
4-
LL | async { (ty, ty1) }
5-
| ^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send`
6-
|
7-
note: captured value is not `Send`
8-
--> $DIR/issue-70818.rs:6:18
9-
|
10-
LL | async { (ty, ty1) }
11-
| ^^^ has type `U` which is not `Send`
12-
note: required by a bound in an opaque type
13-
--> $DIR/issue-70818.rs:4:69
14-
|
15-
LL | fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
16-
| ^^^^
17-
help: consider restricting type parameter `U` with trait `Send`
18-
|
19-
LL | fn foo<T: Send, U: std::marker::Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
20-
| +++++++++++++++++++
21-
221
error: future cannot be sent between threads safely
232
--> $DIR/issue-70818.rs:4:38
243
|
@@ -35,5 +14,5 @@ help: consider restricting type parameter `U` with trait `Send`
3514
LL | fn foo<T: Send, U: std::marker::Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
3615
| +++++++++++++++++++
3716

38-
error: aborting due to 2 previous errors
17+
error: aborting due to 1 previous error
3918

tests/ui/async-await/issue-70935-complex-spans.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ async fn baz<T>(_c: impl FnMut() -> T) where T: Future<Output=()> {
1515
fn foo(x: NotSync) -> impl Future + Send {
1616
//~^ ERROR `*mut ()` cannot be shared between threads safely
1717
async move {
18-
//~^ ERROR `*mut ()` cannot be shared between threads safely
1918
baz(|| async {
2019
foo(x.clone());
2120
}).await;
Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,3 @@
1-
error[E0277]: `*mut ()` cannot be shared between threads safely
2-
--> $DIR/issue-70935-complex-spans.rs:17:5
3-
|
4-
LL | / async move {
5-
LL | |
6-
LL | | baz(|| async {
7-
LL | | foo(x.clone());
8-
LL | | }).await;
9-
LL | | }
10-
| |_____^ `*mut ()` cannot be shared between threads safely
11-
|
12-
= help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()`
13-
note: required because it appears within the type `PhantomData<*mut ()>`
14-
--> $SRC_DIR/core/src/marker.rs:LL:COL
15-
note: required because it appears within the type `NotSync`
16-
--> $DIR/issue-70935-complex-spans.rs:9:8
17-
|
18-
LL | struct NotSync(PhantomData<*mut ()>);
19-
| ^^^^^^^
20-
= note: required for `&NotSync` to implement `Send`
21-
note: required because it's used within this closure
22-
--> $DIR/issue-70935-complex-spans.rs:19:13
23-
|
24-
LL | baz(|| async {
25-
| ^^
26-
note: required because it's used within this `async` fn body
27-
--> $DIR/issue-70935-complex-spans.rs:12:67
28-
|
29-
LL | async fn baz<T>(_c: impl FnMut() -> T) where T: Future<Output=()> {
30-
| ___________________________________________________________________^
31-
LL | | }
32-
| |_^
33-
note: required because it's used within this `async` block
34-
--> $DIR/issue-70935-complex-spans.rs:17:5
35-
|
36-
LL | async move {
37-
| ^^^^^^^^^^
38-
note: required by a bound in an opaque type
39-
--> $DIR/issue-70935-complex-spans.rs:15:37
40-
|
41-
LL | fn foo(x: NotSync) -> impl Future + Send {
42-
| ^^^^
43-
441
error[E0277]: `*mut ()` cannot be shared between threads safely
452
--> $DIR/issue-70935-complex-spans.rs:15:23
463
|
@@ -57,7 +14,7 @@ LL | struct NotSync(PhantomData<*mut ()>);
5714
| ^^^^^^^
5815
= note: required for `&NotSync` to implement `Send`
5916
note: required because it's used within this closure
60-
--> $DIR/issue-70935-complex-spans.rs:19:13
17+
--> $DIR/issue-70935-complex-spans.rs:18:13
6118
|
6219
LL | baz(|| async {
6320
| ^^
@@ -74,6 +31,6 @@ note: required because it's used within this `async` block
7431
LL | async move {
7532
| ^^^^^^^^^^
7633

77-
error: aborting due to 2 previous errors
34+
error: aborting due to 1 previous error
7835

7936
For more information about this error, try `rustc --explain E0277`.

tests/ui/coroutine/issue-105084.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ fn main() {
3636
// one inside `g` and one inside `h`.
3737
// Proceed and drop `t` in `g`.
3838
Pin::new(&mut g).resume(());
39-
//~^ ERROR borrow of moved value: `g`
4039

4140
// Proceed and drop `t` in `h` -> double free!
4241
Pin::new(&mut h).resume(());
Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
error[E0382]: borrow of moved value: `g`
2-
--> $DIR/issue-105084.rs:38:14
3-
|
4-
LL | let mut g = #[coroutine]
5-
| ----- move occurs because `g` has type `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}`, which does not implement the `Copy` trait
6-
...
7-
LL | let mut h = copy(g);
8-
| - value moved here
9-
...
10-
LL | Pin::new(&mut g).resume(());
11-
| ^^^^^^ value borrowed here after move
12-
|
13-
note: consider changing this parameter type in function `copy` to borrow instead if owning the value isn't necessary
14-
--> $DIR/issue-105084.rs:10:21
15-
|
16-
LL | fn copy<T: Copy>(x: T) -> T {
17-
| ---- ^ this parameter takes ownership of the value
18-
| |
19-
| in this function
20-
help: consider cloning the value if the performance cost is acceptable
21-
|
22-
LL | let mut h = copy(g.clone());
23-
| ++++++++
24-
251
error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `{coroutine@$DIR/issue-105084.rs:16:5: 16:7}`
262
--> $DIR/issue-105084.rs:32:17
273
|
@@ -45,7 +21,6 @@ note: required by a bound in `copy`
4521
LL | fn copy<T: Copy>(x: T) -> T {
4622
| ^^^^ required by this bound in `copy`
4723

48-
error: aborting due to 2 previous errors
24+
error: aborting due to 1 previous error
4925

50-
Some errors have detailed explanations: E0277, E0382.
51-
For more information about an error, try `rustc --explain E0277`.
26+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//@ edition: 2021
2+
3+
// Regression tests for #137916 and #138274
4+
// We now check stalled coroutine obligations eagerly at the start of `mir_borrowck`.
5+
// So these unsatisfied bounds are caught before causing ICEs.
6+
use std::ptr::null;
7+
8+
async fn a() -> Box<dyn Send> {
9+
Box::new(async {
10+
//~^ ERROR: future cannot be sent between threads safely
11+
let non_send = null::<()>();
12+
&non_send;
13+
async {}.await
14+
})
15+
}
16+
17+
18+
trait Trait {}
19+
fn foo() -> Box<dyn Trait> { todo!() }
20+
21+
fn fetch() {
22+
async {
23+
let fut = async {
24+
let _x = foo();
25+
async {}.await;
26+
};
27+
let _: Box<dyn Send> = Box::new(fut);
28+
//~^ ERROR: future cannot be sent between threads safely
29+
};
30+
}
31+
32+
fn main() {}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
error: future cannot be sent between threads safely
2+
--> $DIR/stalled-coroutine-obligations.rs:9:5
3+
|
4+
LL | / Box::new(async {
5+
LL | |
6+
LL | | let non_send = null::<()>();
7+
LL | | &non_send;
8+
LL | | async {}.await
9+
LL | | })
10+
| |______^ future created by async block is not `Send`
11+
|
12+
= help: within `{async block@$DIR/stalled-coroutine-obligations.rs:9:14: 9:19}`, the trait `Send` is not implemented for `*const ()`
13+
note: future is not `Send` as this value is used across an await
14+
--> $DIR/stalled-coroutine-obligations.rs:13:18
15+
|
16+
LL | let non_send = null::<()>();
17+
| -------- has type `*const ()` which is not `Send`
18+
LL | &non_send;
19+
LL | async {}.await
20+
| ^^^^^ await occurs here, with `non_send` maybe used later
21+
= note: required for the cast from `Box<{async block@$DIR/stalled-coroutine-obligations.rs:9:14: 9:19}>` to `Box<dyn Send>`
22+
23+
error: future cannot be sent between threads safely
24+
--> $DIR/stalled-coroutine-obligations.rs:27:32
25+
|
26+
LL | let _: Box<dyn Send> = Box::new(fut);
27+
| ^^^^^^^^^^^^^ future created by async block is not `Send`
28+
|
29+
= help: the trait `Send` is not implemented for `dyn Trait`
30+
note: future is not `Send` as this value is used across an await
31+
--> $DIR/stalled-coroutine-obligations.rs:25:22
32+
|
33+
LL | let _x = foo();
34+
| -- has type `Box<dyn Trait>` which is not `Send`
35+
LL | async {}.await;
36+
| ^^^^^ await occurs here, with `_x` maybe used later
37+
= note: required for the cast from `Box<{async block@$DIR/stalled-coroutine-obligations.rs:23:19: 23:24}>` to `Box<dyn Send>`
38+
39+
error: aborting due to 2 previous errors
40+

0 commit comments

Comments
 (0)