]> git.lizzy.rs Git - rust.git/commitdiff
Patch rustdoc to include missing types, make the match exhaustive
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 26 Nov 2014 15:11:27 +0000 (10:11 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Sun, 14 Dec 2014 09:21:56 +0000 (04:21 -0500)
to prevent such oversights in the future.

src/librustdoc/clean/mod.rs
src/librustdoc/html/format.rs

index 630d41fa7e209b7a31ec39288f94091526bfc6b1..8045dab6c2d6780cd241b15bc02fcce7a2599705 100644 (file)
@@ -1165,12 +1165,19 @@ pub enum Type {
         mutability: Mutability,
         type_: Box<Type>,
     },
+
+    // <Type as Trait>::Name
     QPath {
         name: String,
         self_type: Box<Type>,
         trait_: Box<Type>
     },
-    // region, raw, other boxes, mutable
+
+    // _
+    Infer,
+
+    // for<'a> Foo(&'a)
+    PolyTraitRef(Vec<TyParamBound>),
 }
 
 #[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash)]
@@ -1307,11 +1314,18 @@ fn clean(&self, cx: &DocContext) -> Type {
                 }
             }
             TyClosure(ref c) => Closure(box c.clean(cx)),
-            TyProc(ref c) => Proc(box c.clean(cx)),
             TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)),
             TyParen(ref ty) => ty.clean(cx),
             TyQPath(ref qp) => qp.clean(cx),
-            ref x => panic!("Unimplemented type {}", x),
+            TyPolyTraitRef(ref bounds) => {
+                PolyTraitRef(bounds.clean(cx))
+            },
+            TyInfer(..) => {
+                Infer
+            },
+            TyTypeof(..) => {
+                panic!("Unimplemented type {}", self.node)
+            },
         }
     }
 }
index 484eed649bbcd945eec13ab4c2546e3166ea897e..cf92a71369fa33524d1e6ebaaa14f5ff22ff19fb 100644 (file)
@@ -390,6 +390,16 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 try!(resolved_path(f, did, path, false));
                 tybounds(f, typarams)
             }
+            clean::PolyTraitRef(ref bounds) => {
+                for (i, bound) in bounds.iter().enumerate() {
+                    if i != 0 {
+                        try!(write!(f, " + "));
+                    }
+                    try!(write!(f, "{}", *bound));
+                }
+                Ok(())
+            }
+            clean::Infer => write!(f, "_"),
             clean::Self(..) => f.write("Self".as_bytes()),
             clean::Primitive(prim) => primitive_link(f, prim, prim.to_string()),
             clean::Closure(ref decl) => {