about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWithout Boats <boats@mozilla.com>2018-05-17 14:47:52 -0700
committerTaylor Cramer <cramertj@google.com>2018-06-21 22:30:50 -0700
commit589446e19cbf7a2c7eddf80b490992d31134015c (patch)
tree5da55c723fc914bfdf722daf1996c7ee5f2f7de9
parent18ff7d091a07706b87c131bf3efc226993916f88 (diff)
downloadrust-589446e19cbf7a2c7eddf80b490992d31134015c.tar.gz
rust-589446e19cbf7a2c7eddf80b490992d31134015c.zip
Display async fn in rustdoc.
-rw-r--r--src/librustdoc/html/format.rs13
-rw-r--r--src/librustdoc/html/render.rs8
2 files changed, 18 insertions, 3 deletions
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, "{}<pre class='rust fn'>", render_spotlight_traits(it)?)?;
     render_attributes(w, it)?;
     write!(w,
-           "{vis}{constness}{unsafety}{abi}fn {name}{generics}{decl}{where_clause}</pre>",
+           "{vis}{constness}{asyncness}{unsafety}{abi}fn {name}{generics}{decl}{where_clause}</pre>",
            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(),