},
WherePredicate::EqPredicate(ref pred) => {
let mut visitor = RefVisitor::new(cx);
- walk_ty(&mut visitor, &pred.ty);
+ walk_ty(&mut visitor, &pred.lhs_ty);
+ walk_ty(&mut visitor, &pred.rhs_ty);
if !visitor.lts.is_empty() {
return true;
}
fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty, bindings: &mut Vec<(Name, Span)>) {
match ty.node {
- TyObjectSum(ref sty, _) |
TySlice(ref sty) => check_ty(cx, sty, bindings),
TyArray(ref fty, body_id) => {
check_ty(cx, fty, bindings);
// the "normal" components of a type: named types, arrays/tuples
TyPath(..) | TySlice(..) | TyTup(..) | TyArray(..) => (10 * self.nest, 1),
- // "Sum" of trait bounds
- TyObjectSum(..) => (20 * self.nest, 0),
-
- // function types and "for<...>" bring a lot of overhead
- TyBareFn(..) |
- TyPolyTraitRef(..) => (50 * self.nest, 1),
+ // function types bring a lot of overhead
+ TyBareFn(..) => (50 * self.nest, 1),
+
+ TyTraitObject(ref bounds) => {
+ let has_lifetimes = bounds.iter()
+ .any(|bound| match *bound {
+ TraitTyParamBound(ref poly_trait, ..) => !poly_trait.bound_lifetimes.is_empty(),
+ RegionTyParamBound(..) => true,
+ });
+ if has_lifetimes {
+ // complex trait bounds like A<'a, 'b>
+ (50 * self.nest, 1)
+ } else {
+ // simple trait bounds like A + B
+ (20 * self.nest, 0)
+ }
+ },
_ => (0, 0),
};
ast::ExprKind::Try(..) |
ast::ExprKind::Tup(..) |
ast::ExprKind::TupField(..) |
- ast::ExprKind::Vec(..) |
+ ast::ExprKind::Array(..) |
ast::ExprKind::While(..) |
ast::ExprKind::WhileLet(..) => Sugg::NonParen(snippet),
ast::ExprKind::Range(.., RangeLimits::HalfOpen) => Sugg::BinOp(AssocOp::DotDot, snippet),