Skip to content

Commit

Permalink
Fix rustdoc and remove default impl for FnHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
cramertj committed Jun 23, 2018
1 parent 9a310ab commit a62c4aa
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
11 changes: 0 additions & 11 deletions src/librustc/hir/mod.rs
Expand Up @@ -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.
Expand Down
13 changes: 10 additions & 3 deletions src/librustc/hir/print.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/inline.rs
Expand Up @@ -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,
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/librustdoc/clean/mod.rs
Expand Up @@ -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 {
Expand All @@ -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,
}
})
}
Expand Down Expand Up @@ -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) => {
Expand Down
12 changes: 7 additions & 5 deletions src/librustdoc/html/render.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand All @@ -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,
Expand Down

0 comments on commit a62c4aa

Please sign in to comment.