Skip to content

Commit 9a14380

Browse files
committed
bless tests
1 parent d8ff397 commit 9a14380

8 files changed

Lines changed: 118 additions & 98 deletions

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: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//@ edition: 2024
2+
//@ compile-flags: -Znext-solver --diagnostic-width=300
3+
4+
// Previously we check stalled coroutine obligations after borrowck pass.
5+
// And we wrongly assume that these obligations hold in borrowck which leads to
6+
// silent normalization failures.
7+
// In the next solver, we register opaques types via `NormalizesTo` goals.
8+
// So these failures also cause those opaques types not registered in storage.
9+
//
10+
// Regression test for #151322 and #151323.
11+
12+
#![feature(type_alias_impl_trait)]
13+
#![feature(negative_impls)]
14+
#![feature(auto_traits)]
15+
16+
fn stalled_copy_clone() {
17+
type T = impl Copy;
18+
let foo: T = async {};
19+
//~^ ERROR: the trait bound
20+
21+
type U = impl Clone;
22+
let bar: U = async {};
23+
//~^ ERROR: the trait bound
24+
}
25+
26+
auto trait Valid {}
27+
struct False;
28+
impl !Valid for False {}
29+
30+
fn stalled_auto_traits() {
31+
type T = impl Valid;
32+
let a = False;
33+
let foo: T = async { a };
34+
//~^ ERROR: the trait bound `False: Valid` is not satisfied
35+
}
36+
37+
38+
trait Trait {
39+
fn stalled_send(&self, b: *mut ()) -> impl Future + Send {
40+
//~^ ERROR: type mismatch resolving
41+
//~| ERROR: type mismatch resolving
42+
async move {
43+
//~^ ERROR: type mismatch resolving
44+
b
45+
}
46+
}
47+
}
48+
49+
50+
fn main() {}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
error[E0277]: the trait bound `{async block@$DIR/stalled-coroutine-obligations.rs:18:18: 18:23}: Copy` is not satisfied
2+
--> $DIR/stalled-coroutine-obligations.rs:18:14
3+
|
4+
LL | let foo: T = async {};
5+
| ^ the trait `Copy` is not implemented for `{async block@$DIR/stalled-coroutine-obligations.rs:18:18: 18:23}`
6+
7+
error[E0277]: the trait bound `{async block@$DIR/stalled-coroutine-obligations.rs:22:18: 22:23}: Clone` is not satisfied
8+
--> $DIR/stalled-coroutine-obligations.rs:22:14
9+
|
10+
LL | let bar: U = async {};
11+
| ^ the trait `Clone` is not implemented for `{async block@$DIR/stalled-coroutine-obligations.rs:22:18: 22:23}`
12+
13+
error[E0277]: the trait bound `False: Valid` is not satisfied in `{async block@$DIR/stalled-coroutine-obligations.rs:33:18: 33:23}`
14+
--> $DIR/stalled-coroutine-obligations.rs:33:14
15+
|
16+
LL | let foo: T = async { a };
17+
| ^ ----- within this `{async block@$DIR/stalled-coroutine-obligations.rs:33:18: 33:23}`
18+
| |
19+
| unsatisfied trait bound
20+
|
21+
help: within `{async block@$DIR/stalled-coroutine-obligations.rs:33:18: 33:23}`, the trait `Valid` is not implemented for `False`
22+
--> $DIR/stalled-coroutine-obligations.rs:27:1
23+
|
24+
LL | struct False;
25+
| ^^^^^^^^^^^^
26+
note: captured value does not implement `Valid`
27+
--> $DIR/stalled-coroutine-obligations.rs:33:26
28+
|
29+
LL | let foo: T = async { a };
30+
| ^ has type `False` which does not implement `Valid`
31+
32+
error[E0271]: type mismatch resolving `impl Future + Send == {async block@$DIR/stalled-coroutine-obligations.rs:42:9: 42:19}`
33+
--> $DIR/stalled-coroutine-obligations.rs:39:5
34+
|
35+
LL | fn stalled_send(&self, b: *mut ()) -> impl Future + Send {
36+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ
37+
38+
error[E0271]: type mismatch resolving `impl Future + Send == {async block@$DIR/stalled-coroutine-obligations.rs:42:9: 42:19}`
39+
--> $DIR/stalled-coroutine-obligations.rs:42:9
40+
|
41+
LL | / async move {
42+
LL | |
43+
LL | | b
44+
LL | | }
45+
| |_________^ types differ
46+
47+
error[E0271]: type mismatch resolving `{async block@$DIR/stalled-coroutine-obligations.rs:42:9: 42:19} <: impl Future + Send`
48+
--> $DIR/stalled-coroutine-obligations.rs:39:62
49+
|
50+
LL | fn stalled_send(&self, b: *mut ()) -> impl Future + Send {
51+
| ______________________________________________________________^
52+
LL | |
53+
LL | |
54+
LL | | async move {
55+
... |
56+
LL | | }
57+
| |_____^ types differ
58+
59+
error: aborting due to 6 previous errors
60+
61+
Some errors have detailed explanations: E0271, E0277.
62+
For more information about an error, try `rustc --explain E0271`.

0 commit comments

Comments
 (0)