Skip to content

Commit b135976

Browse files
committed
Some fixups
1 parent 5381ddf commit b135976

8 files changed

+117
-77
lines changed

src/librustc/traits/error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
22552255
}
22562256

22572257
},
2258-
_ => return false,
2258+
_ => break,
22592259
}
22602260
};
22612261

src/test/ui/async-await/async-fn-nonsend.stderr

+50-36
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@ LL | fn assert_send(_: impl Send) {}
55
| ----------- ---- required by this bound in `assert_send`
66
...
77
LL | assert_send(local_dropped_before_await());
8-
| ^^^^^^^^^^^ `std::rc::Rc<()>` cannot be sent between threads safely
8+
| ^^^^^^^^^^^ future returned by `local_dropped_before_await` is not `Send`
99
|
1010
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>`
11-
= note: required because it appears within the type `impl std::fmt::Debug`
12-
= note: required because it appears within the type `{impl std::fmt::Debug, impl std::future::Future, impl std::future::Future, ()}`
13-
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:21:39: 26:2 {impl std::fmt::Debug, impl std::future::Future, impl std::future::Future, ()}]`
14-
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:21:39: 26:2 {impl std::fmt::Debug, impl std::future::Future, impl std::future::Future, ()}]>`
15-
= note: required because it appears within the type `impl std::future::Future`
16-
= note: required because it appears within the type `impl std::future::Future`
11+
= note: future cannot be sent between threads safely
12+
note: future is not `Send` as this value is used across an await
13+
--> $DIR/async-fn-nonsend.rs:25:5
14+
|
15+
LL | let x = non_send();
16+
| - has type `impl std::fmt::Debug`
17+
LL | drop(x);
18+
LL | fut().await;
19+
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
20+
LL | }
21+
| - `x` is later dropped here
1722

1823
error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely
1924
--> $DIR/async-fn-nonsend.rs:52:5
@@ -22,15 +27,20 @@ LL | fn assert_send(_: impl Send) {}
2227
| ----------- ---- required by this bound in `assert_send`
2328
...
2429
LL | assert_send(non_send_temporary_in_match());
25-
| ^^^^^^^^^^^ `std::rc::Rc<()>` cannot be sent between threads safely
30+
| ^^^^^^^^^^^ future returned by `non_send_temporary_in_match` is not `Send`
2631
|
2732
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>`
28-
= note: required because it appears within the type `impl std::fmt::Debug`
29-
= note: required because it appears within the type `{impl std::fmt::Debug, std::option::Option<impl std::fmt::Debug>, impl std::future::Future, impl std::future::Future, ()}`
30-
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:28:40: 37:2 {impl std::fmt::Debug, std::option::Option<impl std::fmt::Debug>, impl std::future::Future, impl std::future::Future, ()}]`
31-
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:28:40: 37:2 {impl std::fmt::Debug, std::option::Option<impl std::fmt::Debug>, impl std::future::Future, impl std::future::Future, ()}]>`
32-
= note: required because it appears within the type `impl std::future::Future`
33-
= note: required because it appears within the type `impl std::future::Future`
33+
= note: future cannot be sent between threads safely
34+
note: future is not `Send` as this value is used across an await
35+
--> $DIR/async-fn-nonsend.rs:34:20
36+
|
37+
LL | match Some(non_send()) {
38+
| ---------- has type `impl std::fmt::Debug`
39+
LL | Some(_) => fut().await,
40+
| ^^^^^^^^^^^ await occurs here, with `non_send()` maybe used later
41+
...
42+
LL | }
43+
| - `non_send()` is later dropped here
3444

3545
error[E0277]: `dyn std::fmt::Write` cannot be sent between threads safely
3646
--> $DIR/async-fn-nonsend.rs:54:5
@@ -39,17 +49,21 @@ LL | fn assert_send(_: impl Send) {}
3949
| ----------- ---- required by this bound in `assert_send`
4050
...
4151
LL | assert_send(non_sync_with_method_call());
42-
| ^^^^^^^^^^^ `dyn std::fmt::Write` cannot be sent between threads safely
52+
| ^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send`
4353
|
4454
= help: the trait `std::marker::Send` is not implemented for `dyn std::fmt::Write`
45-
= note: required because of the requirements on the impl of `std::marker::Send` for `&mut dyn std::fmt::Write`
46-
= note: required because it appears within the type `std::fmt::Formatter<'_>`
47-
= note: required because of the requirements on the impl of `std::marker::Send` for `&mut std::fmt::Formatter<'_>`
48-
= note: required because it appears within the type `for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, bool, impl std::future::Future, impl std::future::Future, ()}`
49-
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, bool, impl std::future::Future, impl std::future::Future, ()}]`
50-
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, bool, impl std::future::Future, impl std::future::Future, ()}]>`
51-
= note: required because it appears within the type `impl std::future::Future`
52-
= note: required because it appears within the type `impl std::future::Future`
55+
= note: future cannot be sent between threads safely
56+
note: future is not `Send` as this value is used across an await
57+
--> $DIR/async-fn-nonsend.rs:43:9
58+
|
59+
LL | let f: &mut std::fmt::Formatter = panic!();
60+
| - has type `&mut std::fmt::Formatter<'_>`
61+
LL | if non_sync().fmt(f).unwrap() == () {
62+
LL | fut().await;
63+
| ^^^^^^^^^^^ await occurs here, with `f` maybe used later
64+
LL | }
65+
LL | }
66+
| - `f` is later dropped here
5367

