Display async fn in rustdoc.
This commit is contained in:
parent
18ff7d091a
commit
589446e19c
@ -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 {
|
||||
|
@ -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(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user