From 8ed8ee895aab89add6101233e3cbceb19f7d6d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 29 May 2018 10:56:58 +0200 Subject: [PATCH] Update to nightly 2018-05-28 --- clippy_lints/src/format.rs | 4 +- clippy_lints/src/lib.rs | 4 +- clippy_lints/src/misc.rs | 4 +- clippy_lints/src/redundant_field_names.rs | 2 +- clippy_lints/src/shadow.rs | 4 +- clippy_lints/src/utils/author.rs | 4 +- clippy_lints/src/utils/higher.rs | 2 +- clippy_lints/src/utils/hir_utils.rs | 8 +- clippy_lints/src/utils/inspector.rs | 8 +- clippy_lints/src/utils/sugg.rs | 4 +- clippy_lints/src/write.rs | 8 +- tests/ui/for_loop.stderr | 36 +++--- tests/ui/implicit_hasher.stderr | 32 ++--- tests/ui/matches.stderr | 4 +- tests/ui/needless_pass_by_value.rs | 9 +- tests/ui/needless_pass_by_value.stderr | 144 +++++++++++----------- tests/ui/needless_range_loop.stderr | 6 +- tests/ui/op_ref.stderr | 2 +- 18 files changed, 141 insertions(+), 144 deletions(-) diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 25cff794f..f418681cf 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -147,9 +147,9 @@ fn check_unformatted(expr: &Expr) -> bool { if let ExprArray(ref exprs) = expr.node; if exprs.len() == 1; if let ExprStruct(_, ref fields, _) = exprs[0].node; - if let Some(format_field) = fields.iter().find(|f| f.name.node == "format"); + if let Some(format_field) = fields.iter().find(|f| f.ident.name == "format"); if let ExprStruct(_, ref fields, _) = format_field.expr.node; - if let Some(align_field) = fields.iter().find(|f| f.name.node == "width"); + if let Some(align_field) = fields.iter().find(|f| f.ident.name == "width"); if let ExprPath(ref qpath) = align_field.expr.node; if last_path_segment(qpath).name == "Implied"; then { diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 05902614d..1e75d42dd 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -10,13 +10,13 @@ #![recursion_limit = "256"] #![allow(stable_features)] #![feature(iterator_find_map)] - +#![feature(macro_at_most_once_rep)] extern crate cargo_metadata; #[macro_use] extern crate rustc; -extern crate rustc_typeck; extern crate rustc_target; +extern crate rustc_typeck; extern crate syntax; extern crate syntax_pos; diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 080a2716f..2654def13 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -392,8 +392,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { None } }, - ExprField(_, spanned) => { - let name = spanned.node.as_str(); + ExprField(_, ident) => { + let name = ident.as_str(); if name.starts_with('_') && !name.starts_with("__") { Some(name) } else { diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index 5e24361f1..a0465f211 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -45,7 +45,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantFieldNames { if let ExprStruct(_, ref fields, _) = expr.node { for field in fields { - let name = field.name.node; + let name = field.ident.name; if match_var(&field.expr, name) && !field.is_shorthand { span_lint_and_sugg ( diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 05a6650ae..59f18d215 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -187,10 +187,10 @@ fn check_pat<'a, 'tcx>( PatKind::Struct(_, ref pfields, _) => if let Some(init_struct) = init { if let ExprStruct(_, ref efields, _) = init_struct.node { for field in pfields { - let name = field.node.name; + let name = field.node.ident.name; let efield = efields .iter() - .find(|f| f.name.node == name) + .find(|f| f.ident.name == name) .map(|f| &*f.expr); check_pat(cx, &field.node.pat, efield, span, bindings); } diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index dd43a0d21..79fde40b4 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -383,11 +383,11 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { self.current = value_pat; self.visit_expr(value); }, - Expr_::ExprField(ref object, ref field_name) => { + Expr_::ExprField(ref object, ref field_ident) => { let obj_pat = self.next("object"); let field_name_pat = self.next("field_name"); println!("Field(ref {}, ref {}) = {};", obj_pat, field_name_pat, current); - println!(" if {}.node.as_str() == {:?}", field_name_pat, field_name.node.as_str()); + println!(" if {}.node.as_str() == {:?}", field_name_pat, field_ident.name.as_str()); self.current = obj_pat; self.visit_expr(object); }, diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 9a4fcd45d..5a20bfc81 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -77,7 +77,7 @@ pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> O /// Find the field named `name` in the field. Always return `Some` for /// convenience. fn get_field<'a>(name: &str, fields: &'a [hir::Field]) -> Option<&'a hir::Expr> { - let expr = &fields.iter().find(|field| field.name.node == name)?.expr; + let expr = &fields.iter().find(|field| field.ident.name == name)?.expr; Some(expr) } diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index deaa796aa..0b70d61da 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -101,7 +101,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { (&ExprCast(ref lx, ref lt), &ExprCast(ref rx, ref rt)) | (&ExprType(ref lx, ref lt), &ExprType(ref rx, ref rt)) => self.eq_expr(lx, rx) && self.eq_ty(lt, rt), (&ExprField(ref l_f_exp, ref l_f_ident), &ExprField(ref r_f_exp, ref r_f_ident)) => { - l_f_ident.node == r_f_ident.node && self.eq_expr(l_f_exp, r_f_exp) + l_f_ident.name == r_f_ident.name && self.eq_expr(l_f_exp, r_f_exp) }, (&ExprIndex(ref la, ref li), &ExprIndex(ref ra, ref ri)) => self.eq_expr(la, ra) && self.eq_expr(li, ri), (&ExprIf(ref lc, ref lt, ref le), &ExprIf(ref rc, ref rt, ref re)) => { @@ -149,7 +149,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { } fn eq_field(&mut self, left: &Field, right: &Field) -> bool { - left.name.node == right.name.node && self.eq_expr(&left.expr, &right.expr) + left.ident.name == right.ident.name && self.eq_expr(&left.expr, &right.expr) } fn eq_lifetime(&mut self, left: &Lifetime, right: &Lifetime) -> bool { @@ -419,7 +419,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { let c: fn(_, _) -> _ = ExprField; c.hash(&mut self.s); self.hash_expr(e); - self.hash_name(&f.node); + self.hash_name(&f.name); }, ExprIndex(ref a, ref i) => { let c: fn(_, _) -> _ = ExprIndex; @@ -502,7 +502,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { self.hash_qpath(path); for f in fields { - self.hash_name(&f.name.node); + self.hash_name(&f.ident.name); self.hash_expr(&f.expr); } diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 6c3d8bc29..03682a197 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -268,9 +268,9 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) { println!("{}rhs:", ind); print_expr(cx, rhs, indent + 1); }, - hir::ExprField(ref e, ref name) => { + hir::ExprField(ref e, ref ident) => { println!("{}Field", ind); - println!("{}field name: {}", ind, name.node); + println!("{}field name: {}", ind, ident.name); println!("{}struct expr:", ind); print_expr(cx, e, indent + 1); }, @@ -322,7 +322,7 @@ fn print_expr(cx: &LateContext, expr: &hir::Expr, indent: usize) { println!("{}Struct", ind); println!("{}path: {:?}", ind, path); for field in fields { - println!("{}field \"{}\":", ind, field.name.node); + println!("{}field \"{}\":", ind, field.ident.name); print_expr(cx, &field.expr, indent + 1); } if let Some(ref base) = *base { @@ -433,7 +433,7 @@ fn print_pat(cx: &LateContext, pat: &hir::Pat, indent: usize) { println!("{}ignore leftover fields: {}", ind, ignore); println!("{}fields:", ind); for field in fields { - println!("{} field name: {}", ind, field.node.name); + println!("{} field name: {}", ind, field.node.ident.name); if field.node.is_shorthand { println!("{} in shorthand notation", ind); } diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index a9e5a3222..e7f63bb9a 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -97,6 +97,7 @@ impl<'a> Sugg<'a> { ast::ExprKind::Closure(..) | ast::ExprKind::If(..) | ast::ExprKind::IfLet(..) | + ast::ExprKind::ObsoleteInPlace(..) | ast::ExprKind::Unary(..) | ast::ExprKind::Match(..) => Sugg::MaybeParen(snippet), ast::ExprKind::Block(..) | @@ -320,6 +321,7 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg, rhs: &Sugg) -> Sugg<'static> { AssocOp::ShiftRight | AssocOp::Subtract => format!("{} {} {}", lhs, op.to_ast_binop().expect("Those are AST ops").to_string(), rhs), AssocOp::Assign => format!("{} = {}", lhs, rhs), + AssocOp::ObsoleteInPlace => format!("in ({}) {}", lhs, rhs), AssocOp::AssignOp(op) => format!("{} {}= {}", lhs, token_to_string(&token::BinOp(op)), rhs), AssocOp::As => format!("{} as {}", lhs, rhs), AssocOp::DotDot => format!("{}..{}", lhs, rhs), @@ -360,7 +362,7 @@ fn associativity(op: &AssocOp) -> Associativity { use syntax::util::parser::AssocOp::*; match *op { - Assign | AssignOp(_) => Associativity::Right, + ObsoleteInPlace | Assign | AssignOp(_) => Associativity::Right, Add | BitAnd | BitOr | BitXor | LAnd | LOr | Multiply | As | Colon => Associativity::Both, Divide | Equal | diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 9a32d4e69..fdd4f8ced 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -375,7 +375,7 @@ where if let ExprArray(ref format_exprs) = format_expr.node; if format_exprs.len() >= 1; if let ExprStruct(_, ref fields, _) = format_exprs[idx].node; - if let Some(format_field) = fields.iter().find(|f| f.name.node == "format"); + if let Some(format_field) = fields.iter().find(|f| f.ident.name == "format"); if check_unformatted(&format_field.expr); then { lint_fn(tup_val.span); @@ -469,13 +469,13 @@ fn is_in_debug_impl(cx: &LateContext, expr: &Expr) -> bool { pub fn check_unformatted(format_field: &Expr) -> bool { if_chain! { if let ExprStruct(_, ref fields, _) = format_field.node; - if let Some(width_field) = fields.iter().find(|f| f.name.node == "width"); + if let Some(width_field) = fields.iter().find(|f| f.ident.name == "width"); if let ExprPath(ref qpath) = width_field.expr.node; if last_path_segment(qpath).name == "Implied"; - if let Some(align_field) = fields.iter().find(|f| f.name.node == "align"); + if let Some(align_field) = fields.iter().find(|f| f.ident.name == "align"); if let ExprPath(ref qpath) = align_field.expr.node; if last_path_segment(qpath).name == "Unknown"; - if let Some(precision_field) = fields.iter().find(|f| f.name.node == "precision"); + if let Some(precision_field) = fields.iter().find(|f| f.ident.name == "precision"); if let ExprPath(ref qpath_precision) = precision_field.expr.node; if last_path_segment(qpath_precision).name == "Implied"; then { diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index 34b3527fb..582ca84b1 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -78,7 +78,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 86 | for in &vec { - | + | ^^^^^^ ^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:95:14 @@ -88,7 +88,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 95 | for in &vec { - | + | ^^^^^^ ^^^^ error: the loop variable `j` is only used to index `STATIC`. --> $DIR/for_loop.rs:100:14 @@ -98,7 +98,7 @@ error: the loop variable `j` is only used to index `STATIC`. help: consider using an iterator | 100 | for in STATIC.iter().take(4) { - | + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `j` is only used to index `CONST`. --> $DIR/for_loop.rs:104:14 @@ -108,7 +108,7 @@ error: the loop variable `j` is only used to index `CONST`. help: consider using an iterator | 104 | for in CONST.iter().take(4) { - | + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is used to index `vec` --> $DIR/for_loop.rs:108:14 @@ -118,7 +118,7 @@ error: the loop variable `i` is used to index `vec` help: consider using an iterator | 108 | for (i, ) in vec.iter().enumerate() { - | + | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec2`. --> $DIR/for_loop.rs:116:14 @@ -128,7 +128,7 @@ error: the loop variable `i` is only used to index `vec2`. help: consider using an iterator | 116 | for in vec2.iter().take(vec.len()) { - | + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:120:14 @@ -138,7 +138,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 120 | for in vec.iter().skip(5) { - | + | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:124:14 @@ -148,7 +148,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 124 | for in vec.iter().take(MAX_LEN) { - | + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:128:14 @@ -158,7 +158,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 128 | for in vec.iter().take(MAX_LEN + 1) { - | + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:132:14 @@ -168,7 +168,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 132 | for in vec.iter().take(10).skip(5) { - | + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. --> $DIR/for_loop.rs:136:14 @@ -178,7 +178,7 @@ error: the loop variable `i` is only used to index `vec`. help: consider using an iterator | 136 | for in vec.iter().take(10 + 1).skip(5) { - | + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is used to index `vec` --> $DIR/for_loop.rs:140:14 @@ -188,7 +188,7 @@ error: the loop variable `i` is used to index `vec` help: consider using an iterator | 140 | for (i, ) in vec.iter().enumerate().skip(5) { - | + | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is used to index `vec` --> $DIR/for_loop.rs:144:14 @@ -198,7 +198,7 @@ error: the loop variable `i` is used to index `vec` help: consider using an iterator | 144 | for (i, ) in vec.iter().enumerate().take(10).skip(5) { - | + | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run --> $DIR/for_loop.rs:148:14 @@ -384,7 +384,7 @@ error: you seem to want to iterate on a map's values help: use the corresponding method | 385 | for v in m.values() { - | + | ^ ^^^^^^^^^^ error: you seem to want to iterate on a map's values --> $DIR/for_loop.rs:390:19 @@ -394,7 +394,7 @@ error: you seem to want to iterate on a map's values help: use the corresponding method | 390 | for v in (*m).values() { - | + | ^ ^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values --> $DIR/for_loop.rs:398:19 @@ -404,7 +404,7 @@ error: you seem to want to iterate on a map's values help: use the corresponding method | 398 | for v in m.values_mut() { - | + | ^ ^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values --> $DIR/for_loop.rs:403:19 @@ -414,7 +414,7 @@ error: you seem to want to iterate on a map's values help: use the corresponding method | 403 | for v in (*m).values_mut() { - | + | ^ ^^^^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's keys --> $DIR/for_loop.rs:409:24 @@ -424,7 +424,7 @@ error: you seem to want to iterate on a map's keys help: use the corresponding method | 409 | for k in rm.keys() { - | + | ^ ^^^^^^^^^ error: it looks like you're manually copying between slices --> $DIR/for_loop.rs:462:14 diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index cdba5372b..f41ce4051 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -8,11 +8,11 @@ error: impl for `HashMap` should be generalized over different hashers help: consider adding a type parameter | 11 | impl Foo for HashMap { - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | 17 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) - | + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:20:36 @@ -22,11 +22,11 @@ error: impl for `HashMap` should be generalized over different hashers help: consider adding a type parameter | 20 | impl Foo for (HashMap,) { - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | 22 | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) - | + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:25:19 @@ -36,11 +36,11 @@ error: impl for `HashMap` should be generalized over different hashers help: consider adding a type parameter | 25 | impl Foo for HashMap { - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: ...and use generic constructor | 27 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) - | + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:43:32 @@ -50,11 +50,11 @@ error: impl for `HashSet` should be generalized over different hashers help: consider adding a type parameter | 43 | impl Foo for HashSet { - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ help: ...and use generic constructor | 45 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) - | + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:48:19 @@ -64,11 +64,11 @@ error: impl for `HashSet` should be generalized over different hashers help: consider adding a type parameter | 48 | impl Foo for HashSet { - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ help: ...and use generic constructor | 50 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) - | + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:65:23 @@ -78,7 +78,7 @@ error: parameter of type `HashMap` should be generalized over different hashers help: consider adding a type parameter | 65 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:65:53 @@ -88,7 +88,7 @@ error: parameter of type `HashSet` should be generalized over different hashers help: consider adding a type parameter | 65 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:70:43 @@ -101,11 +101,11 @@ error: impl for `HashMap` should be generalized over different hashers help: consider adding a type parameter | 70 | impl Foo for HashMap { - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | 72 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) - | + | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:78:33 @@ -118,7 +118,7 @@ error: parameter of type `HashMap` should be generalized over different hashers help: consider adding a type parameter | 78 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:78:63 @@ -131,7 +131,7 @@ error: parameter of type `HashSet` should be generalized over different hashers help: consider adding a type parameter | 78 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ error: aborting due to 10 previous errors diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index cc43cdb25..e0afc939b 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -65,7 +65,7 @@ error: you don't need to add `&` to all patterns help: instead of prefixing all patterns with `&`, you can dereference the expression | 57 | if let None = *a { - | + | ^^^^ ^^ error: you don't need to add `&` to both the expression and the patterns --> $DIR/matches.rs:62:5 @@ -77,7 +77,7 @@ error: you don't need to add `&` to both the expression and the patterns help: try | 62 | if let None = b { - | + | ^^^^ ^ error: some ranges overlap --> $DIR/matches.rs:71:9 diff --git a/tests/ui/needless_pass_by_value.rs b/tests/ui/needless_pass_by_value.rs index 3459d3820..322df0b87 100644 --- a/tests/ui/needless_pass_by_value.rs +++ b/tests/ui/needless_pass_by_value.rs @@ -1,11 +1,6 @@ - - - #![warn(needless_pass_by_value)] #![allow(dead_code, single_match, if_let_redundant_pattern_matching, many_single_char_names, option_option)] -#![feature(collections_range)] - use std::borrow::Borrow; use std::convert::AsRef; @@ -116,8 +111,8 @@ trait FalsePositive { extern "C" fn ext(x: String) -> usize { x.len() } // whitelist RangeArgument -fn range>(range: T) { - let _ = range.start(); +fn range>(range: T) { + let _ = range.start_bound(); } struct CopyWrapper(u32); diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index 469c16fa3..2fef0595c 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -1,187 +1,187 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:14:23 - | -14 | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { - | ^^^^^^ help: consider changing the type to: `&[T]` - | - = note: `-D needless-pass-by-value` implied by `-D warnings` + --> $DIR/needless_pass_by_value.rs:9:23 + | +9 | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { + | ^^^^^^ help: consider changing the type to: `&[T]` + | + = note: `-D needless-pass-by-value` implied by `-D warnings` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:28:11 + --> $DIR/needless_pass_by_value.rs:23:11 | -28 | fn bar(x: String, y: Wrapper) { +23 | fn bar(x: String, y: Wrapper) { | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:28:22 + --> $DIR/needless_pass_by_value.rs:23:22 | -28 | fn bar(x: String, y: Wrapper) { +23 | fn bar(x: String, y: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:34:71 + --> $DIR/needless_pass_by_value.rs:29:71 | -34 | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { +29 | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { | ^ help: consider taking a reference instead: `&V` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:46:18 + --> $DIR/needless_pass_by_value.rs:41:18 | -46 | fn test_match(x: Option>, y: Option>) { +41 | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead | -46 | fn test_match(x: &Option>, y: Option>) { -47 | match *x { +41 | fn test_match(x: &Option>, y: Option>) { +42 | match *x { | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:59:24 + --> $DIR/needless_pass_by_value.rs:54:24 | -59 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +54 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:59:36 + --> $DIR/needless_pass_by_value.rs:54:36 | -59 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +54 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead | -59 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { -60 | let Wrapper(s) = z; // moved -61 | let Wrapper(ref t) = *y; // not moved -62 | let Wrapper(_) = *y; // still not moved +54 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { +55 | let Wrapper(s) = z; // moved +56 | let Wrapper(ref t) = *y; // not moved +57 | let Wrapper(_) = *y; // still not moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:75:49 + --> $DIR/needless_pass_by_value.rs:70:49 | -75 | fn test_blanket_ref(_foo: T, _serializable: S) {} +70 | fn test_blanket_ref(_foo: T, _serializable: S) {} | ^ help: consider taking a reference instead: `&T` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:77:18 + --> $DIR/needless_pass_by_value.rs:72:18 | -77 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +72 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:77:29 + --> $DIR/needless_pass_by_value.rs:72:29 | -77 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +72 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider changing the type to | -77 | fn issue_2114(s: String, t: &str, u: Vec, v: Vec) { +72 | fn issue_2114(s: String, t: &str, u: Vec, v: Vec) { | ^^^^ help: change `t.clone()` to | -79 | let _ = t.to_string(); +74 | let _ = t.to_string(); | ^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:77:40 + --> $DIR/needless_pass_by_value.rs:72:40 | -77 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +72 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider taking a reference instead: `&Vec` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:77:53 + --> $DIR/needless_pass_by_value.rs:72:53 | -77 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +72 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider changing the type to | -77 | fn issue_2114(s: String, t: String, u: Vec, v: &[i32]) { +72 | fn issue_2114(s: String, t: String, u: Vec, v: &[i32]) { | ^^^^^^ help: change `v.clone()` to | -81 | let _ = v.to_owned(); +76 | let _ = v.to_owned(); | ^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:89:12 + --> $DIR/needless_pass_by_value.rs:84:12 | -89 | s: String, +84 | s: String, | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:90:12 + --> $DIR/needless_pass_by_value.rs:85:12 | -90 | t: String, +85 | t: String, | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:102:13 - | -102 | _u: U, - | ^ help: consider taking a reference instead: `&U` + --> $DIR/needless_pass_by_value.rs:97:13 + | +97 | _u: U, + | ^ help: consider taking a reference instead: `&U` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:103:13 - | -103 | _s: Self, - | ^^^^ help: consider taking a reference instead: `&Self` + --> $DIR/needless_pass_by_value.rs:98:13 + | +98 | _s: Self, + | ^^^^ help: consider taking a reference instead: `&Self` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:125:24 + --> $DIR/needless_pass_by_value.rs:120:24 | -125 | fn bar_copy(x: u32, y: CopyWrapper) { +120 | fn bar_copy(x: u32, y: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:123:1 + --> $DIR/needless_pass_by_value.rs:118:1 | -123 | struct CopyWrapper(u32); +118 | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:131:29 + --> $DIR/needless_pass_by_value.rs:126:29 | -131 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { +126 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:123:1 + --> $DIR/needless_pass_by_value.rs:118:1 | -123 | struct CopyWrapper(u32); +118 | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:131:45 + --> $DIR/needless_pass_by_value.rs:126:45 | -131 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { +126 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:123:1 + --> $DIR/needless_pass_by_value.rs:118:1 | -123 | struct CopyWrapper(u32); +118 | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead | -131 | fn test_destructure_copy(x: CopyWrapper, y: &CopyWrapper, z: CopyWrapper) { -132 | let CopyWrapper(s) = z; // moved -133 | let CopyWrapper(ref t) = *y; // not moved -134 | let CopyWrapper(_) = *y; // still not moved +126 | fn test_destructure_copy(x: CopyWrapper, y: &CopyWrapper, z: CopyWrapper) { +127 | let CopyWrapper(s) = z; // moved +128 | let CopyWrapper(ref t) = *y; // not moved +129 | let CopyWrapper(_) = *y; // still not moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:131:61 + --> $DIR/needless_pass_by_value.rs:126:61 | -131 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { +126 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:123:1 + --> $DIR/needless_pass_by_value.rs:118:1 | -123 | struct CopyWrapper(u32); +118 | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead | -131 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: &CopyWrapper) { -132 | let CopyWrapper(s) = *z; // moved +126 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: &CopyWrapper) { +127 | let CopyWrapper(s) = *z; // moved | error: aborting due to 20 previous errors diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index 84ccd5d46..c394469c1 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -8,7 +8,7 @@ error: the loop variable `i` is only used to index `ns`. help: consider using an iterator | 8 | for in ns.iter().take(10).skip(3) { - | + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `ms`. --> $DIR/needless_range_loop.rs:29:14 @@ -18,7 +18,7 @@ error: the loop variable `i` is only used to index `ms`. help: consider using an iterator | 29 | for in &mut ms { - | + | ^^^^^^ ^^^^^^^ error: the loop variable `i` is only used to index `ms`. --> $DIR/needless_range_loop.rs:35:14 @@ -28,7 +28,7 @@ error: the loop variable `i` is only used to index `ms`. help: consider using an iterator | 35 | for in &mut ms { - | + | ^^^^^^ ^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index 28223563d..4a6ff6fe6 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -8,7 +8,7 @@ error: needlessly taken reference of both operands help: use the values directly | 13 | let foo = 5 - 6; - | + | ^ ^ error: taken reference of right operand --> $DIR/op_ref.rs:21:8