5468
error[E0277]: `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely
5569
--> $DIR/async-fn-nonsend.rs:54:5
@@ -58,21 +72,21 @@ LL | fn assert_send(_: impl Send) {}
5872
| ----------- ---- required by this bound in `assert_send`
5973
...
6074
LL | assert_send(non_sync_with_method_call());
61-
| ^^^^^^^^^^^ `*mut (dyn std::ops::Fn() + 'static)` cannot be shared between threads safely
75+
| ^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send`
6276
|
6377
= help: within `std::fmt::ArgumentV1<'_>`, the trait `std::marker::Sync` is not implemented for `*mut (dyn std::ops::Fn() + 'static)`
64-
= note: required because it appears within the type `std::marker::PhantomData<*mut (dyn std::ops::Fn() + 'static)>`
65-
= note: required because it appears within the type `core::fmt::Void`
66-
= note: required because it appears within the type `&core::fmt::Void`
67-
= note: required because it appears within the type `std::fmt::ArgumentV1<'_>`
68-
= note: required because of the requirements on the impl of `std::marker::Send` for `std::slice::Iter<'_, std::fmt::ArgumentV1<'_>>`
69-
= note: required because it appears within the type `std::fmt::Formatter<'_>`
70-
= note: required because of the requirements on the impl of `std::marker::Send` for `&mut std::fmt::Formatter<'_>`
71-
= note: required because it appears within the type `for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, bool, impl std::future::Future, impl std::future::Future, ()}`
72-
= note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, bool, impl std::future::Future, impl std::future::Future, ()}]`
73-
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, bool, impl std::future::Future, impl std::future::Future, ()}]>`
74-
= note: required because it appears within the type `impl std::future::Future`
75-
= note: required because it appears within the type `impl std::future::Future`
78+
= note: future cannot be sent between threads safely
79+
note: future is not `Send` as this value is used across an await
80+
--> $DIR/async-fn-nonsend.rs:43:9
81+
|
82+
LL | let f: &mut std::fmt::Formatter = panic!();
83+
| - has type `&mut std::fmt::Formatter<'_>`
84+
LL | if non_sync().fmt(f).unwrap() == () {
85+
LL | fut().await;
86+
| ^^^^^^^^^^^ await occurs here, with `f` maybe used later
87+
LL | }
88+
LL | }
89+
| - `f` is later dropped here
7690

7791
error: aborting due to 4 previous errors
7892

src/test/ui/async-await/issue-64130-1-sync.stderr

