From c7e3cc1e277dceace0c1536bab8fc42995c48535 Mon Sep 17 00:00:00 2001 From: mcarton Date: Wed, 23 Nov 2016 22:44:00 +0100 Subject: [PATCH] Rustup to *rustc 1.15.0-nightly (3bf2be9ce 2016-11-22)* --- clippy_lints/src/consts.rs | 3 +- clippy_lints/src/drop_ref.rs | 2 +- clippy_lints/src/entry.rs | 2 +- clippy_lints/src/len_zero.rs | 3 +- clippy_lints/src/methods.rs | 58 ++++++++++--------------------- clippy_lints/src/minmax.rs | 3 +- clippy_lints/src/misc.rs | 3 +- clippy_lints/src/mut_reference.rs | 3 +- clippy_lints/src/no_effect.rs | 4 +-- clippy_lints/src/transmute.rs | 4 +-- clippy_lints/src/utils/higher.rs | 5 ++- clippy_lints/src/utils/hir.rs | 4 +-- clippy_lints/src/utils/mod.rs | 4 +-- 13 files changed, 36 insertions(+), 62 deletions(-) diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 79e2cc86ee4..89c57bba233 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -9,7 +9,6 @@ use std::cmp::Ordering::{self, Equal}; use std::cmp::PartialOrd; use std::hash::{Hash, Hasher}; use std::mem; -use std::ops::Deref; use std::rc::Rc; use syntax::ast::{FloatTy, LitIntType, LitKind, StrStyle, UintTy, IntTy}; use syntax::ptr::P; @@ -279,7 +278,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { /// create `Some(Vec![..])` of all constants, unless there is any /// non-constant part - fn multi + Sized>(&mut self, vec: &[E]) -> Option> { + fn multi(&mut self, vec: &[Expr]) -> Option> { vec.iter() .map(|elem| self.expr(elem)) .collect::>() diff --git a/clippy_lints/src/drop_ref.rs b/clippy_lints/src/drop_ref.rs index 4fb4009dd2f..b369a3ae386 100644 --- a/clippy_lints/src/drop_ref.rs +++ b/clippy_lints/src/drop_ref.rs @@ -44,7 +44,7 @@ impl LateLintPass for Pass { if args.len() != 1 { return; } - check_drop_arg(cx, expr.span, &*args[0]); + check_drop_arg(cx, expr.span, &args[0]); } } } diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 7a0e1733553..b251b02632f 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -117,7 +117,7 @@ impl<'a, 'tcx, 'v, 'b> Visitor<'v> for InsertVisitor<'a, 'tcx, 'b> { let ExprMethodCall(ref name, _, ref params) = expr.node, params.len() == 3, &*name.node.as_str() == "insert", - get_item_name(self.cx, self.map) == get_item_name(self.cx, &*params[0]), + get_item_name(self.cx, self.map) == get_item_name(self.cx, ¶ms[0]), SpanlessEq::new(self.cx).eq_expr(self.key, ¶ms[1]) ], { span_lint_and_then(self.cx, MAP_ENTRY, self.span, diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index c81fcdc8624..be93699bae6 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -4,7 +4,6 @@ use rustc::ty; use rustc::hir::*; use syntax::ast::{Lit, LitKind, Name}; use syntax::codemap::{Span, Spanned}; -use syntax::ptr::P; use utils::{get_item_name, in_macro, snippet, span_lint, span_lint_and_then, walk_ptrs_ty}; /// **What it does:** Checks for getting the length of something via `.len()` @@ -170,7 +169,7 @@ fn check_cmp(cx: &LateContext, span: Span, left: &Expr, right: &Expr, op: &str) } } -fn check_len_zero(cx: &LateContext, span: Span, name: &Name, args: &[P], lit: &Lit, op: &str) { +fn check_len_zero(cx: &LateContext, span: Span, name: &Name, args: &[Expr], lit: &Lit, op: &str) { if let Spanned { node: LitKind::Int(0, _), .. } = *lit { if &*name.as_str() == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) { span_lint_and_then(cx, LEN_ZERO, span, "length comparison to zero", |db| { diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 7c48b7a1177..53c6eae9188 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -8,11 +8,9 @@ use rustc_const_eval::eval_const_expr_partial; use std::borrow::Cow; use std::fmt; use syntax::codemap::Span; -use syntax::ptr::P; use utils::{get_trait_def_id, implements_trait, in_external_macro, in_macro, is_copy, match_path, match_trait_method, match_type, method_chain_args, return_ty, same_tys, snippet, span_lint, span_lint_and_then, span_note_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth}; -use utils::MethodArgs; use utils::paths; use utils::sugg; @@ -693,7 +691,7 @@ impl LateLintPass for Pass { } /// Checks for the `OR_FUN_CALL` lint. -fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[P]) { +fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir::Expr]) { /// Check for `unwrap_or(T::new())` or `unwrap_or(T::default())`. fn check_unwrap_or_default(cx: &LateContext, name: &str, fun: &hir::Expr, self_expr: &hir::Expr, arg: &hir::Expr, or_has_args: bool, span: Span) @@ -825,7 +823,7 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_t } } -fn lint_vec_extend(cx: &LateContext, expr: &hir::Expr, args: &MethodArgs) { +fn lint_vec_extend(cx: &LateContext, expr: &hir::Expr, args: &[hir::Expr]) { let arg_ty = cx.tcx.tables().expr_ty(&args[1]); if let Some(slice) = derefs_to_slice(cx, &args[1], arg_ty) { span_lint_and_then(cx, EXTEND_FROM_SLICE, expr.span, "use of `extend` to extend a Vec by a slice", |db| { @@ -838,7 +836,7 @@ fn lint_vec_extend(cx: &LateContext, expr: &hir::Expr, args: &MethodArgs) { } } -fn lint_string_extend(cx: &LateContext, expr: &hir::Expr, args: &MethodArgs) { +fn lint_string_extend(cx: &LateContext, expr: &hir::Expr, args: &[hir::Expr]) { let arg = &args[1]; if let Some(arglists) = method_chain_args(arg, &["chars"]) { let target = &arglists[0][0]; @@ -866,7 +864,7 @@ fn lint_string_extend(cx: &LateContext, expr: &hir::Expr, args: &MethodArgs) { } } -fn lint_extend(cx: &LateContext, expr: &hir::Expr, args: &MethodArgs) { +fn lint_extend(cx: &LateContext, expr: &hir::Expr, args: &[hir::Expr]) { let (obj_ty, _) = walk_ptrs_ty_depth(cx.tcx.tables().expr_ty(&args[0])); if match_type(cx, obj_ty, &paths::VEC) { lint_vec_extend(cx, expr, args); @@ -891,9 +889,7 @@ fn lint_cstring_as_ptr(cx: &LateContext, expr: &hir::Expr, new: &hir::Expr, unwr }} } -#[allow(ptr_arg)] -// Type of MethodArgs is potentially a Vec -fn lint_iter_nth(cx: &LateContext, expr: &hir::Expr, iter_args: &MethodArgs, is_mut: bool){ +fn lint_iter_nth(cx: &LateContext, expr: &hir::Expr, iter_args: &[hir::Expr], is_mut: bool){ let mut_str = if is_mut { "_mut" } else {""}; let caller_type = if derefs_to_slice(cx, &iter_args[0], cx.tcx.tables().expr_ty(&iter_args[0])).is_some() { "slice" @@ -917,7 +913,7 @@ fn lint_iter_nth(cx: &LateContext, expr: &hir::Expr, iter_args: &MethodArgs, is_ ); } -fn lint_get_unwrap(cx: &LateContext, expr: &hir::Expr, get_args: &MethodArgs, is_mut: bool) { +fn lint_get_unwrap(cx: &LateContext, expr: &hir::Expr, get_args: &[hir::Expr], is_mut: bool) { // Note: we don't want to lint `get_mut().unwrap` for HashMap or BTreeMap, // because they do not implement `IndexMut` let expr_ty = cx.tcx.tables().expr_ty(&get_args[0]); @@ -980,7 +976,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option Option(cx: &LateContext, expr: &'a Expr) -> Option<(MinMax, Constant, &' } } -fn fetch_const(args: &[P], m: MinMax) -> Option<(MinMax, Constant, &Expr)> { +fn fetch_const(args: &[Expr], m: MinMax) -> Option<(MinMax, Constant, &Expr)> { if args.len() != 2 { return None; } diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 190cef82db2..6ad63348920 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -8,7 +8,6 @@ use rustc_const_eval::EvalHint::ExprTypeChecked; use rustc_const_eval::eval_const_expr_partial; use rustc_const_math::ConstFloat; use syntax::codemap::{Span, Spanned, ExpnFormat}; -use syntax::ptr::P; use utils::{ get_item_name, get_parent_expr, implements_trait, in_macro, is_integer_literal, match_path, snippet, span_lint, span_lint_and_then, walk_ptrs_ty @@ -412,7 +411,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr, left: bool, op: S } -fn is_str_arg(cx: &LateContext, args: &[P]) -> bool { +fn is_str_arg(cx: &LateContext, args: &[Expr]) -> bool { args.len() == 1 && matches!(walk_ptrs_ty(cx.tcx.tables().expr_ty(&args[0])).sty, ty::TyStr) } diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 21aa21e08a4..b2cdb2cb49b 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -1,7 +1,6 @@ use rustc::lint::*; use rustc::ty::{TypeAndMut, TypeVariants, MethodCall, TyS}; use rustc::hir::*; -use syntax::ptr::P; use utils::span_lint; /// **What it does:** Detects giving a mutable reference to a function that only @@ -57,7 +56,7 @@ impl LateLintPass for UnnecessaryMutPassed { } } -fn check_arguments(cx: &LateContext, arguments: &[P], type_definition: &TyS, name: &str) { +fn check_arguments(cx: &LateContext, arguments: &[Expr], type_definition: &TyS, name: &str) { match type_definition.sty { TypeVariants::TyFnDef(_, _, fn_type) | TypeVariants::TyFnPtr(fn_type) => { diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index f397714e31e..973daa696b6 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -133,7 +133,7 @@ fn reduce_expression<'a>(cx: &LateContext, expr: &'a Expr) -> Option Some(vec![&**a, &**b]), Expr_::ExprArray(ref v) | - Expr_::ExprTup(ref v) => Some(v.iter().map(Deref::deref).collect()), + Expr_::ExprTup(ref v) => Some(v.iter().collect()), Expr_::ExprRepeat(ref inner, _) | Expr_::ExprCast(ref inner, _) | Expr_::ExprType(ref inner, _) | @@ -150,7 +150,7 @@ fn reduce_expression<'a>(cx: &LateContext, expr: &'a Expr) -> Option Some(args.iter().map(Deref::deref).collect()), + Some(Def::VariantCtor(..)) => Some(args.iter().collect()), _ => None, } } diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index b4505c89f3b..a7e16a56f38 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -107,7 +107,7 @@ impl LateLintPass for Transmute { e.span, "transmute from a reference to a pointer", |db| { - if let Some(arg) = sugg::Sugg::hir_opt(cx, &*args[0]) { + if let Some(arg) = sugg::Sugg::hir_opt(cx, &args[0]) { let sugg = if ptr_ty == rty { arg.as_ty(to_ty) } else { @@ -125,7 +125,7 @@ impl LateLintPass for Transmute { e.span, "transmute from an integer to a pointer", |db| { - if let Some(arg) = sugg::Sugg::hir_opt(cx, &*args[0]) { + if let Some(arg) = sugg::Sugg::hir_opt(cx, &args[0]) { db.span_suggestion(e.span, "try", arg.as_ty(&to_ty.to_string()).to_string()); } }, diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 74857232485..41c2861c222 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -5,7 +5,6 @@ use rustc::hir; use rustc::lint::LateContext; use syntax::ast; -use syntax::ptr::P; use utils::{is_expn_of, match_path, match_def_path, resolve_node, paths}; /// Convert a hir binary operator to the corresponding `ast` type. @@ -160,9 +159,9 @@ pub fn for_loop(expr: &hir::Expr) -> Option<(&hir::Pat, &hir::Expr, &hir::Expr)> /// Represent the pre-expansion arguments of a `vec!` invocation. pub enum VecArgs<'a> { /// `vec![elem; len]` - Repeat(&'a P, &'a P), + Repeat(&'a hir::Expr, &'a hir::Expr), /// `vec![a, b, c]` - Vec(&'a [P]), + Vec(&'a [hir::Expr]), } /// Returns the arguments of the `vec!` macro if this expression was expanded from `vec!`. diff --git a/clippy_lints/src/utils/hir.rs b/clippy_lints/src/utils/hir.rs index bd9969714a4..459cf238911 100644 --- a/clippy_lints/src/utils/hir.rs +++ b/clippy_lints/src/utils/hir.rs @@ -134,7 +134,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { } } - fn eq_exprs(&self, left: &[P], right: &[P]) -> bool { + fn eq_exprs(&self, left: &P<[Expr]>, right: &P<[Expr]>) -> bool { over(left, right, |l, r| self.eq_expr(l, r)) } @@ -510,7 +510,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { } } - pub fn hash_exprs(&mut self, e: &[P]) { + pub fn hash_exprs(&mut self, e: &P<[Expr]>) { for e in e { self.hash_expr(e); } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index d8458c3bbcf..47d693e03b2 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -292,14 +292,14 @@ pub fn resolve_node(cx: &LateContext, id: NodeId) -> Option { /// For example, if `expr` represents the `.baz()` in `foo.bar().baz()`, /// `matched_method_chain(expr, &["bar", "baz"])` will return a `Vec` containing the `Expr`s for /// `.bar()` and `.baz()` -pub fn method_chain_args<'a>(expr: &'a Expr, methods: &[&str]) -> Option> { +pub fn method_chain_args<'a>(expr: &'a Expr, methods: &[&str]) -> Option> { let mut current = expr; let mut matched = Vec::with_capacity(methods.len()); for method_name in methods.iter().rev() { // method chains are stored last -> first if let ExprMethodCall(ref name, _, ref args) = current.node { if name.node == *method_name { - matched.push(args); // build up `matched` backwards + matched.push(&**args); // build up `matched` backwards current = &args[0] // go to parent expression } else { return None;