diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 3d360f2f344..2377354b85f 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -39,6 +39,10 @@ pub struct UnsafetySpace(pub hir::Unsafety); /// with a space after it. #[derive(Copy, Clone)] pub struct ConstnessSpace(pub hir::Constness); +/// Similarly to VisSpace, this structure is used to render a function asyncness +/// with a space after it. +#[derive(Copy, Clone)] +pub struct AsyncSpace(pub hir::IsAsync); /// Similar to VisSpace, but used for mutability #[derive(Copy, Clone)] pub struct MutableSpace(pub clean::Mutability); @@ -962,6 +966,15 @@ impl fmt::Display for ConstnessSpace { } } +impl fmt::Display for AsyncSpace { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.0 { + hir::IsAsync::Async => write!(f, "async "), + hir::IsAsync::NotAsync => Ok(()), + } + } +} + impl fmt::Display for clean::Import { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index cfcaf23c4ff..5989694116c 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -67,7 +67,7 @@ use clean::{self, AttributesExt, GetDefId, SelfTy, Mutability}; use doctree; use fold::DocFolder; use html::escape::Escape; -use html::format::{ConstnessSpace}; +use html::format::{AsyncSpace, ConstnessSpace}; use html::format::{GenericBounds, WhereClause, href, AbiSpace}; use html::format::{VisSpace, Method, UnsafetySpace, MutableSpace}; use html::format::fmt_impl_for_trait_page; @@ -2574,9 +2574,10 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, f: &clean::Function) -> fmt::Result { - let name_len = format!("{}{}{}{:#}fn {}{:#}", + let name_len = format!("{}{}{}{}{:#}fn {}{:#}", VisSpace(&it.visibility), ConstnessSpace(f.header.constness), + AsyncSpace(f.header.asyncness), UnsafetySpace(f.header.unsafety), AbiSpace(f.header.abi), it.name.as_ref().unwrap(), @@ -2584,9 +2585,10 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, write!(w, "{}
", render_spotlight_traits(it)?)?; render_attributes(w, it)?; write!(w, - "{vis}{constness}{unsafety}{abi}fn {name}{generics}{decl}{where_clause}", + "{vis}{constness}{asyncness}{unsafety}{abi}fn {name}{generics}{decl}{where_clause}", vis = VisSpace(&it.visibility), constness = ConstnessSpace(f.header.constness), + asyncness = AsyncSpace(f.header.asyncness), unsafety = UnsafetySpace(f.header.unsafety), abi = AbiSpace(f.header.abi), name = it.name.as_ref().unwrap(),