Skip to content

Commit 0b31ad9

Browse files
authored
Merge pull request #193 from dtolnay/consider-restricting
Add ui test to capture current situation of rust issue 93828
2 parents 3d070a6 + 4ff5135 commit 0b31ad9

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

tests/ui/consider-restricting.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// https://github.com/rust-lang/rust/issues/93828
2+
3+
use async_trait::async_trait;
4+
5+
pub trait IntoUrl {}
6+
7+
#[async_trait]
8+
pub trait ClientExt {
9+
async fn publish<T: IntoUrl>(&self, url: T);
10+
}
11+
12+
struct Client;
13+
14+
#[async_trait]
15+
impl ClientExt for Client {
16+
async fn publish<T: IntoUrl>(&self, url: T) {}
17+
}
18+
19+
struct Client2;
20+
21+
#[async_trait]
22+
impl ClientExt for Client2 {
23+
async fn publish<T>(&self, url: T) {}
24+
}
25+
26+
fn main() {}

tests/ui/consider-restricting.stderr

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
error: future cannot be sent between threads safely
2+
--> tests/ui/consider-restricting.rs:16:49
3+
|
4+
16 | async fn publish<T: IntoUrl>(&self, url: T) {}
5+
| ^^ future created by async block is not `Send`
6+
|
7+
note: captured value is not `Send`
8+
--> tests/ui/consider-restricting.rs:16:41
9+
|
10+
16 | async fn publish<T: IntoUrl>(&self, url: T) {}
11+
| ^^^ has type `T` which is not `Send`
12+
= note: required for the cast to the object type `dyn Future<Output = ()> + Send`
13+
help: consider further restricting this bound
14+
|
15+
16 | async fn publish<T + std::marker::Send: IntoUrl>(&self, url: T) {}
16+
| +++++++++++++++++++
17+
18+
error: future cannot be sent between threads safely
19+
--> tests/ui/consider-restricting.rs:23:40
20+
|
21+
23 | async fn publish<T>(&self, url: T) {}
22+
| ^^ future created by async block is not `Send`
23+
|
24+
note: captured value is not `Send`
25+
--> tests/ui/consider-restricting.rs:23:32
26+
|
27+
23 | async fn publish<T>(&self, url: T) {}
28+
| ^^^ has type `T` which is not `Send`
29+
= note: required for the cast to the object type `dyn Future<Output = ()> + Send`
30+
help: consider further restricting this bound
31+
|
32+
23 | async fn publish<T + std::marker::Send>(&self, url: T) {}
33+
| +++++++++++++++++++

0 commit comments

Comments
 (0)