Fix rustdoc and remove default impl for FnHeader

This commit is contained in:
Taylor Cramer 2018-06-22 17:27:58 -07:00
parent 9a310abf79
commit a62c4aa03a
5 changed files with 27 additions and 23 deletions

View File

@ -2024,17 +2024,6 @@ pub struct FnHeader {
pub abi: Abi,
}
impl Default for FnHeader {
fn default() -> FnHeader {
FnHeader {
unsafety: Unsafety::Normal,
constness: Constness::NotConst,
asyncness: IsAsync::NotAsync,
abi: Abi::Rust,
}
}
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum Item_ {
/// An `extern crate` item, with optional *original* crate name if the crate was renamed.

View File

@ -459,7 +459,12 @@ impl<'a> State<'a> {
hir::ForeignItemFn(ref decl, ref arg_names, ref generics) => {
self.head("")?;
self.print_fn(decl,
hir::FnHeader::default(),
hir::FnHeader {
unsafety: hir::Unsafety::Normal,
constness: hir::Constness::NotConst,
abi: Abi::Rust,
asyncness: hir::IsAsync::NotAsync,
},
Some(item.name),
generics,
&item.vis,
@ -2253,8 +2258,10 @@ impl<'a> State<'a> {
};
self.print_fn(decl,
hir::FnHeader {
unsafety, abi,
..hir::FnHeader::default()
unsafety,
abi,
constness: hir::Constness::NotConst,
asyncness: hir::IsAsync::NotAsync,
},
name,
&generics,

View File

@ -202,7 +202,7 @@ fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
unsafety: sig.unsafety(),
abi: sig.abi(),
constness,
..hir::FnHeader::default()
asyncness: hir::IsAsync::NotAsync,
}
}
}

View File

@ -2457,7 +2457,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
unsafety: sig.unsafety(),
abi: sig.abi(),
constness,
..hir::FnHeader::default()
asyncness: hir::IsAsync::NotAsync,
}
})
} else {
@ -2467,7 +2467,8 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
header: hir::FnHeader {
unsafety: sig.unsafety(),
abi: sig.abi(),
..hir::FnHeader::default()
constness: hir::Constness::NotConst,
asyncness: hir::IsAsync::NotAsync,
}
})
}
@ -4007,7 +4008,12 @@ impl Clean<Item> for hir::ForeignItem {
ForeignFunctionItem(Function {
decl,
generics,
header: hir::FnHeader::default(),
header: hir::FnHeader {
unsafety: hir::Unsafety::Unsafe,
abi: Abi::Rust,
constness: hir::Constness::NotConst,
asyncness: hir::IsAsync::NotAsync,
},
})
}
hir::ForeignItemStatic(ref ty, mutbl) => {

View File

@ -2577,20 +2577,20 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
let name_len = format!("{}{}{}{}{:#}fn {}{:#}",
VisSpace(&it.visibility),
ConstnessSpace(f.header.constness),
AsyncSpace(f.header.asyncness),
UnsafetySpace(f.header.unsafety),
AsyncSpace(f.header.asyncness),
AbiSpace(f.header.abi),
it.name.as_ref().unwrap(),
f.generics).len();
write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it)?)?;
render_attributes(w, it)?;
write!(w,
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
"{vis}{constness}{unsafety}{asyncness}{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),
asyncness = AsyncSpace(f.header.asyncness),
abi = AbiSpace(f.header.abi),
name = it.name.as_ref().unwrap(),
generics = f.generics,
@ -3024,10 +3024,11 @@ fn render_assoc_item(w: &mut fmt::Formatter,
href(did).map(|p| format!("{}#{}.{}", p.0, ty, name)).unwrap_or(anchor)
}
};
let mut head_len = format!("{}{}{}{:#}fn {}{:#}",
let mut head_len = format!("{}{}{}{}{:#}fn {}{:#}",
VisSpace(&meth.visibility),
ConstnessSpace(header.constness),
UnsafetySpace(header.unsafety),
AsyncSpace(header.asyncness),
AbiSpace(header.abi),
name,
*g).len();
@ -3038,11 +3039,12 @@ fn render_assoc_item(w: &mut fmt::Formatter,
(0, true)
};
render_attributes(w, meth)?;
write!(w, "{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
write!(w, "{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
{generics}{decl}{where_clause}",
VisSpace(&meth.visibility),
ConstnessSpace(header.constness),
UnsafetySpace(header.unsafety),
AsyncSpace(header.asyncness),
AbiSpace(header.abi),
href = href,
name = name,