]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Support unboxed fn sugar in bounds
authorTom Jakubowski <tom@crystae.net>
Sun, 5 Oct 2014 15:09:41 +0000 (08:09 -0700)
committerTom Jakubowski <tom@crystae.net>
Mon, 6 Oct 2014 09:23:55 +0000 (02:23 -0700)
src/librustdoc/clean/inline.rs
src/librustdoc/clean/mod.rs
src/librustdoc/html/format.rs

index d755378366e540cade8f400fc3222c9f438c2455..4bef672ea0df9a861db83d0fcbb00a04e621e455 100644 (file)
@@ -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!(),
                 }
index e6e4453c4dac176a3e333c44768622e71062cd3a..0b37a21cb0b8076590fe74ef3ab763df2e1e3582 100644 (file)
@@ -474,7 +474,7 @@ fn clean(&self, cx: &DocContext) -> TyParam {
 #[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub enum TyParamBound {
     RegionBound(Lifetime),
-    UnboxedFnBound, // FIXME
+    UnboxedFnBound(UnboxedFnType),
     UnknownBound,
     TraitBound(Type)
 }
@@ -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)),
         }
     }
@@ -598,6 +595,21 @@ fn clean(&self, cx: &DocContext) -> Option<Vec<TyParamBound>> {
     }
 }
 
+#[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);
 
index 7f5be22f391633b7500e1044107bbd5132a46868..9d77b621d4aa03ec4449e15b0a9e6a7adac33a6f 100644 (file)
@@ -143,8 +143,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             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")
@@ -408,7 +408,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                            for bound in decl.bounds.iter() {
                                 match *bound {
                                     clean::RegionBound(..) |
-                                    clean::UnboxedFnBound |
+                                    clean::UnboxedFnBound(..) |
                                     clean::UnknownBound => {}
                                     clean::TraitBound(ref t) => {
                                         if ret.len() == 0 {