rust/tests/ui/async-await/in-trait/async-recursive.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
356 B
Rust
Raw Normal View History

2022-10-07 11:15:13 -05:00
//@ edition: 2021
trait MyTrait {
async fn foo_recursive(&self, n: usize) -> i32;
}
impl MyTrait for i32 {
async fn foo_recursive(&self, n: usize) -> i32 {
2023-11-08 01:19:01 -06:00
//~^ ERROR recursion in an async fn requires boxing
2022-10-07 11:15:13 -05:00
if n > 0 {
self.foo_recursive(n - 1).await
} else {
*self
}
}
}
fn main() {}