about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-01-07 17:19:51 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-01-07 17:19:51 -0800
commitcb344be99d6b491017558ffbd015b9a0b86e8558 (patch)
treec8e4f9c13897e3afe768f8ccfae402793ed275bc /src
parenta204dc56c97f35632575b1baa008f2e069b1bed9 (diff)
parenta0734ff7e03b57db46cf8549c8329cddce4934ec (diff)
downloadrust-cb344be99d6b491017558ffbd015b9a0b86e8558.tar.gz
rust-cb344be99d6b491017558ffbd015b9a0b86e8558.zip
rollup merge of #20725: tomjakubowski/rustdoc-misc
Conflicts:
	src/librustdoc/html/format.rs
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/mod.rs25
-rw-r--r--src/librustdoc/html/format.rs20
2 files changed, 41 insertions, 4 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index bf2664bba6a..ea6bfc64c22 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -530,7 +530,8 @@ fn external_path_params(cx: &DocContext, trait_did: Option<ast::DefId>,
                 _ => {
                     return PathParameters::AngleBracketed {
                         lifetimes: lifetimes,
-                        types: types.clean(cx)
+                        types: types.clean(cx),
+                        bindings: vec![]
                     }
                 }
             };
@@ -547,6 +548,7 @@ fn external_path_params(cx: &DocContext, trait_did: Option<ast::DefId>,
             PathParameters::AngleBracketed {
                 lifetimes: lifetimes,
                 types: types.clean(cx),
+                bindings: vec![] // FIXME(#20646)
             }
         }
     }
@@ -1766,6 +1768,7 @@ pub enum PathParameters {
     AngleBracketed {
         lifetimes: Vec<Lifetime>,
         types: Vec<Type>,
+        bindings: Vec<TypeBinding>
     },
     Parenthesized {
         inputs: Vec<Type>,
@@ -1779,7 +1782,8 @@ impl Clean<PathParameters> for ast::PathParameters {
             ast::AngleBracketedParameters(ref data) => {
                 PathParameters::AngleBracketed {
                     lifetimes: data.lifetimes.clean(cx),
-                    types: data.types.clean(cx)
+                    types: data.types.clean(cx),
+                    bindings: data.bindings.clean(cx)
                 }
             }
 
@@ -2442,8 +2446,25 @@ fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
                 params: PathParameters::AngleBracketed {
                     lifetimes: vec![],
                     types: vec![t.clean(cx)],
+                    bindings: vec![]
                 }
             }],
         },
     }
 }
+
+/// An equality constraint on an associated type, e.g. `A=Bar` in `Foo<A=Bar>`
+#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable)]
+pub struct TypeBinding {
+    pub name: String,
+    pub ty: Type
+}
+
+impl Clean<TypeBinding> for ast::TypeBinding {
+    fn clean(&self, cx: &DocContext) -> TypeBinding {
+        TypeBinding {
+            name: self.ident.clean(cx),
+            ty: self.ty.clean(cx)
+        }
+    }
+}
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index b3cef19e567..244f5926a12 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -206,8 +206,10 @@ impl fmt::String for clean::TyParamBound {
 impl fmt::String for clean::PathParameters {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
-            clean::PathParameters::AngleBracketed { ref lifetimes, ref types } => {
-                if lifetimes.len() > 0 || types.len() > 0 {
+            clean::PathParameters::AngleBracketed {
+                ref lifetimes, ref types, ref bindings
+            } => {
+                if lifetimes.len() > 0 || types.len() > 0 || bindings.len() > 0 {
                     try!(f.write_str("&lt;"));
                     let mut comma = false;
                     for lifetime in lifetimes.iter() {
@@ -224,6 +226,13 @@ impl fmt::String for clean::PathParameters {
                         comma = true;
                         try!(write!(f, "{}", *ty));
                     }
+                    for binding in bindings.iter() {
+                        if comma {
+                            try!(f.write_str(", "));
+                        }
+                        comma = true;
+                        try!(write!(f, "{}", *binding));
+                    }
                     try!(f.write_str("&gt;"));
                 }
             }
@@ -717,6 +726,7 @@ impl fmt::String for clean::ViewListIdent {
                         params: clean::PathParameters::AngleBracketed {
                             lifetimes: Vec::new(),
                             types: Vec::new(),
+                            bindings: Vec::new()
                         }
                     })
                 };
@@ -727,6 +737,12 @@ impl fmt::String for clean::ViewListIdent {
     }
 }
 
+impl fmt::String for clean::TypeBinding {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "{}={}", self.name, self.ty)
+    }
+}
+
 impl fmt::String for MutableSpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {