Skip to content

Commit 6948a2d

Browse files
committed
Support all variants of WherePredicate
Adds support for all variants of ast::WherePredicate in clean/mod.rs. Fixes #20048, but will need modification when EqualityPredicates are fully implemented in #20041.
1 parent 62fb41c commit 6948a2d

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

src/librustdoc/clean/mod.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -683,23 +683,32 @@ impl Clean<Option<Lifetime>> for ty::Region {
683683
}
684684

685685
#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
686-
pub struct WherePredicate {
687-
pub ty: Type,
688-
pub bounds: Vec<TyParamBound>
686+
pub enum WherePredicate {
687+
BoundPredicate { ty: Type, bounds: Vec<TyParamBound> },
688+
RegionPredicate { lifetime: Lifetime, bounds: Vec<Lifetime>},
689+
// FIXME (#20041)
690+
EqPredicate
689691
}
690692

691693
impl Clean<WherePredicate> for ast::WherePredicate {
692694
fn clean(&self, cx: &DocContext) -> WherePredicate {
693695
match *self {
694696
ast::WherePredicate::BoundPredicate(ref wbp) => {
695-
WherePredicate {
697+
WherePredicate::BoundPredicate {
696698
ty: wbp.bounded_ty.clean(cx),
697699
bounds: wbp.bounds.clean(cx)
698700
}
699701
}
700-
// FIXME(#20048)
701-
_ => {
702-
unimplemented!();
702+
703+
ast::WherePredicate::RegionPredicate(ref wrp) => {
704+
WherePredicate::RegionPredicate {
705+
lifetime: wrp.lifetime.clean(cx),
706+
bounds: wrp.bounds.clean(cx)
707+
}
708+
}
709+
710+
ast::WherePredicate::EqPredicate(_) => {
711+
WherePredicate::EqPredicate
703712
}
704713
}
705714
}

src/librustdoc/html/format.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,26 @@ impl<'a> fmt::Show for WhereClause<'a> {
128128
if i > 0 {
129129
try!(f.write(", ".as_bytes()));
130130
}
131-
let bounds = pred.bounds.as_slice();
132-
try!(write!(f, "{}: {}", pred.ty, TyParamBounds(bounds)));
131+
match pred {
132+
&clean::WherePredicate::BoundPredicate {ref ty, ref bounds } => {
133+
let bounds = bounds.as_slice();
134+
try!(write!(f, "{}: {}", ty, TyParamBounds(bounds)));
135+
},
136+
&clean::WherePredicate::RegionPredicate { ref lifetime,
137+
ref bounds } => {
138+
try!(write!(f, "{}: ", lifetime));
139+
for (i, lifetime) in bounds.iter().enumerate() {
140+
if i > 0 {
141+
try!(f.write(" + ".as_bytes()));
142+
}
143+
144+
try!(write!(f, "{}", lifetime));
145+
}
146+
},
147+
&clean::WherePredicate::EqPredicate => {
148+
unimplemented!()
149+
}
150+
}
133151
}
134152
Ok(())
135153
}

0 commit comments

Comments
 (0)