]> git.lizzy.rs Git - rust.git/commitdiff
rustup to rustc 1.16.0-nightly (c07a6ae77 2017-01-17)
authorMrmaxmeier <Mrmaxmeier@gmail.com>
Wed, 18 Jan 2017 20:35:38 +0000 (21:35 +0100)
committerMrmaxmeier <Mrmaxmeier@gmail.com>
Wed, 18 Jan 2017 20:35:38 +0000 (21:35 +0100)
clippy_lints/src/lifetimes.rs
clippy_lints/src/shadow.rs
clippy_lints/src/types.rs
clippy_lints/src/utils/sugg.rs

index ed5c33846556bded80a623dcae749f0df369b8f2..720cf29247c2e28396fce8152f055deea2faee4e 100644 (file)
@@ -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;
                 }
index f84e639d78d72bf8dd85e663d626c642e4b32fc5..9fc089bef43eeccef85421b4117c70b0f25babb6 100644 (file)
@@ -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);
index 41bccef0ace75f32ab03a5b139e826da67c0856b..bae4363659a6d5b06ad1969a249d8dfa4eaef767 100644 (file)
@@ -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),
         };
index 46db4d803fe26cefe02ae900c535464f4c2fb98a..2c10db158cb32ba489f926bb0e6206db4511acc1 100644 (file)
@@ -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),