Skip to content

Commit 12e3222

Browse files
committed
Add regression test
1 parent 5f390ea commit 12e3222

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//@ edition: 2021
2+
3+
use std::future::Future;
4+
use std::pin::Pin;
5+
6+
trait FutureExt: Future + Sized + Send + 'static {
7+
fn boxed(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'static>> {
8+
Box::pin(self)
9+
}
10+
}
11+
12+
trait StreamExt: Future + Sized + Send + 'static {
13+
fn boxed(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'static>> {
14+
Box::pin(self)
15+
}
16+
}
17+
18+
impl<T: Future + Sized + Send + 'static> FutureExt for T {}
19+
20+
fn go(i: usize) -> impl Future<Output = ()> + Send + 'static {
21+
async move {
22+
if i != 0 {
23+
spawn(async move {
24+
let fut = go(i - 1).boxed();
25+
//~^ ERROR: multiple applicable items in scope
26+
fut.await;
27+
})
28+
.await;
29+
}
30+
}
31+
}
32+
33+
pub fn spawn<T: Send>(
34+
_: impl Future<Output = T> + Send + 'static,
35+
) -> impl Future<Output = ()> + Send + 'static {
36+
async move { todo!() }
37+
}
38+
39+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0034]: multiple applicable items in scope
2+
--> $DIR/recursive-parent-trait-method-call.rs:24:37
3+
|
4+
LL | let fut = go(i - 1).boxed();
5+
| ^^^^^ multiple `boxed` found
6+
|
7+
note: candidate #1 is defined in the trait `StreamExt`
8+
--> $DIR/recursive-parent-trait-method-call.rs:13:5
9+
|
10+
LL | fn boxed(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'static>> {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
note: candidate #2 is defined in an impl of the trait `FutureExt` for the type `T`
13+
--> $DIR/recursive-parent-trait-method-call.rs:7:5
14+
|
15+
LL | fn boxed(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'static>> {
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
help: disambiguate the method for candidate #1
18+
|
19+
LL | let fut = StreamExt::boxed(go(i - 1));
20+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
21+
help: disambiguate the method for candidate #2
22+
|
23+
LL | let fut = FutureExt::boxed(go(i - 1));
24+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
25+
26+
error: aborting due to 1 previous error
27+
28+
For more information about this error, try `rustc --explain E0034`.

0 commit comments

Comments
 (0)