2018-08-09 11:46:39 -05:00
|
|
|
// edition:2018
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has async_fn/fn.foo.html '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async fn foo() -> Option<Foo>'
|
2019-02-05 09:12:43 -06:00
|
|
|
pub async fn foo() -> Option<Foo> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has async_fn/fn.bar.html '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async fn bar(a: i32, b: i32) -> i32'
|
2019-02-05 09:12:43 -06:00
|
|
|
pub async fn bar(a: i32, b: i32) -> i32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has async_fn/fn.baz.html '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async fn baz<T>(a: T) -> T'
|
2019-02-05 09:12:43 -06:00
|
|
|
pub async fn baz<T>(a: T) -> T {
|
|
|
|
a
|
|
|
|
}
|
|
|
|
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has async_fn/fn.qux.html '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async unsafe fn qux() -> char'
|
2020-01-20 12:14:51 -06:00
|
|
|
pub async unsafe fn qux() -> char {
|
|
|
|
'⚠'
|
|
|
|
}
|
|
|
|
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has async_fn/fn.mut_args.html '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async fn mut_args(a: usize)'
|
2020-11-08 10:45:13 -06:00
|
|
|
pub async fn mut_args(mut a: usize) {}
|
|
|
|
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has async_fn/fn.mut_ref.html '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async fn mut_ref(x: i32)'
|
2020-11-08 10:45:13 -06:00
|
|
|
pub async fn mut_ref(ref mut x: i32) {}
|
|
|
|
|
2019-02-05 09:12:43 -06:00
|
|
|
trait Bar {}
|
|
|
|
|
|
|
|
impl Bar for () {}
|
|
|
|
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has async_fn/fn.quux.html '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async fn quux() -> impl Bar'
|
2019-02-05 09:12:43 -06:00
|
|
|
pub async fn quux() -> impl Bar {
|
|
|
|
()
|
|
|
|
}
|
|
|
|
|
|
|
|
// @has async_fn/struct.Foo.html
|
2021-07-25 16:41:57 -05:00
|
|
|
// @matches - '//h4[@class="code-header"]' 'pub async fn f\(\)$'
|
|
|
|
// @matches - '//h4[@class="code-header"]' 'pub async unsafe fn g\(\)$'
|
|
|
|
// @matches - '//h4[@class="code-header"]' 'pub async fn mut_self\(self, first: usize\)$'
|
2019-02-05 09:12:43 -06:00
|
|
|
pub struct Foo;
|
2018-08-09 11:46:39 -05:00
|
|
|
|
2019-02-05 09:12:43 -06:00
|
|
|
impl Foo {
|
2018-08-09 11:46:39 -05:00
|
|
|
pub async fn f() {}
|
2020-01-20 12:14:51 -06:00
|
|
|
pub async unsafe fn g() {}
|
2020-11-08 10:45:13 -06:00
|
|
|
pub async fn mut_self(mut self, mut first: usize) {}
|
2018-08-09 11:46:39 -05:00
|
|
|
}
|
2020-11-10 06:49:06 -06:00
|
|
|
|
2020-12-22 20:26:17 -06:00
|
|
|
pub trait Pattern<'a> {}
|
|
|
|
|
2020-11-10 06:49:06 -06:00
|
|
|
pub trait Trait<const N: usize> {}
|
|
|
|
// @has async_fn/fn.const_generics.html
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has - '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async fn const_generics<const N: usize>(_: impl Trait<N>)'
|
2020-11-10 06:49:06 -06:00
|
|
|
pub async fn const_generics<const N: usize>(_: impl Trait<N>) {}
|
2020-12-22 19:22:47 -06:00
|
|
|
|
|
|
|
// test that elided lifetimes are properly elided and not displayed as `'_`
|
|
|
|
// regression test for #63037
|
|
|
|
// @has async_fn/fn.elided.html
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has - '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async fn elided(foo: &str) -> &str'
|
2020-12-22 19:22:47 -06:00
|
|
|
pub async fn elided(foo: &str) -> &str {}
|
|
|
|
// This should really be shown as written, but for implementation reasons it's difficult.
|
2022-12-28 11:06:11 -06:00
|
|
|
// See `impl Clean for TyKind::Ref`.
|
2020-12-22 19:22:47 -06:00
|
|
|
// @has async_fn/fn.user_elided.html
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has - '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async fn user_elided(foo: &str) -> &str'
|
2020-12-22 19:22:47 -06:00
|
|
|
pub async fn user_elided(foo: &'_ str) -> &str {}
|
|
|
|
// @has async_fn/fn.static_trait.html
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has - '//div[@class="item-decl"]/pre[@class="rust"]' 'pub async fn static_trait(foo: &str) -> Box<dyn Bar>'
|
2020-12-22 19:22:47 -06:00
|
|
|
pub async fn static_trait(foo: &str) -> Box<dyn Bar> {}
|
|
|
|
// @has async_fn/fn.lifetime_for_trait.html
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has - '//div[@class="item-decl"]/pre[@class="rust"]' "pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_>"
|
2020-12-22 19:22:47 -06:00
|
|
|
pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_> {}
|
2020-12-22 20:26:17 -06:00
|
|
|
// @has async_fn/fn.elided_in_input_trait.html
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has - '//div[@class="item-decl"]/pre[@class="rust"]' "pub async fn elided_in_input_trait(t: impl Pattern<'_>)"
|
2020-12-22 20:26:17 -06:00
|
|
|
pub async fn elided_in_input_trait(t: impl Pattern<'_>) {}
|
2020-12-22 19:22:47 -06:00
|
|
|
|
|
|
|
struct AsyncFdReadyGuard<'a, T> { x: &'a T }
|
|
|
|
|
|
|
|
impl Foo {
|
|
|
|
// @has async_fn/struct.Foo.html
|
2022-02-02 00:11:36 -06:00
|
|
|
// @has - '//*[@class="method has-srclink"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar) -> impl Iterator<Item = &usize>'
|
2020-12-22 19:22:47 -06:00
|
|
|
pub async fn complicated_lifetimes(&self, context: &impl Bar) -> impl Iterator<Item = &usize> {}
|
|
|
|
// taken from `tokio` as an example of a method that was particularly bad before
|
2022-02-02 00:11:36 -06:00
|
|
|
// @has - '//*[@class="method has-srclink"]' "pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()>"
|
2020-12-22 19:22:47 -06:00
|
|
|
pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()> {}
|
2022-02-02 00:11:36 -06:00
|
|
|
// @has - '//*[@class="method has-srclink"]' "pub async fn mut_self(&mut self)"
|
2020-12-22 20:26:17 -06:00
|
|
|
pub async fn mut_self(&mut self) {}
|
2020-12-22 19:22:47 -06:00
|
|
|
}
|
2020-12-22 20:26:17 -06:00
|
|
|
|
|
|
|
// test named lifetimes, just in case
|
|
|
|
// @has async_fn/fn.named.html
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has - '//div[@class="item-decl"]/pre[@class="rust"]' "pub async fn named<'a, 'b>(foo: &'a str) -> &'b str"
|
2020-12-22 20:26:17 -06:00
|
|
|
pub async fn named<'a, 'b>(foo: &'a str) -> &'b str {}
|
|
|
|
// @has async_fn/fn.named_trait.html
|
2023-01-14 11:58:55 -06:00
|
|
|
// @has - '//div[@class="item-decl"]/pre[@class="rust"]' "pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b>"
|
2020-12-22 20:26:17 -06:00
|
|
|
pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b> {}
|