Rustup to *rustc 1.20.0-nightly (d84693b93 2017-07-09)*

This commit is contained in:
Oliver Schneider 2017-07-10 10:17:40 +02:00
parent fd7dda097b
commit a82cd77b2b
16 changed files with 57 additions and 59 deletions

View file

@ -48,7 +48,7 @@ impl EarlyLintPass for DoubleParens {
}
}
},
ExprKind::MethodCall(_, _, ref params) => {
ExprKind::MethodCall(_, ref params) => {
if params.len() == 2 {
let param = &params[1];
if let ExprKind::Paren(_) = param.node {

View file

@ -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 = &params[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, &params[0]),
SpanlessEq::new(self.cx).eq_expr(self.key, &params[1])
], {

View file

@ -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(_, _) |

View file

@ -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)
},
_ => (),
}

View file

@ -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,

View file

@ -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)

View file

@ -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<sugg::S
}
}
if let hir::ExprMethodCall(name, _, ref args) = expr.node {
if name.node == "iter" && may_slice(cx, cx.tables.expr_ty(&args[0])) {
if let hir::ExprMethodCall(ref path, _, ref args) = expr.node {
if path.name == "iter" && may_slice(cx, cx.tables.expr_ty(&args[0])) {
sugg::Sugg::hir_opt(cx, &args[0]).map(|sugg| sugg.addr())
} else {
None

View file

@ -44,11 +44,11 @@ impl<'a, 'tcx> 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())
},
_ => (),
}

View file

@ -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));
},

View file

@ -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 {

View file

@ -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,

View file

@ -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) {

View file

@ -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,

View file

@ -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) => {

View file

@ -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);
}

View file

@ -336,8 +336,8 @@ pub fn method_chain_args<'a>(expr: &'a Expr, methods: &[&str]) -> Option<Vec<&'a
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 {
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;
}