rust-lang / rust-lang/rust

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

Open
#130,596 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-async-await A-diagnostics A-trait-system C-bug
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the two Rust Playground examples linked in the report with stable Rust and edition 2021, comparing the compiling and failing cases. Trace the reported error at src/lib.rs:44-52 and determine the compiler behavior involved; done means the discrepancy is understood and the reported example compiles or receives an appropriate correction.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.