Skip to content

Commit ceb66ad

Browse files
committed
Add more tests
1 parent 530c33c commit ceb66ad

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ impl Clean<Type> for hir::Ty<'_> {
14481448
// There are two times a `Fresh` lifetime can be created:
14491449
// 1. For `&'_ x`, written by the user. This corresponds to `lower_lifetime` in `rustc_ast_lowering`.
14501450
// 2. For `&x` as a parameter to an `async fn`. This corresponds to `elided_ref_lifetime in `rustc_ast_lowering`.
1451-
// See commit 749349fc9f7b12f212bca9ba2297e463328cb701 for more information.
1451+
// See #59286 for more information.
14521452
// Ideally we would only hide the `'_` for case 2., but I don't know a way to distinguish it.
14531453
// Turning `fn f(&'_ self)` into `fn f(&self)` isn't the worst thing in the world, though;
14541454
// there's no case where it could cause the function to fail to compile.

src/test/rustdoc/async-fn.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ impl Foo {
4949
pub async fn mut_self(mut self, mut first: usize) {}
5050
}
5151

52+
pub trait Pattern<'a> {}
53+
5254
pub trait Trait<const N: usize> {}
5355
// @has async_fn/fn.const_generics.html
5456
// @has - '//pre[@class="rust fn"]' 'pub async fn const_generics<const N: usize>(_: impl Trait<N>)'
@@ -70,6 +72,9 @@ pub async fn static_trait(foo: &str) -> Box<dyn Bar> {}
7072
// @has async_fn/fn.lifetime_for_trait.html
7173
// @has - '//pre[@class="rust fn"]' "pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_>"
7274
pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_> {}
75+
// @has async_fn/fn.elided_in_input_trait.html
76+
// @has - '//pre[@class="rust fn"]' "pub async fn elided_in_input_trait(t: impl Pattern<'_>)"
77+
pub async fn elided_in_input_trait(t: impl Pattern<'_>) {}
7378

7479
struct AsyncFdReadyGuard<'a, T> { x: &'a T }
7580

@@ -80,4 +85,14 @@ impl Foo {
8085
// taken from `tokio` as an example of a method that was particularly bad before
8186
// @has - '//h4[@class="method"]' "pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()>"
8287
pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()> {}
88+
// @has - '//h4[@class="method"]' "pub async fn mut_self(&mut self)"
89+
pub async fn mut_self(&mut self) {}
8390
}
91+
92+
// test named lifetimes, just in case
93+
// @has async_fn/fn.named.html
94+
// @has - '//pre[@class="rust fn"]' "pub async fn named<'a, 'b>(foo: &'a str) -> &'b str"
95+
pub async fn named<'a, 'b>(foo: &'a str) -> &'b str {}
96+
// @has async_fn/fn.named_trait.html
97+
// @has - '//pre[@class="rust fn"]' "pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b>"
98+
pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b> {}

0 commit comments

Comments
 (0)