Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support all variants of WherePredicate in clean/mod.rs #20180

Merged
merged 2 commits into from
Dec 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,23 +683,32 @@ impl Clean<Option<Lifetime>> for ty::Region {
}

#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
pub struct WherePredicate {
pub ty: Type,
pub bounds: Vec<TyParamBound>
pub enum WherePredicate {
BoundPredicate { ty: Type, bounds: Vec<TyParamBound> },
RegionPredicate { lifetime: Lifetime, bounds: Vec<Lifetime>},
// FIXME (#20041)
EqPredicate
}

impl Clean<WherePredicate> for ast::WherePredicate {
fn clean(&self, cx: &DocContext) -> WherePredicate {
match *self {
ast::WherePredicate::BoundPredicate(ref wbp) => {
WherePredicate {
WherePredicate::BoundPredicate {
ty: wbp.bounded_ty.clean(cx),
bounds: wbp.bounds.clean(cx)
}
}
// FIXME(#20048)
_ => {
unimplemented!();

ast::WherePredicate::RegionPredicate(ref wrp) => {
WherePredicate::RegionPredicate {
lifetime: wrp.lifetime.clean(cx),
bounds: wrp.bounds.clean(cx)
}
}

ast::WherePredicate::EqPredicate(_) => {
WherePredicate::EqPredicate
}
}
}
Expand Down
22 changes: 20 additions & 2 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,26 @@ impl<'a> fmt::Show for WhereClause<'a> {
if i > 0 {
try!(f.write(", ".as_bytes()));
}
let bounds = pred.bounds.as_slice();
try!(write!(f, "{}: {}", pred.ty, TyParamBounds(bounds)));
match pred {
&clean::WherePredicate::BoundPredicate { ref ty, ref bounds } => {
let bounds = bounds.as_slice();
try!(write!(f, "{}: {}", ty, TyParamBounds(bounds)));
}
&clean::WherePredicate::RegionPredicate { ref lifetime,
ref bounds } => {
try!(write!(f, "{}: ", lifetime));
for (i, lifetime) in bounds.iter().enumerate() {
if i > 0 {
try!(f.write(" + ".as_bytes()));
}

try!(write!(f, "{}", lifetime));
}
}
&clean::WherePredicate::EqPredicate => {
unimplemented!()
}
}
}
Ok(())
}
Expand Down