Skip to content

Commit a62c4aa

Browse files
committed
Fix rustdoc and remove default impl for FnHeader
1 parent 9a310ab commit a62c4aa

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

src/librustc/hir/mod.rs

-11
Original file line numberDiff line numberDiff line change
@@ -2024,17 +2024,6 @@ pub struct FnHeader {
20242024
pub abi: Abi,
20252025
}
20262026

2027-
impl Default for FnHeader {
2028-
fn default() -> FnHeader {
2029-
FnHeader {
2030-
unsafety: Unsafety::Normal,
2031-
constness: Constness::NotConst,
2032-
asyncness: IsAsync::NotAsync,
2033-
abi: Abi::Rust,
2034-
}
2035-
}
2036-
}
2037-
20382027
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
20392028
pub enum Item_ {
20402029
/// An `extern crate` item, with optional *original* crate name if the crate was renamed.

src/librustc/hir/print.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,12 @@ impl<'a> State<'a> {
459459
hir::ForeignItemFn(ref decl, ref arg_names, ref generics) => {
460460
self.head("")?;
461461
self.print_fn(decl,
462-
hir::FnHeader::default(),
462+
hir::FnHeader {
463+
unsafety: hir::Unsafety::Normal,
464+
constness: hir::Constness::NotConst,
465+
abi: Abi::Rust,
466+
asyncness: hir::IsAsync::NotAsync,
467+
},
463468
Some(item.name),
464469
generics,
465470
&item.vis,
@@ -2253,8 +2258,10 @@ impl<'a> State<'a> {
22532258
};
22542259
self.print_fn(decl,
22552260
hir::FnHeader {
2256-
unsafety, abi,
2257-
..hir::FnHeader::default()
2261+
unsafety,
2262+
abi,
2263+
constness: hir::Constness::NotConst,
2264+
asyncness: hir::IsAsync::NotAsync,
22582265
},
22592266
name,
22602267
&generics,

src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
202202
unsafety: sig.unsafety(),
203203
abi: sig.abi(),
204204
constness,
205-
..hir::FnHeader::default()
205+
asyncness: hir::IsAsync::NotAsync,
206206
}
207207
}
208208
}

src/librustdoc/clean/mod.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
24572457
unsafety: sig.unsafety(),
24582458
abi: sig.abi(),
24592459
constness,
2460-
..hir::FnHeader::default()
2460+
asyncness: hir::IsAsync::NotAsync,
24612461
}
24622462
})
24632463
} else {
@@ -2467,7 +2467,8 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
24672467
header: hir::FnHeader {
24682468
unsafety: sig.unsafety(),
24692469
abi: sig.abi(),
2470-
..hir::FnHeader::default()
2470+
constness: hir::Constness::NotConst,
2471+
asyncness: hir::IsAsync::NotAsync,
24712472
}
24722473
})
24732474
}
@@ -4007,7 +4008,12 @@ impl Clean<Item> for hir::ForeignItem {
40074008
ForeignFunctionItem(Function {
40084009
decl,
40094010
generics,
4010-
header: hir::FnHeader::default(),
4011+
header: hir::FnHeader {
4012+
unsafety: hir::Unsafety::Unsafe,
4013+
abi: Abi::Rust,
4014+
constness: hir::Constness::NotConst,
4015+
asyncness: hir::IsAsync::NotAsync,
4016+
},
40114017
})
40124018
}
40134019
hir::ForeignItemStatic(ref ty, mutbl) => {

src/librustdoc/html/render.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -2577,20 +2577,20 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
25772577
let name_len = format!("{}{}{}{}{:#}fn {}{:#}",
25782578
VisSpace(&it.visibility),
25792579
ConstnessSpace(f.header.constness),
2580-
AsyncSpace(f.header.asyncness),
25812580
UnsafetySpace(f.header.unsafety),
2581+
AsyncSpace(f.header.asyncness),
25822582
AbiSpace(f.header.abi),
25832583
it.name.as_ref().unwrap(),
25842584
f.generics).len();
25852585
write!(w, "{}<pre class='rust fn'>", render_spotlight_traits(it)?)?;
25862586
render_attributes(w, it)?;
25872587
write!(w,
2588-
"{vis}{constness}{asyncness}{unsafety}{abi}fn \
2588+
"{vis}{constness}{unsafety}{asyncness}{abi}fn \
25892589
{name}{generics}{decl}{where_clause}</pre>",
25902590
vis = VisSpace(&it.visibility),
25912591
constness = ConstnessSpace(f.header.constness),
2592-
asyncness = AsyncSpace(f.header.asyncness),
25932592
unsafety = UnsafetySpace(f.header.unsafety),
2593+
asyncness = AsyncSpace(f.header.asyncness),
25942594
abi = AbiSpace(f.header.abi),
25952595
name = it.name.as_ref().unwrap(),
25962596
generics = f.generics,
@@ -3024,10 +3024,11 @@ fn render_assoc_item(w: &mut fmt::Formatter,
30243024
href(did).map(|p| format!("{}#{}.{}", p.0, ty, name)).unwrap_or(anchor)
30253025
}
30263026
};
3027-
let mut head_len = format!("{}{}{}{:#}fn {}{:#}",
3027+
let mut head_len = format!("{}{}{}{}{:#}fn {}{:#}",
30283028
VisSpace(&meth.visibility),
30293029
ConstnessSpace(header.constness),
30303030
UnsafetySpace(header.unsafety),
3031+
AsyncSpace(header.asyncness),
30313032
AbiSpace(header.abi),
30323033
name,
30333034
*g).len();
@@ -3038,11 +3039,12 @@ fn render_assoc_item(w: &mut fmt::Formatter,
30383039
(0, true)
30393040
};
30403041
render_attributes(w, meth)?;
3041-
write!(w, "{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
3042+
write!(w, "{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
30423043
{generics}{decl}{where_clause}",
30433044
VisSpace(&meth.visibility),
30443045
ConstnessSpace(header.constness),
30453046
UnsafetySpace(header.unsafety),
3047+
AsyncSpace(header.asyncness),
30463048
AbiSpace(header.abi),
30473049
href = href,
30483050
name = name,

0 commit comments

Comments
 (0)