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.
This commit is contained in:
commit
5ba6102657
@ -745,23 +745,32 @@ impl Clean<Option<Lifetime>> for ty::Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
|
#[deriving(Clone, RustcEncodable, RustcDecodable, PartialEq)]
|
||||||
pub struct WherePredicate {
|
pub enum WherePredicate {
|
||||||
pub ty: Type,
|
BoundPredicate { ty: Type, bounds: Vec<TyParamBound> },
|
||||||
pub bounds: Vec<TyParamBound>
|
RegionPredicate { lifetime: Lifetime, bounds: Vec<Lifetime>},
|
||||||
|
// FIXME (#20041)
|
||||||
|
EqPredicate
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<WherePredicate> for ast::WherePredicate {
|
impl Clean<WherePredicate> for ast::WherePredicate {
|
||||||
fn clean(&self, cx: &DocContext) -> WherePredicate {
|
fn clean(&self, cx: &DocContext) -> WherePredicate {
|
||||||
match *self {
|
match *self {
|
||||||
ast::WherePredicate::BoundPredicate(ref wbp) => {
|
ast::WherePredicate::BoundPredicate(ref wbp) => {
|
||||||
WherePredicate {
|
WherePredicate::BoundPredicate {
|
||||||
ty: wbp.bounded_ty.clean(cx),
|
ty: wbp.bounded_ty.clean(cx),
|
||||||
bounds: wbp.bounds.clean(cx)
|
bounds: wbp.bounds.clean(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FIXME(#20048)
|
|
||||||
_ => {
|
ast::WherePredicate::RegionPredicate(ref wrp) => {
|
||||||
unimplemented!();
|
WherePredicate::RegionPredicate {
|
||||||
|
lifetime: wrp.lifetime.clean(cx),
|
||||||
|
bounds: wrp.bounds.clean(cx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ast::WherePredicate::EqPredicate(_) => {
|
||||||
|
WherePredicate::EqPredicate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,8 +128,26 @@ impl<'a> fmt::Show for WhereClause<'a> {
|
|||||||
if i > 0 {
|
if i > 0 {
|
||||||
try!(f.write(", ".as_bytes()));
|
try!(f.write(", ".as_bytes()));
|
||||||
}
|
}
|
||||||
let bounds = pred.bounds.as_slice();
|
match pred {
|
||||||
try!(write!(f, "{}: {}", pred.ty, TyParamBounds(bounds)));
|
&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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user