Merge pull request #1715 from Manishearth/rustup

Update to latest nightly
This commit is contained in:
Oliver Schneider 2017-05-03 15:34:46 +02:00 committed by GitHub
commit ef7ff03dae
44 changed files with 393 additions and 1101 deletions

View File

@ -1,6 +1,9 @@
# Change Log # Change Log
All notable changes to this project will be documented in this file. 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 ## 0.0.129 — 2017-05-01
* Update to *rustc 1.19.0-nightly (06fb4d256 2017-04-30)* * Update to *rustc 1.19.0-nightly (06fb4d256 2017-04-30)*

View File

@ -1,6 +1,6 @@
[package] [package]
name = "clippy" name = "clippy"
version = "0.0.129" version = "0.0.130"
authors = [ authors = [
"Manish Goregaokar <manishsmail@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>",
"Andre Bogus <bogusandre@gmail.com>", "Andre Bogus <bogusandre@gmail.com>",
@ -30,7 +30,7 @@ test = false
[dependencies] [dependencies]
# begin automatic update # begin automatic update
clippy_lints = { version = "0.0.129", path = "clippy_lints" } clippy_lints = { version = "0.0.130", path = "clippy_lints" }
# end automatic update # end automatic update
cargo_metadata = "0.1.1" cargo_metadata = "0.1.1"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "clippy_lints" name = "clippy_lints"
# begin automatic update # begin automatic update
version = "0.0.129" version = "0.0.130"
# end automatic update # end automatic update
authors = [ authors = [
"Manish Goregaokar <manishsmail@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>",

View File

@ -386,6 +386,7 @@ fn bool_expr(&self, e: &Expr) {
"this boolean expression can be simplified", "this boolean expression can be simplified",
|db| for suggestion in &improvements { |db| for suggestion in &improvements {
db.span_suggestion(e.span, "try", suggest(self.cx, suggestion, &h2q.terminals)); db.span_suggestion(e.span, "try", suggest(self.cx, suggestion, &h2q.terminals));
break; // FIXME: multiple suggestions in rustc are broken
}); });
} }
} }

View File

@ -299,7 +299,7 @@ fn fetch_path(&mut self, qpath: &QPath, id: NodeId) -> Option<Constant> {
tcx: self.tcx, tcx: self.tcx,
tables: self.tcx.typeck_tables_of(def_id), tables: self.tcx.typeck_tables_of(def_id),
needed_resolution: false, needed_resolution: false,
substs, substs: substs,
}; };
let body = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) { let body = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
self.tcx.mir_const_qualif(def_id); self.tcx.mir_const_qualif(def_id);

View File

@ -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 let ExprBinary(ref op, ref left, ref right) = e.node {
if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) { if is_valid_operator(op) && SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) {
span_lint(cx, span_lint(cx,
EQ_OP, EQ_OP,
e.span, e.span,
&format!("equal expressions as operands to `{}`", op.node.as_str())); &format!("equal expressions as operands to `{}`", op.node.as_str()));
return; return;
} }
let (trait_id, requires_ref) = match op.node { 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 // either operator autorefs or both args are copyable
if (requires_ref || (lcpy && rcpy)) && implements_trait(cx, lty, trait_id, &[rty], None) { if (requires_ref || (lcpy && rcpy)) && implements_trait(cx, lty, trait_id, &[rty], None) {
span_lint_and_then(cx, span_lint_and_then(cx,
OP_REF, OP_REF,
e.span, e.span,
"needlessly taken reference of both operands", "needlessly taken reference of both operands",
|db| { |db| {
let lsnip = snippet(cx, l.span, "...").to_string(); let lsnip = snippet(cx, l.span, "...").to_string();
let rsnip = snippet(cx, r.span, "...").to_string(); let rsnip = snippet(cx, r.span, "...").to_string();
multispan_sugg(db, multispan_sugg(db,
"use the values directly".to_string(), "use the values directly".to_string(),
vec![(left.span, lsnip), vec![(left.span, lsnip),
(right.span, rsnip)]); (right.span, rsnip)]);
}) })
} else if lcpy && !rcpy && implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) { } else if lcpy && !rcpy &&
span_lint_and_then(cx, implements_trait(cx, lty, trait_id, &[cx.tables.expr_ty(right)], None) {
OP_REF, span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
e.span,
"needlessly taken reference of left operand",
|db| {
let lsnip = snippet(cx, l.span, "...").to_string(); let lsnip = snippet(cx, l.span, "...").to_string();
db.span_suggestion(left.span, "use the left value directly", lsnip); 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, span_lint_and_then(cx,
OP_REF, OP_REF,
e.span, e.span,
"needlessly taken reference of right operand", "needlessly taken reference of right operand",
|db| { |db| {
let rsnip = snippet(cx, r.span, "...").to_string(); let rsnip = snippet(cx, r.span, "...").to_string();
db.span_suggestion(right.span, "use the right value directly", rsnip); 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), _) => { (&ExprAddrOf(_, ref l), _) => {
let lty = cx.tables.expr_ty(l); let lty = cx.tables.expr_ty(l);
let lcpy = is_copy(cx, lty, parent); 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| { span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| {
let lsnip = snippet(cx, l.span, "...").to_string(); let lsnip = snippet(cx, l.span, "...").to_string();
db.span_suggestion(left.span, "use the left value directly", lsnip); 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)) => { (_, &ExprAddrOf(_, ref r)) => {
let rty = cx.tables.expr_ty(r); let rty = cx.tables.expr_ty(r);
let rcpy = is_copy(cx, rty, parent); 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| { span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |db| {
let rsnip = snippet(cx, r.span, "...").to_string(); 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);
}) })
} }
}, },

View File

@ -65,7 +65,7 @@ fn check_fn(
_: &'tcx FnDecl, _: &'tcx FnDecl,
body: &'tcx Body, body: &'tcx Body,
_: Span, _: Span,
_id: NodeId node_id: NodeId
) { ) {
// we store the infcx because it is expensive to recreate // we store the infcx because it is expensive to recreate
// the context each time. // the context each time.
@ -78,8 +78,10 @@ fn check_fn(
}; };
let infcx = cx.tcx.borrowck_fake_infer_ctxt(body.id()); 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); vis.consume_body(body);
} }
@ -150,7 +152,7 @@ fn borrow(
borrow_id: NodeId, borrow_id: NodeId,
_: Span, _: Span,
cmt: cmt<'tcx>, cmt: cmt<'tcx>,
_: &ty::Region, _: ty::Region,
_: ty::BorrowKind, _: ty::BorrowKind,
loan_cause: LoanCause loan_cause: LoanCause
) { ) {

View File

@ -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]) { 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| { span_lint_and_then(cx, LEN_ZERO, span, "length comparison to zero", |db| {
db.span_suggestion(span, db.span_suggestion(span,
"consider using `is_empty`", "using `is_empty` is more concise:",
format!("{}{}.is_empty()", op, snippet(cx, args[0].span, "_"))); 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. /// Check the inherent impl's items for an `is_empty(self)` method.
fn has_is_empty_impl(cx: &LateContext, id: DefId) -> bool { fn has_is_empty_impl(cx: &LateContext, id: DefId) -> bool {
cx.tcx.inherent_impls(id) cx.tcx
.inherent_impls(id)
.iter() .iter()
.any(|imp| cx.tcx.associated_items(*imp).any(|item| is_is_empty(cx, &item))) .any(|imp| cx.tcx.associated_items(*imp).any(|item| is_is_empty(cx, &item)))
} }

View File

@ -509,8 +509,11 @@ fn check_for_loop_range<'a, 'tcx>(
// ensure that the indexed variable was declared before the loop, see #601 // ensure that the indexed variable was declared before the loop, see #601
if let Some(indexed_extent) = indexed_extent { if let Some(indexed_extent) = indexed_extent {
let pat_extent = cx.tcx.region_maps.var_scope(pat.id); let parent_id = cx.tcx.hir.get_parent(expr.id);
if cx.tcx.region_maps.is_subscope_of(indexed_extent, pat_extent) { 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; return;
} }
} }
@ -872,7 +875,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
struct VarVisitor<'a, 'tcx: 'a> { struct VarVisitor<'a, 'tcx: 'a> {
cx: &'a LateContext<'a, 'tcx>, // context reference cx: &'a LateContext<'a, 'tcx>, // context reference
var: DefId, // var name to look for as index var: DefId, // var name to look for as index
indexed: HashMap<Name, Option<CodeExtent>>, // indexed variables, the extent is None for global indexed: HashMap<Name, Option<CodeExtent<'tcx>>>, // indexed variables, the extent is None for global
nonindex: bool, // has the var been used otherwise? 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 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 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)); self.indexed.insert(seqvar.segments[0].name, Some(extent));
return; // no need to walk further return; // no need to walk further
} }

View File

@ -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:", "if you mean to use a decimal constant, remove the `0` to remove confusion:",
src[1..].to_string(), src[1..].to_string(),
); );
db.span_suggestion( /*db.span_suggestion(
lit.span, lit.span,
"if you mean to use an octal constant, use `0o`:", "if you mean to use an octal constant, use `0o`:",
format!("0o{}", &src[1..]), format!("0o{}", &src[1..]),
); ); FIXME: rustc doesn't support multiple suggestions anymore */
}); });
} }
}} }}

View File