+11-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ LL | fn is_sync<T: Sync>(t: T) { }
55
| ------- ---- required by this bound in `is_sync`
66
...
77
LL | is_sync(bar());
8-
| ^^^^^^^ `Foo` cannot be shared between threads safely
8+
| ^^^^^^^ future returned by `bar` is not `Sync`
99
|
1010
= help: within `impl std::future::Future`, the trait `std::marker::Sync` is not implemented for `Foo`
11-
= note: required because it appears within the type `{Foo, impl std::future::Future, impl std::future::Future, ()}`
12-
= note: required because it appears within the type `[static generator@$DIR/issue-64130-1-sync.rs:13:16: 16:2 {Foo, impl std::future::Future, impl std::future::Future, ()}]`
13-
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/issue-64130-1-sync.rs:13:16: 16:2 {Foo, impl std::future::Future, impl std::future::Future, ()}]>`
14-
= note: required because it appears within the type `impl std::future::Future`
15-
= note: required because it appears within the type `impl std::future::Future`
11+
= note: future cannot be shared between threads safely
12+
note: future is not `Sync` as this value is used across an await
13+
--> $DIR/issue-64130-1-sync.rs:15:5
14+
|
15+
LL | let x = Foo;
16+
| - has type `Foo`
17+
LL | baz().await;
18+
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
19+
LL | }
20+
| - `x` is later dropped here
1621

1722
error: aborting due to previous error
1823

src/test/ui/async-await/issue-64130-2-send.stderr

+11-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ LL | fn is_send<T: Send>(t: T) { }
55
| ------- ---- required by this bound in `is_send`
66
...
77
LL | is_send(bar());
8-
| ^^^^^^^ `Foo` cannot be sent between threads safely
8+
| ^^^^^^^ future returned by `bar` is not `Send`
99
|
1010
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `Foo`
11-
= note: required because it appears within the type `{Foo, impl std::future::Future, impl std::future::Future, ()}`
12-
= note: required because it appears within the type `[static generator@$DIR/issue-64130-2-send.rs:13:16: 16:2 {Foo, impl std::future::Future, impl std::future::Future, ()}]`
13-
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/issue-64130-2-send.rs:13:16: 16:2 {Foo, impl std::future::Future, impl std::future::Future, ()}]>`
14-
= note: required because it appears within the type `impl std::future::Future`
15-
= note: required because it appears within the type `impl std::future::Future`
11+
= note: future cannot be sent between threads safely
12+
note: future is not `Send` as this value is used across an await
13+
--> $DIR/issue-64130-2-send.rs:15:5
14+
|
15+
LL | let x = Foo;
16+
| - has type `Foo`
17+
LL | baz().await;
18+
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
19+
LL | }
20+
| - `x` is later dropped here
1621

1722
error: aborting due to previous error
1823

src/test/ui/async-await/issue-64130-3-other.stderr

