Incorporate feedback into diagnostics

This commit is contained in:
Tyler Mandry 2020-04-08 11:54:31 -07:00
parent 00795a9940
commit df64c5d260
13 changed files with 41 additions and 49 deletions

View file

@ -12,7 +12,7 @@ note: future is not `Send` as this value is used across an await
--> $DIR/async-fn-nonsend.rs:24:5
|
LL | let x = non_send();
| - created here
| - has type `impl std::fmt::Debug` which is not `Send`
LL | drop(x);
LL | fut().await;
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
@ -33,7 +33,7 @@ note: future is not `Send` as this value is used across an await
--> $DIR/async-fn-nonsend.rs:33:20
|
LL | match Some(non_send()) {
| ---------- created here
| ---------- has type `impl std::fmt::Debug` which is not `Send`
LL | Some(_) => fut().await,
| ^^^^^^^^^^^ await occurs here, with `non_send()` maybe used later
...
@ -54,7 +54,7 @@ note: future is not `Send` as this value is used across an await
--> $DIR/async-fn-nonsend.rs:42:9
|
LL | let f: &mut std::fmt::Formatter = panic!();
| - has type `&mut std::fmt::Formatter<'_>`
| - has type `&mut std::fmt::Formatter<'_>` which is not `Send`
LL | if non_sync().fmt(f).unwrap() == () {
LL | fut().await;
| ^^^^^^^^^^^ await occurs here, with `f` maybe used later

View file

@ -12,7 +12,7 @@ note: future is not `Sync` as this value is used across an await
--> $DIR/issue-64130-1-sync.rs:15:5
|
LL | let x = Foo;
| - has type `Foo`
| - has type `Foo` which is not `Sync`
LL | baz().await;
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
LL | }

View file

@ -12,7 +12,7 @@ note: future is not `Send` as this value is used across an await
--> $DIR/issue-64130-2-send.rs:15:5
|
LL | let x = Foo;
| - has type `Foo`
| - has type `Foo` which is not `Send`
LL | baz().await;
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
LL | }

View file

@ -16,7 +16,7 @@ note: future does not implement `Qux` as this value is used across an await
--> $DIR/issue-64130-3-other.rs:18:5
|
LL | let x = Foo;
| - has type `Foo`
| - has type `Foo` which does not implement `Qux`
LL | baz().await;
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
LL | }

View file

