Skip to content

Send bound of trait object make unexpected async block is not general enough error #130596

Open
@ethe

Description

@ethe

I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=4f2133cbf38d27366a8edd106b5485e5

I expected to see this happen: Same as below, compile pass:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=69e324c356bd126e575a971a7cbbf2fa

Instead, this happened:

error: implementation of `From` is not general enough
  --> src/lib.rs:44:9
   |
44 | /         Box::pin(async move {
45 | |             let response = self.send_request(request).await;
46 | |             match response {
47 | |                 Ok(response) => todo!(),
...  |
51 | |             }
52 | |         })
   | |__________^ implementation of `From` is not general enough
   |
   = note: `Box<(dyn std::error::Error + Send + Sync + 'static)>` must implement `From<Box<(dyn std::error::Error + Send + Sync + '0)>>`, for any lifetime `'0`...
   = note: ...but it actually implements `From<Box<(dyn std::error::Error + Send + Sync + 'static)>>`

error: could not compile `playground` (lib) due to 1 previous error; 1 warning emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions