Skip to content

Commit

Permalink
Add ui test to capture current situation of rust issue 93828
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 25, 2022
1 parent 3d070a6 commit 4ff5135
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/ui/consider-restricting.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// https://github.com/rust-lang/rust/issues/93828

use async_trait::async_trait;

pub trait IntoUrl {}

#[async_trait]
pub trait ClientExt {
async fn publish<T: IntoUrl>(&self, url: T);
}

struct Client;

#[async_trait]
impl ClientExt for Client {
async fn publish<T: IntoUrl>(&self, url: T) {}
}

struct Client2;

#[async_trait]
impl ClientExt for Client2 {
async fn publish<T>(&self, url: T) {}
}

fn main() {}
33 changes: 33 additions & 0 deletions tests/ui/consider-restricting.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
error: future cannot be sent between threads safely
--> tests/ui/consider-restricting.rs:16:49
|
16 | async fn publish<T: IntoUrl>(&self, url: T) {}
| ^^ future created by async block is not `Send`
|
note: captured value is not `Send`
--> tests/ui/consider-restricting.rs:16:41
|
16 | async fn publish<T: IntoUrl>(&self, url: T) {}
| ^^^ has type `T` which is not `Send`
= note: required for the cast to the object type `dyn Future<Output = ()> + Send`
help: consider further restricting this bound
|
16 | async fn publish<T + std::marker::Send: IntoUrl>(&self, url: T) {}
| +++++++++++++++++++

error: future cannot be sent between threads safely
--> tests/ui/consider-restricting.rs:23:40
|
23 | async fn publish<T>(&self, url: T) {}
| ^^ future created by async block is not `Send`
|
note: captured value is not `Send`
--> tests/ui/consider-restricting.rs:23:32
|
23 | async fn publish<T>(&self, url: T) {}
| ^^^ has type `T` which is not `Send`
= note: required for the cast to the object type `dyn Future<Output = ()> + Send`
help: consider further restricting this bound
|
23 | async fn publish<T + std::marker::Send>(&self, url: T) {}
| +++++++++++++++++++

0 comments on commit 4ff5135

Please sign in to comment.