+9-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ LL | is_qux(bar());
99
|
1010
= help: the following implementations were found:
1111
<Foo as Qux>
12-
= note: required because it appears within the type `{Foo, impl std::future::Future, impl std::future::Future, ()}`
13-
= note: required because it appears within the type `[static generator@$DIR/issue-64130-3-other.rs:15:16: 18:2 {Foo, impl std::future::Future, impl std::future::Future, ()}]`
14-
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/issue-64130-3-other.rs:15:16: 18:2 {Foo, impl std::future::Future, impl std::future::Future, ()}]>`
15-
= note: required because it appears within the type `impl std::future::Future`
16-
= note: required because it appears within the type `impl std::future::Future`
12+
note: future does not implement `Qux` as this value is used across an await
13+
--> $DIR/issue-64130-3-other.rs:17:5
14+
|
15+
LL | let x = Foo;
16+
| - has type `Foo`
17+
LL | baz().await;
18+
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
19+
LL | }
20+
| - `x` is later dropped here
1721

1822
error: aborting due to previous error
1923

src/test/ui/async-await/issue-64130-4-async-move.stderr

+13-9
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ error[E0277]: `(dyn std::any::Any + std::marker::Send + 'static)` cannot be shar
22
--> $DIR/issue-64130-4-async-move.rs:15:17
33
|
44
LL | pub fn foo() -> impl Future + Send {
5-
| ^^^^^^^^^^^^^^^^^^ `(dyn std::any::Any + std::marker::Send + 'static)` cannot be shared between threads safely
5+
| ^^^^^^^^^^^^^^^^^^ future returned by `foo` is not `Send`
66
|
77
= help: the trait `std::marker::Sync` is not implemented for `(dyn std::any::Any + std::marker::Send + 'static)`
8-
= note: required because of the requirements on the impl of `std::marker::Sync` for `std::ptr::Unique<(dyn std::any::Any + std::marker::Send + 'static)>`
9-
= note: required because it appears within the type `std::boxed::Box<(dyn std::any::Any + std::marker::Send + 'static)>`
10-
= note: required because it appears within the type `Client`
11-
= note: required because of the requirements on the impl of `std::marker::Send` for `&Client`
12-
= note: required because it appears within the type `for<'r> {&'r Client, Client, u16, u16, impl std::future::Future, impl std::future::Future, ()}`
13-
= note: required because it appears within the type `[static generator@$DIR/issue-64130-4-async-move.rs:18:16: 25:6 client:Client for<'r> {&'r Client, Client, u16, u16, impl std::future::Future, impl std::future::Future, ()}]`
14-
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/issue-64130-4-async-move.rs:18:16: 25:6 client:Client for<'r> {&'r Client, Client, u16, u16, impl std::future::Future, impl std::future::Future, ()}]>`
15-
= note: required because it appears within the type `impl std::future::Future`
8+
= note: future cannot be sent between threads safely
9+
note: future is not `Send` as this value is used across an await
10+
--> $DIR/issue-64130-4-async-move.rs:21:26
11+
|
12+
LL | match client.status() {
13+
| ------ has type `&Client`
14+
LL | 200 => {
15+
LL | let _x = get().await;
16+
| ^^^^^^^^^^^ await occurs here, with `client` maybe used later
17+
...
18+
LL | }
19+
| - `client` is later dropped here
1620
= note: the return type of a function must have a statically known size
1721

1822
error: aborting due to previous error

src/test/ui/async-await/issue-64130-non-send-future-diags.stderr

+11-11
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ LL | fn is_send<T: Send>(t: T) { }
55
| ------- ---- required by this bound in `is_send`
66
...
77
LL | is_send(foo());
8-
| ^^^^^^^ `std::sync::MutexGuard<'_, u32>` cannot be sent between threads safely
8+
| ^^^^^^^ future returned by `foo` is not `Send`
99
|
1010
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::MutexGuard<'_, u32>`
11-
= note: required because it appears within the type `for<'r, 's> {&'r std::sync::Mutex<u32>, std::sync::MutexGuard<'s, u32>, impl std::future::Future, impl std::future::Future, ()}`
12-
= note: required because it appears within the type `[static generator@$DIR/issue-64130-non-send-future-diags.rs:13:30: 16:2 x:&std::sync::Mutex<u32> for<'r, 's> {&'r std::sync::Mutex<u32>, std::sync::MutexGuard<'s, u32>, impl std::future::Future, impl std::future::Future, ()}]`
13-
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/issue-64130-non-send-future-diags.rs:13:30: 16:2 x:&std::sync::Mutex<u32> for<'r, 's> {&'r std::sync::Mutex<u32>, std::sync::MutexGuard<'s, u32>, impl std::future::Future, impl std::future::Future, ()}]>`
14-
= note: required because it appears within the type `impl std::future::Future`
15-
= note: required because it appears within the type `impl std::future::Future`
16-
= note: required because it appears within the type `for<'r, 's, 't0, 't1> {u32, std::sync::Mutex<u32>, &'r std::sync::Mutex<u32>, &'s std::sync::Mutex<u32>, impl std::future::Future, impl std::future::Future, ()}`
17-
= note: required because it appears within the type `[static generator@$DIR/issue-64130-non-send-future-diags.rs:9:16: 11:2 for<'r, 's, 't0, 't1> {u32, std::sync::Mutex<u32>, &'r std::sync::Mutex<u32>, &'s std::sync::Mutex<u32>, impl std::future::Future, impl std::future::Future, ()}]`
18-
= note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/issue-64130-non-send-future-diags.rs:9:16: 11:2 for<'r, 's, 't0, 't1> {u32, std::sync::Mutex<u32>, &'r std::sync::Mutex<u32>, &'s std::sync::Mutex<u32>, impl std::future::Future, impl std::future::Future, ()}]>`
19-
= note: required because it appears within the type `impl std::future::Future`
20-
= note: required because it appears within the type `impl std::future::Future`
11+
= note: future cannot be sent between threads safely
12+
note: future is not `Send` as this value is used across an await
13+
--> $DIR/issue-64130-non-send-future-diags.rs:15:5
14+
|
15+
LL | let g = x.lock().unwrap();
16+
| - has type `std::sync::MutexGuard<'_, u32>`
17+
LL | baz().await;
18+
| ^^^^^^^^^^^ await occurs here, with `g` maybe used later
19+
LL | }
20+
| - `g` is later dropped here
2121

2222
error: aborting due to previous error
2323

src/test/ui/generator/not-send-sync.stderr

+11-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ LL | fn assert_sync<T: Sync>(_: T) {}
1818
| ----------- ---- required by this bound in `main::assert_sync`
1919
...
2020
LL | assert_sync(|| {
21-
| ^^^^^^^^^^^ `std::cell::Cell<i32>` cannot be shared between threads safely
21+
| ^^^^^^^^^^^ future returned by `main` is not `Sync`
2222
|
2323
= help: within `[generator@$DIR/not-send-sync.rs:9:17: 13:6 {std::cell::Cell<i32>, ()}]`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell<i32>`
24-
= note: required because it appears within the type `{std::cell::Cell<i32>, ()}`
25-
= note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:9:17: 13:6 {std::cell::Cell<i32>, ()}]`
24+
= note: future cannot be shared between threads safely
25+
note: future is not `Sync` as this value is used across an yield
26+
--> $DIR/not-send-sync.rs:12:9
27+
|
28+
LL | let a = Cell::new(2);
29+
| - has type `std::cell::Cell<i32>`
30+
LL | yield;
31+
| ^^^^^ yield occurs here, with `a` maybe used later
32+
LL | });
33+
| - `a` is later dropped here
2634

2735
error: aborting due to 2 previous errors
2836

0 commit comments

Comments
 (0)