From a82cd77b2b3583f8f0bd27c1c1b783fcf2e9dd6b Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 10 Jul 2017 10:17:40 +0200 Subject: [PATCH] Rustup to *rustc 1.20.0-nightly (d84693b93 2017-07-09)* --- clippy_lints/src/double_parens.rs | 2 +- clippy_lints/src/entry.rs | 8 ++++---- clippy_lints/src/eval_order_dependence.rs | 2 +- clippy_lints/src/len_zero.rs | 6 +++--- clippy_lints/src/loops.rs | 16 ++++++++-------- clippy_lints/src/map_clone.rs | 8 ++++---- clippy_lints/src/methods.rs | 16 ++++++++-------- clippy_lints/src/mut_reference.rs | 4 ++-- clippy_lints/src/open_options.rs | 8 ++++---- clippy_lints/src/precedence.rs | 2 +- clippy_lints/src/ranges.rs | 13 ++++++------- clippy_lints/src/strings.rs | 4 ++-- clippy_lints/src/unused_io_amount.rs | 8 ++++---- clippy_lints/src/utils/hir_utils.rs | 11 +++++------ clippy_lints/src/utils/inspector.rs | 4 ++-- clippy_lints/src/utils/mod.rs | 4 ++-- 16 files changed, 57 insertions(+), 59 deletions(-) diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index a5b469d9c6c..5ef16638878 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -48,7 +48,7 @@ impl EarlyLintPass for DoubleParens { } } }, - ExprKind::MethodCall(_, _, ref params) => { + ExprKind::MethodCall(_, ref params) => { if params.len() == 2 { let param = ¶ms[1]; if let ExprKind::Paren(_) = param.node { diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index fd43b5bb6c6..43d8357e335 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -89,9 +89,9 @@ fn check_cond<'a, 'tcx, 'b>( check: &'b Expr ) -> Option<(&'static str, &'b Expr, &'b Expr)> { if_let_chain! {[ - let ExprMethodCall(ref name, _, ref params) = check.node, + let ExprMethodCall(ref path, _, ref params) = check.node, params.len() >= 2, - name.node == "contains_key", + path.name == "contains_key", let ExprAddrOf(_, ref key) = params[1].node ], { let map = ¶ms[0]; @@ -123,9 +123,9 @@ struct InsertVisitor<'a, 'tcx: 'a, 'b> { impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> { fn visit_expr(&mut self, expr: &'tcx Expr) { if_let_chain! {[ - let ExprMethodCall(ref name, _, ref params) = expr.node, + let ExprMethodCall(ref path, _, ref params) = expr.node, params.len() == 3, - name.node == "insert", + path.name == "insert", get_item_name(self.cx, self.map) == get_item_name(self.cx, ¶ms[0]), SpanlessEq::new(self.cx).eq_expr(self.key, ¶ms[1]) ], { diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 81a94220ea1..765da9ea877 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -219,7 +219,7 @@ fn check_expr<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, expr: &'tcx Expr) -> St match expr.node { ExprArray(_) | ExprTup(_) | - ExprMethodCall(_, _, _) | + ExprMethodCall(..) | ExprCall(_, _) | ExprAssign(_, _) | ExprIndex(_, _) | diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index c6a74b22c99..4f97f939964 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -158,9 +158,9 @@ fn check_cmp(cx: &LateContext, span: Span, left: &Expr, right: &Expr, op: &str) } } match (&left.node, &right.node) { - (&ExprLit(ref lit), &ExprMethodCall(ref method, _, ref args)) | - (&ExprMethodCall(ref method, _, ref args), &ExprLit(ref lit)) => { - check_len_zero(cx, span, method.node, args, lit, op) + (&ExprLit(ref lit), &ExprMethodCall(ref method_path, _, ref args)) | + (&ExprMethodCall(ref method_path, _, ref args), &ExprLit(ref lit)) => { + check_len_zero(cx, span, method_path.name, args, lit, op) }, _ => (), } diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index becb423b5f2..c71a36ab9a7 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -405,10 +405,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { if let ExprMatch(ref match_expr, ref arms, MatchSource::WhileLetDesugar) = expr.node { let pat = &arms[0].pats[0].node; if let (&PatKind::TupleStruct(ref qpath, ref pat_args, _), - &ExprMethodCall(method_name, _, ref method_args)) = (pat, &match_expr.node) { + &ExprMethodCall(ref method_path, _, ref method_args)) = (pat, &match_expr.node) { let iter_expr = &method_args[0]; let lhs_constructor = last_path_segment(qpath); - if self.loop_count < 2 && method_name.node == "next" && + if self.loop_count < 2 && method_path.name == "next" && match_trait_method(cx, match_expr, &paths::ITERATOR) && lhs_constructor.name == "Some" && !is_refutable(cx, &pat_args[0]) && !is_iterator_used_after_while_let(cx, iter_expr) { @@ -428,7 +428,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { if let StmtSemi(ref expr, _) = stmt.node { if let ExprMethodCall(ref method, _, ref args) = expr.node { - if args.len() == 1 && method.node == "collect" && match_trait_method(cx, expr, &paths::ITERATOR) { + if args.len() == 1 && method.name == "collect" && match_trait_method(cx, expr, &paths::ITERATOR) { span_lint(cx, UNUSED_COLLECT, expr.span, @@ -660,9 +660,9 @@ fn check_for_loop_range<'a, 'tcx>( fn is_len_call(expr: &Expr, var: &Name) -> bool { if_let_chain! {[ - let ExprMethodCall(method, _, ref len_args) = expr.node, + let ExprMethodCall(ref method, _, ref len_args) = expr.node, len_args.len() == 1, - method.node == "len", + method.name == "len", let ExprPath(QPath::Resolved(_, ref path)) = len_args[0].node, path.segments.len() == 1, path.segments[0].name == *var @@ -747,11 +747,11 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) { if let ExprMethodCall(ref method, _, ref args) = arg.node { // just the receiver, no arguments if args.len() == 1 { - let method_name = method.node.as_str(); + let method_name = &*method.name.as_str(); // check for looping over x.iter() or x.iter_mut(), could use &x or &mut x if method_name == "iter" || method_name == "iter_mut" { if is_ref_iterable_type(cx, &args[0]) { - lint_iter_method(cx, args, arg, &method_name); + lint_iter_method(cx, args, arg, method_name); } } else if method_name == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) { let def_id = cx.tables.type_dependent_defs[&arg.id].def_id(); @@ -761,7 +761,7 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) { let fn_arg_tys = method_type.fn_sig(cx.tcx).inputs(); assert_eq!(fn_arg_tys.skip_binder().len(), 1); if fn_arg_tys.skip_binder()[0].is_region_ptr() { - lint_iter_method(cx, args, arg, &method_name); + lint_iter_method(cx, args, arg, method_name); } else { let object = snippet(cx, args[0].span, "_"); span_lint_and_sugg(cx, diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index 6b721a970a6..1661c71167e 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -28,8 +28,8 @@ pub struct Pass; impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { // call to .map() - if let ExprMethodCall(name, _, ref args) = expr.node { - if name.node == "map" && args.len() == 2 { + if let ExprMethodCall(ref method, _, ref args) = expr.node { + if method.name == "map" && args.len() == 2 { match args[1].node { ExprClosure(_, ref decl, closure_eid, _) => { let body = cx.tcx.hir.body(closure_eid); @@ -59,8 +59,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { } } // explicit clone() calls ( .map(|x| x.clone()) ) - else if let ExprMethodCall(clone_call, _, ref clone_args) = closure_expr.node { - if clone_call.node == "clone" && + else if let ExprMethodCall(ref clone_call, _, ref clone_args) = closure_expr.node { + if clone_call.name == "clone" && clone_args.len() == 1 && match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) && expr_eq_name(&clone_args[0], arg_ident) diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 031aad08c53..835b836f7ec 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -559,7 +559,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { } match expr.node { - hir::ExprMethodCall(name, _, ref args) => { + hir::ExprMethodCall(ref method_call, _, ref args) => { // Chain calls // GET_UNWRAP needs to be checked before general `UNWRAP` lints if let Some(arglists) = method_chain_args(expr, &["get", "unwrap"]) { @@ -604,17 +604,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { lint_iter_cloned_collect(cx, expr, arglists[0]); } - lint_or_fun_call(cx, expr, &name.node.as_str(), args); + lint_or_fun_call(cx, expr, &method_call.name.as_str(), args); let self_ty = cx.tables.expr_ty_adjusted(&args[0]); - if args.len() == 1 && name.node == "clone" { + if args.len() == 1 && method_call.name == "clone" { lint_clone_on_copy(cx, expr, &args[0], self_ty); } match self_ty.sty { ty::TyRef(_, ty) if ty.ty.sty == ty::TyStr => { for &(method, pos) in &PATTERN_METHODS { - if name.node == method && args.len() > pos { + if method_call.name == method && args.len() > pos { lint_single_char_pattern(cx, expr, &args[pos]); } } @@ -804,8 +804,8 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir: check_general_case(cx, name, fun.span, &args[0], &args[1], or_has_args, expr.span); } }, - hir::ExprMethodCall(fun, _, ref or_args) => { - check_general_case(cx, name, fun.span, &args[0], &args[1], !or_args.is_empty(), expr.span) + hir::ExprMethodCall(_, span, ref or_args) => { + check_general_case(cx, name, span, &args[0], &args[1], !or_args.is_empty(), expr.span) }, _ => {}, } @@ -981,8 +981,8 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: Ty) -> Option LateLintPass<'a, 'tcx> for UnnecessaryMutPassed { &print::to_string(print::NO_ANN, |s| s.print_qpath(path, false))); } }, - ExprMethodCall(ref name, _, ref arguments) => { + ExprMethodCall(ref path, _, ref arguments) => { let def_id = cx.tables.type_dependent_defs[&e.id].def_id(); let substs = cx.tables.node_substs(e.id); let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs); - check_arguments(cx, arguments, method_type, &name.node.as_str()) + check_arguments(cx, arguments, method_type, &path.name.as_str()) }, _ => (), } diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index b59c32005a3..429d02d068b 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -34,9 +34,9 @@ impl LintPass for NonSensical { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSensical { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { - if let ExprMethodCall(ref name, _, ref arguments) = e.node { + if let ExprMethodCall(ref path, _, ref arguments) = e.node { let (obj_ty, _) = walk_ptrs_ty_depth(cx.tables.expr_ty(&arguments[0])); - if name.node == "open" && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) { + if path.name == "open" && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) { let mut options = Vec::new(); get_open_options(cx, &arguments[0], &mut options); check_open_options(cx, &options, e.span); @@ -62,7 +62,7 @@ enum OpenOption { } fn get_open_options(cx: &LateContext, argument: &Expr, options: &mut Vec<(OpenOption, Argument)>) { - if let ExprMethodCall(ref name, _, ref arguments) = argument.node { + if let ExprMethodCall(ref path, _, ref arguments) = argument.node { let (obj_ty, _) = walk_ptrs_ty_depth(cx.tables.expr_ty(&arguments[0])); // Only proceed if this is a call on some object of type std::fs::OpenOptions @@ -81,7 +81,7 @@ fn get_open_options(cx: &LateContext, argument: &Expr, options: &mut Vec<(OpenOp _ => Argument::Unknown, }; - match &*name.node.as_str() { + match &*path.name.as_str() { "create" => { options.push((OpenOption::Create, argument_option)); }, diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index 08b4cf166f2..e7b34136891 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -75,7 +75,7 @@ impl EarlyLintPass for Precedence { } if let ExprKind::Unary(UnOp::Neg, ref rhs) = expr.node { - if let ExprKind::MethodCall(_, _, ref args) = rhs.node { + if let ExprKind::MethodCall(_, ref args) = rhs.node { if let Some(slf) = args.first() { if let ExprKind::Lit(ref lit) = slf.node { match lit.node { diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 4f4d6add1dd..037ebf8ba2c 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -1,6 +1,5 @@ use rustc::lint::*; use rustc::hir::*; -use syntax::codemap::Spanned; use utils::{is_integer_literal, paths, snippet, span_lint}; use utils::{higher, implements_trait, get_trait_def_id}; @@ -49,8 +48,8 @@ impl LintPass for StepByZero { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StepByZero { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { - if let ExprMethodCall(Spanned { node: ref name, .. }, _, ref args) = expr.node { - let name = name.as_str(); + if let ExprMethodCall(ref path, _, ref args) = expr.node { + let name = path.name.as_str(); // Range with step_by(0). if name == "step_by" && args.len() == 2 && has_step_by(cx, &args[0]) { @@ -69,14 +68,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StepByZero { let zip_arg = &args[1]; if_let_chain! {[ // .iter() call - let ExprMethodCall( Spanned { node: iter_name, .. }, _, ref iter_args ) = *iter, - iter_name == "iter", + let ExprMethodCall(ref iter_path, _, ref iter_args ) = *iter, + iter_path.name == "iter", // range expression in .zip() call: 0..x.len() let Some(higher::Range { start: Some(start), end: Some(end), .. }) = higher::range(zip_arg), is_integer_literal(start, 0), // .len() call - let ExprMethodCall(Spanned { node: len_name, .. }, _, ref len_args) = end.node, - len_name == "len" && len_args.len() == 1, + let ExprMethodCall(ref len_path, _, ref len_args) = end.node, + len_path.name == "len" && len_args.len() == 1, // .iter() and .len() called on same Path let ExprPath(QPath::Resolved(_, ref iter_path)) = iter_args[0].node, let ExprPath(QPath::Resolved(_, ref len_path)) = len_args[0].node, diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index a2801cb82e0..043d1dff8e5 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -142,8 +142,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes { use syntax::ast::LitKind; use utils::{snippet, in_macro}; - if let ExprMethodCall(ref name, _, ref args) = e.node { - if name.node == "as_bytes" { + if let ExprMethodCall(ref path, _, ref args) = e.node { + if path.name == "as_bytes" { if let ExprLit(ref lit) = args[0].node { if let LitKind::Str(ref lit_content, _) = lit.node { if lit_content.as_str().chars().all(|c| c.is_ascii()) && !in_macro(args[0].span) { diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index 1f19e454857..5a97254f3ad 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -55,8 +55,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount { } }, - hir::ExprMethodCall(ref symbol, _, ref args) => { - match &*symbol.node.as_str() { + hir::ExprMethodCall(ref path, _, ref args) => { + match &*path.name.as_str() { "expect" | "unwrap" | "unwrap_or" | "unwrap_or_else" => { check_method_call(cx, &args[0], expr); }, @@ -70,8 +70,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount { } fn check_method_call(cx: &LateContext, call: &hir::Expr, expr: &hir::Expr) { - if let hir::ExprMethodCall(ref symbol, _, _) = call.node { - let symbol = &*symbol.node.as_str(); + if let hir::ExprMethodCall(ref path, _, _) = call.node { + let symbol = &*path.name.as_str(); if match_trait_method(cx, call, &paths::IO_READ) && symbol == "read" { span_lint(cx, UNUSED_IO_AMOUNT, diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 5820f600434..bd7edf2f564 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -110,10 +110,9 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { over(&l.pats, &r.pats, |l, r| self.eq_pat(l, r)) }) }, - (&ExprMethodCall(ref l_name, ref l_tys, ref l_args), - &ExprMethodCall(ref r_name, ref r_tys, ref r_args)) => { - !self.ignore_fn && l_name.node == r_name.node && over(l_tys, r_tys, |l, r| self.eq_ty(l, r)) && - self.eq_exprs(l_args, r_args) + (&ExprMethodCall(ref l_path, _, ref l_args), + &ExprMethodCall(ref r_path, _, ref r_args)) => { + !self.ignore_fn && l_path == r_path && self.eq_exprs(l_args, r_args) }, (&ExprRepeat(ref le, ll_id), &ExprRepeat(ref re, rl_id)) => { self.eq_expr(le, re) && @@ -428,10 +427,10 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { s.hash(&mut self.s); }, - ExprMethodCall(ref name, ref _tys, ref args) => { + ExprMethodCall(ref path, ref _tys, ref args) => { let c: fn(_, _, _) -> _ = ExprMethodCall; c.hash(&mut self.s); - self.hash_name(&name.node); + self.hash_name(&path.name); self.hash_exprs(args); }, ExprRepeat(ref e, l_id) => { diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 19e205c9920..9962eca5075 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -175,9 +175,9 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) { print_expr(cx, arg, indent + 1); } }, - hir::ExprMethodCall(ref name, _, ref args) => { + hir::ExprMethodCall(ref path, _, ref args) => { println!("{}MethodCall", ind); - println!("{}method name: {}", ind, name.node); + println!("{}method name: {}", ind, path.name); for arg in args { print_expr(cx, arg, indent + 1); } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 66c99a1e1ef..5b53d6dbea7 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -336,8 +336,8 @@ pub fn method_chain_args<'a>(expr: &'a Expr, methods: &[&str]) -> Option first - if let ExprMethodCall(ref name, _, ref args) = current.node { - if name.node == *method_name { + if let ExprMethodCall(ref path, _, ref args) = current.node { + if path.name == *method_name { if args.iter().any(|e| in_macro(e.span)) { return None; }