@ -29,7 +29,7 @@
//! This lint is **warn** by default. //! This lint is **warn** by default.
use rustc::lint::*; use rustc::lint::*;
use syntax::ast; use syntax::ast;
use syntax::codemap::{original_sp,DUMMY_SP}; use syntax::codemap::{original_sp, DUMMY_SP};
use std::borrow::Cow; use std::borrow::Cow;
use utils::{in_macro, span_help_and_lint, snippet_block, snippet, trim_multiline}; 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 * // region C
* } * }
* } * }
*/ * */
/// Given an expression, returns true if either of the following is true /// 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 { fn is_first_block_stmt_continue(block: &ast::Block) -> bool {
block.stmts.get(0).map_or(false, |stmt| match stmt.node { block.stmts.get(0).map_or(false, |stmt| match stmt.node {
ast::StmtKind::Semi(ref e) | ast::StmtKind::Semi(ref e) |
ast::StmtKind::Expr(ref e) => if let ast::ExprKind::Continue(_) = e.node { ast::StmtKind::Expr(ref e) => {
true if let ast::ExprKind::Continue(_) = e.node {
} else { true
false } else {
false
}
}, },
_ => 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 /// If `expr` is a loop expression (while/while let/for/loop), calls `func` with
/// the AST object representing the loop block of `expr`. /// the AST object representing the loop block of `expr`.
fn with_loop_block<F>(expr: &ast::Expr, mut func: F) where F: FnMut(&ast::Block) { fn with_loop_block<F>(expr: &ast::Expr, mut func: F)
where F: FnMut(&ast::Block)
{
match expr.node { match expr.node {
ast::ExprKind::While(_, ref loop_block, _) | ast::ExprKind::While(_, ref loop_block, _) |
ast::ExprKind::WhileLet(_, _, ref loop_block, _) | ast::ExprKind::WhileLet(_, _, ref loop_block, _) |
ast::ExprKind::ForLoop( _, _, ref loop_block, _) | ast::ExprKind::ForLoop(_, _, ref loop_block, _) |
ast::ExprKind::Loop(ref loop_block, _) => func(loop_block), ast::ExprKind::Loop(ref loop_block, _) => func(loop_block),
_ => {}, _ => {},
} }
} }
@ -211,7 +215,8 @@ fn with_loop_block<F>(expr: &ast::Expr, mut func: F) where F: FnMut(&ast::Block)
/// - The `else` expression. /// - The `else` expression.
/// ///
fn with_if_expr<F>(stmt: &ast::Stmt, mut func: F) fn with_if_expr<F>(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 { match stmt.node {
ast::StmtKind::Semi(ref e) | ast::StmtKind::Semi(ref e) |
ast::StmtKind::Expr(ref e) => { ast::StmtKind::Expr(ref e) => {
@ -219,7 +224,7 @@ fn with_if_expr<F>(stmt: &ast::Stmt, mut func: F)
func(e, cond, if_block, else_expr); 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_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 = const DROP_ELSE_BLOCK_AND_MERGE_MSG: &'static str = "Consider dropping the else clause and merging the code that \
"Consider dropping the else clause and merging the code that follows (in the loop) with the if block, like so:\n"; follows (in the loop) with the if block, like so:\n";
const DROP_ELSE_BLOCK_MSG: &'static str = const DROP_ELSE_BLOCK_MSG: &'static str = "Consider dropping the else clause, and moving out the code in the else \
"Consider dropping the else clause, and moving out the code in the else block, like so:\n"; block, like so:\n";
fn emit_warning<'a>(ctx: &EarlyContext, fn emit_warning<'a>(ctx: &EarlyContext, data: &'a LintData, header: &str, typ: LintType) {
data: &'a LintData,
header: &str,
typ: LintType) {
// snip is the whole *help* message that appears after the warning. // snip is the whole *help* message that appears after the warning.
// message is the warning message. // message is the warning message.
// expr is the expression which the lint warning message refers to. // expr is the expression which the lint warning message refers to.
let (snip, message, expr) = match typ { let (snip, message, expr) = match typ {
LintType::ContinueInsideElseBlock => { LintType::ContinueInsideElseBlock => {
(suggestion_snippet_for_continue_inside_else(ctx, data, header), (suggestion_snippet_for_continue_inside_else(ctx, data, header), MSG_REDUNDANT_ELSE_BLOCK, data.else_expr)
MSG_REDUNDANT_ELSE_BLOCK,
data.else_expr)
}, },
LintType::ContinueInsideThenBlock => { LintType::ContinueInsideThenBlock => {
(suggestion_snippet_for_continue_inside_if(ctx, data, header), (suggestion_snippet_for_continue_inside_if(ctx, data, header), MSG_ELSE_BLOCK_NOT_NEEDED, data.if_expr)
MSG_ELSE_BLOCK_NOT_NEEDED, },
data.if_expr)
}
}; };
span_help_and_lint(ctx, NEEDLESS_CONTINUE, expr.span, message, &snip); span_help_and_lint(ctx, NEEDLESS_CONTINUE, expr.span, message, &snip);
} }
fn suggestion_snippet_for_continue_inside_if<'a>(ctx: &EarlyContext, fn suggestion_snippet_for_continue_inside_if<'a>(ctx: &EarlyContext, data: &'a LintData, header: &str) -> String {
data: &'a LintData,
header: &str) -> String {
let cond_code = snippet(ctx, data.if_cond.span, ".."); let cond_code = snippet(ctx, data.if_cond.span, "..");
let if_code = format!("if {} {{\n continue;\n}}\n", cond_code); let if_code = format!("if {} {{\n continue;\n}}\n", cond_code);
/* ^^^^--- Four spaces of indentation. */ /* ^^^^--- Four spaces of indentation. */
// region B // region B
let else_code = snippet(ctx, data.else_expr.span, "..").into_owned(); let else_code = snippet(ctx, data.else_expr.span, "..").into_owned();
let else_code = erode_block(&else_code); let else_code = erode_block(&else_code);
@ -300,12 +297,9 @@ fn suggestion_snippet_for_continue_inside_if<'a>(ctx: &EarlyContext,
ret ret
} }
fn suggestion_snippet_for_continue_inside_else<'a>(ctx: &EarlyContext, fn suggestion_snippet_for_continue_inside_else<'a>(ctx: &EarlyContext, data: &'a LintData, header: &str) -> String {
data: &'a LintData,
header: &str) -> String
{
let cond_code = snippet(ctx, data.if_cond.span, ".."); 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 // Region B
let block_code = &snippet(ctx, data.if_block.span, "..").into_owned(); 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 // 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 // we are complaining about. We want to pull all of this code into the
// `then` block of the `if` statement. // `then` block of the `if` statement.
let to_annex = data.block_stmts[data.stmt_idx+1..] let to_annex = data.block_stmts[data.stmt_idx + 1..]
.iter() .iter()
.map(|stmt| { .map(|stmt| original_sp(stmt.span, DUMMY_SP))
original_sp(stmt.span, DUMMY_SP) .map(|span| snippet_block(ctx, span, "..").into_owned())
}) .collect::<Vec<_>>()
.map(|span| snippet_block(ctx, span, "..").into_owned()) .join("\n");
.collect::<Vec<_>>().join("\n");
let mut ret = String::from(header); 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) { fn check_and_warn<'a>(ctx: &EarlyContext, expr: &'a ast::Expr) {
with_loop_block(expr, |loop_block| { with_loop_block(expr, |loop_block| for (i, stmt) in loop_block.stmts.iter().enumerate() {
for (i, stmt) in loop_block.stmts.iter().enumerate() { with_if_expr(stmt, |if_expr, cond, then_block, else_expr| {
with_if_expr(stmt, |if_expr, cond, then_block, else_expr| { let data = &LintData {
let data = &LintData { stmt_idx: i,
stmt_idx: i, if_expr: if_expr,
if_expr: if_expr, if_cond: cond,
if_cond: cond, if_block: then_block,
if_block: then_block, else_expr: else_expr,
else_expr: else_expr, block_stmts: &loop_block.stmts,
block_stmts: &loop_block.stmts, };
}; if needless_continue_in_else(else_expr) {
if needless_continue_in_else(else_expr) { emit_warning(ctx, data, DROP_ELSE_BLOCK_AND_MERGE_MSG, LintType::ContinueInsideElseBlock);
emit_warning(ctx, data, DROP_ELSE_BLOCK_AND_MERGE_MSG, LintType::ContinueInsideElseBlock); } else if is_first_block_stmt_continue(then_block) {
} else if is_first_block_stmt_continue(then_block) { emit_warning(ctx, data, DROP_ELSE_BLOCK_MSG, LintType::ContinueInsideThenBlock);
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. /// an empty string will be returned in that case.
pub fn erode_from_back(s: &str) -> String { pub fn erode_from_back(s: &str) -> String {
let mut ret = String::from(s); 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() { while let Some(c) = ret.pop() {
if !c.is_whitespace() { if !c.is_whitespace() {
ret.push(c); ret.push(c);
@ -409,10 +400,10 @@ pub fn erode_from_back(s: &str) -> String {
/// ///
pub fn erode_from_front(s: &str) -> String { pub fn erode_from_front(s: &str) -> String {
s.chars() s.chars()
.skip_while(|c| c.is_whitespace()) .skip_while(|c| c.is_whitespace())
.skip_while(|c| *c == '{') .skip_while(|c| *c == '{')
.skip_while(|c| *c == '\n') .skip_while(|c| *c == '\n')
.collect::<String>() .collect::<String>()
} }
/// If `s` contains the code for a block, delimited by braces, this function /// If `s` contains the code for a block, delimited by braces, this function

View File

@ -86,18 +86,20 @@ fn check_fn(
.collect() .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. // Collect moved variables and spans which will need dereferencings from the function body.
let MovedVariablesCtxt { moved_vars, spans_need_deref, .. } = { let MovedVariablesCtxt { moved_vars, spans_need_deref, .. } = {
let mut ctx = MovedVariablesCtxt::new(cx); let mut ctx = MovedVariablesCtxt::new(cx);
let infcx = cx.tcx.borrowck_fake_infer_ctxt(body.id()); 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); v.consume_body(body);
} }
ctx 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 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.type_of(fn_def_id).fn_sig();
let fn_sig = cx.tcx.liberate_late_bound_regions(param_env.free_id_outlive, &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, "_")); let slice_ty = format!("&[{}]", snippet(cx, elem_ty.span, "_"));
db.span_suggestion(input.span, db.span_suggestion(input.span,
&format!("consider changing the type to `{}`", slice_ty), "consider changing the type to",
slice_ty); slice_ty);
assert!(deref_span.is_none()); assert!(deref_span.is_none());
return; // `Vec` and `String` cannot be destructured - no need for `*` suggestion 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) { if match_type(cx, ty, &paths::STRING) {
db.span_suggestion(input.span, db.span_suggestion(input.span,
"consider changing the type to `&str`", "consider changing the type to",
"&str".to_string()); "&str".to_string());
assert!(deref_span.is_none()); assert!(deref_span.is_none());
return; return;
@ -282,16 +284,7 @@ fn consume_pat(&mut self, consume_pat: &Pat, cmt: mc::cmt<'tcx>, mode: euv::Cons
} }
} }
fn borrow( fn borrow(&mut self, _: NodeId, _: Span, _: mc::cmt<'tcx>, _: ty::Region, _: ty::BorrowKind, _: euv::LoanCause) {}
&mut self,
_: NodeId,
_: Span,
_: mc::cmt<'tcx>,
_: &'tcx ty::Region,
_: ty::BorrowKind,
_: euv::LoanCause
) {
}
fn mutate(&mut self, _: NodeId, _: Span, _: mc::cmt<'tcx>, _: euv::MutateMode) {} fn mutate(&mut self, _: NodeId, _: Span, _: mc::cmt<'tcx>, _: euv::MutateMode) {}

View File

@ -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 /// 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. /// 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)>) { 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()), msp: MultiSpan::from_spans(sugg.iter().map(|&(span, _)| span).collect()),
substitutes: sugg.into_iter().map(|(_, subs)| subs).collect(), substitutes: sugg.into_iter().map(|(_, subs)| subs).collect(),
}); msg: help_msg,
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),
}; };
db.children.push(sub); assert!(db.suggestion.is_none());
db.suggestion = Some(sugg);
} }
/// Return the base type for references and raw pointers. /// 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) .infer_ctxt((), Reveal::All)
.enter(|infcx| ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes())) .enter(|infcx| ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes()))
} }

View File

@ -2,200 +2,139 @@ error: assign operation detected
--> $DIR/assign_ops.rs:8:5 --> $DIR/assign_ops.rs:8:5
| |
8 | i += 2; 8 | i += 2;
| ^^^^^^ | ^^^^^^ help: replace it with `i = i + 2`
| |
note: lint level defined here note: lint level defined here
--> $DIR/assign_ops.rs:4:8 --> $DIR/assign_ops.rs:4:8
| |
4 | #[deny(assign_ops)] 4 | #[deny(assign_ops)]
| ^^^^^^^^^^ | ^^^^^^^^^^
help: replace it with
| i = i + 2;
error: assign operation detected error: assign operation detected
--> $DIR/assign_ops.rs:11:5 --> $DIR/assign_ops.rs:11:5
| |
11 | i += 2 + 17; 11 | i += 2 + 17;
| ^^^^^^^^^^^ | ^^^^^^^^^^^ help: replace it with `i = i + 2 + 17`
|
help: replace it with
| i = i + 2 + 17;
error: assign operation detected error: assign operation detected
--> $DIR/assign_ops.rs:14:5 --> $DIR/assign_ops.rs:14:5
| |
14 | i -= 6; 14 | i -= 6;
| ^^^^^^ | ^^^^^^ help: replace it with `i = i - 6`
|
help: replace it with
| i = i - 6;
error: assign operation detected error: assign operation detected
--> $DIR/assign_ops.rs:17:5 --> $DIR/assign_ops.rs:17:5
| |
17 | i -= 2 - 1; 17 | i -= 2 - 1;
| ^^^^^^^^^^ | ^^^^^^^^^^ help: replace it with `i = i - (2 - 1)`
|
help: replace it with
| i = i - (2 - 1);
error: assign operation detected error: assign operation detected
--> $DIR/assign_ops.rs:21:5 --> $DIR/assign_ops.rs:21:5
| |
21 | i *= 5; 21 | i *= 5;
| ^^^^^^ | ^^^^^^ help: replace it with `i = i * 5`
|
help: replace it with
| i = i * 5;
error: assign operation detected error: assign operation detected
--> $DIR/assign_ops.rs:24:5 --> $DIR/assign_ops.rs:24:5
| |
24 | i *= 1+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 error: assign operation detected
--> $DIR/assign_ops.rs:27:5 --> $DIR/assign_ops.rs:27:5
| |
27 | i /= 32; 27 | i /= 32;
| ^^^^^^^ | ^^^^^^^ help: replace it with `i = i / 32`
|
help: replace it with
| i = i / 32;
error: assign operation detected error: assign operation detected
--> $DIR/assign_ops.rs:30:5 --> $DIR/assign_ops.rs:30:5
| |
30 | i /= 32 | 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 error: assign operation detected
--> $DIR/assign_ops.rs:33:5 --> $DIR/assign_ops.rs:33:5
| |
33 | i /= 32 / 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 error: assign operation detected
--> $DIR/assign_ops.rs:36:5 --> $DIR/assign_ops.rs:36:5
| |
36 | i %= 42; 36 | i %= 42;
| ^^^^^^^ | ^^^^^^^ help: replace it with `i = i % 42`
|
help: replace it with
| i = i % 42;
error: assign operation detected error: assign operation detected
--> $DIR/assign_ops.rs:39:5 --> $DIR/assign_ops.rs:39:5
| |
39 | i >>= i; 39 | i >>= i;
| ^^^^^^^ | ^^^^^^^ help: replace it with `i = i >> i`
|
help: replace it with
| i = i >> i;
error: assign operation detected error: assign operation detected
--> $DIR/assign_ops.rs:42:5 --> $DIR/assign_ops.rs:42:5
| |
42 | i <<= 9 + 6 - 7; 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 error: assign operation detected
--> $DIR/assign_ops.rs:45:5 --> $DIR/assign_ops.rs:45:5
| |
45 | i += 1 << 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 error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:55:5 --> $DIR/assign_ops.rs:55:5
| |
55 | a = a + 1; 55 | a = a + 1;
| ^^^^^^^^^ | ^^^^^^^^^ help: replace it with `a += 1`
| |
note: lint level defined here note: lint level defined here
--> $DIR/assign_ops.rs:52:8 --> $DIR/assign_ops.rs:52:8
| |
52 | #[deny(assign_op_pattern)] 52 | #[deny(assign_op_pattern)]
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
help: replace it with
| a += 1;
error: manual implementation of an assign operation error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:58:5 --> $DIR/assign_ops.rs:58:5
| |
58 | a = 1 + a; 58 | a = 1 + a;
| ^^^^^^^^^ | ^^^^^^^^^ help: replace it with `a += 1`
|
help: replace it with
| a += 1;
error: manual implementation of an assign operation error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:61:5 --> $DIR/assign_ops.rs:61:5
| |
61 | a = a - 1; 61 | a = a - 1;
| ^^^^^^^^^ | ^^^^^^^^^ help: replace it with `a -= 1`
|
help: replace it with
| a -= 1;
error: manual implementation of an assign operation error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:64:5 --> $DIR/assign_ops.rs:64:5
| |
64 | a = a * 99; 64 | a = a * 99;
| ^^^^^^^^^^ | ^^^^^^^^^^ help: replace it with `a *= 99`
|
help: replace it with
| a *= 99;
error: manual implementation of an assign operation error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:67:5 --> $DIR/assign_ops.rs:67:5
| |
67 | a = 42 * a; 67 | a = 42 * a;
| ^^^^^^^^^^ | ^^^^^^^^^^ help: replace it with `a *= 42`
|
help: replace it with
| a *= 42;
error: manual implementation of an assign operation error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:70:5 --> $DIR/assign_ops.rs:70:5
| |
70 | a = a / 2; 70 | a = a / 2;
| ^^^^^^^^^ | ^^^^^^^^^ help: replace it with `a /= 2`
|
help: replace it with
| a /= 2;
error: manual implementation of an assign operation error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:73:5 --> $DIR/assign_ops.rs:73:5
| |
73 | a = a % 5; 73 | a = a % 5;
| ^^^^^^^^^ | ^^^^^^^^^ help: replace it with `a %= 5`
|
help: replace it with
| a %= 5;
error: manual implementation of an assign operation error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:76:5 --> $DIR/assign_ops.rs:76:5
| |
76 | a = a & 1; 76 | a = a & 1;
| ^^^^^^^^^ | ^^^^^^^^^ help: replace it with `a &= 1`
|
help: replace it with
| a &= 1;
error: aborting due to 21 previous errors error: aborting due to 21 previous errors

View File

@ -2,78 +2,55 @@ error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:8:5 --> $DIR/assign_ops2.rs:8:5
| |
8 | a += a + 1; 8 | a += a + 1;
| ^^^^^^^^^^ | ^^^^^^^^^^ help: replace it with `a += 1`
| |
note: lint level defined here note: lint level defined here
--> $DIR/assign_ops2.rs:5:8 --> $DIR/assign_ops2.rs:5:8
| |
5 | #[deny(misrefactored_assign_op)] 5 | #[deny(misrefactored_assign_op)]
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
help: replace it with
| a += 1;
error: variable appears on both sides of an assignment operation error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:11:5 --> $DIR/assign_ops2.rs:11:5
| |
11 | a += 1 + a; 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 error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:14:5 --> $DIR/assign_ops2.rs:14:5
| |
14 | a -= a - 1; 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 error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:17:5 --> $DIR/assign_ops2.rs:17:5
| |
17 | a *= a * 99; 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 error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:20:5 --> $DIR/assign_ops2.rs:20:5
| |
20 | a *= 42 * a; 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 error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:23:5 --> $DIR/assign_ops2.rs:23:5
| |
23 | a /= a / 2; 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 error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:26:5 --> $DIR/assign_ops2.rs:26:5
| |
26 | a %= a % 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 error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:29:5 --> $DIR/assign_ops2.rs:29:5
| |
29 | a &= a & 1; 29 | a &= a & 1;
| ^^^^^^^^^^ | ^^^^^^^^^^ help: replace it with `a &= 1`
|
help: replace it with
| a &= 1;
error: aborting due to 8 previous errors error: aborting due to 8 previous errors

View File

@ -54,15 +54,13 @@ warning: this boolean expression can be simplified
--> $DIR/block_in_if_condition.rs:70:8 --> $DIR/block_in_if_condition.rs:70:8
| |
70 | if true && x == 3 { 70 | if true && x == 3 {
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^ help: try `x == 3`
| |
note: lint level defined here note: lint level defined here
--> $DIR/block_in_if_condition.rs:7:9 --> $DIR/block_in_if_condition.rs:7:9
| |
7 | #![warn(nonminimal_bool)] 7 | #![warn(nonminimal_bool)]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
help: try
| if x == 3 {
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View File

@ -2,42 +2,31 @@ error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:7:8 --> $DIR/bool_comparison.rs:7:8
| |
7 | if x == true { "yes" } else { "no" }; 7 | if x == true { "yes" } else { "no" };
| ^^^^^^^^^ | ^^^^^^^^^ help: try simplifying it as shown: `x`
| |
note: lint level defined here note: lint level defined here
--> $DIR/bool_comparison.rs:4:8 --> $DIR/bool_comparison.rs:4:8
| |
4 | #[deny(bool_comparison)] 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 error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:11:8 --> $DIR/bool_comparison.rs:11:8
| |
11 | if x == false { "yes" } else { "no" }; 11 | if x == false { "yes" } else { "no" };
| ^^^^^^^^^^ | ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
help: try simplifying it as shown:
| if !x { "yes" } else { "no" };
error: equality checks against true are unnecessary error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:15:8 --> $DIR/bool_comparison.rs:15:8
| |
15 | if true == x { "yes" } else { "no" }; 15 | if true == x { "yes" } else { "no" };
| ^^^^^^^^^ | ^^^^^^^^^ help: try simplifying it as shown: `x`
|
help: try simplifying it as shown:
| if x { "yes" } else { "no" };
error: equality checks against false can be replaced by a negation error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:19:8 --> $DIR/bool_comparison.rs:19:8
| |
19 | if false == x { "yes" } else { "no" }; 19 | if false == x { "yes" } else { "no" };
| ^^^^^^^^^^ | ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
help: try simplifying it as shown:
| if !x { "yes" } else { "no" };
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View File

@ -2,7 +2,7 @@ error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:12:13 --> $DIR/booleans.rs:12:13
| |
12 | let _ = a && b || a; 12 | let _ = a && b || a;
| ^^^^^^^^^^^ | ^^^^^^^^^^^ help: it would look like the following `a`
| |
note: lint level defined here note: lint level defined here
--> $DIR/booleans.rs:3:26 --> $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; 12 | let _ = a && b || a;
| ^ | ^
help: it would look like the following
| let _ = a;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/booleans.rs:17:13 --> $DIR/booleans.rs:17:13
| |
17 | let _ = !true; 17 | let _ = !true;
| ^^^^^ | ^^^^^ help: try `false`
| |
note: lint level defined here note: lint level defined here
--> $DIR/booleans.rs:3:9 --> $DIR/booleans.rs:3:9
| |
3 | #![deny(nonminimal_bool, logic_bug)] 3 | #![deny(nonminimal_bool, logic_bug)]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
help: try
| let _ = false;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/booleans.rs:20:13 --> $DIR/booleans.rs:20:13
| |
20 | let _ = !false; 20 | let _ = !false;
| ^^^^^^ | ^^^^^^ help: try `true`
|
help: try
| let _ = true;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/booleans.rs:23:13 --> $DIR/booleans.rs:23:13
| |
23 | let _ = !!a; 23 | let _ = !!a;
| ^^^ | ^^^ help: try `a`
|
help: try
| let _ = a;
error: this boolean expression contains a logic bug error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:27:13 --> $DIR/booleans.rs:27:13
| |
27 | let _ = false && a; 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 help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:27:22 --> $DIR/booleans.rs:27:22
| |
27 | let _ = false && a; 27 | let _ = false && a;
| ^ | ^
help: it would look like the following
| let _ = false;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/booleans.rs:32:13 --> $DIR/booleans.rs:32:13
| |
32 | let _ = false || a; 32 | let _ = false || a;
| ^^^^^^^^^^ | ^^^^^^^^^^ help: try `a`
|
help: try
| let _ = a;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/booleans.rs:43:13 --> $DIR/booleans.rs:43:13
| |
43 | let _ = !(!a && b); 43 | let _ = !(!a && b);
| ^^^^^^^^^^ | ^^^^^^^^^^ help: try `!b || a`
|
help: try
| let _ = !b || a;
error: this boolean expression contains a logic bug error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:55:13 --> $DIR/booleans.rs:55:13
| |
55 | let _ = a == b && a != b; 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 help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:55:13 --> $DIR/booleans.rs:55:13
| |
55 | let _ = a == b && a != b; 55 | let _ = a == b && a != b;
| ^^^^^^ | ^^^^^^
help: it would look like the following
| let _ = false;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/booleans.rs:60:13 --> $DIR/booleans.rs:60:13
| |
60 | let _ = a == b && c == 5 && a == b; 60 | let _ = a == b && c == 5 && a == b;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `a == b && c == 5`
|
help: try
| let _ = a == b && c == 5;
help: try
| let _ = !(c != 5 || a != b);
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/booleans.rs:66:13 --> $DIR/booleans.rs:66:13
| |
66 | let _ = a == b && c == 5 && b == a; 66 | let _ = a == b && c == 5 && b == a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `a == b && c == 5`
|
help: try
| let _ = a == b && c == 5;
help: try
| let _ = !(c != 5 || a != b);
error: this boolean expression contains a logic bug error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:72:13 --> $DIR/booleans.rs:72:13
| |
72 | let _ = a < b && a >= b; 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 help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:72:13 --> $DIR/booleans.rs:72:13
| |
72 | let _ = a < b && a >= b; 72 | let _ = a < b && a >= b;
| ^^^^^ | ^^^^^
help: it would look like the following
| let _ = false;
error: this boolean expression contains a logic bug error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:77:13 --> $DIR/booleans.rs:77:13
| |
77 | let _ = a > b && a <= b; 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 help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:77:13 --> $DIR/booleans.rs:77:13
| |
77 | let _ = a > b && a <= b; 77 | let _ = a > b && a <= b;
| ^^^^^ | ^^^^^
help: it would look like the following
| let _ = false;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/booleans.rs:84:13 --> $DIR/booleans.rs:84:13
| |
84 | let _ = a != b || !(a != b || c == d); 84 | let _ = a != b || !(a != b || c == d);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `c != d || a != b`
|
help: try
| let _ = c != d || a != b;
help: try
| let _ = !(a == b && c == d);
error: aborting due to 13 previous errors error: aborting due to 13 previous errors

View File

@ -2,69 +2,49 @@ error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:13:5 --> $DIR/entry.rs:13:5
| |
13 | if !m.contains_key(&k) { m.insert(k, v); } 13 | if !m.contains_key(&k) { m.insert(k, v); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k).or_insert(v)`
| |
note: lint level defined here note: lint level defined here
--> $DIR/entry.rs:5:9 --> $DIR/entry.rs:5:9
| |
5 | #![deny(map_entry)] 5 | #![deny(map_entry)]
| ^^^^^^^^^ | ^^^^^^^^^
help: consider using
| m.entry(k).or_insert(v)
error: usage of `contains_key` followed by `insert` on a `HashMap` error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:20:5 --> $DIR/entry.rs:20:5
| |
20 | if !m.contains_key(&k) { foo(); m.insert(k, v); } 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` error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:27:5 --> $DIR/entry.rs:27:5
| |
27 | if !m.contains_key(&k) { m.insert(k, v) } else { None }; 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` error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:34:5 --> $DIR/entry.rs:34:5
| |
34 | if m.contains_key(&k) { None } else { m.insert(k, v) }; 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` error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:41:5 --> $DIR/entry.rs:41:5
| |
41 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; 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` error: usage of `contains_key` followed by `insert` on a `HashMap`
--> $DIR/entry.rs:48:5 --> $DIR/entry.rs:48:5
| |
48 | if m.contains_key(&k) { None } else { foo(); m.insert(k, v) }; 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` error: usage of `contains_key` followed by `insert` on a `BTreeMap`
--> $DIR/entry.rs:55:5 --> $DIR/entry.rs:55:5
| |
55 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; 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 error: aborting due to 7 previous errors

View File

@ -2,60 +2,43 @@ error: this boolean expression can be simplified
--> $DIR/eq_op.rs:41:5 --> $DIR/eq_op.rs:41:5
| |
41 | true && true; 41 | true && true;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: try `true`
| |
note: lint level defined here note: lint level defined here
--> $DIR/eq_op.rs:7:8 --> $DIR/eq_op.rs:7:8
| |
7 | #[deny(nonminimal_bool)] 7 | #[deny(nonminimal_bool)]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
help: try
| true;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/eq_op.rs:43:5 --> $DIR/eq_op.rs:43:5
| |
43 | true || true; 43 | true || true;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: try `true`
|
help: try
| true;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/eq_op.rs:49:5 --> $DIR/eq_op.rs:49:5
| |
49 | a == b && b == a; 49 | a == b && b == a;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^ help: try `a == b`
|
help: try
| a == b;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/eq_op.rs:51:5 --> $DIR/eq_op.rs:51:5
| |
51 | a != b && b != a; 51 | a != b && b != a;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^ help: try `a != b`
|
help: try
| a != b;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/eq_op.rs:53:5 --> $DIR/eq_op.rs:53:5
| |
53 | a < b && b > a; 53 | a < b && b > a;
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^ help: try `a < b`
|
help: try
| a < b;
error: this boolean expression can be simplified error: this boolean expression can be simplified
--> $DIR/eq_op.rs:55:5 --> $DIR/eq_op.rs:55:5
| |
55 | a <= b && b >= a; 55 | a <= b && b >= a;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^ help: try `a <= b`
|
help: try
| a <= b;
error: equal expressions as operands to `==` error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:10:5 --> $DIR/eq_op.rs:10:5
@ -223,11 +206,11 @@ warning: taken reference of right operand
--> $DIR/eq_op.rs:97:13 --> $DIR/eq_op.rs:97:13
| |
97 | let z = x & &y; 97 | let z = x & &y;
| ^^^^^^ | ^^^^--
| |
| help: use the right value directly `y`
| |
= note: #[warn(op_ref)] on by default = note: #[warn(op_ref)] on by default
help: use the right value directly
| let z = y & &y;
error: aborting due to 32 previous errors error: aborting due to 32 previous errors

View File

@ -2,33 +2,25 @@ error: redundant closure found
--> $DIR/eta.rs:7:27 --> $DIR/eta.rs:7:27
| |
7 | let a = Some(1u8).map(|a| foo(a)); 7 | let a = Some(1u8).map(|a| foo(a));
| ^^^^^^^^^^ | ^^^^^^^^^^ help: remove closure as shown: `foo`
| |
note: lint level defined here note: lint level defined here
--> $DIR/eta.rs:4:9 --> $DIR/eta.rs:4:9
| |
4 | #![deny(redundant_closure)] 4 | #![deny(redundant_closure)]
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
help: remove closure as shown:
| let a = Some(1u8).map(foo);
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:11:10 --> $DIR/eta.rs:11:10
| |
11 | meta(|a| foo(a)); 11 | meta(|a| foo(a));
| ^^^^^^^^^^ | ^^^^^^^^^^ help: remove closure as shown: `foo`
|
help: remove closure as shown:
| meta(foo);
error: redundant closure found error: redundant closure found
--> $DIR/eta.rs:15:27 --> $DIR/eta.rs:15:27
| |
15 | let c = Some(1u8).map(|a| {1+2; foo}(a)); 15 | let c = Some(1u8).map(|a| {1+2; foo}(a));
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}`
|
help: remove closure as shown:
| let c = Some(1u8).map({1+2; foo});
warning: this expression borrows a reference that is immediately dereferenced by the compiler warning: this expression borrows a reference that is immediately dereferenced by the compiler
--> $DIR/eta.rs:20:21 --> $DIR/eta.rs:20:21
@ -42,10 +34,7 @@ error: redundant closure found
--> $DIR/eta.rs:28:27 --> $DIR/eta.rs:28:27
| |
28 | let e = Some(1u8).map(|a| generic(a)); 28 | let e = Some(1u8).map(|a| generic(a));
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^ help: remove closure as shown: `generic`
|
help: remove closure as shown:
| let e = Some(1u8).map(generic);
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View File

@ -2,15 +2,13 @@ error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:43:5 --> $DIR/float_cmp.rs:43:5
| |
43 | ONE == 1f32; 43 | ONE == 1f32;
| ^^^^^^^^^^^ | ^^^^^^^^^^^ help: consider comparing them within some error `(ONE - 1f32).abs() < error`
| |
note: lint level defined here note: lint level defined here
--> $DIR/float_cmp.rs:4:9 --> $DIR/float_cmp.rs:4:9
| |
4 | #![deny(float_cmp)] 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. note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:43:5 --> $DIR/float_cmp.rs:43:5
| |
@ -21,10 +19,8 @@ error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:47:5 --> $DIR/float_cmp.rs:47:5
| |
47 | ONE == 1.0 + 0.0; 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. note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:47:5 --> $DIR/float_cmp.rs:47:5
| |
@ -35,10 +31,8 @@ error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:52:5 --> $DIR/float_cmp.rs:52:5
| |
52 | ONE + ONE == ZERO + ONE + ONE; 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. note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:52:5 --> $DIR/float_cmp.rs:52:5
| |
@ -49,10 +43,8 @@ error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:57:5 --> $DIR/float_cmp.rs:57:5
| |
57 | ONE != 2.0; 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. note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:57:5 --> $DIR/float_cmp.rs:57:5
| |
@ -63,10 +55,8 @@ error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:62:5 --> $DIR/float_cmp.rs:62:5
| |
62 | twice(ONE) != ONE; 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. note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:62:5 --> $DIR/float_cmp.rs:62:5
| |
@ -77,10 +67,8 @@ error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:66:5 --> $DIR/float_cmp.rs:66:5
| |
66 | ONE as f64 != 2.0; 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. note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:66:5 --> $DIR/float_cmp.rs:66:5
| |
@ -91,10 +79,8 @@ error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:74:5 --> $DIR/float_cmp.rs:74:5
| |
74 | x == 1.0; 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. note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:74:5 --> $DIR/float_cmp.rs:74:5
| |
@ -105,10 +91,8 @@ error: strict comparison of f32 or f64
--> $DIR/float_cmp.rs:80:5 --> $DIR/float_cmp.rs:80:5
| |
80 | twice(x) != twice(ONE as f64); 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. note: std::f32::EPSILON and std::f64::EPSILON are available.
--> $DIR/float_cmp.rs:80:5 --> $DIR/float_cmp.rs:80:5
| |

View File

@ -365,128 +365,91 @@ error: it is more idiomatic to loop over references to containers instead of usi
--> $DIR/for_loop.rs:289:15 --> $DIR/for_loop.rs:289:15
| |
289 | for _v in vec.iter() { } 289 | for _v in vec.iter() { }
| ^^^^^^^^^^ | ^^^^^^^^^^ help: to write this more concisely, try `&vec`
| |
note: lint level defined here note: lint level defined here
--> $DIR/for_loop.rs:90:29 --> $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)] 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 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:294:15 --> $DIR/for_loop.rs:294:15
| |
294 | for _v in vec.iter_mut() { } 294 | for _v in vec.iter_mut() { }
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^ help: to write this more concisely, try `&mut vec`
|
help: to write this more concisely, try
| for _v in &mut vec { }
error: it is more idiomatic to loop over containers instead of using explicit iteration methods` error: it is more idiomatic to loop over containers instead of using explicit iteration methods`
--> $DIR/for_loop.rs:300:15 --> $DIR/for_loop.rs:300:15
| |
300 | for _v in out_vec.into_iter() { } 300 | for _v in out_vec.into_iter() { }
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `out_vec`
| |
note: lint level defined here note: lint level defined here
--> $DIR/for_loop.rs:90:49 --> $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)] 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 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:306:15 --> $DIR/for_loop.rs:306:15
| |
306 | for _v in array.into_iter() {} 306 | for _v in array.into_iter() {}
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `&array`
|
help: to write this more concisely, try
| for _v in &array {}
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:311:15 --> $DIR/for_loop.rs:311:15
| |
311 | for _v in [1, 2, 3].iter() { } 311 | for _v in [1, 2, 3].iter() { }
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try `&[1, 2, 3]`
|
help: to write this more concisely, try
| for _v in &[1, 2, 3] { }
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:318:15 --> $DIR/for_loop.rs:318:15
| |
318 | for _v in [0; 32].iter() {} 318 | for _v in [0; 32].iter() {}
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^ help: to write this more concisely, try `&[0; 32]`
|
help: to write this more concisely, try
| for _v in &[0; 32] {}
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:326:15 --> $DIR/for_loop.rs:326:15
| |
326 | for _v in ll.iter() { } 326 | for _v in ll.iter() { }
| ^^^^^^^^^ | ^^^^^^^^^ help: to write this more concisely, try `&ll`
|
help: to write this more concisely, try
| for _v in &ll { }
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:332:15 --> $DIR/for_loop.rs:332:15
| |
332 | for _v in vd.iter() { } 332 | for _v in vd.iter() { }
| ^^^^^^^^^ | ^^^^^^^^^ help: to write this more concisely, try `&vd`
|
help: to write this more concisely, try
| for _v in &vd { }
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:338:15 --> $DIR/for_loop.rs:338:15
| |
338 | for _v in bh.iter() { } 338 | for _v in bh.iter() { }
| ^^^^^^^^^ | ^^^^^^^^^ help: to write this more concisely, try `&bh`
|
help: to write this more concisely, try
| for _v in &bh { }
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:344:15 --> $DIR/for_loop.rs:344:15
| |
344 | for _v in hm.iter() { } 344 | for _v in hm.iter() { }
| ^^^^^^^^^ | ^^^^^^^^^ help: to write this more concisely, try `&hm`
|
help: to write this more concisely, try
| for _v in &hm { }
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:350:15 --> $DIR/for_loop.rs:350:15
| |
350 | for _v in bt.iter() { } 350 | for _v in bt.iter() { }
| ^^^^^^^^^ | ^^^^^^^^^ help: to write this more concisely, try `&bt`
|
help: to write this more concisely, try
| for _v in &bt { }
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:356:15 --> $DIR/for_loop.rs:356:15
| |
356 | for _v in hs.iter() { } 356 | for _v in hs.iter() { }
| ^^^^^^^^^ | ^^^^^^^^^ help: to write this more concisely, try `&hs`
|
help: to write this more concisely, try
| for _v in &hs { }
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:362:15 --> $DIR/for_loop.rs:362:15
| |
362 | for _v in bs.iter() { } 362 | for _v in bs.iter() { }
| ^^^^^^^^^ | ^^^^^^^^^ help: to write this more concisely, try `&bs`
|
help: to write this more concisely, try
| for _v in &bs { }
error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want 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 --> $DIR/for_loop.rs:368:5

View File

@ -2,7 +2,7 @@ error: redundant pattern matching, consider using `is_ok()`
--> $DIR/if_let_redundant_pattern_matching.rs:9:12 --> $DIR/if_let_redundant_pattern_matching.rs:9:12
| |
9 | if let Ok(_) = Ok::<i32, i32>(42) {} 9 | if let Ok(_) = Ok::<i32, i32>(42) {}
| ^^^^^ | -------^^^^^--------------------- help: try this `if Ok::<i32, i32>(42).is_ok()`
| |
= note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)] = note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -10,38 +10,30 @@ note: lint level defined here
| |
4 | #![deny(clippy)] 4 | #![deny(clippy)]
| ^^^^^^ | ^^^^^^
help: try this
| if Ok::<i32, i32>(42).is_ok() {}
error: redundant pattern matching, consider using `is_err()` error: redundant pattern matching, consider using `is_err()`
--> $DIR/if_let_redundant_pattern_matching.rs:14:12 --> $DIR/if_let_redundant_pattern_matching.rs:14:12
| |
14 | if let Err(_) = Err::<i32, i32>(42) { 14 | if let Err(_) = Err::<i32, i32>(42) {
| ^^^^^^ | -------^^^^^^---------------------- help: try this `if Err::<i32, i32>(42).is_err()`
| |
= note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)] = note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)]
help: try this
| if Err::<i32, i32>(42).is_err() {
error: redundant pattern matching, consider using `is_none()` error: redundant pattern matching, consider using `is_none()`
--> $DIR/if_let_redundant_pattern_matching.rs:20:12 --> $DIR/if_let_redundant_pattern_matching.rs:20:12
| |
20 | if let None = None::<()> { 20 | if let None = None::<()> {
| ^^^^ | -------^^^^------------- help: try this `if None::<()>.is_none()`
| |
= note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)] = 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()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/if_let_redundant_pattern_matching.rs:26:12 --> $DIR/if_let_redundant_pattern_matching.rs:26:12
| |
26 | if let Some(_) = Some(42) { 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)] = 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 error: aborting due to 4 previous errors

View File

@ -50,69 +50,49 @@ error: length comparison to zero
--> $DIR/len_zero.rs:130:8 --> $DIR/len_zero.rs:130:8
| |
130 | if x.len() == 0 { 130 | if x.len() == 0 {
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: using `is_empty` is more concise: `x.is_empty()`
| |
note: lint level defined here note: lint level defined here
--> $DIR/len_zero.rs:4:31 --> $DIR/len_zero.rs:4:31
| |
4 | #![deny(len_without_is_empty, len_zero)] 4 | #![deny(len_without_is_empty, len_zero)]
| ^^^^^^^^ | ^^^^^^^^
help: consider using `is_empty`
| if x.is_empty() {
error: length comparison to zero error: length comparison to zero
--> $DIR/len_zero.rs:137:8 --> $DIR/len_zero.rs:137:8
| |
137 | if "".len() == 0 { 137 | if "".len() == 0 {
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^ help: using `is_empty` is more concise: `"".is_empty()`
|
help: consider using `is_empty`
| if "".is_empty() {
error: length comparison to zero error: length comparison to zero
--> $DIR/len_zero.rs:154:8 --> $DIR/len_zero.rs:154:8
| |
154 | if has_is_empty.len() == 0 { 154 | if has_is_empty.len() == 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `has_is_empty.is_empty()`
|
help: consider using `is_empty`
| if has_is_empty.is_empty() {
error: length comparison to zero error: length comparison to zero
--> $DIR/len_zero.rs:160:8 --> $DIR/len_zero.rs:160:8
| |
160 | if has_is_empty.len() != 0 { 160 | if has_is_empty.len() != 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()`
|
help: consider using `is_empty`
| if !has_is_empty.is_empty() {
error: length comparison to zero error: length comparison to zero
--> $DIR/len_zero.rs:166:8 --> $DIR/len_zero.rs:166:8
| |
166 | if has_is_empty.len() > 0 { 166 | if has_is_empty.len() > 0 {
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()`
|
help: consider using `is_empty`
| if !has_is_empty.is_empty() {
error: length comparison to zero error: length comparison to zero
--> $DIR/len_zero.rs:175:8 --> $DIR/len_zero.rs:175:8
| |
175 | if with_is_empty.len() == 0 { 175 | if with_is_empty.len() == 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `with_is_empty.is_empty()`
|
help: consider using `is_empty`
| if with_is_empty.is_empty() {
error: length comparison to zero error: length comparison to zero
--> $DIR/len_zero.rs:190:8 --> $DIR/len_zero.rs:190:8
| |
190 | if b.len() != 0 { 190 | if b.len() != 0 {
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: using `is_empty` is more concise: `!b.is_empty()`
|
help: consider using `is_empty`
| if !b.is_empty() {
error: aborting due to 11 previous errors error: aborting due to 11 previous errors

View File

@ -8,15 +8,13 @@ error: `if _ { .. } else { .. }` is an expression
61 | | if f() { 61 | | if f() {
62 | | foo = 42; 62 | | foo = 42;
63 | | } 63 | | }
| |_____^ | |_____^ help: it is more idiomatic to write `let <mut> foo = if f() { 42 } else { 0 };`
| |
note: lint level defined here note: lint level defined here
--> $DIR/let_if_seq.rs:5:9 --> $DIR/let_if_seq.rs:5:9
| |
5 | #![deny(useless_let_if_seq)] 5 | #![deny(useless_let_if_seq)]
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
help: it is more idiomatic to write
| let <mut> foo = if f() { 42 } else { 0 };
= note: you might not need `mut` at all = note: you might not need `mut` at all
error: `if _ { .. } else { .. }` is an expression error: `if _ { .. } else { .. }` is an expression
@ -29,10 +27,8 @@ error: `if _ { .. } else { .. }` is an expression
... | ... |
74 | | f(); 74 | | f();
75 | | } 75 | | }
| |_____^ | |_____^ help: it is more idiomatic to write `let <mut> bar = if f() { ..; 42 } else { ..; 0 };`
| |
help: it is more idiomatic to write
| let <mut> bar = if f() { ..; 42 } else { ..; 0 };
= note: you might not need `mut` at all = note: you might not need `mut` at all
error: `if _ { .. } else { .. }` is an expression error: `if _ { .. } else { .. }` is an expression
@ -45,10 +41,7 @@ error: `if _ { .. } else { .. }` is an expression
... | ... |
85 | | quz = 0; 85 | | quz = 0;
86 | | } 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 error: `if _ { .. } else { .. }` is an expression
--> $DIR/let_if_seq.rs:111:5 --> $DIR/let_if_seq.rs:111:5
@ -60,10 +53,8 @@ error: `if _ { .. } else { .. }` is an expression
115 | | if f() { 115 | | if f() {
116 | | baz = 42; 116 | | baz = 42;
117 | | } 117 | | }
| |_____^ | |_____^ help: it is more idiomatic to write `let <mut> baz = if f() { 42 } else { 0 };`
| |
help: it is more idiomatic to write
| let <mut> baz = if f() { 42 } else { 0 };
= note: you might not need `mut` at all = note: you might not need `mut` at all
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View File

@ -71,8 +71,6 @@ note: lint level defined here
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
help: if you mean to use a decimal constant, remove the `0` to remove confusion: help: if you mean to use a decimal constant, remove the `0` to remove confusion:
| let fail8 = 123; | let fail8 = 123;
help: if you mean to use an octal constant, use `0o`:
| let fail8 = 0o123;
error: aborting due to 9 previous errors error: aborting due to 9 previous errors

View File

@ -8,15 +8,13 @@ error: you seem to be trying to use match for destructuring a single pattern. Co
30 | | ExprNode::ExprAddrOf => Some(&NODE), 30 | | ExprNode::ExprAddrOf => Some(&NODE),
31 | | _ => { let x = 5; None }, 31 | | _ => { let x = 5; None },
32 | | } 32 | | }
| |_____^ | |_____^ help: try this `if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None }`
| |
note: lint level defined here note: lint level defined here
--> $DIR/matches.rs:7:9 --> $DIR/matches.rs:7:9
| |
7 | #![deny(single_match_else)] 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` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> $DIR/matches.rs:38:5 --> $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); } 42 | | Some(y) => { println!("{:?}", y); }
43 | | _ => () 43 | | _ => ()
44 | | }; 44 | | };
| |_____^ | |_____^ help: try this `if let Some(y) = x { println!("{:?}", y); }`
| |
= note: #[deny(single_match)] implied by #[deny(clippy)] = note: #[deny(single_match)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -36,8 +34,6 @@ note: lint level defined here
| |
5 | #![deny(clippy)] 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` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> $DIR/matches.rs:47:5 --> $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(), 51 | | (2...3, 7...9) => dummy(),
52 | | _ => {} 52 | | _ => {}
53 | | }; 53 | | };
| |_____^ | |_____^ help: try this `if let (2...3, 7...9) = z { dummy() }`
| |
= note: #[deny(single_match)] implied by #[deny(clippy)] = 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` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> $DIR/matches.rs:72:5 --> $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(), 76 | | Some(y) => dummy(),
77 | | None => () 77 | | None => ()
78 | | }; 78 | | };
| |_____^ | |_____^ help: try this `if let Some(y) = x { dummy() }`
| |
= note: #[deny(single_match)] implied by #[deny(clippy)] = 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` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> $DIR/matches.rs:80:5 --> $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(), 84 | | Ok(y) => dummy(),
85 | | Err(..) => () 85 | | Err(..) => ()
86 | | }; 86 | | };
| |_____^ | |_____^ help: try this `if let Ok(y) = y { dummy() }`
| |
= note: #[deny(single_match)] implied by #[deny(clippy)] = 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` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
--> $DIR/matches.rs:90:5 --> $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(), 94 | | Cow::Borrowed(..) => dummy(),
95 | | Cow::Owned(..) => (), 95 | | Cow::Owned(..) => (),
96 | | }; 96 | | };
| |_____^ | |_____^ help: try this `if let Cow::Borrowed(..) = c { dummy() }`
| |
= note: #[deny(single_match)] implied by #[deny(clippy)] = 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 error: you seem to be trying to match on a boolean expression
--> $DIR/matches.rs:114:5 --> $DIR/matches.rs:114:5
@ -113,7 +101,7 @@ error: you seem to be trying to match on a boolean expression
118 | | true => 0, 118 | | true => 0,
119 | | false => 42, 119 | | false => 42,
120 | | }; 120 | | };
| |_____^ | |_____^ help: consider using an if/else expression `if test { 0 } else { 42 }`
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = note: #[deny(match_bool)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -121,8 +109,6 @@ note: lint level defined here
| |
5 | #![deny(clippy)] 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 error: you seem to be trying to match on a boolean expression
--> $DIR/matches.rs:123:5 --> $DIR/matches.rs:123:5
@ -134,11 +120,9 @@ error: you seem to be trying to match on a boolean expression
127 | | true => 1, 127 | | true => 1,
128 | | false => 0, 128 | | false => 0,
129 | | }; 129 | | };
| |_____^ | |_____^ help: consider using an if/else expression `if option == 1 { 1 } else { 0 }`
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = 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 error: you seem to be trying to match on a boolean expression
--> $DIR/matches.rs:131:5 --> $DIR/matches.rs:131:5
@ -150,11 +134,9 @@ error: you seem to be trying to match on a boolean expression
135 | | true => (), 135 | | true => (),
136 | | false => { println!("Noooo!"); } 136 | | false => { println!("Noooo!"); }
137 | | }; 137 | | };
| |_____^ | |_____^ help: consider using an if/else expression `if !test { println!("Noooo!"); }`
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = 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 error: you seem to be trying to match on a boolean expression
--> $DIR/matches.rs:139:5 --> $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!"); } 143 | | false => { println!("Noooo!"); }
144 | | _ => (), 144 | | _ => (),
145 | | }; 145 | | };
| |_____^ | |_____^ help: consider using an if/else expression `if !test { println!("Noooo!"); }`
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = 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 error: you seem to be trying to match on a boolean expression
--> $DIR/matches.rs:147:5 --> $DIR/matches.rs:147:5
@ -182,11 +162,9 @@ error: you seem to be trying to match on a boolean expression
... | ... |
153 | | _ => (), 153 | | _ => (),
154 | | }; 154 | | };
| |_____^ | |_____^ help: consider using an if/else expression `if !(test && test) { println!("Noooo!"); }`
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = 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 `&&` error: equal expressions as operands to `&&`
--> $DIR/matches.rs:147:11 --> $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!"); } 160 | | false => { println!("Noooo!"); }
161 | | true => { println!("Yes!"); } 161 | | true => { println!("Yes!"); }
162 | | }; 162 | | };
| |_____^ | |_____^ help: consider using an if/else expression `if test { println!("Yes!"); } else { println!("Noooo!"); }`
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = 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 error: you don't need to add `&` to all patterns
--> $DIR/matches.rs:175:9 --> $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), 201 | | &Some(v) => println!("{:?}", v),
202 | | &None => println!("none"), 202 | | &None => println!("none"),
203 | | } 203 | | }
| |_____^ | |_____^ help: try `match w { .. }`
| |
= note: #[deny(match_ref_pats)] implied by #[deny(clippy)] = note: #[deny(match_ref_pats)] implied by #[deny(clippy)]
help: try
| match w { .. }
error: you don't need to add `&` to all patterns error: you don't need to add `&` to all patterns
--> $DIR/matches.rs:211:5 --> $DIR/matches.rs:211:5
@ -294,11 +268,9 @@ error: you don't need to add `&` to both the expression and the patterns
222 | | 222 | |
223 | | println!("none"); 223 | | println!("none");
224 | | } 224 | | }
| |_____^ | |_____^ help: try `if let .. = b { .. }`
| |
= note: #[deny(match_ref_pats)] implied by #[deny(clippy)] = note: #[deny(match_ref_pats)] implied by #[deny(clippy)]
help: try
| if let .. = b { .. }
error: some ranges overlap error: some ranges overlap
--> $DIR/matches.rs:231:9 --> $DIR/matches.rs:231:9

