Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustdoc renders async fn incorrectly #58027

Closed
ebkalderon opened this issue Jan 31, 2019 · 0 comments
Closed

Rustdoc renders async fn incorrectly #58027

ebkalderon opened this issue Jan 31, 2019 · 0 comments
Labels
A-async-await Area: Async & Await C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ebkalderon
Copy link
Contributor

ebkalderon commented Jan 31, 2019

Summary

While experimenting with async fn and await!() on nightly Rust, I noticed that cargo doc renders them incorrectly. It displays the following:

pub async fn foo(&self, bar: Bar) -> impl Future<Output = Option<Baz>> + '_

I expected the output to be something like this:

pub async fn foo(&self, bar: Bar) -> Option<Baz>

I believe having async fn displayed as returning an impl Future like that is misleading because the async keyword at the beginning makes it seem like the return value is a nested future, when it really isn't. That is, it erroneously suggests that the desugared form of the async fn is:

pub fn foo(&self, bar: Bar) -> impl Future<Output = impl Future<Output = Option<Baz>> + '_> + '_

Toolchain information

  • rustc 1.33.0-nightly (b43986184 2019-01-11)
  • rustdoc 1.33.0-nightly (b43986184 2019-01-11)
  • macOS Mojave 10.14.2 (x86_64-apple-darwin)

How to reproduce

The minimal verifiable example for this issue is essentially creating a new Cargo project with some trivial async fn code in it, and then running cargo doc --open.

@csmoe csmoe added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 31, 2019
@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Jan 31, 2019
kennytm added a commit to kennytm/rust that referenced this issue Feb 8, 2019
rustdoc: display sugared return types for async functions

Fixes rust-lang#58027.
pietroalbini added a commit to pietroalbini/rust that referenced this issue Feb 10, 2019
rustdoc: display sugared return types for async functions

Fixes rust-lang#58027.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Feb 10, 2019
rustdoc: display sugared return types for async functions

Fixes rust-lang#58027.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Feb 10, 2019
rustdoc: display sugared return types for async functions

Fixes rust-lang#58027.
@jonas-schievink jonas-schievink added the A-async-await Area: Async & Await label Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants