Skip to content

Commit cb344be

Browse files
committed
rollup merge of #20725: tomjakubowski/rustdoc-misc
Conflicts: src/librustdoc/html/format.rs
2 parents a204dc5 + a0734ff commit cb344be

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ fn external_path_params(cx: &DocContext, trait_did: Option<ast::DefId>,
530530
_ => {
531531
return PathParameters::AngleBracketed {
532532
lifetimes: lifetimes,
533-
types: types.clean(cx)
533+
types: types.clean(cx),
534+
bindings: vec![]
534535
}
535536
}
536537
};
@@ -547,6 +548,7 @@ fn external_path_params(cx: &DocContext, trait_did: Option<ast::DefId>,
547548
PathParameters::AngleBracketed {
548549
lifetimes: lifetimes,
549550
types: types.clean(cx),
551+
bindings: vec![] // FIXME(#20646)
550552
}
551553
}
552554
}
@@ -1766,6 +1768,7 @@ pub enum PathParameters {
17661768
AngleBracketed {
17671769
lifetimes: Vec<Lifetime>,
17681770
types: Vec<Type>,
1771+
bindings: Vec<TypeBinding>
17691772
},
17701773
Parenthesized {
17711774
inputs: Vec<Type>,
@@ -1779,7 +1782,8 @@ impl Clean<PathParameters> for ast::PathParameters {
17791782
ast::AngleBracketedParameters(ref data) => {
17801783
PathParameters::AngleBracketed {
17811784
lifetimes: data.lifetimes.clean(cx),
1782-
types: data.types.clean(cx)
1785+
types: data.types.clean(cx),
1786+
bindings: data.bindings.clean(cx)
17831787
}
17841788
}
17851789

@@ -2442,8 +2446,25 @@ fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
24422446
params: PathParameters::AngleBracketed {
24432447
lifetimes: vec![],
24442448
types: vec![t.clean(cx)],
2449+
bindings: vec![]
24452450
}
24462451
}],
24472452
},
24482453
}
24492454
}
2455+
2456+
/// An equality constraint on an associated type, e.g. `A=Bar` in `Foo<A=Bar>`
2457+
#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable)]
2458+
pub struct TypeBinding {
2459+
pub name: String,
2460+
pub ty: Type
2461+
}
2462+
2463+
impl Clean<TypeBinding> for ast::TypeBinding {
2464+
fn clean(&self, cx: &DocContext) -> TypeBinding {
2465+
TypeBinding {
2466+
name: self.ident.clean(cx),
2467+
ty: self.ty.clean(cx)
2468+
}
2469+
}
2470+
}

src/librustdoc/html/format.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@ impl fmt::String for clean::TyParamBound {
206206
impl fmt::String for clean::PathParameters {
207207
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
208208
match *self {
209-
clean::PathParameters::AngleBracketed { ref lifetimes, ref types } => {
210-
if lifetimes.len() > 0 || types.len() > 0 {
209+
clean::PathParameters::AngleBracketed {
210+
ref lifetimes, ref types, ref bindings
211+
} => {
212+
if lifetimes.len() > 0 || types.len() > 0 || bindings.len() > 0 {
211213
try!(f.write_str("&lt;"));
212214
let mut comma = false;
213215
for lifetime in lifetimes.iter() {
@@ -224,6 +226,13 @@ impl fmt::String for clean::PathParameters {
224226
comma = true;
225227
try!(write!(f, "{}", *ty));
226228
}
229+
for binding in bindings.iter() {
230+
if comma {
231+
try!(f.write_str(", "));
232+
}
233+
comma = true;
234+
try!(write!(f, "{}", *binding));
235+
}
227236
try!(f.write_str("&gt;"));
228237
}
229238
}
@@ -717,6 +726,7 @@ impl fmt::String for clean::ViewListIdent {
717726
params: clean::PathParameters::AngleBracketed {
718727
lifetimes: Vec::new(),
719728
types: Vec::new(),
729+
bindings: Vec::new()
720730
}
721731
})
722732
};
@@ -727,6 +737,12 @@ impl fmt::String for clean::ViewListIdent {
727737
}
728738
}
729739

740+
impl fmt::String for clean::TypeBinding {
741+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
742+
write!(f, "{}={}", self.name, self.ty)
743+
}
744+
}
745+
730746
impl fmt::String for MutableSpace {
731747
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
732748
match *self {

0 commit comments

Comments
 (0)