Skip to content

Commit

Permalink
rustdoc: Support unboxed fn sugar in bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjakubowski committed Oct 6, 2014
1 parent 2f955c7 commit 7be2057
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/clean/inline.rs
Expand Up @@ -324,7 +324,7 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
trait_: associated_trait.clean(cx).map(|bound| {
match bound {
clean::TraitBound(ty) => ty,
clean::UnboxedFnBound => unimplemented!(),
clean::UnboxedFnBound(..) |
clean::RegionBound(..) |
clean::UnknownBound => unreachable!(),
}
Expand Down
22 changes: 17 additions & 5 deletions src/librustdoc/clean/mod.rs
Expand Up @@ -474,7 +474,7 @@ impl Clean<TyParam> for ty::TypeParameterDef {
#[deriving(Clone, Encodable, Decodable, PartialEq)]
pub enum TyParamBound {
RegionBound(Lifetime),
UnboxedFnBound, // FIXME
UnboxedFnBound(UnboxedFnType),
UnknownBound,
TraitBound(Type)
}
Expand All @@ -483,10 +483,7 @@ impl Clean<TyParamBound> for ast::TyParamBound {
fn clean(&self, cx: &DocContext) -> TyParamBound {
match *self {
ast::RegionTyParamBound(lt) => RegionBound(lt.clean(cx)),
ast::UnboxedFnTyParamBound(_) => {
// FIXME(pcwalton): Wrong.
UnboxedFnBound
},
ast::UnboxedFnTyParamBound(ref ty) => { UnboxedFnBound(ty.clean(cx)) },
ast::TraitTyParamBound(ref t) => TraitBound(t.clean(cx)),
}
}
Expand Down Expand Up @@ -598,6 +595,21 @@ impl Clean<Option<Vec<TyParamBound>>> for subst::Substs {
}
}

#[deriving(Clone, Encodable, Decodable, PartialEq)]
pub struct UnboxedFnType {
pub path: Path,
pub decl: FnDecl
}

impl Clean<UnboxedFnType> for ast::UnboxedFnBound {
fn clean(&self, cx: &DocContext) -> UnboxedFnType {
UnboxedFnType {
path: self.path.clean(cx),
decl: self.decl.clean(cx)
}
}
}

#[deriving(Clone, Encodable, Decodable, PartialEq)]
pub struct Lifetime(String);

Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/format.rs
Expand Up @@ -143,8 +143,8 @@ impl fmt::Show for clean::TyParamBound {
clean::RegionBound(ref lt) => {
write!(f, "{}", *lt)
}
clean::UnboxedFnBound(..) => {
write!(f, "Fn(???)") // FIXME
clean::UnboxedFnBound(ref ty) => {
write!(f, "{}{}", ty.path, ty.decl)
}
clean::UnknownBound => {
write!(f, "'static")
Expand Down Expand Up @@ -408,7 +408,7 @@ impl fmt::Show for clean::Type {
for bound in decl.bounds.iter() {
match *bound {
clean::RegionBound(..) |
clean::UnboxedFnBound |
clean::UnboxedFnBound(..) |
clean::UnknownBound => {}
clean::TraitBound(ref t) => {
if ret.len() == 0 {
Expand Down

0 comments on commit 7be2057

Please sign in to comment.