From 79b0ad7441970dee66ebbdec9271ed8a6ea07944 Mon Sep 17 00:00:00 2001 From: mcarton Date: Thu, 3 Mar 2016 20:09:31 +0100 Subject: [PATCH 1/3] `vec!` now uses `box` --- src/vec.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/vec.rs b/src/vec.rs index fe3c1f901991..dda552bc8f9b 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -3,7 +3,7 @@ use rustc::middle::ty::TypeVariants; use rustc_front::hir::*; use syntax::codemap::Span; use syntax::ptr::P; -use utils::{BOX_NEW_PATH, VEC_FROM_ELEM_PATH}; +use utils::VEC_FROM_ELEM_PATH; use utils::{is_expn_of, match_path, snippet, span_lint_and_then}; /// **What it does:** This lint warns about using `&vec![..]` when using `&[..]` would be possible. @@ -33,9 +33,7 @@ impl LintPass for UselessVec { impl LateLintPass for UselessVec { fn check_expr(&mut self, cx: &LateContext, expr: &Expr) { - unexpand_vec(cx, expr); - - // search for `&!vec[_]` expressions where the adjusted type is `&[_]` + // search for `&vec![_]` expressions where the adjusted type is `&[_]` if_let_chain!{[ let TypeVariants::TyRef(_, ref ty) = cx.tcx.expr_ty_adjusted(expr).sty, let TypeVariants::TySlice(..) = ty.ty.sty, @@ -71,7 +69,7 @@ impl LateLintPass for UselessVec { /// Represent the pre-expansion arguments of a `vec!` invocation. pub enum VecArgs<'a> { - /// `vec![elem, len]` + /// `vec![elem; len]` Repeat(&'a P, &'a P), /// `vec![a, b, c]` Vec(&'a [P]), @@ -91,10 +89,8 @@ pub fn unexpand_vec<'e>(cx: &LateContext, expr: &'e Expr) -> Option> else if match_path(path, &["into_vec"]) && args.len() == 1 { // `vec![a, b, c]` case if_let_chain!{[ - let ExprCall(ref fun, ref args) = args[0].node, - let ExprPath(_, ref path) = fun.node, - match_path(path, &BOX_NEW_PATH) && args.len() == 1, - let ExprVec(ref args) = args[0].node + let ExprBox(ref boxed) = args[0].node, + let ExprVec(ref args) = boxed.node ], { return Some(VecArgs::Vec(&*args)); }} From c7bf0681210bdf2e504f08967568fc7d807afea1 Mon Sep 17 00:00:00 2001 From: mcarton Date: Fri, 4 Mar 2016 14:25:34 +0100 Subject: [PATCH 2/3] s/ctxt/TyCtxt --- src/cyclomatic_complexity.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cyclomatic_complexity.rs b/src/cyclomatic_complexity.rs index 3f956f1fc41b..7034f87f59fa 100644 --- a/src/cyclomatic_complexity.rs +++ b/src/cyclomatic_complexity.rs @@ -116,7 +116,7 @@ impl<'a> Visitor<'a> for MatchArmCounter { } } -struct DivergenceCounter<'a, 'tcx: 'a>(u64, &'a ty::ctxt<'tcx>); +struct DivergenceCounter<'a, 'tcx: 'a>(u64, &'a ty::TyCtxt<'tcx>); impl<'a, 'b, 'tcx> Visitor<'a> for DivergenceCounter<'b, 'tcx> { fn visit_expr(&mut self, e: &'a Expr) { From 026d443e1e091aee21b6f5fd4cfb13058427039a Mon Sep 17 00:00:00 2001 From: mcarton Date: Fri, 4 Mar 2016 14:25:53 +0100 Subject: [PATCH 3/3] Bump to 0.0.46 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 71d6d2864f2f..bee10dccd6f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.45" +version = "0.0.46" authors = [ "Manish Goregaokar ", "Andre Bogus ",