Skip to content

Minor syntax errors in async functions give a wall of unrelated "the future is not Send" errors #119678

Closed
@jamesmunns

Description

@jamesmunns

Code

Inside of an async function, make some kind of syntax error, like calling a function that doesn't exist or was not yet imported.

Current output

This produces a very large amount of output:

    Checking flippy v0.1.0 (/Users/james/personal/erdnuss/host/flippy)
error[E0425]: cannot find function `esteban` in this scope
   --> src/dom_worker.rs:102:13
    |
102 |             esteban();
    |             ^^^^^^^ not found in this scope

error: future cannot be sent between threads safely
   --> src/client.rs:160:49
    |
160 | ...k::spawn(runtil(ctxt.clone(), wrx, device)),
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `runtil` is not `Send`
    |
note: opaque type is declared here
   --> src/dom_worker.rs:90:7
    |
90  |     ) {
    |       ^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
   --> src/client.rs:139:10
    |
139 | async fn watch_devices(ctxt: Arc<Context>) {
    |          ^^^^^^^^^^^^^
note: future is not `Send` as this value is used across an await
   --> src/dom_worker.rs:217:9
    |
214 |           let incoming = self.incoming(&mut biq, mac, tx, &...
    |               -------- has type `impl Future<Output = ()>` which is not `Send`
...
217 | /         select! {
218 | |             _ = incoming => {
219 | |                 tracing::info!(
220 | |                     dom_short = self.dev.short,
...   |
235 | |             }
236 | |         };
    | |_________^ await occurs here, with `incoming` maybe used later
...
245 |       }
    |       - `incoming` is later dropped here
note: required by a bound in `tokio::spawn`
   --> /Users/james/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/spawn.rs:166:21
    |
164 |     pub fn spawn<F>(future: F) -> JoinHandle<F::Output>
    |            ----- required by a bound in this function
165 |     where
166 |         F: Future + Send + 'static,
    |                     ^^^^ required by this bound in `spawn`
    = note: this error originates in the macro `$crate::select` which comes from the expansion of the macro `select` (in Nightly builds, run with -Z macro-backtrace for more info)

error: cannot check whether the hidden type of opaque type satisfies auto traits
   --> src/client.rs:34:28
    |
34  |         tokio::task::spawn(watch_devices(ctxt.clone()));
    |         ------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |         |
    |         required by a bound introduced by this call
    |
note: opaque type is declared here
   --> src/client.rs:139:44
    |
139 | async fn watch_devices(ctxt: Arc<Context>) {
    |                                            ^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
   --> src/client.rs:29:12
    |
29  |     pub fn new() -> Option<Self> {
    |            ^^^
note: required by a bound in `tokio::spawn`
   --> /Users/james/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/spawn.rs:166:21
    |
164 |     pub fn spawn<F>(future: F) -> JoinHandle<F::Output>
    |            ----- required by a bound in this function
165 |     where
166 |         F: Future + Send + 'static,
    |                     ^^^^ required by this bound in `spawn`

For more information about this error, try `rustc --explain E0425`.
error: could not compile `flippy` (bin "flippy") due to 3 previous errors

In particular in the console, ONLY the first error is useful, the rest is just noise.

Desired output

Just the first error, please:

error[E0425]: cannot find function `esteban` in this scope
   --> src/dom_worker.rs:102:13
    |
102 |             esteban();
    |             ^^^^^^^ not found in this scope

Rationale and extra context

Screenshot 2024-01-07 at 02 35 49

This is what it looks like graphically, at the moment.

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions