Skip to content

Commit 7be2057

Browse files
committed
rustdoc: Support unboxed fn sugar in bounds
1 parent 2f955c7 commit 7be2057

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
324324
trait_: associated_trait.clean(cx).map(|bound| {
325325
match bound {
326326
clean::TraitBound(ty) => ty,
327-
clean::UnboxedFnBound => unimplemented!(),
327+
clean::UnboxedFnBound(..) |
328328
clean::RegionBound(..) |
329329
clean::UnknownBound => unreachable!(),
330330
}

src/librustdoc/clean/mod.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl Clean<TyParam> for ty::TypeParameterDef {
474474
#[deriving(Clone, Encodable, Decodable, PartialEq)]
475475
pub enum TyParamBound {
476476
RegionBound(Lifetime),
477-
UnboxedFnBound, // FIXME
477+
UnboxedFnBound(UnboxedFnType),
478478
UnknownBound,
479479
TraitBound(Type)
480480
}
@@ -483,10 +483,7 @@ impl Clean<TyParamBound> for ast::TyParamBound {
483483
fn clean(&self, cx: &DocContext) -> TyParamBound {
484484
match *self {
485485
ast::RegionTyParamBound(lt) => RegionBound(lt.clean(cx)),
486-
ast::UnboxedFnTyParamBound(_) => {
487-
// FIXME(pcwalton): Wrong.
488-
UnboxedFnBound
489-
},
486+
ast::UnboxedFnTyParamBound(ref ty) => { UnboxedFnBound(ty.clean(cx)) },
490487
ast::TraitTyParamBound(ref t) => TraitBound(t.clean(cx)),
491488
}
492489
}
@@ -598,6 +595,21 @@ impl Clean<Option<Vec<TyParamBound>>> for subst::Substs {
598595
}
599596
}
600597

598+
#[deriving(Clone, Encodable, Decodable, PartialEq)]
599+
pub struct UnboxedFnType {
600+
pub path: Path,
601+
pub decl: FnDecl
602+
}
603+
604+
impl Clean<UnboxedFnType> for ast::UnboxedFnBound {
605+
fn clean(&self, cx: &DocContext) -> UnboxedFnType {
606+
UnboxedFnType {
607+
path: self.path.clean(cx),
608+
decl: self.decl.clean(cx)
609+
}
610+
}
611+
}
612+
601613
#[deriving(Clone, Encodable, Decodable, PartialEq)]
602614
pub struct Lifetime(String);
603615

src/librustdoc/html/format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ impl fmt::Show for clean::TyParamBound {
143143
clean::RegionBound(ref lt) => {
144144
write!(f, "{}", *lt)
145145
}
146-
clean::UnboxedFnBound(..) => {
147-
write!(f, "Fn(???)") // FIXME
146+
clean::UnboxedFnBound(ref ty) => {
147+
write!(f, "{}{}", ty.path, ty.decl)
148148
}
149149
clean::UnknownBound => {
150150
write!(f, "'static")
@@ -408,7 +408,7 @@ impl fmt::Show for clean::Type {
408408
for bound in decl.bounds.iter() {
409409
match *bound {
410410
clean::RegionBound(..) |
411-
clean::UnboxedFnBound |
411+
clean::UnboxedFnBound(..) |
412412
clean::UnknownBound => {}
413413
clean::TraitBound(ref t) => {
414414
if ret.len() == 0 {

0 commit comments

Comments
 (0)