Skip to content

Rustdoc renders async fn incorrectly #58027

Closed
@ebkalderon

Description

@ebkalderon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions