From 84c57ad2213d61b677ce7a022e8a929721468631 Mon Sep 17 00:00:00 2001 From: Mrmaxmeier Date: Wed, 18 Jan 2017 21:35:38 +0100 Subject: [PATCH] rustup to rustc 1.16.0-nightly (c07a6ae77 2017-01-17) --- clippy_lints/src/lifetimes.rs | 3 ++- clippy_lints/src/shadow.rs | 1 - clippy_lints/src/types.rs | 23 +++++++++++++++++------ clippy_lints/src/utils/sugg.rs | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index ed5c3384655..720cf29247c 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -326,7 +326,8 @@ fn has_where_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, where_clause: & }, 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; } diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index f84e639d78d..9fc089bef43 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -335,7 +335,6 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings: 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); diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 41bccef0ace..bae4363659a 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -699,12 +699,23 @@ fn visit_ty(&mut self, ty: &'tcx Ty) { // 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), }; diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index 46db4d803fe..2c10db158cb 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -116,7 +116,7 @@ pub fn ast(cx: &EarlyContext, expr: &ast::Expr, default: &'a str) -> Sugg<'a> { 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), -- 2.44.0