-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
In http-rs/tide#370 we had a user report that they encountered a Send
error similar to the ones discussed in #64130. Thanks to the diagnostics introduced #65345 on nightly we were able to correctly diagnose the root cause of the error.
But for many users this might still not be enough to figure out how to solve this, and we could improve by providing a hint.
Current Diagnostics
Compiling tide-demo v0.1.0 (/home/anon/Code/importcjj/tide-demo)
error: future cannot be sent between threads safely
--> src/main.rs:47:27
|
47 | app.at("/submit").post(|req: tide::Request<State>| {
| ^^^^ future is not `Send`
|
= help: the trait `std::marker::Sync` is not implemented for `(dyn futures_io::if_std::AsyncBufRead + std::marker::Send + 'static)`
note: future is not `Send` as this value is used across an await
--> src/main.rs:49:29
|
49 | let conn = &req.state().pool.get().await;
| ---^^^^^^^^^^^^^^^^^^^^^^^^^- `req` is later dropped here
| |
| await occurs here, with `req` maybe used later
| has type `&tide::request::Request<State>`
Suggested Diagnostics
@estebank suggested we could add a suggestion here:
help: consider assigning `&req.state().pool` to a temporary variable
Repro
Refs
gilescope
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.