diff --git a/CHANGELOG.md b/CHANGELOG.md index 16307e5a2f3..85363172e3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## 0.0.130 - 2017-05-01 +* Update to *rustc 1.19.0-nightly (6a5fc9eec 2017-05-02)* + ## 0.0.129 — 2017-05-01 * Update to *rustc 1.19.0-nightly (06fb4d256 2017-04-30)* diff --git a/Cargo.toml b/Cargo.toml index 4ad24ffd9ee..014a06c2631 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.129" +version = "0.0.130" authors = [ "Manish Goregaokar ", "Andre Bogus ", @@ -30,7 +30,7 @@ test = false [dependencies] # begin automatic update -clippy_lints = { version = "0.0.129", path = "clippy_lints" } +clippy_lints = { version = "0.0.130", path = "clippy_lints" } # end automatic update cargo_metadata = "0.1.1" diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index 33564a8df23..54cdb962d3b 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "clippy_lints" # begin automatic update -version = "0.0.129" +version = "0.0.130" # end automatic update authors = [ "Manish Goregaokar ", diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index fd357feab6b..7727074f7b3 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -386,6 +386,7 @@ fn bool_expr(&self, e: &Expr) { "this boolean expression can be simplified", |db| for suggestion in &improvements { db.span_suggestion(e.span, "try", suggest(self.cx, suggestion, &h2q.terminals)); + break; // FIXME: multiple suggestions in rustc are broken }); } } diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index eac72e12e90..e094e8da3fc 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -299,7 +299,7 @@ fn fetch_path(&mut self, qpath: &QPath, id: NodeId) -> Option { tcx: self.tcx, tables: self.tcx.typeck_tables_of(def_id), needed_resolution: false, - substs, + substs: substs, }; let body = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) { self.tcx.mir_const_qualif(def_id); diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index 6dedbe4b673..b2183ff1c73 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -54,9 +54,9 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { if let ExprBinary(ref op, ref left, ref right) = e.node { if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) { span_lint(cx, - EQ_OP, - e.span, - &format!("equal expressions as operands to `{}`", op.node.as_str())); + EQ_OP, + e.span, + &format!("equal expressions as operands to `{}`", op.node.as_str())); return; } let (trait_id, requires_ref) = match op.node { @@ -91,32 +91,30 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { // either operator autorefs or both args are copyable if (requires_ref || (lcpy && rcpy)) && implements_trait(cx, lty, trait_id, &[rty], None) { span_lint_and_then(cx, - OP_REF, - e.span, - "needlessly taken reference of both operands", - |db| { + OP_REF, + e.span, + "needlessly taken reference of both operands", + |db| { let lsnip = snippet(cx, l.span, "...").to_string(); let rsnip = snippet(cx, r.span, "...").to_string(); multispan_sugg(db, - "use the values directly".to_string(), - vec![(left.span, lsnip), + "use the values directly".to_string(), + vec![(left.span, lsnip), (right.span, rsnip)]); }) - } else if lcpy && !rcpy && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) { - span_lint_and_then(cx, - OP_REF, - e.span, - "needlessly taken reference of left operand", - |db| { + } else if lcpy && !rcpy && + implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) { + span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| { let lsnip = snippet(cx, l.span, "...").to_string(); db.span_suggestion(left.span, "use the left value directly", lsnip); }) - } else if !lcpy && rcpy && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) { + } else if !lcpy && rcpy && + implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) { span_lint_and_then(cx, - OP_REF, - e.span, - "needlessly taken reference of right operand", - |db| { + OP_REF, + e.span, + "needlessly taken reference of right operand", + |db| { let rsnip = snippet(cx, r.span, "...").to_string(); db.span_suggestion(right.span, "use the right value directly", rsnip); }) @@ -126,7 +124,8 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { (&ExprAddrOf(_, ref l), _) => { let lty = cx.tables.expr_ty(l); let lcpy = is_copy(cx, lty, parent); - if (requires_ref || lcpy) && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) { + if (requires_ref || lcpy) && + implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) { span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| { let lsnip = snippet(cx, l.span, "...").to_string(); db.span_suggestion(left.span, "use the left value directly", lsnip); @@ -137,10 +136,11 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { (_, &ExprAddrOf(_, ref r)) => { let rty = cx.tables.expr_ty(r); let rcpy = is_copy(cx, rty, parent); - if (requires_ref || rcpy) && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) { + if (requires_ref || rcpy) && + implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty], None) { span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |db| { let rsnip = snippet(cx, r.span, "...").to_string(); - db.span_suggestion(left.span, "use the right value directly", rsnip); + db.span_suggestion(right.span, "use the right value directly", rsnip); }) } }, diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 0db45efeb38..a36951b5f36 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -65,7 +65,7 @@ fn check_fn( _: &'tcx FnDecl, body: &'tcx Body, _: Span, - _id: NodeId + node_id: NodeId ) { // we store the infcx because it is expensive to recreate // the context each time. @@ -78,8 +78,10 @@ fn check_fn( }; let infcx = cx.tcx.borrowck_fake_infer_ctxt(body.id()); + let fn_def_id = cx.tcx.hir.local_def_id(node_id); + let region_maps = &cx.tcx.region_maps(fn_def_id); { - let mut vis = ExprUseVisitor::new(&mut v, &infcx); + let mut vis = ExprUseVisitor::new(&mut v, region_maps, &infcx); vis.consume_body(body); } @@ -150,7 +152,7 @@ fn borrow( borrow_id: NodeId, _: Span, cmt: cmt<'tcx>, - _: &ty::Region, + _: ty::Region, _: ty::BorrowKind, loan_cause: LoanCause ) { diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index ea68b53b57b..148eb616be0 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -173,7 +173,7 @@ fn check_len_zero(cx: &LateContext, span: Span, name: Name, args: &[Expr], lit: if name == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) { span_lint_and_then(cx, LEN_ZERO, span, "length comparison to zero", |db| { db.span_suggestion(span, - "consider using `is_empty`", + "using `is_empty` is more concise:", format!("{}{}.is_empty()", op, snippet(cx, args[0].span, "_"))); }); } @@ -199,7 +199,8 @@ fn is_is_empty(cx: &LateContext, item: &ty::AssociatedItem) -> bool { /// Check the inherent impl's items for an `is_empty(self)` method. fn has_is_empty_impl(cx: &LateContext, id: DefId) -> bool { - cx.tcx.inherent_impls(id) + cx.tcx + .inherent_impls(id) .iter() .any(|imp| cx.tcx.associated_items(*imp).any(|item| is_is_empty(cx, &item))) } diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 7f0174fce58..8c2712104bd 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -509,8 +509,11 @@ fn check_for_loop_range<'a, 'tcx>( // ensure that the indexed variable was declared before the loop, see #601 if let Some(indexed_extent) = indexed_extent { - let pat_extent = cx.tcx.region_maps.var_scope(pat.id); - if cx.tcx.region_maps.is_subscope_of(indexed_extent, pat_extent) { + let parent_id = cx.tcx.hir.get_parent(expr.id); + let parent_def_id = cx.tcx.hir.local_def_id(parent_id); + let region_maps = cx.tcx.region_maps(parent_def_id); + let pat_extent = region_maps.var_scope(pat.id); + if region_maps.is_subscope_of(indexed_extent, pat_extent) { return; } } @@ -872,7 +875,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { struct VarVisitor<'a, 'tcx: 'a> { cx: &'a LateContext<'a, 'tcx>, // context reference var: DefId, // var name to look for as index - indexed: HashMap>, // indexed variables, the extent is None for global + indexed: HashMap>>, // indexed variables, the extent is None for global nonindex: bool, // has the var been used otherwise? } @@ -895,7 +898,9 @@ fn visit_expr(&mut self, expr: &'tcx Expr) { let def_id = def.def_id(); let node_id = self.cx.tcx.hir.as_local_node_id(def_id).expect("local/upvar are local nodes"); - let extent = self.cx.tcx.region_maps.var_scope(node_id); + let parent_id = self.cx.tcx.hir.get_parent(expr.id); + let parent_def_id = self.cx.tcx.hir.local_def_id(parent_id); + let extent = self.cx.tcx.region_maps(parent_def_id).var_scope(node_id); self.indexed.insert(seqvar.segments[0].name, Some(extent)); return; // no need to walk further } diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index 57c0c637f41..03de9cabd2c 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -335,11 +335,11 @@ fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) { "if you mean to use a decimal constant, remove the `0` to remove confusion:", src[1..].to_string(), ); - db.span_suggestion( + /*db.span_suggestion( lit.span, "if you mean to use an octal constant, use `0o`:", format!("0o{}", &src[1..]), - ); + ); FIXME: rustc doesn't support multiple suggestions anymore */ }); } }} diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index d524b08e6aa..076bf82b687 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -29,7 +29,7 @@ //! This lint is **warn** by default. use rustc::lint::*; use syntax::ast; -use syntax::codemap::{original_sp,DUMMY_SP}; +use syntax::codemap::{original_sp, DUMMY_SP}; use std::borrow::Cow; use utils::{in_macro, span_help_and_lint, snippet_block, snippet, trim_multiline}; @@ -163,7 +163,7 @@ fn check_expr(&mut self, ctx: &EarlyContext, expr: &ast::Expr) { * // region C * } * } - */ + * */ /// Given an expression, returns true if either of the following is true /// @@ -181,10 +181,12 @@ fn needless_continue_in_else(else_expr: &ast::Expr) -> bool { fn is_first_block_stmt_continue(block: &ast::Block) -> bool { block.stmts.get(0).map_or(false, |stmt| match stmt.node { ast::StmtKind::Semi(ref e) | - ast::StmtKind::Expr(ref e) => if let ast::ExprKind::Continue(_) = e.node { - true - } else { - false + ast::StmtKind::Expr(ref e) => { + if let ast::ExprKind::Continue(_) = e.node { + true + } else { + false + } }, _ => false, }) @@ -192,12 +194,14 @@ fn is_first_block_stmt_continue(block: &ast::Block) -> bool { /// If `expr` is a loop expression (while/while let/for/loop), calls `func` with /// the AST object representing the loop block of `expr`. -fn with_loop_block(expr: &ast::Expr, mut func: F) where F: FnMut(&ast::Block) { +fn with_loop_block(expr: &ast::Expr, mut func: F) + where F: FnMut(&ast::Block) +{ match expr.node { - ast::ExprKind::While(_, ref loop_block, _) | + ast::ExprKind::While(_, ref loop_block, _) | ast::ExprKind::WhileLet(_, _, ref loop_block, _) | - ast::ExprKind::ForLoop( _, _, ref loop_block, _) | - ast::ExprKind::Loop(ref loop_block, _) => func(loop_block), + ast::ExprKind::ForLoop(_, _, ref loop_block, _) | + ast::ExprKind::Loop(ref loop_block, _) => func(loop_block), _ => {}, } } @@ -211,7 +215,8 @@ fn with_loop_block(expr: &ast::Expr, mut func: F) where F: FnMut(&ast::Block) /// - The `else` expression. /// fn with_if_expr(stmt: &ast::Stmt, mut func: F) - where F: FnMut(&ast::Expr, &ast::Expr, &ast::Block, &ast::Expr) { + where F: FnMut(&ast::Expr, &ast::Expr, &ast::Block, &ast::Expr) +{ match stmt.node { ast::StmtKind::Semi(ref e) | ast::StmtKind::Expr(ref e) => { @@ -219,7 +224,7 @@ fn with_if_expr(stmt: &ast::Stmt, mut func: F) func(e, cond, if_block, else_expr); } }, - _ => { }, + _ => {}, } } @@ -249,45 +254,37 @@ struct LintData<'a> { const MSG_REDUNDANT_ELSE_BLOCK: &'static str = "This else block is redundant.\n"; -const MSG_ELSE_BLOCK_NOT_NEEDED: &'static str = "There is no need for an explicit `else` block for this `if` expression\n"; +const MSG_ELSE_BLOCK_NOT_NEEDED: &'static str = "There is no need for an explicit `else` block for this `if` \ + expression\n"; -const DROP_ELSE_BLOCK_AND_MERGE_MSG: &'static str = - "Consider dropping the else clause and merging the code that follows (in the loop) with the if block, like so:\n"; +const DROP_ELSE_BLOCK_AND_MERGE_MSG: &'static str = "Consider dropping the else clause and merging the code that \ + follows (in the loop) with the if block, like so:\n"; -const DROP_ELSE_BLOCK_MSG: &'static str = - "Consider dropping the else clause, and moving out the code in the else block, like so:\n"; +const DROP_ELSE_BLOCK_MSG: &'static str = "Consider dropping the else clause, and moving out the code in the else \ + block, like so:\n"; -fn emit_warning<'a>(ctx: &EarlyContext, - data: &'a LintData, - header: &str, - typ: LintType) { +fn emit_warning<'a>(ctx: &EarlyContext, data: &'a LintData, header: &str, typ: LintType) { // snip is the whole *help* message that appears after the warning. // message is the warning message. // expr is the expression which the lint warning message refers to. let (snip, message, expr) = match typ { LintType::ContinueInsideElseBlock => { - (suggestion_snippet_for_continue_inside_else(ctx, data, header), - MSG_REDUNDANT_ELSE_BLOCK, - data.else_expr) + (suggestion_snippet_for_continue_inside_else(ctx, data, header), MSG_REDUNDANT_ELSE_BLOCK, data.else_expr) }, LintType::ContinueInsideThenBlock => { - (suggestion_snippet_for_continue_inside_if(ctx, data, header), - MSG_ELSE_BLOCK_NOT_NEEDED, - data.if_expr) - } + (suggestion_snippet_for_continue_inside_if(ctx, data, header), MSG_ELSE_BLOCK_NOT_NEEDED, data.if_expr) + }, }; span_help_and_lint(ctx, NEEDLESS_CONTINUE, expr.span, message, &snip); } -fn suggestion_snippet_for_continue_inside_if<'a>(ctx: &EarlyContext, - data: &'a LintData, - header: &str) -> String { +fn suggestion_snippet_for_continue_inside_if<'a>(ctx: &EarlyContext, data: &'a LintData, header: &str) -> String { let cond_code = snippet(ctx, data.if_cond.span, ".."); - let if_code = format!("if {} {{\n continue;\n}}\n", cond_code); - /* ^^^^--- Four spaces of indentation. */ + let if_code = format!("if {} {{\n continue;\n}}\n", cond_code); + /* ^^^^--- Four spaces of indentation. */ // region B let else_code = snippet(ctx, data.else_expr.span, "..").into_owned(); let else_code = erode_block(&else_code); @@ -300,12 +297,9 @@ fn suggestion_snippet_for_continue_inside_if<'a>(ctx: &EarlyContext, ret } -fn suggestion_snippet_for_continue_inside_else<'a>(ctx: &EarlyContext, - data: &'a LintData, - header: &str) -> String -{ +fn suggestion_snippet_for_continue_inside_else<'a>(ctx: &EarlyContext, data: &'a LintData, header: &str) -> String { let cond_code = snippet(ctx, data.if_cond.span, ".."); - let mut if_code = format!("if {} {{\n", cond_code); + let mut if_code = format!("if {} {{\n", cond_code); // Region B let block_code = &snippet(ctx, data.if_block.span, "..").into_owned(); @@ -318,13 +312,12 @@ fn suggestion_snippet_for_continue_inside_else<'a>(ctx: &EarlyContext, // These is the code in the loop block that follows the if/else construction // we are complaining about. We want to pull all of this code into the // `then` block of the `if` statement. - let to_annex = data.block_stmts[data.stmt_idx+1..] - .iter() - .map(|stmt| { - original_sp(stmt.span, DUMMY_SP) - }) - .map(|span| snippet_block(ctx, span, "..").into_owned()) - .collect::>().join("\n"); + let to_annex = data.block_stmts[data.stmt_idx + 1..] + .iter() + .map(|stmt| original_sp(stmt.span, DUMMY_SP)) + .map(|span| snippet_block(ctx, span, "..").into_owned()) + .collect::>() + .join("\n"); let mut ret = String::from(header); @@ -336,24 +329,22 @@ fn suggestion_snippet_for_continue_inside_else<'a>(ctx: &EarlyContext, } fn check_and_warn<'a>(ctx: &EarlyContext, expr: &'a ast::Expr) { - with_loop_block(expr, |loop_block| { - for (i, stmt) in loop_block.stmts.iter().enumerate() { - with_if_expr(stmt, |if_expr, cond, then_block, else_expr| { - let data = &LintData { - stmt_idx: i, - if_expr: if_expr, - if_cond: cond, - if_block: then_block, - else_expr: else_expr, - block_stmts: &loop_block.stmts, - }; - if needless_continue_in_else(else_expr) { - emit_warning(ctx, data, DROP_ELSE_BLOCK_AND_MERGE_MSG, LintType::ContinueInsideElseBlock); - } else if is_first_block_stmt_continue(then_block) { - emit_warning(ctx, data, DROP_ELSE_BLOCK_MSG, LintType::ContinueInsideThenBlock); - } - }); - } + with_loop_block(expr, |loop_block| for (i, stmt) in loop_block.stmts.iter().enumerate() { + with_if_expr(stmt, |if_expr, cond, then_block, else_expr| { + let data = &LintData { + stmt_idx: i, + if_expr: if_expr, + if_cond: cond, + if_block: then_block, + else_expr: else_expr, + block_stmts: &loop_block.stmts, + }; + if needless_continue_in_else(else_expr) { + emit_warning(ctx, data, DROP_ELSE_BLOCK_AND_MERGE_MSG, LintType::ContinueInsideElseBlock); + } else if is_first_block_stmt_continue(then_block) { + emit_warning(ctx, data, DROP_ELSE_BLOCK_MSG, LintType::ContinueInsideThenBlock); + } + }); }); } @@ -378,7 +369,7 @@ fn check_and_warn<'a>(ctx: &EarlyContext, expr: &'a ast::Expr) { /// an empty string will be returned in that case. pub fn erode_from_back(s: &str) -> String { let mut ret = String::from(s); - while ret.pop().map_or(false, |c| c != '}') { } + while ret.pop().map_or(false, |c| c != '}') {} while let Some(c) = ret.pop() { if !c.is_whitespace() { ret.push(c); @@ -409,10 +400,10 @@ pub fn erode_from_back(s: &str) -> String { /// pub fn erode_from_front(s: &str) -> String { s.chars() - .skip_while(|c| c.is_whitespace()) - .skip_while(|c| *c == '{') - .skip_while(|c| *c == '\n') - .collect::() + .skip_while(|c| c.is_whitespace()) + .skip_while(|c| *c == '{') + .skip_while(|c| *c == '\n') + .collect::() } /// If `s` contains the code for a block, delimited by braces, this function diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 8cf5bfd0770..f443ea1f9dc 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -86,18 +86,20 @@ fn check_fn( .collect() }; + let fn_def_id = cx.tcx.hir.local_def_id(node_id); + // Collect moved variables and spans which will need dereferencings from the function body. let MovedVariablesCtxt { moved_vars, spans_need_deref, .. } = { let mut ctx = MovedVariablesCtxt::new(cx); let infcx = cx.tcx.borrowck_fake_infer_ctxt(body.id()); + let region_maps = &cx.tcx.region_maps(fn_def_id); { - let mut v = euv::ExprUseVisitor::new(&mut ctx, &infcx); + let mut v = euv::ExprUseVisitor::new(&mut ctx, region_maps, &infcx); v.consume_body(body); } ctx }; - let fn_def_id = cx.tcx.hir.local_def_id(node_id); let param_env = ty::ParameterEnvironment::for_item(cx.tcx, node_id); let fn_sig = cx.tcx.type_of(fn_def_id).fn_sig(); let fn_sig = cx.tcx.liberate_late_bound_regions(param_env.free_id_outlive, &fn_sig); @@ -146,7 +148,7 @@ fn check_fn( ], { let slice_ty = format!("&[{}]", snippet(cx, elem_ty.span, "_")); db.span_suggestion(input.span, - &format!("consider changing the type to `{}`", slice_ty), + "consider changing the type to", slice_ty); assert!(deref_span.is_none()); return; // `Vec` and `String` cannot be destructured - no need for `*` suggestion @@ -154,7 +156,7 @@ fn check_fn( if match_type(cx, ty, &paths::STRING) { db.span_suggestion(input.span, - "consider changing the type to `&str`", + "consider changing the type to", "&str".to_string()); assert!(deref_span.is_none()); return; @@ -282,16 +284,7 @@ fn consume_pat(&mut self, consume_pat: &Pat, cmt: mc::cmt<'tcx>, mode: euv::Cons } } - fn borrow( - &mut self, - _: NodeId, - _: Span, - _: mc::cmt<'tcx>, - _: &'tcx ty::Region, - _: ty::BorrowKind, - _: euv::LoanCause - ) { - } + fn borrow(&mut self, _: NodeId, _: Span, _: mc::cmt<'tcx>, _: ty::Region, _: ty::BorrowKind, _: euv::LoanCause) {} fn mutate(&mut self, _: NodeId, _: Span, _: mc::cmt<'tcx>, _: euv::MutateMode) {} diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index cb00d1cae01..2c1043cffa0 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -593,18 +593,13 @@ pub fn span_lint_and_sugg<'a, 'tcx: 'a, T: LintContext<'tcx>>( /// Note: in the JSON format (used by `compiletest_rs`), the help message will appear once per /// replacement. In human-readable format though, it only appears once before the whole suggestion. pub fn multispan_sugg(db: &mut DiagnosticBuilder, help_msg: String, sugg: Vec<(Span, String)>) { - let sugg = rustc_errors::RenderSpan::Suggestion(rustc_errors::CodeSuggestion { + let sugg = rustc_errors::CodeSuggestion { msp: MultiSpan::from_spans(sugg.iter().map(|&(span, _)| span).collect()), substitutes: sugg.into_iter().map(|(_, subs)| subs).collect(), - }); - - let sub = rustc_errors::SubDiagnostic { - level: rustc_errors::Level::Help, - message: vec![(help_msg, rustc_errors::snippet::Style::LabelPrimary)], - span: MultiSpan::new(), - render_span: Some(sugg), + msg: help_msg, }; - db.children.push(sub); + assert!(db.suggestion.is_none()); + db.suggestion = Some(sugg); } /// Return the base type for references and raw pointers. @@ -983,4 +978,3 @@ pub fn type_size<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>) -> Opti .infer_ctxt((), Reveal::All) .enter(|infcx| ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes())) } - diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index 8ce2ae375f3..77e251db8a6 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -2,200 +2,139 @@ error: assign operation detected --> $DIR/assign_ops.rs:8:5 | 8 | i += 2; - | ^^^^^^ + | ^^^^^^ help: replace it with `i = i + 2` | note: lint level defined here --> $DIR/assign_ops.rs:4:8 | 4 | #[deny(assign_ops)] | ^^^^^^^^^^ -help: replace it with - | i = i + 2; error: assign operation detected --> $DIR/assign_ops.rs:11:5 | 11 | i += 2 + 17; - | ^^^^^^^^^^^ - | -help: replace it with - | i = i + 2 + 17; + | ^^^^^^^^^^^ help: replace it with `i = i + 2 + 17` error: assign operation detected --> $DIR/assign_ops.rs:14:5 | 14 | i -= 6; - | ^^^^^^ - | -help: replace it with - | i = i - 6; + | ^^^^^^ help: replace it with `i = i - 6` error: assign operation detected --> $DIR/assign_ops.rs:17:5 | 17 | i -= 2 - 1; - | ^^^^^^^^^^ - | -help: replace it with - | i = i - (2 - 1); + | ^^^^^^^^^^ help: replace it with `i = i - (2 - 1)` error: assign operation detected --> $DIR/assign_ops.rs:21:5 | 21 | i *= 5; - | ^^^^^^ - | -help: replace it with - | i = i * 5; + | ^^^^^^ help: replace it with `i = i * 5` error: assign operation detected --> $DIR/assign_ops.rs:24:5 | 24 | i *= 1+5; - | ^^^^^^^^ - | -help: replace it with - | i = i * (1+5); + | ^^^^^^^^ help: replace it with `i = i * (1+5)` error: assign operation detected --> $DIR/assign_ops.rs:27:5 | 27 | i /= 32; - | ^^^^^^^ - | -help: replace it with - | i = i / 32; + | ^^^^^^^ help: replace it with `i = i / 32` error: assign operation detected --> $DIR/assign_ops.rs:30:5 | 30 | i /= 32 | 5; - | ^^^^^^^^^^^ - | -help: replace it with - | i = i / (32 | 5); + | ^^^^^^^^^^^ help: replace it with `i = i / (32 | 5)` error: assign operation detected --> $DIR/assign_ops.rs:33:5 | 33 | i /= 32 / 5; - | ^^^^^^^^^^^ - | -help: replace it with - | i = i / (32 / 5); + | ^^^^^^^^^^^ help: replace it with `i = i / (32 / 5)` error: assign operation detected --> $DIR/assign_ops.rs:36:5 | 36 | i %= 42; - | ^^^^^^^ - | -help: replace it with - | i = i % 42; + | ^^^^^^^ help: replace it with `i = i % 42` error: assign operation detected --> $DIR/assign_ops.rs:39:5 | 39 | i >>= i; - | ^^^^^^^ - | -help: replace it with - | i = i >> i; + | ^^^^^^^ help: replace it with `i = i >> i` error: assign operation detected --> $DIR/assign_ops.rs:42:5 | 42 | i <<= 9 + 6 - 7; - | ^^^^^^^^^^^^^^^ - | -help: replace it with - | i = i << (9 + 6 - 7); + | ^^^^^^^^^^^^^^^ help: replace it with `i = i << (9 + 6 - 7)` error: assign operation detected --> $DIR/assign_ops.rs:45:5 | 45 | i += 1 << 5; - | ^^^^^^^^^^^ - | -help: replace it with - | i = i + (1 << 5); + | ^^^^^^^^^^^ help: replace it with `i = i + (1 << 5)` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:55:5 | 55 | a = a + 1; - | ^^^^^^^^^ + | ^^^^^^^^^ help: replace it with `a += 1` | note: lint level defined here --> $DIR/assign_ops.rs:52:8 | 52 | #[deny(assign_op_pattern)] | ^^^^^^^^^^^^^^^^^ -help: replace it with - | a += 1; error: manual implementation of an assign operation --> $DIR/assign_ops.rs:58:5 | 58 | a = 1 + a; - | ^^^^^^^^^ - | -help: replace it with - | a += 1; + | ^^^^^^^^^ help: replace it with `a += 1` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:61:5 | 61 | a = a - 1; - | ^^^^^^^^^ - | -help: replace it with - | a -= 1; + | ^^^^^^^^^ help: replace it with `a -= 1` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:64:5 | 64 | a = a * 99; - | ^^^^^^^^^^ - | -help: replace it with - | a *= 99; + | ^^^^^^^^^^ help: replace it with `a *= 99` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:67:5 | 67 | a = 42 * a; - | ^^^^^^^^^^ - | -help: replace it with - | a *= 42; + | ^^^^^^^^^^ help: replace it with `a *= 42` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:70:5 | 70 | a = a / 2; - | ^^^^^^^^^ - | -help: replace it with - | a /= 2; + | ^^^^^^^^^ help: replace it with `a /= 2` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:73:5 | 73 | a = a % 5; - | ^^^^^^^^^ - | -help: replace it with - | a %= 5; + | ^^^^^^^^^ help: replace it with `a %= 5` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:76:5 | 76 | a = a & 1; - | ^^^^^^^^^ - | -help: replace it with - | a &= 1; + | ^^^^^^^^^ help: replace it with `a &= 1` error: aborting due to 21 previous errors diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index ded39d1efc7..adab959f6ee 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -2,78 +2,55 @@ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:8:5 | 8 | a += a + 1; - | ^^^^^^^^^^ + | ^^^^^^^^^^ help: replace it with `a += 1` | note: lint level defined here --> $DIR/assign_ops2.rs:5:8 | 5 | #[deny(misrefactored_assign_op)] | ^^^^^^^^^^^^^^^^^^^^^^^ -help: replace it with - | a += 1; error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:11:5 | 11 | a += 1 + a; - | ^^^^^^^^^^ - | -help: replace it with - | a += 1; + | ^^^^^^^^^^ help: replace it with `a += 1` error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:14:5 | 14 | a -= a - 1; - | ^^^^^^^^^^ - | -help: replace it with - | a -= 1; + | ^^^^^^^^^^ help: replace it with `a -= 1` error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:17:5 | 17 | a *= a * 99; - | ^^^^^^^^^^^ - | -help: replace it with - | a *= 99; + | ^^^^^^^^^^^ help: replace it with `a *= 99` error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:20:5 | 20 | a *= 42 * a; - | ^^^^^^^^^^^ - | -help: replace it with - | a *= 42; + | ^^^^^^^^^^^ help: replace it with `a *= 42` error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:23:5 | 23 | a /= a / 2; - | ^^^^^^^^^^ - | -help: replace it with - | a /= 2; + | ^^^^^^^^^^ help: replace it with `a /= 2` error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:26:5 | 26 | a %= a % 5; - | ^^^^^^^^^^ - | -help: replace it with - | a %= 5; + | ^^^^^^^^^^ help: replace it with `a %= 5` error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:29:5 | 29 | a &= a & 1; - | ^^^^^^^^^^ - | -help: replace it with - | a &= 1; + | ^^^^^^^^^^ help: replace it with `a &= 1` error: aborting due to 8 previous errors diff --git a/tests/ui/block_in_if_condition.stderr b/tests/ui/block_in_if_condition.stderr index 263193491b7..403ad7efe8d 100644 --- a/tests/ui/block_in_if_condition.stderr +++ b/tests/ui/block_in_if_condition.stderr @@ -54,15 +54,13 @@ warning: this boolean expression can be simplified --> $DIR/block_in_if_condition.rs:70:8 | 70 | if true && x == 3 { - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ help: try `x == 3` | note: lint level defined here --> $DIR/block_in_if_condition.rs:7:9 | 7 | #![warn(nonminimal_bool)] | ^^^^^^^^^^^^^^^ -help: try - | if x == 3 { error: aborting due to 4 previous errors diff --git a/tests/ui/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index 9da1c76d07e..341f0734430 100644 --- a/tests/ui/bool_comparison.stderr +++ b/tests/ui/bool_comparison.stderr @@ -2,42 +2,31 @@ error: equality checks against true are unnecessary --> $DIR/bool_comparison.rs:7:8 | 7 | if x == true { "yes" } else { "no" }; - | ^^^^^^^^^ + | ^^^^^^^^^ help: try simplifying it as shown: `x` | note: lint level defined here --> $DIR/bool_comparison.rs:4:8 | 4 | #[deny(bool_comparison)] | ^^^^^^^^^^^^^^^ -help: try simplifying it as shown: - | if x { "yes" } else { "no" }; error: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:11:8 | 11 | if x == false { "yes" } else { "no" }; - | ^^^^^^^^^^ - | -help: try simplifying it as shown: - | if !x { "yes" } else { "no" }; + | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary --> $DIR/bool_comparison.rs:15:8 | 15 | if true == x { "yes" } else { "no" }; - | ^^^^^^^^^ - | -help: try simplifying it as shown: - | if x { "yes" } else { "no" }; + | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:19:8 | 19 | if false == x { "yes" } else { "no" }; - | ^^^^^^^^^^ - | -help: try simplifying it as shown: - | if !x { "yes" } else { "no" }; + | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: aborting due to 4 previous errors diff --git a/tests/ui/booleans.stderr b/tests/ui/booleans.stderr index 54f6638b938..dd8190d1011 100644 --- a/tests/ui/booleans.stderr +++ b/tests/ui/booleans.stderr @@ -2,7 +2,7 @@ error: this boolean expression contains a logic bug --> $DIR/booleans.rs:12:13 | 12 | let _ = a && b || a; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ help: it would look like the following `a` | note: lint level defined here --> $DIR/booleans.rs:3:26 @@ -14,147 +14,108 @@ help: this expression can be optimized out by applying boolean operations to the | 12 | let _ = a && b || a; | ^ -help: it would look like the following - | let _ = a; error: this boolean expression can be simplified --> $DIR/booleans.rs:17:13 | 17 | let _ = !true; - | ^^^^^ + | ^^^^^ help: try `false` | note: lint level defined here --> $DIR/booleans.rs:3:9 | 3 | #![deny(nonminimal_bool, logic_bug)] | ^^^^^^^^^^^^^^^ -help: try - | let _ = false; error: this boolean expression can be simplified --> $DIR/booleans.rs:20:13 | 20 | let _ = !false; - | ^^^^^^ - | -help: try - | let _ = true; + | ^^^^^^ help: try `true` error: this boolean expression can be simplified --> $DIR/booleans.rs:23:13 | 23 | let _ = !!a; - | ^^^ - | -help: try - | let _ = a; + | ^^^ help: try `a` error: this boolean expression contains a logic bug --> $DIR/booleans.rs:27:13 | 27 | let _ = false && a; - | ^^^^^^^^^^ + | ^^^^^^^^^^ help: it would look like the following `false` | help: this expression can be optimized out by applying boolean operations to the outer expression --> $DIR/booleans.rs:27:22 | 27 | let _ = false && a; | ^ -help: it would look like the following - | let _ = false; error: this boolean expression can be simplified --> $DIR/booleans.rs:32:13 | 32 | let _ = false || a; - | ^^^^^^^^^^ - | -help: try - | let _ = a; + | ^^^^^^^^^^ help: try `a` error: this boolean expression can be simplified --> $DIR/booleans.rs:43:13 | 43 | let _ = !(!a && b); - | ^^^^^^^^^^ - | -help: try - | let _ = !b || a; + | ^^^^^^^^^^ help: try `!b || a` error: this boolean expression contains a logic bug --> $DIR/booleans.rs:55:13 | 55 | let _ = a == b && a != b; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ help: it would look like the following `false` | help: this expression can be optimized out by applying boolean operations to the outer expression --> $DIR/booleans.rs:55:13 | 55 | let _ = a == b && a != b; | ^^^^^^ -help: it would look like the following - | let _ = false; error: this boolean expression can be simplified --> $DIR/booleans.rs:60:13 | 60 | let _ = a == b && c == 5 && a == b; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _ = a == b && c == 5; -help: try - | let _ = !(c != 5 || a != b); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `a == b && c == 5` error: this boolean expression can be simplified --> $DIR/booleans.rs:66:13 | 66 | let _ = a == b && c == 5 && b == a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _ = a == b && c == 5; -help: try - | let _ = !(c != 5 || a != b); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `a == b && c == 5` error: this boolean expression contains a logic bug --> $DIR/booleans.rs:72:13 | 72 | let _ = a < b && a >= b; - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ help: it would look like the following `false` | help: this expression can be optimized out by applying boolean operations to the outer expression --> $DIR/booleans.rs:72:13 | 72 | let _ = a < b && a >= b; | ^^^^^ -help: it would look like the following - | let _ = false; error: this boolean expression contains a logic bug --> $DIR/booleans.rs:77:13 | 77 | let _ = a > b && a <= b; - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ help: it would look like the following `false` | help: this expression can be optimized out by applying boolean operations to the outer expression --> $DIR/booleans.rs:77:13 | 77 | let _ = a > b && a <= b; | ^^^^^ -help: it would look like the following - | let _ = false; error: this boolean expression can be simplified --> $DIR/booleans.rs:84:13 | 84 | let _ = a != b || !(a != b || c == d); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _ = c != d || a != b; -help: try - | let _ = !(a == b && c == d); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `c != d || a != b` error: aborting due to 13 previous errors diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index b4e09d2671b..84edc47a714 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -2,69 +2,49 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:13:5 | 13 | if !m.contains_key(&k) { m.insert(k, v); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k).or_insert(v)` | note: lint level defined here --> $DIR/entry.rs:5:9 | 5 | #![deny(map_entry)] | ^^^^^^^^^ -help: consider using - | m.entry(k).or_insert(v) error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:20:5 | 20 | if !m.contains_key(&k) { foo(); m.insert(k, v); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using - | m.entry(k) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:27:5 | 27 | if !m.contains_key(&k) { m.insert(k, v) } else { None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using - | m.entry(k); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:34:5 | 34 | if m.contains_key(&k) { None } else { m.insert(k, v) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using - | m.entry(k); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:41:5 | 41 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using - | m.entry(k); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:48:5 | 48 | if m.contains_key(&k) { None } else { foo(); m.insert(k, v) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using - | m.entry(k); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `BTreeMap` --> $DIR/entry.rs:55:5 | 55 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using - | m.entry(k); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: aborting due to 7 previous errors diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index b4ece862e00..ab51797fe82 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -2,60 +2,43 @@ error: this boolean expression can be simplified --> $DIR/eq_op.rs:41:5 | 41 | true && true; - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ help: try `true` | note: lint level defined here --> $DIR/eq_op.rs:7:8 | 7 | #[deny(nonminimal_bool)] | ^^^^^^^^^^^^^^^ -help: try - | true; error: this boolean expression can be simplified --> $DIR/eq_op.rs:43:5 | 43 | true || true; - | ^^^^^^^^^^^^ - | -help: try - | true; + | ^^^^^^^^^^^^ help: try `true` error: this boolean expression can be simplified --> $DIR/eq_op.rs:49:5 | 49 | a == b && b == a; - | ^^^^^^^^^^^^^^^^ - | -help: try - | a == b; + | ^^^^^^^^^^^^^^^^ help: try `a == b` error: this boolean expression can be simplified --> $DIR/eq_op.rs:51:5 | 51 | a != b && b != a; - | ^^^^^^^^^^^^^^^^ - | -help: try - | a != b; + | ^^^^^^^^^^^^^^^^ help: try `a != b` error: this boolean expression can be simplified --> $DIR/eq_op.rs:53:5 | 53 | a < b && b > a; - | ^^^^^^^^^^^^^^ - | -help: try - | a < b; + | ^^^^^^^^^^^^^^ help: try `a < b` error: this boolean expression can be simplified --> $DIR/eq_op.rs:55:5 | 55 | a <= b && b >= a; - | ^^^^^^^^^^^^^^^^ - | -help: try - | a <= b; + | ^^^^^^^^^^^^^^^^ help: try `a <= b` error: equal expressions as operands to `==` --> $DIR/eq_op.rs:10:5 @@ -223,11 +206,11 @@ warning: taken reference of right operand --> $DIR/eq_op.rs:97:13 | 97 | let z = x & &y; - | ^^^^^^ + | ^^^^-- + | | + | help: use the right value directly `y` | = note: #[warn(op_ref)] on by default -help: use the right value directly - | let z = y & &y; error: aborting due to 32 previous errors diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index 4683ae2708f..355db4deae4 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -2,33 +2,25 @@ error: redundant closure found --> $DIR/eta.rs:7:27 | 7 | let a = Some(1u8).map(|a| foo(a)); - | ^^^^^^^^^^ + | ^^^^^^^^^^ help: remove closure as shown: `foo` | note: lint level defined here --> $DIR/eta.rs:4:9 | 4 | #![deny(redundant_closure)] | ^^^^^^^^^^^^^^^^^ -help: remove closure as shown: - | let a = Some(1u8).map(foo); error: redundant closure found --> $DIR/eta.rs:11:10 | 11 | meta(|a| foo(a)); - | ^^^^^^^^^^ - | -help: remove closure as shown: - | meta(foo); + | ^^^^^^^^^^ help: remove closure as shown: `foo` error: redundant closure found --> $DIR/eta.rs:15:27 | 15 | let c = Some(1u8).map(|a| {1+2; foo}(a)); - | ^^^^^^^^^^^^^^^^^ - | -help: remove closure as shown: - | let c = Some(1u8).map({1+2; foo}); + | ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}` warning: this expression borrows a reference that is immediately dereferenced by the compiler --> $DIR/eta.rs:20:21 @@ -42,10 +34,7 @@ error: redundant closure found --> $DIR/eta.rs:28:27 | 28 | let e = Some(1u8).map(|a| generic(a)); - | ^^^^^^^^^^^^^^ - | -help: remove closure as shown: - | let e = Some(1u8).map(generic); + | ^^^^^^^^^^^^^^ help: remove closure as shown: `generic` error: aborting due to 4 previous errors diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index 8c6abadadec..1eff9cdecc4 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -2,15 +2,13 @@ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:43:5 | 43 | ONE == 1f32; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ help: consider comparing them within some error `(ONE - 1f32).abs() < error` | note: lint level defined here --> $DIR/float_cmp.rs:4:9 | 4 | #![deny(float_cmp)] | ^^^^^^^^^ -help: consider comparing them within some error - | (ONE - 1f32).abs() < error; note: std::f32::EPSILON and std::f64::EPSILON are available. --> $DIR/float_cmp.rs:43:5 | @@ -21,10 +19,8 @@ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:47:5 | 47 | ONE == 1.0 + 0.0; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(ONE - (1.0 + 0.0)).abs() < error` | -help: consider comparing them within some error - | (ONE - (1.0 + 0.0)).abs() < error; note: std::f32::EPSILON and std::f64::EPSILON are available. --> $DIR/float_cmp.rs:47:5 | @@ -35,10 +31,8 @@ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:52:5 | 52 | ONE + ONE == ZERO + ONE + ONE; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(ONE + ONE - (ZERO + ONE + ONE)).abs() < error` | -help: consider comparing them within some error - | (ONE + ONE - (ZERO + ONE + ONE)).abs() < error; note: std::f32::EPSILON and std::f64::EPSILON are available. --> $DIR/float_cmp.rs:52:5 | @@ -49,10 +43,8 @@ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:57:5 | 57 | ONE != 2.0; - | ^^^^^^^^^^ + | ^^^^^^^^^^ help: consider comparing them within some error `(ONE - 2.0).abs() < error` | -help: consider comparing them within some error - | (ONE - 2.0).abs() < error; note: std::f32::EPSILON and std::f64::EPSILON are available. --> $DIR/float_cmp.rs:57:5 | @@ -63,10 +55,8 @@ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:62:5 | 62 | twice(ONE) != ONE; - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(twice(ONE) - ONE).abs() < error` | -help: consider comparing them within some error - | (twice(ONE) - ONE).abs() < error; note: std::f32::EPSILON and std::f64::EPSILON are available. --> $DIR/float_cmp.rs:62:5 | @@ -77,10 +67,8 @@ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:66:5 | 66 | ONE as f64 != 2.0; - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(ONE as f64 - 2.0).abs() < error` | -help: consider comparing them within some error - | (ONE as f64 - 2.0).abs() < error; note: std::f32::EPSILON and std::f64::EPSILON are available. --> $DIR/float_cmp.rs:66:5 | @@ -91,10 +79,8 @@ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:74:5 | 74 | x == 1.0; - | ^^^^^^^^ + | ^^^^^^^^ help: consider comparing them within some error `(x - 1.0).abs() < error` | -help: consider comparing them within some error - | (x - 1.0).abs() < error; note: std::f32::EPSILON and std::f64::EPSILON are available. --> $DIR/float_cmp.rs:74:5 | @@ -105,10 +91,8 @@ error: strict comparison of f32 or f64 --> $DIR/float_cmp.rs:80:5 | 80 | twice(x) != twice(ONE as f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(twice(x) - twice(ONE as f64)).abs() < error` | -help: consider comparing them within some error - | (twice(x) - twice(ONE as f64)).abs() < error; note: std::f32::EPSILON and std::f64::EPSILON are available. --> $DIR/float_cmp.rs:80:5 | diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index aff2baeed0c..ca93e4a38c6 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -365,128 +365,91 @@ error: it is more idiomatic to loop over references to containers instead of usi --> $DIR/for_loop.rs:289:15 | 289 | for _v in vec.iter() { } - | ^^^^^^^^^^ + | ^^^^^^^^^^ help: to write this more concisely, try `&vec` | note: lint level defined here --> $DIR/for_loop.rs:90:29 | 90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] | ^^^^^^^^^^^^^^^^^^ -help: to write this more concisely, try - | for _v in &vec { } error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:294:15 | 294 | for _v in vec.iter_mut() { } - | ^^^^^^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &mut vec { } + | ^^^^^^^^^^^^^^ help: to write this more concisely, try `&mut vec` error: it is more idiomatic to loop over containers instead of using explicit iteration methods` --> $DIR/for_loop.rs:300:15 | 300 | for _v in out_vec.into_iter() { } - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `out_vec` | note: lint level defined here --> $DIR/for_loop.rs:90:49 | 90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] | ^^^^^^^^^^^^^^^^^^^^^^^ -help: to write this more concisely, try - | for _v in out_vec { } error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:306:15 | 306 | for _v in array.into_iter() {} - | ^^^^^^^^^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &array {} + | ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `&array` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:311:15 | 311 | for _v in [1, 2, 3].iter() { } - | ^^^^^^^^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &[1, 2, 3] { } + | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try `&[1, 2, 3]` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:318:15 | 318 | for _v in [0; 32].iter() {} - | ^^^^^^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &[0; 32] {} + | ^^^^^^^^^^^^^^ help: to write this more concisely, try `&[0; 32]` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:326:15 | 326 | for _v in ll.iter() { } - | ^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &ll { } + | ^^^^^^^^^ help: to write this more concisely, try `&ll` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:332:15 | 332 | for _v in vd.iter() { } - | ^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &vd { } + | ^^^^^^^^^ help: to write this more concisely, try `&vd` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:338:15 | 338 | for _v in bh.iter() { } - | ^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &bh { } + | ^^^^^^^^^ help: to write this more concisely, try `&bh` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:344:15 | 344 | for _v in hm.iter() { } - | ^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &hm { } + | ^^^^^^^^^ help: to write this more concisely, try `&hm` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:350:15 | 350 | for _v in bt.iter() { } - | ^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &bt { } + | ^^^^^^^^^ help: to write this more concisely, try `&bt` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:356:15 | 356 | for _v in hs.iter() { } - | ^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &hs { } + | ^^^^^^^^^ help: to write this more concisely, try `&hs` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:362:15 | 362 | for _v in bs.iter() { } - | ^^^^^^^^^ - | -help: to write this more concisely, try - | for _v in &bs { } + | ^^^^^^^^^ help: to write this more concisely, try `&bs` error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want --> $DIR/for_loop.rs:368:5 diff --git a/tests/ui/if_let_redundant_pattern_matching.stderr b/tests/ui/if_let_redundant_pattern_matching.stderr index cc011b4a90c..198a1974065 100644 --- a/tests/ui/if_let_redundant_pattern_matching.stderr +++ b/tests/ui/if_let_redundant_pattern_matching.stderr @@ -2,7 +2,7 @@ error: redundant pattern matching, consider using `is_ok()` --> $DIR/if_let_redundant_pattern_matching.rs:9:12 | 9 | if let Ok(_) = Ok::(42) {} - | ^^^^^ + | -------^^^^^--------------------- help: try this `if Ok::(42).is_ok()` | = note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)] note: lint level defined here @@ -10,38 +10,30 @@ note: lint level defined here | 4 | #![deny(clippy)] | ^^^^^^ -help: try this - | if Ok::(42).is_ok() {} error: redundant pattern matching, consider using `is_err()` --> $DIR/if_let_redundant_pattern_matching.rs:14:12 | 14 | if let Err(_) = Err::(42) { - | ^^^^^^ + | -------^^^^^^---------------------- help: try this `if Err::(42).is_err()` | = note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)] -help: try this - | if Err::(42).is_err() { error: redundant pattern matching, consider using `is_none()` --> $DIR/if_let_redundant_pattern_matching.rs:20:12 | 20 | if let None = None::<()> { - | ^^^^ + | -------^^^^------------- help: try this `if None::<()>.is_none()` | = note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)] -help: try this - | if None::<()>.is_none() { error: redundant pattern matching, consider using `is_some()` --> $DIR/if_let_redundant_pattern_matching.rs:26:12 | 26 | if let Some(_) = Some(42) { - | ^^^^^^^ + | -------^^^^^^^----------- help: try this `if Some(42).is_some()` | = note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)] -help: try this - | if Some(42).is_some() { error: aborting due to 4 previous errors diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index 2961ae9e5b5..27fa35e6c03 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -50,69 +50,49 @@ error: length comparison to zero --> $DIR/len_zero.rs:130:8 | 130 | if x.len() == 0 { - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ help: using `is_empty` is more concise: `x.is_empty()` | note: lint level defined here --> $DIR/len_zero.rs:4:31 | 4 | #![deny(len_without_is_empty, len_zero)] | ^^^^^^^^ -help: consider using `is_empty` - | if x.is_empty() { error: length comparison to zero --> $DIR/len_zero.rs:137:8 | 137 | if "".len() == 0 { - | ^^^^^^^^^^^^^ - | -help: consider using `is_empty` - | if "".is_empty() { + | ^^^^^^^^^^^^^ help: using `is_empty` is more concise: `"".is_empty()` error: length comparison to zero --> $DIR/len_zero.rs:154:8 | 154 | if has_is_empty.len() == 0 { - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using `is_empty` - | if has_is_empty.is_empty() { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `has_is_empty.is_empty()` error: length comparison to zero --> $DIR/len_zero.rs:160:8 | 160 | if has_is_empty.len() != 0 { - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using `is_empty` - | if !has_is_empty.is_empty() { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` error: length comparison to zero --> $DIR/len_zero.rs:166:8 | 166 | if has_is_empty.len() > 0 { - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using `is_empty` - | if !has_is_empty.is_empty() { + | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` error: length comparison to zero --> $DIR/len_zero.rs:175:8 | 175 | if with_is_empty.len() == 0 { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using `is_empty` - | if with_is_empty.is_empty() { + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `with_is_empty.is_empty()` error: length comparison to zero --> $DIR/len_zero.rs:190:8 | 190 | if b.len() != 0 { - | ^^^^^^^^^^^^ - | -help: consider using `is_empty` - | if !b.is_empty() { + | ^^^^^^^^^^^^ help: using `is_empty` is more concise: `!b.is_empty()` error: aborting due to 11 previous errors diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index 65139c9ba92..c080c54d057 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -8,15 +8,13 @@ error: `if _ { .. } else { .. }` is an expression 61 | | if f() { 62 | | foo = 42; 63 | | } - | |_____^ + | |_____^ help: it is more idiomatic to write `let foo = if f() { 42 } else { 0 };` | note: lint level defined here --> $DIR/let_if_seq.rs:5:9 | 5 | #![deny(useless_let_if_seq)] | ^^^^^^^^^^^^^^^^^^ -help: it is more idiomatic to write - | let foo = if f() { 42 } else { 0 }; = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression @@ -29,10 +27,8 @@ error: `if _ { .. } else { .. }` is an expression ... | 74 | | f(); 75 | | } - | |_____^ + | |_____^ help: it is more idiomatic to write `let bar = if f() { ..; 42 } else { ..; 0 };` | -help: it is more idiomatic to write - | let bar = if f() { ..; 42 } else { ..; 0 }; = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression @@ -45,10 +41,7 @@ error: `if _ { .. } else { .. }` is an expression ... | 85 | | quz = 0; 86 | | } - | |_____^ - | -help: it is more idiomatic to write - | let quz = if f() { 42 } else { 0 }; + | |_____^ help: it is more idiomatic to write `let quz = if f() { 42 } else { 0 };` error: `if _ { .. } else { .. }` is an expression --> $DIR/let_if_seq.rs:111:5 @@ -60,10 +53,8 @@ error: `if _ { .. } else { .. }` is an expression 115 | | if f() { 116 | | baz = 42; 117 | | } - | |_____^ + | |_____^ help: it is more idiomatic to write `let baz = if f() { 42 } else { 0 };` | -help: it is more idiomatic to write - | let baz = if f() { 42 } else { 0 }; = note: you might not need `mut` at all error: aborting due to 4 previous errors diff --git a/tests/ui/literals.stderr b/tests/ui/literals.stderr index b9a0fc04181..e87fe887bf4 100644 --- a/tests/ui/literals.stderr +++ b/tests/ui/literals.stderr @@ -71,8 +71,6 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^^^^ help: if you mean to use a decimal constant, remove the `0` to remove confusion: | let fail8 = 123; -help: if you mean to use an octal constant, use `0o`: - | let fail8 = 0o123; error: aborting due to 9 previous errors diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index 25653b6aa5a..47c323cbfeb 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -8,15 +8,13 @@ error: you seem to be trying to use match for destructuring a single pattern. Co 30 | | ExprNode::ExprAddrOf => Some(&NODE), 31 | | _ => { let x = 5; None }, 32 | | } - | |_____^ + | |_____^ help: try this `if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None }` | note: lint level defined here --> $DIR/matches.rs:7:9 | 7 | #![deny(single_match_else)] | ^^^^^^^^^^^^^^^^^ -help: try this - | if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None } error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` --> $DIR/matches.rs:38:5 @@ -28,7 +26,7 @@ error: you seem to be trying to use match for destructuring a single pattern. Co 42 | | Some(y) => { println!("{:?}", y); } 43 | | _ => () 44 | | }; - | |_____^ + | |_____^ help: try this `if let Some(y) = x { println!("{:?}", y); }` | = note: #[deny(single_match)] implied by #[deny(clippy)] note: lint level defined here @@ -36,8 +34,6 @@ note: lint level defined here | 5 | #![deny(clippy)] | ^^^^^^ -help: try this - | if let Some(y) = x { println!("{:?}", y); }; error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` --> $DIR/matches.rs:47:5 @@ -49,11 +45,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co 51 | | (2...3, 7...9) => dummy(), 52 | | _ => {} 53 | | }; - | |_____^ + | |_____^ help: try this `if let (2...3, 7...9) = z { dummy() }` | = note: #[deny(single_match)] implied by #[deny(clippy)] -help: try this - | if let (2...3, 7...9) = z { dummy() }; error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` --> $DIR/matches.rs:72:5 @@ -65,11 +59,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co 76 | | Some(y) => dummy(), 77 | | None => () 78 | | }; - | |_____^ + | |_____^ help: try this `if let Some(y) = x { dummy() }` | = note: #[deny(single_match)] implied by #[deny(clippy)] -help: try this - | if let Some(y) = x { dummy() }; error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` --> $DIR/matches.rs:80:5 @@ -81,11 +73,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co 84 | | Ok(y) => dummy(), 85 | | Err(..) => () 86 | | }; - | |_____^ + | |_____^ help: try this `if let Ok(y) = y { dummy() }` | = note: #[deny(single_match)] implied by #[deny(clippy)] -help: try this - | if let Ok(y) = y { dummy() }; error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` --> $DIR/matches.rs:90:5 @@ -97,11 +87,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co 94 | | Cow::Borrowed(..) => dummy(), 95 | | Cow::Owned(..) => (), 96 | | }; - | |_____^ + | |_____^ help: try this `if let Cow::Borrowed(..) = c { dummy() }` | = note: #[deny(single_match)] implied by #[deny(clippy)] -help: try this - | if let Cow::Borrowed(..) = c { dummy() }; error: you seem to be trying to match on a boolean expression --> $DIR/matches.rs:114:5 @@ -113,7 +101,7 @@ error: you seem to be trying to match on a boolean expression 118 | | true => 0, 119 | | false => 42, 120 | | }; - | |_____^ + | |_____^ help: consider using an if/else expression `if test { 0 } else { 42 }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] note: lint level defined here @@ -121,8 +109,6 @@ note: lint level defined here | 5 | #![deny(clippy)] | ^^^^^^ -help: consider using an if/else expression - | if test { 0 } else { 42 }; error: you seem to be trying to match on a boolean expression --> $DIR/matches.rs:123:5 @@ -134,11 +120,9 @@ error: you seem to be trying to match on a boolean expression 127 | | true => 1, 128 | | false => 0, 129 | | }; - | |_____^ + | |_____^ help: consider using an if/else expression `if option == 1 { 1 } else { 0 }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] -help: consider using an if/else expression - | if option == 1 { 1 } else { 0 }; error: you seem to be trying to match on a boolean expression --> $DIR/matches.rs:131:5 @@ -150,11 +134,9 @@ error: you seem to be trying to match on a boolean expression 135 | | true => (), 136 | | false => { println!("Noooo!"); } 137 | | }; - | |_____^ + | |_____^ help: consider using an if/else expression `if !test { println!("Noooo!"); }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] -help: consider using an if/else expression - | if !test { println!("Noooo!"); }; error: you seem to be trying to match on a boolean expression --> $DIR/matches.rs:139:5 @@ -166,11 +148,9 @@ error: you seem to be trying to match on a boolean expression 143 | | false => { println!("Noooo!"); } 144 | | _ => (), 145 | | }; - | |_____^ + | |_____^ help: consider using an if/else expression `if !test { println!("Noooo!"); }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] -help: consider using an if/else expression - | if !test { println!("Noooo!"); }; error: you seem to be trying to match on a boolean expression --> $DIR/matches.rs:147:5 @@ -182,11 +162,9 @@ error: you seem to be trying to match on a boolean expression ... | 153 | | _ => (), 154 | | }; - | |_____^ + | |_____^ help: consider using an if/else expression `if !(test && test) { println!("Noooo!"); }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] -help: consider using an if/else expression - | if !(test && test) { println!("Noooo!"); }; error: equal expressions as operands to `&&` --> $DIR/matches.rs:147:11 @@ -211,11 +189,9 @@ error: you seem to be trying to match on a boolean expression 160 | | false => { println!("Noooo!"); } 161 | | true => { println!("Yes!"); } 162 | | }; - | |_____^ + | |_____^ help: consider using an if/else expression `if test { println!("Yes!"); } else { println!("Noooo!"); }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] -help: consider using an if/else expression - | if test { println!("Yes!"); } else { println!("Noooo!"); }; error: you don't need to add `&` to all patterns --> $DIR/matches.rs:175:9 @@ -264,11 +240,9 @@ error: you don't need to add `&` to both the expression and the patterns 201 | | &Some(v) => println!("{:?}", v), 202 | | &None => println!("none"), 203 | | } - | |_____^ + | |_____^ help: try `match w { .. }` | = note: #[deny(match_ref_pats)] implied by #[deny(clippy)] -help: try - | match w { .. } error: you don't need to add `&` to all patterns --> $DIR/matches.rs:211:5 @@ -294,11 +268,9 @@ error: you don't need to add `&` to both the expression and the patterns 222 | | 223 | | println!("none"); 224 | | } - | |_____^ + | |_____^ help: try `if let .. = b { .. }` | = note: #[deny(match_ref_pats)] implied by #[deny(clippy)] -help: try - | if let .. = b { .. } error: some ranges overlap --> $DIR/matches.rs:231:9 diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index 3d5289d2c1d..da8d300c058 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -241,7 +241,7 @@ error: use of `unwrap_or` followed by a function call --> $DIR/methods.rs:278:5 | 278 | with_constructor.unwrap_or(make()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_constructor.unwrap_or_else(make)` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] note: lint level defined here @@ -249,118 +249,94 @@ note: lint level defined here | 5 | #![deny(clippy, clippy_pedantic)] | ^^^^^^ -help: try this - | with_constructor.unwrap_or_else(make); error: use of `unwrap_or` followed by a call to `new` --> $DIR/methods.rs:284:5 | 284 | with_new.unwrap_or(Vec::new()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_new.unwrap_or_default()` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | with_new.unwrap_or_default(); error: use of `unwrap_or` followed by a function call --> $DIR/methods.rs:290:5 | 290 | with_const_args.unwrap_or(Vec::with_capacity(12)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_const_args.unwrap_or_else(|| Vec::with_capacity(12))` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | with_const_args.unwrap_or_else(|| Vec::with_capacity(12)); error: use of `unwrap_or` followed by a function call --> $DIR/methods.rs:296:5 | 296 | with_err.unwrap_or(make()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_err.unwrap_or_else(|_| make())` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | with_err.unwrap_or_else(|_| make()); error: use of `unwrap_or` followed by a function call --> $DIR/methods.rs:302:5 | 302 | with_err_args.unwrap_or(Vec::with_capacity(12)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_err_args.unwrap_or_else(|_| Vec::with_capacity(12))` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | with_err_args.unwrap_or_else(|_| Vec::with_capacity(12)); error: use of `unwrap_or` followed by a call to `default` --> $DIR/methods.rs:308:5 | 308 | with_default_trait.unwrap_or(Default::default()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_default_trait.unwrap_or_default()` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | with_default_trait.unwrap_or_default(); error: use of `unwrap_or` followed by a call to `default` --> $DIR/methods.rs:314:5 | 314 | with_default_type.unwrap_or(u64::default()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_default_type.unwrap_or_default()` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | with_default_type.unwrap_or_default(); error: use of `unwrap_or` followed by a function call --> $DIR/methods.rs:320:5 | 320 | with_vec.unwrap_or(vec![]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_vec.unwrap_or_else(|| < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ))` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | with_vec.unwrap_or_else(|| < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] )); error: use of `unwrap_or` followed by a function call --> $DIR/methods.rs:326:5 | 326 | without_default.unwrap_or(Foo::new()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `without_default.unwrap_or_else(Foo::new)` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | without_default.unwrap_or_else(Foo::new); error: use of `or_insert` followed by a function call --> $DIR/methods.rs:332:5 | 332 | map.entry(42).or_insert(String::new()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `map.entry(42).or_insert_with(String::new)` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | map.entry(42).or_insert_with(String::new); error: use of `or_insert` followed by a function call --> $DIR/methods.rs:338:5 | 338 | btree.entry(42).or_insert(String::new()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `btree.entry(42).or_insert_with(String::new)` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | btree.entry(42).or_insert_with(String::new); error: use of `unwrap_or` followed by a function call --> $DIR/methods.rs:344:13 | 344 | let _ = stringy.unwrap_or("".to_owned()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `stringy.unwrap_or_else(|| "".to_owned())` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] -help: try this - | let _ = stringy.unwrap_or_else(|| "".to_owned()); error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable --> $DIR/methods.rs:358:23 @@ -464,7 +440,7 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more co --> $DIR/methods.rs:429:17 | 429 | let _ = boxed_slice.get(1).unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&boxed_slice[1]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] note: lint level defined here @@ -472,98 +448,78 @@ note: lint level defined here | 5 | #![deny(clippy, clippy_pedantic)] | ^^^^^^ -help: try this - | let _ = &boxed_slice[1]; error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/methods.rs:433:17 | 433 | let _ = some_slice.get(0).unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_slice[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] -help: try this - | let _ = &some_slice[0]; error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/methods.rs:437:17 | 437 | let _ = some_vec.get(0).unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_vec[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] -help: try this - | let _ = &some_vec[0]; error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise --> $DIR/methods.rs:441:17 | 441 | let _ = some_vecdeque.get(0).unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_vecdeque[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] -help: try this - | let _ = &some_vecdeque[0]; error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise --> $DIR/methods.rs:445:17 | 445 | let _ = some_hashmap.get(&1).unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_hashmap[&1]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] -help: try this - | let _ = &some_hashmap[&1]; error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise --> $DIR/methods.rs:449:17 | 449 | let _ = some_btreemap.get(&1).unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_btreemap[&1]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] -help: try this - | let _ = &some_btreemap[&1]; error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/methods.rs:458:10 | 458 | *boxed_slice.get_mut(0).unwrap() = 1; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut boxed_slice[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] -help: try this - | *&mut boxed_slice[0] = 1; error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/methods.rs:462:10 | 462 | *some_slice.get_mut(0).unwrap() = 1; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut some_slice[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] -help: try this - | *&mut some_slice[0] = 1; error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/methods.rs:466:10 | 466 | *some_vec.get_mut(0).unwrap() = 1; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut some_vec[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] -help: try this - | *&mut some_vec[0] = 1; error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise --> $DIR/methods.rs:470:10 | 470 | *some_vecdeque.get_mut(0).unwrap() = 1; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut some_vecdeque[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] -help: try this - | *&mut some_vecdeque[0] = 1; error: used unwrap() on an Option value. If you don't want to handle the None case gracefully, consider using expect() to provide a better panic message --> $DIR/methods.rs:488:13 @@ -640,7 +596,7 @@ error: you should use the `starts_with` method --> $DIR/methods.rs:517:5 | 517 | "".chars().next() == Some(' '); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this `"".starts_with(' ')` | = note: #[deny(chars_next_cmp)] implied by #[deny(clippy)] note: lint level defined here @@ -648,24 +604,20 @@ note: lint level defined here | 5 | #![deny(clippy, clippy_pedantic)] | ^^^^^^ -help: like this - | "".starts_with(' '); error: you should use the `starts_with` method --> $DIR/methods.rs:522:5 | 522 | Some(' ') != "".chars().next(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this `!"".starts_with(' ')` | = note: #[deny(chars_next_cmp)] implied by #[deny(clippy)] -help: like this - | !"".starts_with(' '); error: calling `.extend(_.chars())` --> $DIR/methods.rs:534:5 | 534 | s.extend(abc.chars()); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ help: try this `s.push_str(abc)` | = note: #[deny(string_extend_chars)] implied by #[deny(clippy)] note: lint level defined here @@ -673,34 +625,28 @@ note: lint level defined here | 5 | #![deny(clippy, clippy_pedantic)] | ^^^^^^ -help: try this - | s.push_str(abc); error: calling `.extend(_.chars())` --> $DIR/methods.rs:540:5 | 540 | s.extend("abc".chars()); - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try this `s.push_str("abc")` | = note: #[deny(string_extend_chars)] implied by #[deny(clippy)] -help: try this - | s.push_str("abc"); error: calling `.extend(_.chars())` --> $DIR/methods.rs:546:5 | 546 | s.extend(def.chars()); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ help: try this `s.push_str(&def)` | = note: #[deny(string_extend_chars)] implied by #[deny(clippy)] -help: try this - | s.push_str(&def); error: using `clone` on a `Copy` type --> $DIR/methods.rs:560:5 | 560 | 42.clone(); - | ^^^^^^^^^^ + | ^^^^^^^^^^ help: try removing the `clone` call `42` | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] note: lint level defined here @@ -708,44 +654,36 @@ note: lint level defined here | 5 | #![deny(clippy, clippy_pedantic)] | ^^^^^^ -help: try removing the `clone` call - | 42; error: using `clone` on a `Copy` type --> $DIR/methods.rs:565:5 | 565 | (&42).clone(); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ help: try dereferencing it `*(&42)` | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] -help: try dereferencing it - | *(&42); error: using `clone` on a `Copy` type --> $DIR/methods.rs:571:5 | 571 | t.clone(); - | ^^^^^^^^^ + | ^^^^^^^^^ help: try removing the `clone` call `t` | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] -help: try removing the `clone` call - | t; error: using `clone` on a `Copy` type --> $DIR/methods.rs:574:5 | 574 | Some(t).clone(); - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ help: try removing the `clone` call `Some(t)` | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] -help: try removing the `clone` call - | Some(t); error: using `clone` on a double-reference; this will copy the reference instead of cloning the inner type --> $DIR/methods.rs:582:22 | 582 | let z: &Vec<_> = y.clone(); - | ^^^^^^^^^ + | ^^^^^^^^^ help: try dereferencing it `(*y).clone()` | = note: #[deny(clone_double_ref)] implied by #[deny(clippy)] note: lint level defined here @@ -753,14 +691,12 @@ note: lint level defined here | 5 | #![deny(clippy, clippy_pedantic)] | ^^^^^^ -help: try dereferencing it - | let z: &Vec<_> = (*y).clone(); error: single-character string constant used as pattern --> $DIR/methods.rs:590:13 | 590 | x.split("x"); - | ^^^ + | --------^^^- help: try using a char instead: `x.split('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] note: lint level defined here @@ -768,168 +704,134 @@ note: lint level defined here | 5 | #![deny(clippy, clippy_pedantic)] | ^^^^^^ -help: try using a char instead: - | x.split('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:614:16 | 614 | x.contains("x"); - | ^^^ + | -----------^^^- help: try using a char instead: `x.contains('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.contains('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:618:19 | 618 | x.starts_with("x"); - | ^^^ + | --------------^^^- help: try using a char instead: `x.starts_with('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.starts_with('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:622:17 | 622 | x.ends_with("x"); - | ^^^ + | ------------^^^- help: try using a char instead: `x.ends_with('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.ends_with('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:626:12 | 626 | x.find("x"); - | ^^^ + | -------^^^- help: try using a char instead: `x.find('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.find('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:630:13 | 630 | x.rfind("x"); - | ^^^ + | --------^^^- help: try using a char instead: `x.rfind('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.rfind('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:634:14 | 634 | x.rsplit("x"); - | ^^^ + | ---------^^^- help: try using a char instead: `x.rsplit('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.rsplit('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:638:24 | 638 | x.split_terminator("x"); - | ^^^ + | -------------------^^^- help: try using a char instead: `x.split_terminator('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.split_terminator('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:642:25 | 642 | x.rsplit_terminator("x"); - | ^^^ + | --------------------^^^- help: try using a char instead: `x.rsplit_terminator('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.rsplit_terminator('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:646:17 | 646 | x.splitn(0, "x"); - | ^^^ + | ------------^^^- help: try using a char instead: `x.splitn(0, 'x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.splitn(0, 'x'); error: single-character string constant used as pattern --> $DIR/methods.rs:650:18 | 650 | x.rsplitn(0, "x"); - | ^^^ + | -------------^^^- help: try using a char instead: `x.rsplitn(0, 'x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.rsplitn(0, 'x'); error: single-character string constant used as pattern --> $DIR/methods.rs:654:15 | 654 | x.matches("x"); - | ^^^ + | ----------^^^- help: try using a char instead: `x.matches('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.matches('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:658:16 | 658 | x.rmatches("x"); - | ^^^ + | -----------^^^- help: try using a char instead: `x.rmatches('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.rmatches('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:662:21 | 662 | x.match_indices("x"); - | ^^^ + | ----------------^^^- help: try using a char instead: `x.match_indices('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.match_indices('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:666:22 | 666 | x.rmatch_indices("x"); - | ^^^ + | -----------------^^^- help: try using a char instead: `x.rmatch_indices('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.rmatch_indices('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:670:25 | 670 | x.trim_left_matches("x"); - | ^^^ + | --------------------^^^- help: try using a char instead: `x.trim_left_matches('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.trim_left_matches('x'); error: single-character string constant used as pattern --> $DIR/methods.rs:674:26 | 674 | x.trim_right_matches("x"); - | ^^^ + | ---------------------^^^- help: try using a char instead: `x.trim_right_matches('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] -help: try using a char instead: - | x.trim_right_matches('x'); error: you are getting the inner pointer of a temporary `CString` --> $DIR/methods.rs:687:5 diff --git a/tests/ui/needless_bool.stderr b/tests/ui/needless_bool.stderr index 930a3cba514..b978085b6a9 100644 --- a/tests/ui/needless_bool.stderr +++ b/tests/ui/needless_bool.stderr @@ -20,28 +20,19 @@ error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:11:5 | 11 | if x { true } else { false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: you can reduce it to - | x; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `x` error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:15:5 | 15 | if x { false } else { true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: you can reduce it to - | !x; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `!x` error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:19:5 | 19 | if x && y { false } else { true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: you can reduce it to - | !(x && y); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `!(x && y)` error: this if-then-else expression will always return true --> $DIR/needless_bool.rs:34:5 @@ -59,37 +50,25 @@ error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:46:5 | 46 | if x { return true } else { return false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: you can reduce it to - | return x; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `return x` error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:54:5 | 54 | if x && y { return true } else { return false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: you can reduce it to - | return x && y; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `return x && y` error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:62:5 | 62 | if x { return false } else { return true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: you can reduce it to - | return !x; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `return !x` error: this if-then-else expression returns a bool literal --> $DIR/needless_bool.rs:70:5 | 70 | if x && y { return false } else { return true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: you can reduce it to - | return !(x && y); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `return !(x && y)` error: aborting due to 11 previous errors diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index 88a424a9696..6cc5149d183 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -2,42 +2,31 @@ error: this argument is passed by value, but not consumed in the function body --> $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: lint level defined here --> $DIR/needless_pass_by_value.rs:4:9 | 4 | #![deny(needless_pass_by_value)] | ^^^^^^^^^^^^^^^^^^^^^^ -help: consider changing the type to `&[T]` - | fn foo(v: &[T], w: Vec, mut x: Vec, y: Vec) -> Vec { error: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:23:11 | 23 | fn bar(x: String, y: Wrapper) { - | ^^^^^^ - | -help: consider changing the type to `&str` - | fn bar(x: &str, 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:23:22 | 23 | fn bar(x: String, y: Wrapper) { - | ^^^^^^^ - | -help: consider taking a reference instead - | 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:29:63 | 29 | fn test_borrow_trait, U>(t: T, u: U) { - | ^ - | -help: consider taking a reference instead - | fn test_borrow_trait, U>(t: T, 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:40:18 @@ -53,10 +42,7 @@ error: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:53:24 | 53 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { - | ^^^^^^^ - | -help: consider taking a reference instead - | 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:53:36 diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 0d9f5f9a57d..300713202c7 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -2,78 +2,55 @@ error: unneeded return statement --> $DIR/needless_return.rs:11:5 | 11 | return true; - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ help: remove `return` as shown: `true` | note: lint level defined here --> $DIR/needless_return.rs:4:9 | 4 | #![deny(needless_return)] | ^^^^^^^^^^^^^^^ -help: remove `return` as shown: - | true error: unneeded return statement --> $DIR/needless_return.rs:18:5 | 18 | return true - | ^^^^^^^^^^^ - | -help: remove `return` as shown: - | true + | ^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement --> $DIR/needless_return.rs:26:9 | 26 | return true; - | ^^^^^^^^^^^^ - | -help: remove `return` as shown: - | true + | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement --> $DIR/needless_return.rs:31:9 | 31 | return false; - | ^^^^^^^^^^^^^ - | -help: remove `return` as shown: - | false + | ^^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement --> $DIR/needless_return.rs:40:17 | 40 | true => return false, - | ^^^^^^^^^^^^ - | -help: remove `return` as shown: - | true => false, + | ^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement --> $DIR/needless_return.rs:46:13 | 46 | return true; - | ^^^^^^^^^^^^ - | -help: remove `return` as shown: - | true + | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement --> $DIR/needless_return.rs:56:9 | 56 | return true; - | ^^^^^^^^^^^^ - | -help: remove `return` as shown: - | true + | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement --> $DIR/needless_return.rs:61:16 | 61 | let _ = || return true; - | ^^^^^^^^^^^ - | -help: remove `return` as shown: - | let _ = || true; + | ^^^^^^^^^^^ help: remove `return` as shown: `true` error: aborting due to 8 previous errors diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index 5fd1d7c425b..7a74473dd3b 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -158,177 +158,121 @@ error: statement can be reduced --> $DIR/no_effect.rs:65:5 | 65 | Tuple(get_number()); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` | note: lint level defined here --> $DIR/no_effect.rs:4:20 | 4 | #![deny(no_effect, unnecessary_operation)] | ^^^^^^^^^^^^^^^^^^^^^ -help: replace it with - | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:68:5 | 68 | Struct { field: get_number() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: replace it with - | get_number(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:71:5 | 71 | Struct { ..get_struct() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: replace it with - | get_struct(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_struct();` error: statement can be reduced --> $DIR/no_effect.rs:74:5 | 74 | Enum::Tuple(get_number()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: replace it with - | get_number(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:77:5 | 77 | Enum::Struct { field: get_number() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: replace it with - | get_number(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:80:5 | 80 | 5 + get_number(); - | ^^^^^^^^^^^^^^^^^ - | -help: replace it with - | 5;get_number(); + | ^^^^^^^^^^^^^^^^^ help: replace it with `5;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:83:5 | 83 | *&get_number(); - | ^^^^^^^^^^^^^^^ - | -help: replace it with - | get_number(); + | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:86:5 | 86 | &get_number(); - | ^^^^^^^^^^^^^^ - | -help: replace it with - | get_number(); + | ^^^^^^^^^^^^^^ help: replace it with `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:89:5 | 89 | (5, 6, get_number()); - | ^^^^^^^^^^^^^^^^^^^^^ - | -help: replace it with - | 5;6;get_number(); + | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with `5;6;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:92:5 | 92 | box get_number(); - | ^^^^^^^^^^^^^^^^^ - | -help: replace it with - | get_number(); + | ^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:95:5 | 95 | get_number()..; - | ^^^^^^^^^^^^^^^ - | -help: replace it with - | get_number(); + | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:98:5 | 98 | ..get_number(); - | ^^^^^^^^^^^^^^^ - | -help: replace it with - | get_number(); + | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:101:5 | 101 | 5..get_number(); - | ^^^^^^^^^^^^^^^^ - | -help: replace it with - | 5;get_number(); + | ^^^^^^^^^^^^^^^^ help: replace it with `5;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:104:5 | 104 | [42, get_number()]; - | ^^^^^^^^^^^^^^^^^^^ - | -help: replace it with - | 42;get_number(); + | ^^^^^^^^^^^^^^^^^^^ help: replace it with `42;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:107:5 | 107 | [42, 55][get_number() as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: replace it with - | [42, 55];get_number() as usize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `[42, 55];get_number() as usize;` error: statement can be reduced --> $DIR/no_effect.rs:110:5 | 110 | (42, get_number()).1; - | ^^^^^^^^^^^^^^^^^^^^^ - | -help: replace it with - | 42;get_number(); + | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with `42;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:113:5 | 113 | [get_number(); 55]; - | ^^^^^^^^^^^^^^^^^^^ - | -help: replace it with - | get_number(); + | ^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:116:5 | 116 | [42; 55][get_number() as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: replace it with - | [42; 55];get_number() as usize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `[42; 55];get_number() as usize;` error: statement can be reduced --> $DIR/no_effect.rs:119:5 | 119 | {get_number()}; - | ^^^^^^^^^^^^^^^ - | -help: replace it with - | get_number(); + | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` error: aborting due to 44 previous errors diff --git a/tests/ui/precedence.stderr b/tests/ui/precedence.stderr index 5eb8d91ec21..9dd86d19181 100644 --- a/tests/ui/precedence.stderr +++ b/tests/ui/precedence.stderr @@ -2,87 +2,61 @@ error: operator precedence can trip the unwary --> $DIR/precedence.rs:8:5 | 8 | 1 << 2 + 3; - | ^^^^^^^^^^ + | ^^^^^^^^^^ help: consider parenthesizing your expression `1 << (2 + 3)` | note: lint level defined here --> $DIR/precedence.rs:4:8 | 4 | #[deny(precedence)] | ^^^^^^^^^^ -help: consider parenthesizing your expression - | 1 << (2 + 3); error: operator precedence can trip the unwary --> $DIR/precedence.rs:11:5 | 11 | 1 + 2 << 3; - | ^^^^^^^^^^ - | -help: consider parenthesizing your expression - | (1 + 2) << 3; + | ^^^^^^^^^^ help: consider parenthesizing your expression `(1 + 2) << 3` error: operator precedence can trip the unwary --> $DIR/precedence.rs:14:5 | 14 | 4 >> 1 + 1; - | ^^^^^^^^^^ - | -help: consider parenthesizing your expression - | 4 >> (1 + 1); + | ^^^^^^^^^^ help: consider parenthesizing your expression `4 >> (1 + 1)` error: operator precedence can trip the unwary --> $DIR/precedence.rs:17:5 | 17 | 1 + 3 >> 2; - | ^^^^^^^^^^ - | -help: consider parenthesizing your expression - | (1 + 3) >> 2; + | ^^^^^^^^^^ help: consider parenthesizing your expression `(1 + 3) >> 2` error: operator precedence can trip the unwary --> $DIR/precedence.rs:20:5 | 20 | 1 ^ 1 - 1; - | ^^^^^^^^^ - | -help: consider parenthesizing your expression - | 1 ^ (1 - 1); + | ^^^^^^^^^ help: consider parenthesizing your expression `1 ^ (1 - 1)` error: operator precedence can trip the unwary --> $DIR/precedence.rs:23:5 | 23 | 3 | 2 - 1; - | ^^^^^^^^^ - | -help: consider parenthesizing your expression - | 3 | (2 - 1); + | ^^^^^^^^^ help: consider parenthesizing your expression `3 | (2 - 1)` error: operator precedence can trip the unwary --> $DIR/precedence.rs:26:5 | 26 | 3 & 5 - 2; - | ^^^^^^^^^ - | -help: consider parenthesizing your expression - | 3 & (5 - 2); + | ^^^^^^^^^ help: consider parenthesizing your expression `3 & (5 - 2)` error: unary minus has lower precedence than method call --> $DIR/precedence.rs:30:5 | 30 | -1i32.abs(); - | ^^^^^^^^^^^ - | -help: consider adding parentheses to clarify your intent - | -(1i32.abs()); + | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent `-(1i32.abs())` error: unary minus has lower precedence than method call --> $DIR/precedence.rs:33:5 | 33 | -1f32.abs(); - | ^^^^^^^^^^^ - | -help: consider adding parentheses to clarify your intent - | -(1f32.abs()); + | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent `-(1f32.abs())` error: aborting due to 9 previous errors diff --git a/tests/ui/redundant_closure_call.stderr b/tests/ui/redundant_closure_call.stderr index 287f465bb4a..bc3ceef0f70 100644 --- a/tests/ui/redundant_closure_call.stderr +++ b/tests/ui/redundant_closure_call.stderr @@ -20,10 +20,7 @@ error: Try not to call a closure in the expression where it is declared. --> $DIR/redundant_closure_call.rs:7:10 | 7 | \tlet a = (|| 42)(); - | \t ^^^^^^^^^ - | -help: Try doing something like: - | \tlet a = 42; + | \t ^^^^^^^^^ help: Try doing something like: `42` error: Try not to call a closure in the expression where it is declared. --> $DIR/redundant_closure_call.rs:13:10 diff --git a/tests/ui/reference.stderr b/tests/ui/reference.stderr index 6701016b3be..5d41c1809b4 100644 --- a/tests/ui/reference.stderr +++ b/tests/ui/reference.stderr @@ -2,105 +2,73 @@ error: immediately dereferencing a reference --> $DIR/reference.rs:19:13 | 19 | let b = *&a; - | ^^^ + | ^^^ help: try this `a` | note: lint level defined here --> $DIR/reference.rs:14:8 | 14 | #[deny(deref_addrof)] | ^^^^^^^^^^^^ -help: try this - | let b = a; error: immediately dereferencing a reference --> $DIR/reference.rs:24:13 | 24 | let b = *&get_number(); - | ^^^^^^^^^^^^^^ - | -help: try this - | let b = get_number(); + | ^^^^^^^^^^^^^^ help: try this `get_number()` error: immediately dereferencing a reference --> $DIR/reference.rs:32:13 | 32 | let b = *&bytes[1..2][0]; - | ^^^^^^^^^^^^^^^^ - | -help: try this - | let b = bytes[1..2][0]; + | ^^^^^^^^^^^^^^^^ help: try this `bytes[1..2][0]` error: immediately dereferencing a reference --> $DIR/reference.rs:39:13 | 39 | let b = *&(a); - | ^^^^^ - | -help: try this - | let b = (a); + | ^^^^^ help: try this `(a)` error: immediately dereferencing a reference --> $DIR/reference.rs:44:13 | 44 | let b = *(&a); - | ^^^^^ - | -help: try this - | let b = a; + | ^^^^^ help: try this `a` error: immediately dereferencing a reference --> $DIR/reference.rs:49:13 | 49 | let b = *((&a)); - | ^^^^^^^ - | -help: try this - | let b = a; + | ^^^^^^^ help: try this `a` error: immediately dereferencing a reference --> $DIR/reference.rs:54:13 | 54 | let b = *&&a; - | ^^^^ - | -help: try this - | let b = &a; + | ^^^^ help: try this `&a` error: immediately dereferencing a reference --> $DIR/reference.rs:59:14 | 59 | let b = **&aref; - | ^^^^^^ - | -help: try this - | let b = *aref; + | ^^^^^^ help: try this `aref` error: immediately dereferencing a reference --> $DIR/reference.rs:66:14 | 66 | let b = **&&a; - | ^^^^ - | -help: try this - | let b = *&a; + | ^^^^ help: try this `&a` error: immediately dereferencing a reference --> $DIR/reference.rs:73:17 | 73 | let y = *&mut x; - | ^^^^^^^ - | -help: try this - | let y = x; + | ^^^^^^^ help: try this `x` error: immediately dereferencing a reference --> $DIR/reference.rs:83:18 | 83 | let y = **&mut &mut x; - | ^^^^^^^^^^^^ - | -help: try this - | let y = *&mut x; + | ^^^^^^^^^^^^ help: try this `&mut x` error: aborting due to 11 previous errors diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index 4c865ebeb19..09e24fa7de6 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -2,33 +2,25 @@ error: boolean short circuit operator in statement may be clearer using an expli --> $DIR/short_circuit_statement.rs:7:5 | 7 | f() && g(); - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ help: replace it with `if f() { g(); }` | note: lint level defined here --> $DIR/short_circuit_statement.rs:4:9 | 4 | #![deny(short_circuit_statement)] | ^^^^^^^^^^^^^^^^^^^^^^^ -help: replace it with - | if f() { g(); } error: boolean short circuit operator in statement may be clearer using an explicit test --> $DIR/short_circuit_statement.rs:11:5 | 11 | f() || g(); - | ^^^^^^^^^^^ - | -help: replace it with - | if !f() { g(); } + | ^^^^^^^^^^^ help: replace it with `if !f() { g(); }` error: boolean short circuit operator in statement may be clearer using an explicit test --> $DIR/short_circuit_statement.rs:15:5 | 15 | 1 == 2 || g(); - | ^^^^^^^^^^^^^^ - | -help: replace it with - | if !(1 == 2) { g(); } + | ^^^^^^^^^^^^^^ help: replace it with `if !(1 == 2) { g(); }` error: aborting due to 3 previous errors diff --git a/tests/ui/strings.stderr b/tests/ui/strings.stderr index b16724261d8..57502888744 100644 --- a/tests/ui/strings.stderr +++ b/tests/ui/strings.stderr @@ -56,25 +56,21 @@ error: calling `as_bytes()` on a string literal --> $DIR/strings.rs:50:14 | 50 | let bs = "hello there".as_bytes(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead `b"hello there"` | note: lint level defined here --> $DIR/strings.rs:48:8 | 48 | #[deny(string_lit_as_bytes)] | ^^^^^^^^^^^^^^^^^^^ -help: consider using a byte string literal instead - | let bs = b"hello there"; warning: manual implementation of an assign operation --> $DIR/strings.rs:68:7 | 68 | ; x = x + 1; - | ^^^^^^^^^ + | ^^^^^^^^^ help: replace it with `x += 1` | = note: #[warn(assign_op_pattern)] on by default -help: replace it with - | ; x += 1; error: aborting due to 6 previous errors diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index 5aaf351b241..0bd8721b4ff 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -4,7 +4,7 @@ error: this looks like you are swapping elements of `foo` manually 11 | / let temp = foo[0]; 12 | | foo[0] = foo[1]; 13 | | foo[1] = temp; - | |_________________^ + | |_________________^ help: try `foo.swap(0, 1)` | = note: #[deny(manual_swap)] implied by #[deny(clippy)] note: lint level defined here @@ -12,8 +12,6 @@ note: lint level defined here | 4 | #![deny(clippy)] | ^^^^^^ -help: try - | foo.swap(0, 1); error: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:23:5 @@ -21,11 +19,9 @@ error: this looks like you are swapping elements of `foo` manually 23 | / let temp = foo[0]; 24 | | foo[0] = foo[1]; 25 | | foo[1] = temp; - | |_________________^ + | |_________________^ help: try `foo.swap(0, 1)` | = note: #[deny(manual_swap)] implied by #[deny(clippy)] -help: try - | foo.swap(0, 1); error: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:35:5 @@ -33,11 +29,9 @@ error: this looks like you are swapping elements of `foo` manually 35 | / let temp = foo[0]; 36 | | foo[0] = foo[1]; 37 | | foo[1] = temp; - | |_________________^ + | |_________________^ help: try `foo.swap(0, 1)` | = note: #[deny(manual_swap)] implied by #[deny(clippy)] -help: try - | foo.swap(0, 1); error: this looks like you are swapping `a` and `b` manually --> $DIR/swap.rs:60:7 @@ -46,11 +40,9 @@ error: this looks like you are swapping `a` and `b` manually | _______^ 61 | | a = b; 62 | | b = t; - | |_________^ + | |_________^ help: try `std::mem::swap(&mut a, &mut b)` | = note: #[deny(manual_swap)] implied by #[deny(clippy)] -help: try - | ; std::mem::swap(&mut a, &mut b); = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `c.0` and `a` manually @@ -60,11 +52,9 @@ error: this looks like you are swapping `c.0` and `a` manually | _______^ 78 | | c.0 = a; 79 | | a = t; - | |_________^ + | |_________^ help: try `std::mem::swap(&mut c.0, &mut a)` | = note: #[deny(manual_swap)] implied by #[deny(clippy)] -help: try - | ; std::mem::swap(&mut c.0, &mut a); = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` @@ -72,7 +62,7 @@ error: this looks like you are trying to swap `a` and `b` | 53 | / a = b; 54 | | b = a; - | |_________^ + | |_________^ help: try `std::mem::swap(&mut a, &mut b)` | = note: #[deny(almost_swapped)] implied by #[deny(clippy)] note: lint level defined here @@ -80,8 +70,6 @@ note: lint level defined here | 4 | #![deny(clippy)] | ^^^^^^ -help: try - | std::mem::swap(&mut a, &mut b); = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `c.0` and `a` @@ -89,11 +77,9 @@ error: this looks like you are trying to swap `c.0` and `a` | 70 | / c.0 = a; 71 | | a = c.0; - | |___________^ + | |___________^ help: try `std::mem::swap(&mut c.0, &mut a)` | = note: #[deny(almost_swapped)] implied by #[deny(clippy)] -help: try - | std::mem::swap(&mut c.0, &mut a); = note: or maybe you should use `std::mem::replace`? error: aborting due to 7 previous errors diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index 86dd880ed12..85faa0d15ab 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -15,41 +15,33 @@ error: `ref` on an entire `let` pattern is discouraged, take a reference with `& --> $DIR/toplevel_ref_arg.rs:18:7 | 18 | let ref x = 1; - | ^^^^^ + | ----^^^^^----- help: try `let x = &1;` | = note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] -help: try - | let x = &1; error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:23:7 | 23 | let ref y: (&_, u8) = (&1, 2); - | ^^^^^ + | ----^^^^^--------------------- help: try `let y: &(&_, u8) = &(&1, 2);` | = note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] -help: try - | let y: &(&_, u8) = &(&1, 2); error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:28:7 | 28 | let ref z = 1 + 2; - | ^^^^^ + | ----^^^^^--------- help: try `let z = &(1 + 2);` | = note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] -help: try - | let z = &(1 + 2); error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:33:7 | 33 | let ref mut z = 1 + 2; - | ^^^^^^^^^ + | ----^^^^^^^^^--------- help: try `let z = &mut (1 + 2);` | = note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] -help: try - | let z = &mut (1 + 2); error: aborting due to 5 previous errors diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index ec9e7941855..49a35e48bf6 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -14,128 +14,91 @@ error: transmute from a reference to a pointer --> $DIR/transmute.rs:27:23 | 27 | let _: *const T = core::intrinsics::transmute(t); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: *const T = t as *const T; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T` error: transmute from a reference to a pointer --> $DIR/transmute.rs:32:21 | 32 | let _: *mut T = core::intrinsics::transmute(t); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: *mut T = t as *const T as *mut T; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T as *mut T` error: transmute from a reference to a pointer --> $DIR/transmute.rs:37:23 | 37 | let _: *const U = core::intrinsics::transmute(t); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: *const U = t as *const T as *const U; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T as *const U` error: transmute from a pointer type (`*const T`) to a reference type (`&T`) --> $DIR/transmute.rs:45:17 | 45 | let _: &T = std::mem::transmute(p); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*p` | note: lint level defined here --> $DIR/transmute.rs:43:8 | 43 | #[deny(transmute_ptr_to_ref)] | ^^^^^^^^^^^^^^^^^^^^ -help: try - | let _: &T = &*p; error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) --> $DIR/transmute.rs:51:21 | 51 | let _: &mut T = std::mem::transmute(m); - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: &mut T = &mut *m; + | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *m` error: transmute from a pointer type (`*mut T`) to a reference type (`&T`) --> $DIR/transmute.rs:57:17 | 57 | let _: &T = std::mem::transmute(m); - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: &T = &*m; + | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*m` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) --> $DIR/transmute.rs:63:21 | 63 | let _: &mut T = std::mem::transmute(p as *mut T); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: &mut T = &mut *(p as *mut T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *(p as *mut T)` error: transmute from a pointer type (`*const U`) to a reference type (`&T`) --> $DIR/transmute.rs:69:17 | 69 | let _: &T = std::mem::transmute(o); - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: &T = &*(o as *const T); + | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(o as *const T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`) --> $DIR/transmute.rs:75:21 | 75 | let _: &mut T = std::mem::transmute(om); - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: &mut T = &mut *(om as *mut T); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *(om as *mut T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&T`) --> $DIR/transmute.rs:81:17 | 81 | let _: &T = std::mem::transmute(om); - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: &T = &*(om as *const T); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(om as *const T)` error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, u8>`) --> $DIR/transmute.rs:95:32 | 95 | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const Foo<_>)` | note: lint level defined here --> $DIR/transmute.rs:88:8 | 88 | #[deny(transmute_ptr_to_ref)] | ^^^^^^^^^^^^^^^^^^^^ -help: try - | let _: &Foo = unsafe { &*(raw as *const Foo<_>) }; error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, &u8>`) --> $DIR/transmute.rs:100:33 | 100 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: &Foo<&u8> = unsafe { &*(raw as *const Foo<&_>) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const Foo<&_>)` error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) --> $DIR/transmute.rs:107:14 | 107 | unsafe { std::mem::transmute::<_, Bar>(raw) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | unsafe { &*(raw as *const u8) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const u8)` error: transmute from a type (`std::vec::Vec`) to itself --> $DIR/transmute.rs:116:27 @@ -177,19 +140,13 @@ error: transmute from an integer to a pointer --> $DIR/transmute.rs:137:31 | 137 | let _: *const usize = std::mem::transmute(5_isize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: *const usize = 5_isize as *const usize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `5_isize as *const usize` error: transmute from an integer to a pointer --> $DIR/transmute.rs:143:31 | 143 | let _: *const usize = std::mem::transmute(1+1usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | let _: *const usize = (1+1usize) as *const usize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `(1+1usize) as *const usize` error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`) --> $DIR/transmute.rs:160:24 diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index 05d3da4ca3f..911321e5f74 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -2,15 +2,13 @@ error: useless lint attribute --> $DIR/useless_attribute.rs:5:1 | 5 | #[allow(dead_code)] - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use `#![allow(dead_code)]` | note: lint level defined here --> $DIR/useless_attribute.rs:3:9 | 3 | #![deny(useless_attribute)] | ^^^^^^^^^^^^^^^^^ -help: if you just forgot a `!`, use - | #![allow(dead_code)] error: aborting due to previous error diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index c42b156fced..bffd30297d9 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -2,60 +2,43 @@ error: useless use of `vec!` --> $DIR/vec.rs:24:14 | 24 | on_slice(&vec![]); - | ^^^^^^^ + | ^^^^^^^ help: you can use a slice directly `&[]` | note: lint level defined here --> $DIR/vec.rs:4:9 | 4 | #![deny(useless_vec)] | ^^^^^^^^^^^ -help: you can use a slice directly - | on_slice(&[]); error: useless use of `vec!` --> $DIR/vec.rs:30:14 | 30 | on_slice(&vec![1, 2]); - | ^^^^^^^^^^^ - | -help: you can use a slice directly - | on_slice(&[1, 2]); + | ^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]` error: useless use of `vec!` --> $DIR/vec.rs:36:14 | 36 | on_slice(&vec ![1, 2]); - | ^^^^^^^^^^^^ - | -help: you can use a slice directly - | on_slice(&[1, 2]); + | ^^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]` error: useless use of `vec!` --> $DIR/vec.rs:42:14 | 42 | on_slice(&vec!(1, 2)); - | ^^^^^^^^^^^ - | -help: you can use a slice directly - | on_slice(&[1, 2]); + | ^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]` error: useless use of `vec!` --> $DIR/vec.rs:48:14 | 48 | on_slice(&vec![1; 2]); - | ^^^^^^^^^^^ - | -help: you can use a slice directly - | on_slice(&[1; 2]); + | ^^^^^^^^^^^ help: you can use a slice directly `&[1; 2]` error: useless use of `vec!` --> $DIR/vec.rs:64:14 | 64 | for a in vec![1, 2, 3] { - | ^^^^^^^^^^^^^ - | -help: you can use a slice directly - | for a in &[1, 2, 3] { + | ^^^^^^^^^^^^^ help: you can use a slice directly `&[1, 2, 3]` error: aborting due to 6 previous errors diff --git a/tests/ui/while_loop.stderr b/tests/ui/while_loop.stderr index 221b6a249b0..319d099c41e 100644 --- a/tests/ui/while_loop.stderr +++ b/tests/ui/while_loop.stderr @@ -8,15 +8,13 @@ error: this loop could be written as a `while let` loop ... | 17 | | } 18 | | } - | |_____^ + | |_____^ help: try `while let Some(_x) = y { .. }` | note: lint level defined here --> $DIR/while_loop.rs:4:9 | 4 | #![deny(while_let_loop, empty_loop, while_let_on_iterator)] | ^^^^^^^^^^^^^^ -help: try - | while let Some(_x) = y { .. } error: this loop could be written as a `while let` loop --> $DIR/while_loop.rs:25:5 @@ -28,10 +26,7 @@ error: this loop could be written as a `while let` loop ... | 32 | | }; 33 | | } - | |_____^ - | -help: try - | while let Some(_x) = y { .. } + | |_____^ help: try `while let Some(_x) = y { .. }` error: this loop could be written as a `while let` loop --> $DIR/while_loop.rs:34:5 @@ -43,10 +38,7 @@ error: this loop could be written as a `while let` loop ... | 43 | | let _str = "foo"; 44 | | } - | |_____^ - | -help: try - | while let Some(x) = y { .. } + | |_____^ help: try `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop --> $DIR/while_loop.rs:45:5 @@ -58,10 +50,7 @@ error: this loop could be written as a `while let` loop ... | 54 | | { let _b = "foobar"; } 55 | | } - | |_____^ - | -help: try - | while let Some(x) = y { .. } + | |_____^ help: try `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop --> $DIR/while_loop.rs:70:5 @@ -73,10 +62,7 @@ error: this loop could be written as a `while let` loop ... | 79 | | let _ = (e, l); 80 | | } - | |_____^ - | -help: try - | while let Some(word) = "".split_whitespace().next() { .. } + | |_____^ help: try `while let Some(word) = "".split_whitespace().next() { .. }` error: this loop could be written as a `for` loop --> $DIR/while_loop.rs:83:5 @@ -87,15 +73,13 @@ error: this loop could be written as a `for` loop 86 | | 87 | | println!("{}", x); 88 | | } - | |_____^ + | |_____^ help: try `for x in iter { .. }` | note: lint level defined here --> $DIR/while_loop.rs:4:37 | 4 | #![deny(while_let_loop, empty_loop, while_let_on_iterator)] | ^^^^^^^^^^^^^^^^^^^^^ -help: try - | for x in iter { .. } error: this loop could be written as a `for` loop --> $DIR/while_loop.rs:91:5 @@ -106,19 +90,13 @@ error: this loop could be written as a `for` loop 94 | | 95 | | println!("{}", x); 96 | | } - | |_____^ - | -help: try - | for x in iter { .. } + | |_____^ help: try `for x in iter { .. }` error: this loop could be written as a `for` loop --> $DIR/while_loop.rs:99:5 | 99 | while let Some(_) = iter.next() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | for _ in iter { .. } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `for _ in iter { .. }` error: this loop could be written as a `while let` loop --> $DIR/while_loop.rs:142:5 @@ -130,10 +108,7 @@ error: this loop could be written as a `while let` loop ... | 150 | | loop {} 151 | | } - | |_____^ - | -help: try - | while let Some(ele) = iter.next() { .. } + | |_____^ help: try `while let Some(ele) = iter.next() { .. }` error: empty `loop {}` detected. You may want to either use `panic!()` or add `std::thread::sleep(..);` to the loop body. --> $DIR/while_loop.rs:150:9