diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2020-12-22 20:22:47 -0500 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2020-12-22 20:49:33 -0500 |
| commit | 530c33cd5fd92c17e44c692bbe7a4006d57340f8 (patch) | |
| tree | 540e442bd1d91e86124ff4b731423928c6ea865e /src/test/rustdoc | |
| parent | 50a90975c0f78219db45d3bee0676a22695ec103 (diff) | |
| download | rust-530c33cd5fd92c17e44c692bbe7a4006d57340f8.tar.gz rust-530c33cd5fd92c17e44c692bbe7a4006d57340f8.zip | |
Fix elided lifetimes shown as `'_` on async functions
Diffstat (limited to 'src/test/rustdoc')
| -rw-r--r-- | src/test/rustdoc/async-fn.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/rustdoc/async-fn.rs b/src/test/rustdoc/async-fn.rs index e7a7d1831f7..7a673b9f670 100644 --- a/src/test/rustdoc/async-fn.rs +++ b/src/test/rustdoc/async-fn.rs @@ -1,3 +1,4 @@ +// ignore-tidy-linelength // edition:2018 #![feature(min_const_generics)] @@ -52,3 +53,31 @@ pub trait Trait<const N: usize> {} // @has async_fn/fn.const_generics.html // @has - '//pre[@class="rust fn"]' 'pub async fn const_generics<const N: usize>(_: impl Trait<N>)' pub async fn const_generics<const N: usize>(_: impl Trait<N>) {} + +// test that elided lifetimes are properly elided and not displayed as `'_` +// regression test for #63037 +// @has async_fn/fn.elided.html +// @has - '//pre[@class="rust fn"]' 'pub async fn elided(foo: &str) -> &str' +pub async fn elided(foo: &str) -> &str {} +// This should really be shown as written, but for implementation reasons it's difficult. +// See `impl Clean for TyKind::Rptr`. +// @has async_fn/fn.user_elided.html +// @has - '//pre[@class="rust fn"]' 'pub async fn user_elided(foo: &str) -> &str' +pub async fn user_elided(foo: &'_ str) -> &str {} +// @has async_fn/fn.static_trait.html +// @has - '//pre[@class="rust fn"]' 'pub async fn static_trait(foo: &str) -> Box<dyn Bar>' +pub async fn static_trait(foo: &str) -> Box<dyn Bar> {} +// @has async_fn/fn.lifetime_for_trait.html +// @has - '//pre[@class="rust fn"]' "pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_>" +pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_> {} + +struct AsyncFdReadyGuard<'a, T> { x: &'a T } + +impl Foo { + // @has async_fn/struct.Foo.html + // @has - '//h4[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar) -> impl Iterator<Item = &usize>' + 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 + // @has - '//h4[@class="method"]' "pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()>" + pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()> {} +} |
