mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Don't double-annotate the same Span
This commit is contained in:
parent
aed7c30e4f
commit
e340375ef8
@ -1389,7 +1389,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
"await occurs here".to_string(),
|
||||
);
|
||||
|
||||
push_target_span(&mut span);
|
||||
if target_span != await_span {
|
||||
push_target_span(&mut span);
|
||||
}
|
||||
|
||||
err.span_note(
|
||||
span,
|
||||
|
@ -35,6 +35,15 @@ fn test1() {
|
||||
//~^ ERROR future cannot be sent between threads
|
||||
}
|
||||
|
||||
fn test1_no_let() {
|
||||
let send_fut = async {
|
||||
let _ = make_non_send_future1().await;
|
||||
ready(0).await;
|
||||
};
|
||||
require_send(send_fut);
|
||||
//~^ ERROR future cannot be sent between threads
|
||||
}
|
||||
|
||||
async fn ready2<T>(t: T) -> T { t }
|
||||
fn make_non_send_future2() -> impl Future<Output = Arc<RefCell<i32>>> {
|
||||
ready2(Arc::new(RefCell::new(0)))
|
||||
|
@ -16,8 +16,24 @@ LL | let non_send_fut = make_non_send_future1();
|
||||
LL | let _ = non_send_fut.await;
|
||||
| ^^^^^^^^^^^^ await occurs here
|
||||
|
||||
error: future cannot be sent between threads safely
|
||||
--> $DIR/issue-68112.rs:43:5
|
||||
|
|
||||
LL | fn require_send(_: impl Send) {}
|
||||
| ------------ ---- required by this bound in `require_send`
|
||||
...
|
||||
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
|
||||
--> $DIR/issue-68112.rs:40:17
|
||||
|
|
||||
LL | let _ = make_non_send_future1().await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ await occurs here
|
||||
|
||||
error[E0277]: `std::cell::RefCell<i32>` cannot be shared between threads safely
|
||||
--> $DIR/issue-68112.rs:49:5
|
||||
--> $DIR/issue-68112.rs:58:5
|
||||
|
|
||||
LL | fn require_send(_: impl Send) {}
|
||||
| ------------ ---- required by this bound in `require_send`
|
||||
@ -27,16 +43,16 @@ LL | require_send(send_fut);
|
||||
|
|
||||
= help: the trait `std::marker::Sync` is not implemented for `std::cell::RefCell<i32>`
|
||||
= note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc<std::cell::RefCell<i32>>`
|
||||
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:38:31: 38:36 t:std::sync::Arc<std::cell::RefCell<i32>> {}]`
|
||||
= note: required because it appears within the type `std::future::from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:38:31: 38:36 t:std::sync::Arc<std::cell::RefCell<i32>> {}]>`
|
||||
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:47:31: 47:36 t:std::sync::Arc<std::cell::RefCell<i32>> {}]`
|
||||
= note: required because it appears within the type `std::future::from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:47:31: 47:36 t:std::sync::Arc<std::cell::RefCell<i32>> {}]>`
|
||||
= 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 `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:44:26: 48: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:44:26: 48: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: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 `impl std::future::Future`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
Loading…
Reference in New Issue
Block a user