View File

@ -241,7 +241,7 @@ error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:278:5 --> $DIR/methods.rs:278:5
| |
278 | with_constructor.unwrap_or(make()); 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: #[deny(or_fun_call)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -249,118 +249,94 @@ note: lint level defined here
| |
5 | #![deny(clippy, clippy_pedantic)] 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` error: use of `unwrap_or` followed by a call to `new`
--> $DIR/methods.rs:284:5 --> $DIR/methods.rs:284:5
| |
284 | with_new.unwrap_or(Vec::new()); 284 | with_new.unwrap_or(Vec::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_new.unwrap_or_default()`
| |
= note: #[deny(or_fun_call)] implied by #[deny(clippy)] = 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 error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:290:5 --> $DIR/methods.rs:290:5
| |
290 | with_const_args.unwrap_or(Vec::with_capacity(12)); 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)] = 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 error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:296:5 --> $DIR/methods.rs:296:5
| |
296 | with_err.unwrap_or(make()); 296 | with_err.unwrap_or(make());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_err.unwrap_or_else(|_| make())`
| |
= note: #[deny(or_fun_call)] implied by #[deny(clippy)] = 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 error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:302:5 --> $DIR/methods.rs:302:5
| |
302 | with_err_args.unwrap_or(Vec::with_capacity(12)); 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)] = 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` error: use of `unwrap_or` followed by a call to `default`
--> $DIR/methods.rs:308:5 --> $DIR/methods.rs:308:5
| |
308 | with_default_trait.unwrap_or(Default::default()); 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)] = 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` error: use of `unwrap_or` followed by a call to `default`
--> $DIR/methods.rs:314:5 --> $DIR/methods.rs:314:5
| |
314 | with_default_type.unwrap_or(u64::default()); 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)] = 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 error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:320:5 --> $DIR/methods.rs:320:5
| |
320 | with_vec.unwrap_or(vec![]); 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)] = 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 error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:326:5 --> $DIR/methods.rs:326:5
| |
326 | without_default.unwrap_or(Foo::new()); 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)] = 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 error: use of `or_insert` followed by a function call
--> $DIR/methods.rs:332:5 --> $DIR/methods.rs:332:5
| |
332 | map.entry(42).or_insert(String::new()); 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)] = 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 error: use of `or_insert` followed by a function call
--> $DIR/methods.rs:338:5 --> $DIR/methods.rs:338:5
| |
338 | btree.entry(42).or_insert(String::new()); 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)] = 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 error: use of `unwrap_or` followed by a function call
--> $DIR/methods.rs:344:13 --> $DIR/methods.rs:344:13
| |
344 | let _ = stringy.unwrap_or("".to_owned()); 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)] = 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 error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
--> $DIR/methods.rs:358:23 --> $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 --> $DIR/methods.rs:429:17
| |
429 | let _ = boxed_slice.get(1).unwrap(); 429 | let _ = boxed_slice.get(1).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&boxed_slice[1]`
| |
= note: #[deny(get_unwrap)] implied by #[deny(clippy)] = note: #[deny(get_unwrap)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -472,98 +448,78 @@ note: lint level defined here
| |
5 | #![deny(clippy, clippy_pedantic)] 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 error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
--> $DIR/methods.rs:433:17 --> $DIR/methods.rs:433:17
| |
433 | let _ = some_slice.get(0).unwrap(); 433 | let _ = some_slice.get(0).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_slice[0]`
| |
= note: #[deny(get_unwrap)] implied by #[deny(clippy)] = 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 error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
--> $DIR/methods.rs:437:17 --> $DIR/methods.rs:437:17
| |
437 | let _ = some_vec.get(0).unwrap(); 437 | let _ = some_vec.get(0).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_vec[0]`
| |
= note: #[deny(get_unwrap)] implied by #[deny(clippy)] = 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 error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
--> $DIR/methods.rs:441:17 --> $DIR/methods.rs:441:17
| |
441 | let _ = some_vecdeque.get(0).unwrap(); 441 | let _ = some_vecdeque.get(0).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_vecdeque[0]`
| |
= note: #[deny(get_unwrap)] implied by #[deny(clippy)] = 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 error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise
--> $DIR/methods.rs:445:17 --> $DIR/methods.rs:445:17
| |
445 | let _ = some_hashmap.get(&1).unwrap(); 445 | let _ = some_hashmap.get(&1).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_hashmap[&1]`
| |
= note: #[deny(get_unwrap)] implied by #[deny(clippy)] = 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 error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise
--> $DIR/methods.rs:449:17 --> $DIR/methods.rs:449:17
| |
449 | let _ = some_btreemap.get(&1).unwrap(); 449 | let _ = some_btreemap.get(&1).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_btreemap[&1]`
| |
= note: #[deny(get_unwrap)] implied by #[deny(clippy)] = 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 error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
--> $DIR/methods.rs:458:10 --> $DIR/methods.rs:458:10
| |
458 | *boxed_slice.get_mut(0).unwrap() = 1; 458 | *boxed_slice.get_mut(0).unwrap() = 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut boxed_slice[0]`
| |
= note: #[deny(get_unwrap)] implied by #[deny(clippy)] = 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 error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
--> $DIR/methods.rs:462:10 --> $DIR/methods.rs:462:10
| |
462 | *some_slice.get_mut(0).unwrap() = 1; 462 | *some_slice.get_mut(0).unwrap() = 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut some_slice[0]`
| |
= note: #[deny(get_unwrap)] implied by #[deny(clippy)] = 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 error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
--> $DIR/methods.rs:466:10 --> $DIR/methods.rs:466:10
| |
466 | *some_vec.get_mut(0).unwrap() = 1; 466 | *some_vec.get_mut(0).unwrap() = 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut some_vec[0]`
| |
= note: #[deny(get_unwrap)] implied by #[deny(clippy)] = 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 error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
--> $DIR/methods.rs:470:10 --> $DIR/methods.rs:470:10
| |
470 | *some_vecdeque.get_mut(0).unwrap() = 1; 470 | *some_vecdeque.get_mut(0).unwrap() = 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut some_vecdeque[0]`
| |
= note: #[deny(get_unwrap)] implied by #[deny(clippy)] = 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 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 --> $DIR/methods.rs:488:13
@ -640,7 +596,7 @@ error: you should use the `starts_with` method
--> $DIR/methods.rs:517:5 --> $DIR/methods.rs:517:5
| |
517 | "".chars().next() == Some(' '); 517 | "".chars().next() == Some(' ');
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this `"".starts_with(' ')`
| |
= note: #[deny(chars_next_cmp)] implied by #[deny(clippy)] = note: #[deny(chars_next_cmp)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -648,24 +604,20 @@ note: lint level defined here
| |
5 | #![deny(clippy, clippy_pedantic)] 5 | #![deny(clippy, clippy_pedantic)]
| ^^^^^^ | ^^^^^^
help: like this
| "".starts_with(' ');
error: you should use the `starts_with` method error: you should use the `starts_with` method
--> $DIR/methods.rs:522:5 --> $DIR/methods.rs:522:5
| |
522 | Some(' ') != "".chars().next(); 522 | Some(' ') != "".chars().next();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this `!"".starts_with(' ')`
| |
= note: #[deny(chars_next_cmp)] implied by #[deny(clippy)] = note: #[deny(chars_next_cmp)] implied by #[deny(clippy)]
help: like this
| !"".starts_with(' ');
error: calling `.extend(_.chars())` error: calling `.extend(_.chars())`
--> $DIR/methods.rs:534:5 --> $DIR/methods.rs:534:5
| |
534 | s.extend(abc.chars()); 534 | s.extend(abc.chars());
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^ help: try this `s.push_str(abc)`
| |
= note: #[deny(string_extend_chars)] implied by #[deny(clippy)] = note: #[deny(string_extend_chars)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -673,34 +625,28 @@ note: lint level defined here
| |
5 | #![deny(clippy, clippy_pedantic)] 5 | #![deny(clippy, clippy_pedantic)]
| ^^^^^^ | ^^^^^^
help: try this
| s.push_str(abc);
error: calling `.extend(_.chars())` error: calling `.extend(_.chars())`
--> $DIR/methods.rs:540:5 --> $DIR/methods.rs:540:5
| |
540 | s.extend("abc".chars()); 540 | s.extend("abc".chars());
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^ help: try this `s.push_str("abc")`
| |
= note: #[deny(string_extend_chars)] implied by #[deny(clippy)] = note: #[deny(string_extend_chars)] implied by #[deny(clippy)]
help: try this
| s.push_str("abc");
error: calling `.extend(_.chars())` error: calling `.extend(_.chars())`
--> $DIR/methods.rs:546:5 --> $DIR/methods.rs:546:5
| |
546 | s.extend(def.chars()); 546 | s.extend(def.chars());
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^ help: try this `s.push_str(&def)`
| |
= note: #[deny(string_extend_chars)] implied by #[deny(clippy)] = note: #[deny(string_extend_chars)] implied by #[deny(clippy)]
help: try this
| s.push_str(&def);
error: using `clone` on a `Copy` type error: using `clone` on a `Copy` type
--> $DIR/methods.rs:560:5 --> $DIR/methods.rs:560:5
| |
560 | 42.clone(); 560 | 42.clone();
| ^^^^^^^^^^ | ^^^^^^^^^^ help: try removing the `clone` call `42`
| |
= note: #[deny(clone_on_copy)] implied by #[deny(clippy)] = note: #[deny(clone_on_copy)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -708,44 +654,36 @@ note: lint level defined here
| |
5 | #![deny(clippy, clippy_pedantic)] 5 | #![deny(clippy, clippy_pedantic)]
| ^^^^^^ | ^^^^^^
help: try removing the `clone` call
| 42;
error: using `clone` on a `Copy` type error: using `clone` on a `Copy` type
--> $DIR/methods.rs:565:5 --> $DIR/methods.rs:565:5
| |
565 | (&42).clone(); 565 | (&42).clone();
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^ help: try dereferencing it `*(&42)`
| |
= note: #[deny(clone_on_copy)] implied by #[deny(clippy)] = note: #[deny(clone_on_copy)] implied by #[deny(clippy)]
help: try dereferencing it
| *(&42);
error: using `clone` on a `Copy` type error: using `clone` on a `Copy` type
--> $DIR/methods.rs:571:5 --> $DIR/methods.rs:571:5
| |
571 | t.clone(); 571 | t.clone();
| ^^^^^^^^^ | ^^^^^^^^^ help: try removing the `clone` call `t`
| |
= note: #[deny(clone_on_copy)] implied by #[deny(clippy)] = note: #[deny(clone_on_copy)] implied by #[deny(clippy)]
help: try removing the `clone` call
| t;
error: using `clone` on a `Copy` type error: using `clone` on a `Copy` type
--> $DIR/methods.rs:574:5 --> $DIR/methods.rs:574:5
| |
574 | Some(t).clone(); 574 | Some(t).clone();
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^ help: try removing the `clone` call `Some(t)`
| |
= note: #[deny(clone_on_copy)] implied by #[deny(clippy)] = 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 error: using `clone` on a double-reference; this will copy the reference instead of cloning the inner type
--> $DIR/methods.rs:582:22 --> $DIR/methods.rs:582:22
| |
582 | let z: &Vec<_> = y.clone(); 582 | let z: &Vec<_> = y.clone();
| ^^^^^^^^^ | ^^^^^^^^^ help: try dereferencing it `(*y).clone()`
| |
= note: #[deny(clone_double_ref)] implied by #[deny(clippy)] = note: #[deny(clone_double_ref)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -753,14 +691,12 @@ note: lint level defined here
| |
5 | #![deny(clippy, clippy_pedantic)] 5 | #![deny(clippy, clippy_pedantic)]
| ^^^^^^ | ^^^^^^
help: try dereferencing it
| let z: &Vec<_> = (*y).clone();
error: single-character string constant used as pattern error: single-character string constant used as pattern
--> $DIR/methods.rs:590:13 --> $DIR/methods.rs:590:13
| |
590 | x.split("x"); 590 | x.split("x");
| ^^^ | --------^^^- help: try using a char instead: `x.split('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = note: #[deny(single_char_pattern)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -768,168 +704,134 @@ note: lint level defined here
| |
5 | #![deny(clippy, clippy_pedantic)] 5 | #![deny(clippy, clippy_pedantic)]
| ^^^^^^ | ^^^^^^
help: try using a char instead:
| x.split('x');
error: single-character string constant used as pattern error: single-character string constant used as pattern
--> $DIR/methods.rs:614:16 --> $DIR/methods.rs:614:16
| |
614 | x.contains("x"); 614 | x.contains("x");
| ^^^ | -----------^^^- help: try using a char instead: `x.contains('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:618:19 --> $DIR/methods.rs:618:19
| |
618 | x.starts_with("x"); 618 | x.starts_with("x");
| ^^^ | --------------^^^- help: try using a char instead: `x.starts_with('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:622:17 --> $DIR/methods.rs:622:17
| |
622 | x.ends_with("x"); 622 | x.ends_with("x");
| ^^^ | ------------^^^- help: try using a char instead: `x.ends_with('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:626:12 --> $DIR/methods.rs:626:12
| |
626 | x.find("x"); 626 | x.find("x");
| ^^^ | -------^^^- help: try using a char instead: `x.find('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:630:13 --> $DIR/methods.rs:630:13
| |
630 | x.rfind("x"); 630 | x.rfind("x");
| ^^^ | --------^^^- help: try using a char instead: `x.rfind('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:634:14 --> $DIR/methods.rs:634:14
| |
634 | x.rsplit("x"); 634 | x.rsplit("x");
| ^^^ | ---------^^^- help: try using a char instead: `x.rsplit('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:638:24 --> $DIR/methods.rs:638:24
| |
638 | x.split_terminator("x"); 638 | x.split_terminator("x");
| ^^^ | -------------------^^^- help: try using a char instead: `x.split_terminator('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:642:25 --> $DIR/methods.rs:642:25
| |
642 | x.rsplit_terminator("x"); 642 | x.rsplit_terminator("x");
| ^^^ | --------------------^^^- help: try using a char instead: `x.rsplit_terminator('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:646:17 --> $DIR/methods.rs:646:17
| |
646 | x.splitn(0, "x"); 646 | x.splitn(0, "x");
| ^^^ | ------------^^^- help: try using a char instead: `x.splitn(0, 'x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:650:18 --> $DIR/methods.rs:650:18
| |
650 | x.rsplitn(0, "x"); 650 | x.rsplitn(0, "x");
| ^^^ | -------------^^^- help: try using a char instead: `x.rsplitn(0, 'x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:654:15 --> $DIR/methods.rs:654:15
| |
654 | x.matches("x"); 654 | x.matches("x");
| ^^^ | ----------^^^- help: try using a char instead: `x.matches('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:658:16 --> $DIR/methods.rs:658:16
| |
658 | x.rmatches("x"); 658 | x.rmatches("x");
| ^^^ | -----------^^^- help: try using a char instead: `x.rmatches('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:662:21 --> $DIR/methods.rs:662:21
| |
662 | x.match_indices("x"); 662 | x.match_indices("x");
| ^^^ | ----------------^^^- help: try using a char instead: `x.match_indices('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:666:22 --> $DIR/methods.rs:666:22
| |
666 | x.rmatch_indices("x"); 666 | x.rmatch_indices("x");
| ^^^ | -----------------^^^- help: try using a char instead: `x.rmatch_indices('x')`
| |
= note: #[deny(single_char_pattern)] implied by #[deny(clippy)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:670:25 --> $DIR/methods.rs:670:25
| |
670 | x.trim_left_matches("x"); 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)] = 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 error: single-character string constant used as pattern
--> $DIR/methods.rs:674:26 --> $DIR/methods.rs:674:26
| |
674 | x.trim_right_matches("x"); 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)] = 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` error: you are getting the inner pointer of a temporary `CString`
--> $DIR/methods.rs:687:5 --> $DIR/methods.rs:687:5

View File

@ -20,28 +20,19 @@ error: this if-then-else expression returns a bool literal
--> $DIR/needless_bool.rs:11:5 --> $DIR/needless_bool.rs:11:5
| |
11 | if x { true } else { false }; 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 error: this if-then-else expression returns a bool literal
--> $DIR/needless_bool.rs:15:5 --> $DIR/needless_bool.rs:15:5
| |
15 | if x { false } else { true }; 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 error: this if-then-else expression returns a bool literal
--> $DIR/needless_bool.rs:19:5 --> $DIR/needless_bool.rs:19:5
| |
19 | if x && y { false } else { true }; 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 error: this if-then-else expression will always return true
--> $DIR/needless_bool.rs:34:5 --> $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 --> $DIR/needless_bool.rs:46:5
| |
46 | if x { return true } else { return false }; 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 error: this if-then-else expression returns a bool literal
--> $DIR/needless_bool.rs:54:5 --> $DIR/needless_bool.rs:54:5
| |
54 | if x && y { return true } else { return false }; 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 error: this if-then-else expression returns a bool literal
--> $DIR/needless_bool.rs:62:5 --> $DIR/needless_bool.rs:62:5
| |
62 | if x { return false } else { return true }; 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 error: this if-then-else expression returns a bool literal
--> $DIR/needless_bool.rs:70:5 --> $DIR/needless_bool.rs:70:5
| |
70 | if x && y { return false } else { return true }; 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 error: aborting due to 11 previous errors

View File

@ -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 --> $DIR/needless_pass_by_value.rs:9:23
| |
9 | fn foo<T: Default>(v: Vec<T>, w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T> { 9 | fn foo<T: Default>(v: Vec<T>, w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T> {
| ^^^^^^ | ^^^^^^ help: consider changing the type to `&[T]`
| |
note: lint level defined here note: lint level defined here
--> $DIR/needless_pass_by_value.rs:4:9 --> $DIR/needless_pass_by_value.rs:4:9
| |
4 | #![deny(needless_pass_by_value)] 4 | #![deny(needless_pass_by_value)]
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
help: consider changing the type to `&[T]`
| fn foo<T: Default>(v: &[T], w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T> {
error: this argument is passed by value, but not consumed in the function body error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:23:11 --> $DIR/needless_pass_by_value.rs:23:11
| |
23 | fn bar(x: String, y: Wrapper) { 23 | fn bar(x: String, y: Wrapper) {
| ^^^^^^ | ^^^^^^ help: consider changing the type to `&str`
|
help: consider changing the type to `&str`
| fn bar(x: &str, y: Wrapper) {
error: this argument is passed by value, but not consumed in the function body error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:23:22 --> $DIR/needless_pass_by_value.rs:23:22
| |
23 | fn bar(x: String, y: Wrapper) { 23 | fn bar(x: String, y: Wrapper) {
| ^^^^^^^ | ^^^^^^^ help: consider taking a reference instead `&Wrapper`
|
help: consider taking a reference instead
| fn bar(x: String, y: &Wrapper) {
error: this argument is passed by value, but not consumed in the function body error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:29:63 --> $DIR/needless_pass_by_value.rs:29:63
| |
29 | fn test_borrow_trait<T: std::borrow::Borrow<str>, U>(t: T, u: U) { 29 | fn test_borrow_trait<T: std::borrow::Borrow<str>, U>(t: T, u: U) {
| ^ | ^ help: consider taking a reference instead `&U`
|
help: consider taking a reference instead
| fn test_borrow_trait<T: std::borrow::Borrow<str>, U>(t: T, u: &U) {
error: this argument is passed by value, but not consumed in the function body error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:40:18 --> $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 --> $DIR/needless_pass_by_value.rs:53:24
| |
53 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { 53 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
| ^^^^^^^ | ^^^^^^^ help: consider taking a reference instead `&Wrapper`
|
help: consider taking a reference instead
| fn test_destructure(x: &Wrapper, y: Wrapper, z: Wrapper) {
error: this argument is passed by value, but not consumed in the function body error: this argument is passed by value, but not consumed in the function body
--> $DIR/needless_pass_by_value.rs:53:36 --> $DIR/needless_pass_by_value.rs:53:36

View File

@ -2,78 +2,55 @@ error: unneeded return statement
--> $DIR/needless_return.rs:11:5 --> $DIR/needless_return.rs:11:5
| |
11 | return true; 11 | return true;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: remove `return` as shown: `true`
| |
note: lint level defined here note: lint level defined here
--> $DIR/needless_return.rs:4:9 --> $DIR/needless_return.rs:4:9
| |
4 | #![deny(needless_return)] 4 | #![deny(needless_return)]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
help: remove `return` as shown:
| true
error: unneeded return statement error: unneeded return statement
--> $DIR/needless_return.rs:18:5 --> $DIR/needless_return.rs:18:5
| |
18 | return true 18 | return true
| ^^^^^^^^^^^ | ^^^^^^^^^^^ help: remove `return` as shown: `true`
|
help: remove `return` as shown:
| true
error: unneeded return statement error: unneeded return statement
--> $DIR/needless_return.rs:26:9 --> $DIR/needless_return.rs:26:9
| |
26 | return true; 26 | return true;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
help: remove `return` as shown:
| true
error: unneeded return statement error: unneeded return statement
--> $DIR/needless_return.rs:31:9 --> $DIR/needless_return.rs:31:9
| |
31 | return false; 31 | return false;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^ help: remove `return` as shown: `false`
|
help: remove `return` as shown:
| false
error: unneeded return statement error: unneeded return statement
--> $DIR/needless_return.rs:40:17 --> $DIR/needless_return.rs:40:17
| |
40 | true => return false, 40 | true => return false,
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: remove `return` as shown: `false`
|
help: remove `return` as shown:
| true => false,
error: unneeded return statement error: unneeded return statement
--> $DIR/needless_return.rs:46:13 --> $DIR/needless_return.rs:46:13
| |
46 | return true; 46 | return true;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
help: remove `return` as shown:
| true
error: unneeded return statement error: unneeded return statement
--> $DIR/needless_return.rs:56:9 --> $DIR/needless_return.rs:56:9
| |
56 | return true; 56 | return true;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: remove `return` as shown: `true`
|
help: remove `return` as shown:
| true
error: unneeded return statement error: unneeded return statement
--> $DIR/needless_return.rs:61:16 --> $DIR/needless_return.rs:61:16
| |
61 | let _ = || return true; 61 | let _ = || return true;
| ^^^^^^^^^^^ | ^^^^^^^^^^^ help: remove `return` as shown: `true`
|
help: remove `return` as shown:
| let _ = || true;
error: aborting due to 8 previous errors error: aborting due to 8 previous errors

View File

@ -158,177 +158,121 @@ error: statement can be reduced
--> $DIR/no_effect.rs:65:5 --> $DIR/no_effect.rs:65:5
| |
65 | Tuple(get_number()); 65 | Tuple(get_number());
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();`
| |
note: lint level defined here note: lint level defined here
--> $DIR/no_effect.rs:4:20 --> $DIR/no_effect.rs:4:20
| |
4 | #![deny(no_effect, unnecessary_operation)] 4 | #![deny(no_effect, unnecessary_operation)]
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
help: replace it with
| get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:68:5 --> $DIR/no_effect.rs:68:5
| |
68 | Struct { field: get_number() }; 68 | Struct { field: get_number() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();`
|
help: replace it with
| get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:71:5 --> $DIR/no_effect.rs:71:5
| |
71 | Struct { ..get_struct() }; 71 | Struct { ..get_struct() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_struct();`
|
help: replace it with
| get_struct();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:74:5 --> $DIR/no_effect.rs:74:5
| |
74 | Enum::Tuple(get_number()); 74 | Enum::Tuple(get_number());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();`
|
help: replace it with
| get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:77:5 --> $DIR/no_effect.rs:77:5
| |
77 | Enum::Struct { field: get_number() }; 77 | Enum::Struct { field: get_number() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();`
|
help: replace it with
| get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:80:5 --> $DIR/no_effect.rs:80:5
| |
80 | 5 + get_number(); 80 | 5 + get_number();
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^ help: replace it with `5;get_number();`
|
help: replace it with
| 5;get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:83:5 --> $DIR/no_effect.rs:83:5
| |
83 | *&get_number(); 83 | *&get_number();
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^ help: replace it with `get_number();`
|
help: replace it with
| get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:86:5 --> $DIR/no_effect.rs:86:5
| |
86 | &get_number(); 86 | &get_number();
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^ help: replace it with `get_number();`
|
help: replace it with
| get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:89:5 --> $DIR/no_effect.rs:89:5
| |
89 | (5, 6, get_number()); 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 error: statement can be reduced
--> $DIR/no_effect.rs:92:5 --> $DIR/no_effect.rs:92:5
| |
92 | box get_number(); 92 | box get_number();
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^ help: replace it with `get_number();`
|
help: replace it with
| get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:95:5 --> $DIR/no_effect.rs:95:5
| |
95 | get_number()..; 95 | get_number()..;
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^ help: replace it with `get_number();`
|
help: replace it with
| get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:98:5 --> $DIR/no_effect.rs:98:5
| |
98 | ..get_number(); 98 | ..get_number();
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^ help: replace it with `get_number();`
|
help: replace it with
| get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:101:5 --> $DIR/no_effect.rs:101:5
| |
101 | 5..get_number(); 101 | 5..get_number();
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^ help: replace it with `5;get_number();`
|
help: replace it with
| 5;get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:104:5 --> $DIR/no_effect.rs:104:5
| |
104 | [42, get_number()]; 104 | [42, get_number()];
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^ help: replace it with `42;get_number();`
|
help: replace it with
| 42;get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:107:5 --> $DIR/no_effect.rs:107:5
| |
107 | [42, 55][get_number() as usize]; 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 error: statement can be reduced
--> $DIR/no_effect.rs:110:5 --> $DIR/no_effect.rs:110:5
| |
110 | (42, get_number()).1; 110 | (42, get_number()).1;
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with `42;get_number();`
|
help: replace it with
| 42;get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:113:5 --> $DIR/no_effect.rs:113:5
| |
113 | [get_number(); 55]; 113 | [get_number(); 55];
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();`
|
help: replace it with
| get_number();
error: statement can be reduced error: statement can be reduced
--> $DIR/no_effect.rs:116:5 --> $DIR/no_effect.rs:116:5
| |
116 | [42; 55][get_number() as usize]; 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 error: statement can be reduced
--> $DIR/no_effect.rs:119:5 --> $DIR/no_effect.rs:119:5
| |
119 | {get_number()}; 119 | {get_number()};
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^ help: replace it with `get_number();`
|
help: replace it with
| get_number();
error: aborting due to 44 previous errors error: aborting due to 44 previous errors

View File

@ -2,87 +2,61 @@ error: operator precedence can trip the unwary
--> $DIR/precedence.rs:8:5 --> $DIR/precedence.rs:8:5
| |
8 | 1 << 2 + 3; 8 | 1 << 2 + 3;
| ^^^^^^^^^^ | ^^^^^^^^^^ help: consider parenthesizing your expression `1 << (2 + 3)`
| |
note: lint level defined here note: lint level defined here
--> $DIR/precedence.rs:4:8 --> $DIR/precedence.rs:4:8
| |
4 | #[deny(precedence)] 4 | #[deny(precedence)]
| ^^^^^^^^^^ | ^^^^^^^^^^
help: consider parenthesizing your expression
| 1 << (2 + 3);
error: operator precedence can trip the unwary error: operator precedence can trip the unwary
--> $DIR/precedence.rs:11:5 --> $DIR/precedence.rs:11:5
| |
11 | 1 + 2 << 3; 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 error: operator precedence can trip the unwary
--> $DIR/precedence.rs:14:5 --> $DIR/precedence.rs:14:5
| |
14 | 4 >> 1 + 1; 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 error: operator precedence can trip the unwary
--> $DIR/precedence.rs:17:5 --> $DIR/precedence.rs:17:5
| |
17 | 1 + 3 >> 2; 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 error: operator precedence can trip the unwary
--> $DIR/precedence.rs:20:5 --> $DIR/precedence.rs:20:5
| |
20 | 1 ^ 1 - 1; 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 error: operator precedence can trip the unwary
--> $DIR/precedence.rs:23:5 --> $DIR/precedence.rs:23:5
| |
23 | 3 | 2 - 1; 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 error: operator precedence can trip the unwary
--> $DIR/precedence.rs:26:5 --> $DIR/precedence.rs:26:5
| |
26 | 3 & 5 - 2; 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 error: unary minus has lower precedence than method call
--> $DIR/precedence.rs:30:5 --> $DIR/precedence.rs:30:5
| |
30 | -1i32.abs(); 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 error: unary minus has lower precedence than method call
--> $DIR/precedence.rs:33:5 --> $DIR/precedence.rs:33:5
| |
33 | -1f32.abs(); 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 error: aborting due to 9 previous errors

View File

@ -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 --> $DIR/redundant_closure_call.rs:7:10
| |
7 | \tlet a = (|| 42)(); 7 | \tlet a = (|| 42)();
| \t ^^^^^^^^^ | \t ^^^^^^^^^ help: Try doing something like: `42`
|
help: Try doing something like:
| \tlet a = 42;
error: Try not to call a closure in the expression where it is declared. error: Try not to call a closure in the expression where it is declared.
--> $DIR/redundant_closure_call.rs:13:10 --> $DIR/redundant_closure_call.rs:13:10

View File

@ -2,105 +2,73 @@ error: immediately dereferencing a reference
--> $DIR/reference.rs:19:13 --> $DIR/reference.rs:19:13
| |
19 | let b = *&a; 19 | let b = *&a;
| ^^^ | ^^^ help: try this `a`
| |
note: lint level defined here note: lint level defined here
--> $DIR/reference.rs:14:8 --> $DIR/reference.rs:14:8
| |
14 | #[deny(deref_addrof)] 14 | #[deny(deref_addrof)]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
help: try this
| let b = a;
error: immediately dereferencing a reference error: immediately dereferencing a reference
--> $DIR/reference.rs:24:13 --> $DIR/reference.rs:24:13
| |
24 | let b = *&get_number(); 24 | let b = *&get_number();
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^ help: try this `get_number()`
|
help: try this
| let b = get_number();
error: immediately dereferencing a reference error: immediately dereferencing a reference
--> $DIR/reference.rs:32:13 --> $DIR/reference.rs:32:13
| |
32 | let b = *&bytes[1..2][0]; 32 | let b = *&bytes[1..2][0];
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^ help: try this `bytes[1..2][0]`
|
help: try this
| let b = bytes[1..2][0];
error: immediately dereferencing a reference error: immediately dereferencing a reference
--> $DIR/reference.rs:39:13 --> $DIR/reference.rs:39:13
| |
39 | let b = *&(a); 39 | let b = *&(a);
| ^^^^^ | ^^^^^ help: try this `(a)`
|
help: try this
| let b = (a);
error: immediately dereferencing a reference error: immediately dereferencing a reference
--> $DIR/reference.rs:44:13 --> $DIR/reference.rs:44:13
| |
44 | let b = *(&a); 44 | let b = *(&a);
| ^^^^^ | ^^^^^ help: try this `a`
|
help: try this
| let b = a;
error: immediately dereferencing a reference error: immediately dereferencing a reference
--> $DIR/reference.rs:49:13 --> $DIR/reference.rs:49:13
| |
49 | let b = *((&a)); 49 | let b = *((&a));
| ^^^^^^^ | ^^^^^^^ help: try this `a`
|
help: try this
| let b = a;
error: immediately dereferencing a reference error: immediately dereferencing a reference
--> $DIR/reference.rs:54:13 --> $DIR/reference.rs:54:13
| |
54 | let b = *&&a; 54 | let b = *&&a;
| ^^^^ | ^^^^ help: try this `&a`
|
help: try this
| let b = &a;
error: immediately dereferencing a reference error: immediately dereferencing a reference
--> $DIR/reference.rs:59:14 --> $DIR/reference.rs:59:14
| |
59 | let b = **&aref; 59 | let b = **&aref;
| ^^^^^^ | ^^^^^^ help: try this `aref`
|
help: try this
| let b = *aref;
error: immediately dereferencing a reference error: immediately dereferencing a reference
--> $DIR/reference.rs:66:14 --> $DIR/reference.rs:66:14
| |
66 | let b = **&&a; 66 | let b = **&&a;
| ^^^^ | ^^^^ help: try this `&a`
|
help: try this
| let b = *&a;
error: immediately dereferencing a reference error: immediately dereferencing a reference
--> $DIR/reference.rs:73:17 --> $DIR/reference.rs:73:17
| |
73 | let y = *&mut x; 73 | let y = *&mut x;
| ^^^^^^^ | ^^^^^^^ help: try this `x`
|
help: try this
| let y = x;
error: immediately dereferencing a reference error: immediately dereferencing a reference
--> $DIR/reference.rs:83:18 --> $DIR/reference.rs:83:18
| |
83 | let y = **&mut &mut x; 83 | let y = **&mut &mut x;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: try this `&mut x`
|
help: try this
| let y = *&mut x;
error: aborting due to 11 previous errors error: aborting due to 11 previous errors

View File

@ -2,33 +2,25 @@ error: boolean short circuit operator in statement may be clearer using an expli
--> $DIR/short_circuit_statement.rs:7:5 --> $DIR/short_circuit_statement.rs:7:5
| |
7 | f() && g(); 7 | f() && g();
| ^^^^^^^^^^^ | ^^^^^^^^^^^ help: replace it with `if f() { g(); }`
| |
note: lint level defined here note: lint level defined here
--> $DIR/short_circuit_statement.rs:4:9 --> $DIR/short_circuit_statement.rs:4:9
| |
4 | #![deny(short_circuit_statement)] 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 error: boolean short circuit operator in statement may be clearer using an explicit test
--> $DIR/short_circuit_statement.rs:11:5 --> $DIR/short_circuit_statement.rs:11:5
| |
11 | f() || g(); 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 error: boolean short circuit operator in statement may be clearer using an explicit test
--> $DIR/short_circuit_statement.rs:15:5 --> $DIR/short_circuit_statement.rs:15:5
| |
15 | 1 == 2 || g(); 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 error: aborting due to 3 previous errors

View File

@ -56,25 +56,21 @@ error: calling `as_bytes()` on a string literal
--> $DIR/strings.rs:50:14 --> $DIR/strings.rs:50:14
| |
50 | let bs = "hello there".as_bytes(); 50 | let bs = "hello there".as_bytes();
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead `b"hello there"`
| |
note: lint level defined here note: lint level defined here
--> $DIR/strings.rs:48:8 --> $DIR/strings.rs:48:8
| |
48 | #[deny(string_lit_as_bytes)] 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 warning: manual implementation of an assign operation
--> $DIR/strings.rs:68:7 --> $DIR/strings.rs:68:7
| |
68 | ; x = x + 1; 68 | ; x = x + 1;
| ^^^^^^^^^ | ^^^^^^^^^ help: replace it with `x += 1`
| |
= note: #[warn(assign_op_pattern)] on by default = note: #[warn(assign_op_pattern)] on by default
help: replace it with
| ; x += 1;
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View File

@ -4,7 +4,7 @@ error: this looks like you are swapping elements of `foo` manually
11 | / let temp = foo[0]; 11 | / let temp = foo[0];
12 | | foo[0] = foo[1]; 12 | | foo[0] = foo[1];
13 | | foo[1] = temp; 13 | | foo[1] = temp;
| |_________________^ | |_________________^ help: try `foo.swap(0, 1)`
| |
= note: #[deny(manual_swap)] implied by #[deny(clippy)] = note: #[deny(manual_swap)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -12,8 +12,6 @@ note: lint level defined here
| |
4 | #![deny(clippy)] 4 | #![deny(clippy)]
| ^^^^^^ | ^^^^^^
help: try
| foo.swap(0, 1);
error: this looks like you are swapping elements of `foo` manually error: this looks like you are swapping elements of `foo` manually
--> $DIR/swap.rs:23:5 --> $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]; 23 | / let temp = foo[0];
24 | | foo[0] = foo[1]; 24 | | foo[0] = foo[1];
25 | | foo[1] = temp; 25 | | foo[1] = temp;
| |_________________^ | |_________________^ help: try `foo.swap(0, 1)`
| |
= note: #[deny(manual_swap)] implied by #[deny(clippy)] = 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 error: this looks like you are swapping elements of `foo` manually
--> $DIR/swap.rs:35:5 --> $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]; 35 | / let temp = foo[0];
36 | | foo[0] = foo[1]; 36 | | foo[0] = foo[1];
37 | | foo[1] = temp; 37 | | foo[1] = temp;
| |_________________^ | |_________________^ help: try `foo.swap(0, 1)`
| |
= note: #[deny(manual_swap)] implied by #[deny(clippy)] = 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 error: this looks like you are swapping `a` and `b` manually
--> $DIR/swap.rs:60:7 --> $DIR/swap.rs:60:7
@ -46,11 +40,9 @@ error: this looks like you are swapping `a` and `b` manually
| _______^ | _______^
61 | | a = b; 61 | | a = b;
62 | | b = t; 62 | | b = t;
| |_________^ | |_________^ help: try `std::mem::swap(&mut a, &mut b)`
| |
= note: #[deny(manual_swap)] implied by #[deny(clippy)] = 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`? = note: or maybe you should use `std::mem::replace`?
error: this looks like you are swapping `c.0` and `a` manually 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; 78 | | c.0 = a;
79 | | a = t; 79 | | a = t;
| |_________^ | |_________^ help: try `std::mem::swap(&mut c.0, &mut a)`
| |
= note: #[deny(manual_swap)] implied by #[deny(clippy)] = 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`? = note: or maybe you should use `std::mem::replace`?
error: this looks like you are trying to swap `a` and `b` 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; 53 | / a = b;
54 | | b = a; 54 | | b = a;
| |_________^ | |_________^ help: try `std::mem::swap(&mut a, &mut b)`
| |
= note: #[deny(almost_swapped)] implied by #[deny(clippy)] = note: #[deny(almost_swapped)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@ -80,8 +70,6 @@ note: lint level defined here
| |
4 | #![deny(clippy)] 4 | #![deny(clippy)]
| ^^^^^^ | ^^^^^^
help: try
| std::mem::swap(&mut a, &mut b);
= note: or maybe you should use `std::mem::replace`? = note: or maybe you should use `std::mem::replace`?
error: this looks like you are trying to swap `c.0` and `a` 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; 70 | / c.0 = a;
71 | | a = c.0; 71 | | a = c.0;
| |___________^ | |___________^ help: try `std::mem::swap(&mut c.0, &mut a)`
| |
= note: #[deny(almost_swapped)] implied by #[deny(clippy)] = 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`? = note: or maybe you should use `std::mem::replace`?
error: aborting due to 7 previous errors error: aborting due to 7 previous errors

View File

@ -15,41 +15,33 @@ error: `ref` on an entire `let` pattern is discouraged, take a reference with `&
--> $DIR/toplevel_ref_arg.rs:18:7 --> $DIR/toplevel_ref_arg.rs:18:7
| |
18 | let ref x = 1; 18 | let ref x = 1;
| ^^^^^ | ----^^^^^----- help: try `let x = &1;`
| |
= note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] = 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 error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
--> $DIR/toplevel_ref_arg.rs:23:7 --> $DIR/toplevel_ref_arg.rs:23:7
| |
23 | let ref y: (&_, u8) = (&1, 2); 23 | let ref y: (&_, u8) = (&1, 2);
| ^^^^^ | ----^^^^^--------------------- help: try `let y: &(&_, u8) = &(&1, 2);`
| |
= note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] = 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 error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
--> $DIR/toplevel_ref_arg.rs:28:7 --> $DIR/toplevel_ref_arg.rs:28:7
| |
28 | let ref z = 1 + 2; 28 | let ref z = 1 + 2;
| ^^^^^ | ----^^^^^--------- help: try `let z = &(1 + 2);`
| |
= note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] = 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 error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
--> $DIR/toplevel_ref_arg.rs:33:7 --> $DIR/toplevel_ref_arg.rs:33:7
| |
33 | let ref mut z = 1 + 2; 33 | let ref mut z = 1 + 2;
| ^^^^^^^^^ | ----^^^^^^^^^--------- help: try `let z = &mut (1 + 2);`
| |
= note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] = note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)]
help: try
| let z = &mut (1 + 2);
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View File

@ -14,128 +14,91 @@ error: transmute from a reference to a pointer
--> $DIR/transmute.rs:27:23 --> $DIR/transmute.rs:27:23
| |
27 | let _: *const T = core::intrinsics::transmute(t); 27 | let _: *const T = core::intrinsics::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T`
|
help: try
| let _: *const T = t as *const T;
error: transmute from a reference to a pointer error: transmute from a reference to a pointer
--> $DIR/transmute.rs:32:21 --> $DIR/transmute.rs:32:21
| |
32 | let _: *mut T = core::intrinsics::transmute(t); 32 | let _: *mut T = core::intrinsics::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T as *mut T`
|
help: try
| let _: *mut T = t as *const T as *mut T;
error: transmute from a reference to a pointer error: transmute from a reference to a pointer
--> $DIR/transmute.rs:37:23 --> $DIR/transmute.rs:37:23
| |
37 | let _: *const U = core::intrinsics::transmute(t); 37 | let _: *const U = core::intrinsics::transmute(t);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T as *const U`
|
help: try
| let _: *const U = t as *const T as *const U;
error: transmute from a pointer type (`*const T`) to a reference type (`&T`) error: transmute from a pointer type (`*const T`) to a reference type (`&T`)
--> $DIR/transmute.rs:45:17 --> $DIR/transmute.rs:45:17
| |
45 | let _: &T = std::mem::transmute(p); 45 | let _: &T = std::mem::transmute(p);
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*p`
| |
note: lint level defined here note: lint level defined here
--> $DIR/transmute.rs:43:8 --> $DIR/transmute.rs:43:8
| |
43 | #[deny(transmute_ptr_to_ref)] 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`) error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`)
--> $DIR/transmute.rs:51:21 --> $DIR/transmute.rs:51:21
| |
51 | let _: &mut T = std::mem::transmute(m); 51 | let _: &mut T = std::mem::transmute(m);
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *m`
|
help: try
| let _: &mut T = &mut *m;
error: transmute from a pointer type (`*mut T`) to a reference type (`&T`) error: transmute from a pointer type (`*mut T`) to a reference type (`&T`)
--> $DIR/transmute.rs:57:17 --> $DIR/transmute.rs:57:17
| |
57 | let _: &T = std::mem::transmute(m); 57 | let _: &T = std::mem::transmute(m);
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*m`
|
help: try
| let _: &T = &*m;
error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`)
--> $DIR/transmute.rs:63:21 --> $DIR/transmute.rs:63:21
| |
63 | let _: &mut T = std::mem::transmute(p as *mut T); 63 | let _: &mut T = std::mem::transmute(p as *mut T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *(p as *mut T)`
|
help: try
| let _: &mut T = &mut *(p as *mut T);
error: transmute from a pointer type (`*const U`) to a reference type (`&T`) error: transmute from a pointer type (`*const U`) to a reference type (`&T`)
--> $DIR/transmute.rs:69:17 --> $DIR/transmute.rs:69:17
| |
69 | let _: &T = std::mem::transmute(o); 69 | let _: &T = std::mem::transmute(o);
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(o as *const T)`
|
help: try
| let _: &T = &*(o as *const T);
error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`) error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`)
--> $DIR/transmute.rs:75:21 --> $DIR/transmute.rs:75:21
| |
75 | let _: &mut T = std::mem::transmute(om); 75 | let _: &mut T = std::mem::transmute(om);
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *(om as *mut T)`
|
help: try
| let _: &mut T = &mut *(om as *mut T);
error: transmute from a pointer type (`*mut U`) to a reference type (`&T`) error: transmute from a pointer type (`*mut U`) to a reference type (`&T`)
--> $DIR/transmute.rs:81:17 --> $DIR/transmute.rs:81:17
| |
81 | let _: &T = std::mem::transmute(om); 81 | let _: &T = std::mem::transmute(om);
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(om as *const T)`
|
help: try
| let _: &T = &*(om as *const T);
error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, u8>`) error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, u8>`)
--> $DIR/transmute.rs:95:32 --> $DIR/transmute.rs:95:32
| |
95 | let _: &Foo<u8> = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; 95 | let _: &Foo<u8> = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const Foo<_>)`
| |
note: lint level defined here note: lint level defined here
--> $DIR/transmute.rs:88:8 --> $DIR/transmute.rs:88:8
| |
88 | #[deny(transmute_ptr_to_ref)] 88 | #[deny(transmute_ptr_to_ref)]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
help: try
| let _: &Foo<u8> = unsafe { &*(raw as *const Foo<_>) };
error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, &u8>`) error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, &u8>`)
--> $DIR/transmute.rs:100:33 --> $DIR/transmute.rs:100:33
| |
100 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; 100 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const Foo<&_>)`
|
help: try
| let _: &Foo<&u8> = unsafe { &*(raw as *const Foo<&_>) };
error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`)
--> $DIR/transmute.rs:107:14 --> $DIR/transmute.rs:107:14
| |
107 | unsafe { std::mem::transmute::<_, Bar>(raw) }; 107 | unsafe { std::mem::transmute::<_, Bar>(raw) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const u8)`
|
help: try
| unsafe { &*(raw as *const u8) };
error: transmute from a type (`std::vec::Vec<i32>`) to itself error: transmute from a type (`std::vec::Vec<i32>`) to itself
--> $DIR/transmute.rs:116:27 --> $DIR/transmute.rs:116:27
@ -177,19 +140,13 @@ error: transmute from an integer to a pointer
--> $DIR/transmute.rs:137:31 --> $DIR/transmute.rs:137:31
| |
137 | let _: *const usize = std::mem::transmute(5_isize); 137 | let _: *const usize = std::mem::transmute(5_isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `5_isize as *const usize`
|
help: try
| let _: *const usize = 5_isize as *const usize;
error: transmute from an integer to a pointer error: transmute from an integer to a pointer
--> $DIR/transmute.rs:143:31 --> $DIR/transmute.rs:143:31
| |
143 | let _: *const usize = std::mem::transmute(1+1usize); 143 | let _: *const usize = std::mem::transmute(1+1usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `(1+1usize) as *const usize`
|
help: try
| let _: *const usize = (1+1usize) as *const usize;
error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`) error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`)
--> $DIR/transmute.rs:160:24 --> $DIR/transmute.rs:160:24

View File

@ -2,15 +2,13 @@ error: useless lint attribute
--> $DIR/useless_attribute.rs:5:1 --> $DIR/useless_attribute.rs:5:1
| |
5 | #[allow(dead_code)] 5 | #[allow(dead_code)]
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use `#![allow(dead_code)]`
| |
note: lint level defined here note: lint level defined here
--> $DIR/useless_attribute.rs:3:9 --> $DIR/useless_attribute.rs:3:9
| |
3 | #![deny(useless_attribute)] 3 | #![deny(useless_attribute)]
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
help: if you just forgot a `!`, use
| #![allow(dead_code)]
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,60 +2,43 @@ error: useless use of `vec!`
--> $DIR/vec.rs:24:14 --> $DIR/vec.rs:24:14
| |
24 | on_slice(&vec![]); 24 | on_slice(&vec![]);
| ^^^^^^^ | ^^^^^^^ help: you can use a slice directly `&[]`
| |
note: lint level defined here note: lint level defined here
--> $DIR/vec.rs:4:9 --> $DIR/vec.rs:4:9
| |
4 | #![deny(useless_vec)] 4 | #![deny(useless_vec)]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
help: you can use a slice directly
| on_slice(&[]);
error: useless use of `vec!` error: useless use of `vec!`
--> $DIR/vec.rs:30:14 --> $DIR/vec.rs:30:14
| |
30 | on_slice(&vec![1, 2]); 30 | on_slice(&vec![1, 2]);
| ^^^^^^^^^^^ | ^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]`
|
help: you can use a slice directly
| on_slice(&[1, 2]);
error: useless use of `vec!` error: useless use of `vec!`
--> $DIR/vec.rs:36:14 --> $DIR/vec.rs:36:14
| |
36 | on_slice(&vec ![1, 2]); 36 | on_slice(&vec ![1, 2]);
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]`
|
help: you can use a slice directly
| on_slice(&[1, 2]);
error: useless use of `vec!` error: useless use of `vec!`
--> $DIR/vec.rs:42:14 --> $DIR/vec.rs:42:14
| |
42 | on_slice(&vec!(1, 2)); 42 | on_slice(&vec!(1, 2));
| ^^^^^^^^^^^ | ^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]`
|
help: you can use a slice directly
| on_slice(&[1, 2]);
error: useless use of `vec!` error: useless use of `vec!`
--> $DIR/vec.rs:48:14 --> $DIR/vec.rs:48:14
| |
48 | on_slice(&vec![1; 2]); 48 | on_slice(&vec![1; 2]);
| ^^^^^^^^^^^ | ^^^^^^^^^^^ help: you can use a slice directly `&[1; 2]`
|
help: you can use a slice directly
| on_slice(&[1; 2]);
error: useless use of `vec!` error: useless use of `vec!`
--> $DIR/vec.rs:64:14 --> $DIR/vec.rs:64:14
| |
64 | for a in vec![1, 2, 3] { 64 | for a in vec![1, 2, 3] {
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^ help: you can use a slice directly `&[1, 2, 3]`
|
help: you can use a slice directly
| for a in &[1, 2, 3] {
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View File

@ -8,15 +8,13 @@ error: this loop could be written as a `while let` loop
... | ... |
17 | | } 17 | | }
18 | | } 18 | | }
| |_____^ | |_____^ help: try `while let Some(_x) = y { .. }`
| |
note: lint level defined here note: lint level defined here
--> $DIR/while_loop.rs:4:9 --> $DIR/while_loop.rs:4:9
| |
4 | #![deny(while_let_loop, empty_loop, while_let_on_iterator)] 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 error: this loop could be written as a `while let` loop
--> $DIR/while_loop.rs:25:5 --> $DIR/while_loop.rs:25:5
@ -28,10 +26,7 @@ error: this loop could be written as a `while let` loop
... | ... |
32 | | }; 32 | | };
33 | | } 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 error: this loop could be written as a `while let` loop
--> $DIR/while_loop.rs:34:5 --> $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"; 43 | | let _str = "foo";
44 | | } 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 error: this loop could be written as a `while let` loop
--> $DIR/while_loop.rs:45:5 --> $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"; } 54 | | { let _b = "foobar"; }
55 | | } 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 error: this loop could be written as a `while let` loop
--> $DIR/while_loop.rs:70:5 --> $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); 79 | | let _ = (e, l);
80 | | } 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 error: this loop could be written as a `for` loop
--> $DIR/while_loop.rs:83:5 --> $DIR/while_loop.rs:83:5
@ -87,15 +73,13 @@ error: this loop could be written as a `for` loop
86 | | 86 | |
87 | | println!("{}", x); 87 | | println!("{}", x);
88 | | } 88 | | }
| |_____^ | |_____^ help: try `for x in iter { .. }`
| |
note: lint level defined here note: lint level defined here
--> $DIR/while_loop.rs:4:37 --> $DIR/while_loop.rs:4:37
| |
4 | #![deny(while_let_loop, empty_loop, while_let_on_iterator)] 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 error: this loop could be written as a `for` loop
--> $DIR/while_loop.rs:91:5 --> $DIR/while_loop.rs:91:5
@ -106,19 +90,13 @@ error: this loop could be written as a `for` loop
94 | | 94 | |
95 | | println!("{}", x); 95 | | println!("{}", x);
96 | | } 96 | | }
| |_____^ | |_____^ help: try `for x in iter { .. }`
|
help: try
| for x in iter { .. }
error: this loop could be written as a `for` loop error: this loop could be written as a `for` loop
--> $DIR/while_loop.rs:99:5 --> $DIR/while_loop.rs:99:5
| |
99 | while let Some(_) = iter.next() {} 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 error: this loop could be written as a `while let` loop
--> $DIR/while_loop.rs:142:5 --> $DIR/while_loop.rs:142:5
@ -130,10 +108,7 @@ error: this loop could be written as a `while let` loop
... | ... |
150 | | loop {} 150 | | loop {}
151 | | } 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. 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 --> $DIR/while_loop.rs:150:9