Skip to content

Commit 5ba6102

Browse files
committed
auto merge of #20180 : jroesch/rust/clean-where-predicate, r=alexcrichton
Add support for all variants of ast::WherePredicate in clean/mod.rs. Fixes #20048, but will need modification when EqualityPredicates are fully implemented in #20041.
2 parents f673e98 + 1775292 commit 5ba6102

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
@@ -745,23 +745,32 @@ impl Clean<Option<Lifetime>> for ty::Region {
745745
}
746746

747747
#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
748-
pub struct WherePredicate {
749-
pub ty: Type,
750-
pub bounds: Vec<TyParamBound>
748+
pub enum WherePredicate {
749+
BoundPredicate { ty: Type, bounds: Vec<TyParamBound> },
750+
RegionPredicate { lifetime: Lifetime, bounds: Vec<Lifetime>},
751+
// FIXME (#20041)
752+
EqPredicate
751753
}
752754

753755
impl Clean<WherePredicate> for ast::WherePredicate {
754756
fn clean(&self, cx: &DocContext) -> WherePredicate {
755757
match *self {
756758
ast::WherePredicate::BoundPredicate(ref wbp) => {
757-
WherePredicate {
759+
WherePredicate::BoundPredicate {
758760
ty: wbp.bounded_ty.clean(cx),
759761
bounds: wbp.bounds.clean(cx)
760762
}
761763
}
762-
// FIXME(#20048)
763-
_ => {
764-
unimplemented!();
764+
765+
ast::WherePredicate::RegionPredicate(ref wrp) => {
766+
WherePredicate::RegionPredicate {
767+
lifetime: wrp.lifetime.clean(cx),
768+
bounds: wrp.bounds.clean(cx)
769+
}
770+
}
771+
772+
ast::WherePredicate::EqPredicate(_) => {
773+
WherePredicate::EqPredicate
765774
}
766775
}
767776
}

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)