@ -18,7 +18,7 @@ note: future is not `Send` as this value is used across an await
--> $DIR/issue-64130-4-async-move.rs:21:26
|
LL | match client.status() {
| ------ has type `&Client`
| ------ has type `&Client` which is not `Send`
LL | 200 => {
LL | let _x = get().await;
| ^^^^^^^^^^^ await occurs here, with `client` maybe used later

View file

@ -12,7 +12,7 @@ note: future is not `Send` as this value is used across an await
--> $DIR/issue-64130-non-send-future-diags.rs:15:5
|
LL | let g = x.lock().unwrap();
| - has type `std::sync::MutexGuard<'_, u32>`
| - has type `std::sync::MutexGuard<'_, u32>` which is not `Send`
LL | baz().await;
| ^^^^^^^^^^^ await occurs here, with `g` maybe used later
LL | }

View file

@ -12,7 +12,7 @@ note: future is not `Send` as this value is used across an await
--> $DIR/issue-67252-unnamed-future.rs:20:9
|
LL | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send`
| -- has type `*mut ()`
| -- has type `*mut ()` which is not `Send`
LL | AFuture.await;
| ^^^^^^^^^^^^^ await occurs here, with `_a` maybe used later
LL | });

View file

@ -49,6 +49,8 @@ fn make_non_send_future2() -> impl Future<Output = Arc<RefCell<i32>>> {
ready2(Arc::new(RefCell::new(0)))
}
// Ideally this test would have diagnostics similar to the test above, but right
// now it doesn't.
fn test2() {
let send_fut = async {
let non_send_fut = make_non_send_future2();

View file

@ -8,13 +8,11 @@ LL | require_send(send_fut);
| ^^^^^^^^^^^^ future created by async block is not `Send`
|
= help: the trait `std::marker::Sync` is not implemented for `std::cell::RefCell<i32>`
note: future is not `Send` as this value is used in an await
note: future is not `Send` as it awaits another future which is not `Send`
--> $DIR/issue-68112.rs:31:17
|
LL | let non_send_fut = make_non_send_future1();
| ------------ created here
LL | let _ = non_send_fut.await;
| ^^^^^^^^^^^^ await occurs here
| ^^^^^^^^^^^^ await occurs here on type `impl std::future::Future`, which is not `Send`
error: future cannot be sent between threads safely
--> $DIR/issue-68112.rs:43:5
@ -26,14 +24,14 @@ LL | require_send(send_fut);
| ^^^^^^^^^^^^ future created by async block is not `Send`
|
= help: the trait `std::marker::Sync` is not implemented for `std::cell::RefCell<i32>`
note: future is not `Send` as this value is used in an await
note: future is not `Send` as it awaits another future which is not `Send`
--> $DIR/issue-68112.rs:40:17
|
LL | let _ = make_non_send_future1().await;
| ^^^^^^^^^^^^^^^^^^^^^^^ await occurs here
| ^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl std::future::Future`, which is not `Send`
error[E0277]: `std::cell::RefCell<i32>` cannot be shared between threads safely
--> $DIR/issue-68112.rs:58:5
--> $DIR/issue-68112.rs:60:5
|
LL | fn require_send(_: impl Send) {}
| ------------ ---- required by this bound in `require_send`
@ -49,8 +47,8 @@ LL | require_send(send_fut);
= note: required because it appears within the type `impl std::future::Future`
= note: required because it appears within the type `impl std::future::Future`
= note: required because it appears within the type `{std::future::ResumeTy, impl std::future::Future, (), i32, Ready<i32>}`
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:53:26: 57:6 {std::future::ResumeTy, impl std::future::Future, (), i32, Ready<i32>}]`
= note: required because it appears within the type `std::future::from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:53:26: 57:6 {std::future::ResumeTy, impl std::future::Future, (), i32, Ready<i32>}]>`
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:55:26: 59:6 {std::future::ResumeTy, impl std::future::Future, (), i32, Ready<i32>}]`
= note: required because it appears within the type `std::future::from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:55:26: 59:6 {std::future::ResumeTy, impl std::future::Future, (), i32, Ready<i32>}]>`
= note: required because it appears within the type `impl std::future::Future`
error: aborting due to 3 previous errors

View file

@ -14,7 +14,7 @@ note: future is not `Send` as this value is used across an await
LL | bar(Foo(std::ptr::null())).await;
| ^^^^^^^^----------------^^^^^^^^- `std::ptr::null()` is later dropped here
| | |
| | has type `*const u8`
| | has type `*const u8` which is not `Send`
| await occurs here, with `std::ptr::null()` maybe used later
help: consider moving this into a `let` binding to create a shorter lived borrow
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:13

View file

@ -8,11 +8,11 @@ LL | require_send(send_gen);
| ^^^^^^^^^^^^ generator is not `Send`
|
= help: the trait `std::marker::Sync` is not implemented for `std::cell::RefCell<i32>`
note: generator is not `Send` as this value is used across an yield
note: generator is not `Send` as this value is used across a yield
--> $DIR/issue-68112.rs:31:9
|
LL | let _non_send_gen = make_non_send_generator();
| ------------- created here
| ------------- has type `impl std::ops::Generator` which is not `Send`
LL | yield;
| ^^^^^ yield occurs here, with `_non_send_gen` maybe used later
LL | };

View file

@ -21,11 +21,11 @@ LL | assert_sync(|| {
| ^^^^^^^^^^^ generator is not `Sync`
|
= 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>`
note: generator is not `Sync` as this value is used across an yield
note: generator is not `Sync` as this value is used across a yield
--> $DIR/not-send-sync.rs:12:9
|
LL | let a = Cell::new(2);
| - has type `std::cell::Cell<i32>`
| - has type `std::cell::Cell<i32>` which is not `Sync`
LL | yield;
| ^^^^^ yield occurs here, with `a` maybe used later
LL | });