1
Fork 0

rustdoc: Support unboxed fn sugar in bounds

This commit is contained in:
Tom Jakubowski 2014-10-05 08:09:41 -07:00
parent 2f955c73d6
commit 7be20574e0
3 changed files with 21 additions and 9 deletions

View file

@ -324,7 +324,7 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
trait_: associated_trait.clean(cx).map(|bound| { trait_: associated_trait.clean(cx).map(|bound| {
match bound { match bound {
clean::TraitBound(ty) => ty, clean::TraitBound(ty) => ty,
clean::UnboxedFnBound => unimplemented!(), clean::UnboxedFnBound(..) |
clean::RegionBound(..) | clean::RegionBound(..) |
clean::UnknownBound => unreachable!(), clean::UnknownBound => unreachable!(),
} }

View file

@ -474,7 +474,7 @@ impl Clean<TyParam> for ty::TypeParameterDef {
#[deriving(Clone, Encodable, Decodable, PartialEq)] #[deriving(Clone, Encodable, Decodable, PartialEq)]
pub enum TyParamBound { pub enum TyParamBound {
RegionBound(Lifetime), RegionBound(Lifetime),
UnboxedFnBound, // FIXME UnboxedFnBound(UnboxedFnType),
UnknownBound, UnknownBound,
TraitBound(Type) TraitBound(Type)
} }
@ -483,10 +483,7 @@ impl Clean<TyParamBound> for ast::TyParamBound {
fn clean(&self, cx: &DocContext) -> TyParamBound { fn clean(&self, cx: &DocContext) -> TyParamBound {
match *self { match *self {
ast::RegionTyParamBound(lt) => RegionBound(lt.clean(cx)), ast::RegionTyParamBound(lt) => RegionBound(lt.clean(cx)),
ast::UnboxedFnTyParamBound(_) => { ast::UnboxedFnTyParamBound(ref ty) => { UnboxedFnBound(ty.clean(cx)) },
// FIXME(pcwalton): Wrong.
UnboxedFnBound
},
ast::TraitTyParamBound(ref t) => TraitBound(t.clean(cx)), ast::TraitTyParamBound(ref t) => TraitBound(t.clean(cx)),
} }
} }
@ -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)] #[deriving(Clone, Encodable, Decodable, PartialEq)]
pub struct Lifetime(String); pub struct Lifetime(String);

View file

@ -143,8 +143,8 @@ impl fmt::Show for clean::TyParamBound {
clean::RegionBound(ref lt) => { clean::RegionBound(ref lt) => {
write!(f, "{}", *lt) write!(f, "{}", *lt)
} }
clean::UnboxedFnBound(..) => { clean::UnboxedFnBound(ref ty) => {
write!(f, "Fn(???)") // FIXME write!(f, "{}{}", ty.path, ty.decl)
} }
clean::UnknownBound => { clean::UnknownBound => {
write!(f, "'static") write!(f, "'static")
@ -408,7 +408,7 @@ impl fmt::Show for clean::Type {
for bound in decl.bounds.iter() { for bound in decl.bounds.iter() {
match *bound { match *bound {
clean::RegionBound(..) | clean::RegionBound(..) |
clean::UnboxedFnBound | clean::UnboxedFnBound(..) |
clean::UnknownBound => {} clean::UnknownBound => {}
clean::TraitBound(ref t) => { clean::TraitBound(ref t) => {
if ret.len() == 0 { if ret.len() == 0 {