Merge remote-tracking branch 'origin/master' into yati_master

This commit is contained in:
Oliver Schneider
2017-04-25 10:31:40 +02:00
53 changed files with 717 additions and 687 deletions

View File

@@ -1,6 +1,18 @@
# 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.126 — 2017-04-24
* Update to *rustc 1.18.0-nightly (2bd4b5c6d 2017-04-23)*
## 0.0.125 — 2017-04-19
* Update to *rustc 1.18.0-nightly (9f2abadca 2017-04-18)*
## 0.0.124 — 2017-04-16
* Update to *rustc 1.18.0-nightly (d5cf1cb64 2017-04-15)*
## 0.0.123 — 2017-04-07
* Fix various false positives
## 0.0.122 — 2017-04-07 ## 0.0.122 — 2017-04-07
* Rustup to *rustc 1.18.0-nightly (91ae22a01 2017-04-05)* * Rustup to *rustc 1.18.0-nightly (91ae22a01 2017-04-05)*
* New lint: [`op_ref`] * New lint: [`op_ref`]

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "clippy" name = "clippy"
version = "0.0.122" version = "0.0.126"
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.122", path = "clippy_lints" } clippy_lints = { version = "0.0.126", 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.122" version = "0.0.126"
# end automatic update # end automatic update
authors = [ authors = [
"Manish Goregaokar <manishsmail@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>",

View File

@@ -1,9 +1,10 @@
use rustc::hir::*; use rustc::hir::*;
use rustc::hir::def::Def; use rustc::hir::def::Def;
use rustc::lint::*; use rustc::lint::*;
use rustc::ty;
use rustc_const_eval::lookup_const_by_id; use rustc_const_eval::lookup_const_by_id;
use syntax::ast::LitKind; use syntax::ast::LitKind;
use syntax::codemap::Span; use syntax::codemap::{Span, DUMMY_SP};
use utils::span_lint; use utils::span_lint;
/// **What it does:** Checks for incompatible bit masks in comparisons. /// **What it does:** Checks for incompatible bit masks in comparisons.
@@ -249,7 +250,15 @@ fn fetch_int_literal(cx: &LateContext, lit: &Expr) -> Option<u128> {
ExprPath(ref qpath) => { ExprPath(ref qpath) => {
let def = cx.tables.qpath_def(qpath, lit.id); let def = cx.tables.qpath_def(qpath, lit.id);
if let Def::Const(def_id) = def { if let Def::Const(def_id) = def {
lookup_const_by_id(cx.tcx, def_id, Substs::empty()).and_then(|(l, _ty)| fetch_int_literal(cx, l)) lookup_const_by_id(cx.tcx, def_id, Substs::empty()).and_then(|(l, _ty)| {
let body = if let Some(id) = cx.tcx.hir.as_local_node_id(l) {
ty::queries::mir_const_qualif::get(cx.tcx, DUMMY_SP, def_id);
cx.tcx.hir.body(cx.tcx.hir.body_owned_by(id))
} else {
cx.tcx.sess.cstore.item_body(cx.tcx, def_id)
};
fetch_int_literal(cx, &body.value)
})
} else { } else {
None None
} }

View File

@@ -13,6 +13,7 @@ use std::mem;
use std::rc::Rc; use std::rc::Rc;
use syntax::ast::{FloatTy, LitKind, StrStyle, NodeId}; use syntax::ast::{FloatTy, LitKind, StrStyle, NodeId};
use syntax::ptr::P; use syntax::ptr::P;
use syntax::codemap::DUMMY_SP;
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub enum FloatWidth { pub enum FloatWidth {
@@ -286,13 +287,19 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
let substs = self.tables let substs = self.tables
.node_id_item_substs(id) .node_id_item_substs(id)
.unwrap_or_else(|| self.tcx.intern_substs(&[])); .unwrap_or_else(|| self.tcx.intern_substs(&[]));
if let Some((const_expr, tables)) = lookup_const_by_id(self.tcx, def_id, substs) { if let Some((const_expr, _)) = lookup_const_by_id(self.tcx, def_id, substs) {
let mut cx = ConstEvalLateContext { let mut cx = ConstEvalLateContext {
tcx: self.tcx, tcx: self.tcx,
tables: tables, tables: self.tcx.item_tables(const_expr),
needed_resolution: false, needed_resolution: false,
}; };
let ret = cx.expr(const_expr); let body = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
ty::queries::mir_const_qualif::get(self.tcx, DUMMY_SP, def_id);
self.tcx.hir.body(self.tcx.hir.body_owned_by(id))
} else {
self.tcx.sess.cstore.item_body(self.tcx, def_id)
};
let ret = cx.expr(&body.value);
if ret.is_some() { if ret.is_some() {
self.needed_resolution = true; self.needed_resolution = true;
} }

View File

@@ -223,7 +223,7 @@ fn lint_match_arms(cx: &LateContext, expr: &Expr) {
/// `if a { c } else if b { d } else { e }`. /// `if a { c } else if b { d } else { e }`.
fn if_sequence(mut expr: &Expr) -> (SmallVector<&Expr>, SmallVector<&Block>) { fn if_sequence(mut expr: &Expr) -> (SmallVector<&Expr>, SmallVector<&Block>) {
let mut conds = SmallVector::new(); let mut conds = SmallVector::new();
let mut blocks : SmallVector<&Block> = SmallVector::new(); let mut blocks: SmallVector<&Block> = SmallVector::new();
while let ExprIf(ref cond, ref then_expr, ref else_expr) = expr.node { while let ExprIf(ref cond, ref then_expr, ref else_expr) = expr.node {
conds.push(&**cond); conds.push(&**cond);
@@ -315,10 +315,10 @@ fn search_same<T, Hash, Eq>(exprs: &[T], hash: Hash, eq: Eq) -> Option<(&T, &T)>
return None; return None;
} else if exprs.len() == 2 { } else if exprs.len() == 2 {
return if eq(&exprs[0], &exprs[1]) { return if eq(&exprs[0], &exprs[1]) {
Some((&exprs[0], &exprs[1])) Some((&exprs[0], &exprs[1]))
} else { } else {
None None
}; };
} }
let mut map: HashMap<_, Vec<&_>> = HashMap::with_capacity(exprs.len()); let mut map: HashMap<_, Vec<&_>> = HashMap::with_capacity(exprs.len());

View File

@@ -46,11 +46,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HashMapLint {
if let Some((ty, map, key)) = check_cond(cx, check) { if let Some((ty, map, key)) = check_cond(cx, check) {
// in case of `if !m.contains_key(&k) { m.insert(k, v); }` // in case of `if !m.contains_key(&k) { m.insert(k, v); }`
// we can give a better error message // we can give a better error message
let sole_expr = { let sole_expr = {
else_block.is_none() && else_block.is_none() &&
if let ExprBlock(ref then_block) = then_block.node { if let ExprBlock(ref then_block) = then_block.node {
(then_block.expr.is_some() as usize) + then_block.stmts.len() == 1 (then_block.expr.is_some() as usize) + then_block.stmts.len() == 1
} else { } else {
true true
} }
}; };

View File

@@ -44,7 +44,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
let variant = &var.node; let variant = &var.node;
if let Some(body_id) = variant.disr_expr { if let Some(body_id) = variant.disr_expr {
use rustc_const_eval::*; use rustc_const_eval::*;
let constcx = ConstContext::new(cx.tcx, body_id); let constcx = ConstContext::with_tables(cx.tcx, cx.tcx.body_tables(body_id));
let bad = match constcx.eval(&cx.tcx.hir.body(body_id).value) { let bad = match constcx.eval(&cx.tcx.hir.body(body_id).value) {
Ok(ConstVal::Integral(Usize(Us64(i)))) => i as u32 as u64 != i, Ok(ConstVal::Integral(Usize(Us64(i)))) => i as u32 as u64 != i,
Ok(ConstVal::Integral(Isize(Is64(i)))) => i as i32 as i64 != i, Ok(ConstVal::Integral(Isize(Is64(i)))) => i as i32 as i64 != i,

View File

@@ -56,9 +56,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
if is_valid_operator(op) { if is_valid_operator(op) {
if SpanlessEq::new(cx).ignore_fn().eq_expr(left, right) { if 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()));
} else { } else {
let trait_id = match op.node { let trait_id = match op.node {
BiAdd => cx.tcx.lang_items.add_trait(), BiAdd => cx.tcx.lang_items.add_trait(),
@@ -66,19 +66,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
BiMul => cx.tcx.lang_items.mul_trait(), BiMul => cx.tcx.lang_items.mul_trait(),
BiDiv => cx.tcx.lang_items.div_trait(), BiDiv => cx.tcx.lang_items.div_trait(),
BiRem => cx.tcx.lang_items.rem_trait(), BiRem => cx.tcx.lang_items.rem_trait(),
BiAnd | BiAnd | BiOr => None,
BiOr => None,
BiBitXor => cx.tcx.lang_items.bitxor_trait(), BiBitXor => cx.tcx.lang_items.bitxor_trait(),
BiBitAnd => cx.tcx.lang_items.bitand_trait(), BiBitAnd => cx.tcx.lang_items.bitand_trait(),
BiBitOr => cx.tcx.lang_items.bitor_trait(), BiBitOr => cx.tcx.lang_items.bitor_trait(),
BiShl => cx.tcx.lang_items.shl_trait(), BiShl => cx.tcx.lang_items.shl_trait(),
BiShr => cx.tcx.lang_items.shr_trait(), BiShr => cx.tcx.lang_items.shr_trait(),
BiNe | BiNe | BiEq => cx.tcx.lang_items.eq_trait(),
BiEq => cx.tcx.lang_items.eq_trait(), BiLt | BiLe | BiGe | BiGt => cx.tcx.lang_items.ord_trait(),
BiLt |
BiLe |
BiGe |
BiGt => cx.tcx.lang_items.ord_trait(),
}; };
if let Some(trait_id) = trait_id { if let Some(trait_id) = trait_id {
#[allow(match_same_arms)] #[allow(match_same_arms)]
@@ -90,57 +85,55 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
(&ExprAddrOf(_, ref l), &ExprAddrOf(_, ref r)) => { (&ExprAddrOf(_, ref l), &ExprAddrOf(_, ref r)) => {
if implements_trait(cx, cx.tables.expr_ty(l), trait_id, &[cx.tables.expr_ty(r)], None) { if implements_trait(cx, cx.tables.expr_ty(l), trait_id, &[cx.tables.expr_ty(r)], None) {
span_lint_and_then(cx, span_lint_and_then(cx,
OP_REF, OP_REF,
e.span, e.span,
"taken reference of both operands, which is done automatically by the operator anyway", "taken reference of both operands, which is done automatically \
|db| { by the operator anyway",
let lsnip = snippet(cx, l.span, "...").to_string(); |db| {
let rsnip = snippet(cx, r.span, "...").to_string(); let lsnip = snippet(cx, l.span, "...").to_string();
multispan_sugg(db, let rsnip = snippet(cx, r.span, "...").to_string();
"use the values directly".to_string(), multispan_sugg(db,
vec![(left.span, lsnip), "use the values directly".to_string(),
vec![(left.span, lsnip),
(right.span, rsnip)]); (right.span, rsnip)]);
} })
)
} }
} },
// &foo == bar // &foo == bar
(&ExprAddrOf(_, ref l), _) => { (&ExprAddrOf(_, ref l), _) => {
if implements_trait(cx, cx.tables.expr_ty(l), trait_id, &[cx.tables.expr_ty(right)], None) { if implements_trait(cx,
span_lint_and_then(cx, cx.tables.expr_ty(l),
OP_REF, trait_id,
e.span, &[cx.tables.expr_ty(right)],
"taken reference of left operand", None) {
|db| { span_lint_and_then(cx, OP_REF, e.span, "taken reference of left operand", |db| {
let lsnip = snippet(cx, l.span, "...").to_string(); let lsnip = snippet(cx, l.span, "...").to_string();
let rsnip = Sugg::hir(cx, right, "...").deref().to_string(); let rsnip = Sugg::hir(cx, right, "...").deref().to_string();
multispan_sugg(db, multispan_sugg(db,
"dereference the right operand instead".to_string(), "dereference the right operand instead".to_string(),
vec![(left.span, lsnip), vec![(left.span, lsnip),
(right.span, rsnip)]); (right.span, rsnip)]);
} })
)
} }
} },
// foo == &bar // foo == &bar
(_, &ExprAddrOf(_, ref r)) => { (_, &ExprAddrOf(_, ref r)) => {
if implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[cx.tables.expr_ty(r)], None) { if implements_trait(cx,
span_lint_and_then(cx, cx.tables.expr_ty(left),
OP_REF, trait_id,
e.span, &[cx.tables.expr_ty(r)],
"taken reference of right operand", None) {
|db| { span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |db| {
let lsnip = Sugg::hir(cx, left, "...").deref().to_string(); let lsnip = Sugg::hir(cx, left, "...").deref().to_string();
let rsnip = snippet(cx, r.span, "...").to_string(); let rsnip = snippet(cx, r.span, "...").to_string();
multispan_sugg(db, multispan_sugg(db,
"dereference the left operand instead".to_string(), "dereference the left operand instead".to_string(),
vec![(left.span, lsnip), vec![(left.span, lsnip),
(right.span, rsnip)]); (right.span, rsnip)]);
} })
)
} }
} },
_ => {} _ => {},
} }
} }
} }

View File

@@ -98,8 +98,8 @@ pub fn get_argument_fmtstr_parts<'a, 'b>(cx: &LateContext<'a, 'b>, expr: &'a Exp
} }
/// Checks if the expressions matches /// Checks if the expressions matches
/// ```rust /// ```rust, ignore
/// { static __STATIC_FMTSTR: s = &["a", "b", c]; __STATIC_FMTSTR } /// { static __STATIC_FMTSTR: &'static[&'static str] = &["a", "b", c]; __STATIC_FMTSTR }
/// ``` /// ```
fn check_static_str(cx: &LateContext, expr: &Expr) -> bool { fn check_static_str(cx: &LateContext, expr: &Expr) -> bool {
if let Some(expr) = get_argument_fmtstr_parts(cx, expr) { if let Some(expr) = get_argument_fmtstr_parts(cx, expr) {

View File

@@ -100,11 +100,19 @@ impl EarlyLintPass for Formatting {
fn check_assign(cx: &EarlyContext, expr: &ast::Expr) { fn check_assign(cx: &EarlyContext, expr: &ast::Expr) {
if let ast::ExprKind::Assign(ref lhs, ref rhs) = expr.node { if let ast::ExprKind::Assign(ref lhs, ref rhs) = expr.node {
if !differing_macro_contexts(lhs.span, rhs.span) && !in_macro(lhs.span) { if !differing_macro_contexts(lhs.span, rhs.span) && !in_macro(lhs.span) {
let eq_span = Span { lo: lhs.span.hi, hi: rhs.span.lo, ctxt: NO_EXPANSION }; let eq_span = Span {
lo: lhs.span.hi,
hi: rhs.span.lo,
ctxt: NO_EXPANSION,
};
if let ast::ExprKind::Unary(op, ref sub_rhs) = rhs.node { if let ast::ExprKind::Unary(op, ref sub_rhs) = rhs.node {
if let Some(eq_snippet) = snippet_opt(cx, eq_span) { if let Some(eq_snippet) = snippet_opt(cx, eq_span) {
let op = ast::UnOp::to_string(op); let op = ast::UnOp::to_string(op);
let eqop_span= Span { lo: lhs.span.hi, hi: sub_rhs.span.lo, ctxt: NO_EXPANSION }; let eqop_span = Span {
lo: lhs.span.hi,
hi: sub_rhs.span.lo,
ctxt: NO_EXPANSION,
};
if eq_snippet.ends_with('=') { if eq_snippet.ends_with('=') {
span_note_and_lint(cx, span_note_and_lint(cx,
SUSPICIOUS_ASSIGNMENT_FORMATTING, SUSPICIOUS_ASSIGNMENT_FORMATTING,
@@ -127,7 +135,11 @@ fn check_else_if(cx: &EarlyContext, expr: &ast::Expr) {
if unsugar_if(else_).is_some() && !differing_macro_contexts(then.span, else_.span) && !in_macro(then.span) { if unsugar_if(else_).is_some() && !differing_macro_contexts(then.span, else_.span) && !in_macro(then.span) {
// this will be a span from the closing } of the “then” block (excluding) to the // this will be a span from the closing } of the “then” block (excluding) to the
// “if” of the “else if” block (excluding) // “if” of the “else if” block (excluding)
let else_span = Span { lo: then.span.hi, hi: else_.span.lo, ctxt: NO_EXPANSION }; let else_span = Span {
lo: then.span.hi,
hi: else_.span.lo,
ctxt: NO_EXPANSION,
};
// the snippet should look like " else \n " with maybe comments anywhere // the snippet should look like " else \n " with maybe comments anywhere
// its bad when there is a \n after the “else” // its bad when there is a \n after the “else”
@@ -154,9 +166,17 @@ fn check_array(cx: &EarlyContext, expr: &ast::Expr) {
for element in array { for element in array {
if let ast::ExprKind::Binary(ref op, ref lhs, _) = element.node { if let ast::ExprKind::Binary(ref op, ref lhs, _) = element.node {
if !differing_macro_contexts(lhs.span, op.span) { if !differing_macro_contexts(lhs.span, op.span) {
let space_span = Span { lo: lhs.span.hi, hi: op.span.lo, ctxt: NO_EXPANSION }; let space_span = Span {
lo: lhs.span.hi,
hi: op.span.lo,
ctxt: NO_EXPANSION,
};
if let Some(space_snippet) = snippet_opt(cx, space_span) { if let Some(space_snippet) = snippet_opt(cx, space_span) {
let lint_span = Span { lo: lhs.span.hi, hi: lhs.span.hi, ctxt: NO_EXPANSION }; let lint_span = Span {
lo: lhs.span.hi,
hi: lhs.span.hi,
ctxt: NO_EXPANSION,
};
if space_snippet.contains('\n') { if space_snippet.contains('\n') {
span_note_and_lint(cx, span_note_and_lint(cx,
POSSIBLE_MISSING_COMMA, POSSIBLE_MISSING_COMMA,
@@ -174,10 +194,14 @@ fn check_array(cx: &EarlyContext, expr: &ast::Expr) {
/// Implementation of the `SUSPICIOUS_ELSE_FORMATTING` lint for consecutive ifs. /// Implementation of the `SUSPICIOUS_ELSE_FORMATTING` lint for consecutive ifs.
fn check_consecutive_ifs(cx: &EarlyContext, first: &ast::Expr, second: &ast::Expr) { fn check_consecutive_ifs(cx: &EarlyContext, first: &ast::Expr, second: &ast::Expr) {
if !differing_macro_contexts(first.span, second.span) && !in_macro(first.span) && if !differing_macro_contexts(first.span, second.span) && !in_macro(first.span) && unsugar_if(first).is_some() &&
unsugar_if(first).is_some() && unsugar_if(second).is_some() { unsugar_if(second).is_some() {
// where the else would be // where the else would be
let else_span = Span { lo: first.span.hi, hi: second.span.lo, ctxt: NO_EXPANSION }; let else_span = Span {
lo: first.span.hi,
hi: second.span.lo,
ctxt: NO_EXPANSION,
};
if let Some(else_snippet) = snippet_opt(cx, else_span) { if let Some(else_snippet) = snippet_opt(cx, else_span) {
if !else_snippet.contains('\n') { if !else_snippet.contains('\n') {

View File

@@ -11,7 +11,6 @@
#![feature(conservative_impl_trait)] #![feature(conservative_impl_trait)]
#![allow(indexing_slicing, shadow_reuse, unknown_lints, missing_docs_in_private_items)] #![allow(indexing_slicing, shadow_reuse, unknown_lints, missing_docs_in_private_items)]
#![allow(needless_lifetimes)]
extern crate syntax; extern crate syntax;
extern crate syntax_pos; extern crate syntax_pos;

View File

@@ -6,6 +6,7 @@ use rustc::hir::intravisit::{Visitor, walk_ty, walk_ty_param_bound, walk_fn_decl
use std::collections::{HashSet, HashMap}; use std::collections::{HashSet, HashMap};
use syntax::codemap::Span; use syntax::codemap::Span;
use utils::{in_external_macro, span_lint, last_path_segment}; use utils::{in_external_macro, span_lint, last_path_segment};
use syntax::symbol::keywords;
/// **What it does:** Checks for lifetime annotations which can be removed by /// **What it does:** Checks for lifetime annotations which can be removed by
/// relying on lifetime elision. /// relying on lifetime elision.
@@ -58,20 +59,24 @@ impl LintPass for LifetimePass {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if let ItemFn(ref decl, _, _, _, ref generics, _) = item.node { if let ItemFn(ref decl, _, _, _, ref generics, id) = item.node {
check_fn_inner(cx, decl, generics, item.span); check_fn_inner(cx, decl, Some(id), generics, item.span);
} }
} }
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) { fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
if let ImplItemKind::Method(ref sig, _) = item.node { if let ImplItemKind::Method(ref sig, id) = item.node {
check_fn_inner(cx, &sig.decl, &sig.generics, item.span); check_fn_inner(cx, &sig.decl, Some(id), &sig.generics, item.span);
} }
} }
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) { fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
if let TraitItemKind::Method(ref sig, _) = item.node { if let TraitItemKind::Method(ref sig, ref body) = item.node {
check_fn_inner(cx, &sig.decl, &sig.generics, item.span); let body = match *body {
TraitMethod::Required(_) => None,
TraitMethod::Provided(id) => Some(id),
};
check_fn_inner(cx, &sig.decl, body, &sig.generics, item.span);
} }
} }
} }
@@ -84,30 +89,38 @@ enum RefLt {
Named(Name), Named(Name),
} }
fn bound_lifetimes(bound: &TyParamBound) -> HirVec<&Lifetime> { fn check_fn_inner<'a, 'tcx>(
if let TraitTyParamBound(ref trait_ref, _) = *bound { cx: &LateContext<'a, 'tcx>,
trait_ref.trait_ref decl: &'tcx FnDecl,
.path body: Option<BodyId>,
.segments generics: &'tcx Generics,
.last() span: Span
.expect("a path must have at least one segment") ) {
.parameters
.lifetimes()
} else {
HirVec::new()
}
}
fn check_fn_inner<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, generics: &'tcx Generics, span: Span) {
if in_external_macro(cx, span) || has_where_lifetimes(cx, &generics.where_clause) { if in_external_macro(cx, span) || has_where_lifetimes(cx, &generics.where_clause) {
return; return;
} }
let bounds_lts = generics.ty_params let mut bounds_lts = Vec::new();
.iter() for typ in &generics.ty_params {
.flat_map(|typ| typ.bounds.iter().flat_map(bound_lifetimes)); for bound in &typ.bounds {
if let TraitTyParamBound(ref trait_ref, _) = *bound {
if could_use_elision(cx, decl, &generics.lifetimes, bounds_lts) { let bounds = trait_ref.trait_ref
.path
.segments
.last()
.expect("a path must have at least one segment")
.parameters
.lifetimes();
for bound in bounds {
if bound.name != "'static" && !bound.is_elided() {
return;
}
bounds_lts.push(bound);
}
}
}
}
if could_use_elision(cx, decl, body, &generics.lifetimes, bounds_lts) {
span_lint(cx, span_lint(cx,
NEEDLESS_LIFETIMES, NEEDLESS_LIFETIMES,
span, span,
@@ -116,11 +129,12 @@ fn check_fn_inner<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, gene
report_extra_lifetimes(cx, decl, generics); report_extra_lifetimes(cx, decl, generics);
} }
fn could_use_elision<'a, 'tcx: 'a, T: Iterator<Item = &'tcx Lifetime>>( fn could_use_elision<'a, 'tcx: 'a>(
cx: &LateContext<'a, 'tcx>, cx: &LateContext<'a, 'tcx>,
func: &'tcx FnDecl, func: &'tcx FnDecl,
body: Option<BodyId>,
named_lts: &'tcx [LifetimeDef], named_lts: &'tcx [LifetimeDef],
bounds_lts: T bounds_lts: Vec<&'tcx Lifetime>
) -> bool { ) -> bool {
// There are two scenarios where elision works: // There are two scenarios where elision works:
// * no output references, all input references have different LT // * no output references, all input references have different LT
@@ -144,8 +158,22 @@ fn could_use_elision<'a, 'tcx: 'a, T: Iterator<Item = &'tcx Lifetime>>(
output_visitor.visit_ty(ty); output_visitor.visit_ty(ty);
} }
let input_lts = lts_from_bounds(input_visitor.into_vec(), bounds_lts); let input_lts = match input_visitor.into_vec() {
let output_lts = output_visitor.into_vec(); Some(lts) => lts_from_bounds(lts, bounds_lts.into_iter()),
None => return false,
};
let output_lts = match output_visitor.into_vec() {
Some(val) => val,
None => return false,
};
if let Some(body_id) = body {
let mut checker = BodyLifetimeChecker { lifetimes_used_in_body: false };
checker.visit_expr(&cx.tcx.hir.body(body_id).value);
if checker.lifetimes_used_in_body {
return false;
}
}
// check for lifetimes from higher scopes // check for lifetimes from higher scopes
for lt in input_lts.iter().chain(output_lts.iter()) { for lt in input_lts.iter().chain(output_lts.iter()) {
@@ -216,6 +244,7 @@ fn unique_lifetimes(lts: &[RefLt]) -> usize {
struct RefVisitor<'a, 'tcx: 'a> { struct RefVisitor<'a, 'tcx: 'a> {
cx: &'a LateContext<'a, 'tcx>, cx: &'a LateContext<'a, 'tcx>,
lts: Vec<RefLt>, lts: Vec<RefLt>,
abort: bool,
} }
impl<'v, 't> RefVisitor<'v, 't> { impl<'v, 't> RefVisitor<'v, 't> {
@@ -223,6 +252,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
RefVisitor { RefVisitor {
cx: cx, cx: cx,
lts: Vec::new(), lts: Vec::new(),
abort: false,
} }
} }
@@ -240,8 +270,8 @@ impl<'v, 't> RefVisitor<'v, 't> {
} }
} }
fn into_vec(self) -> Vec<RefLt> { fn into_vec(self) -> Option<Vec<RefLt>> {
self.lts if self.abort { None } else { Some(self.lts) }
} }
fn collect_anonymous_lifetimes(&mut self, qpath: &QPath, ty: &Ty) { fn collect_anonymous_lifetimes(&mut self, qpath: &QPath, ty: &Ty) {
@@ -292,7 +322,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
}, },
TyTraitObject(ref bounds, ref lt) => { TyTraitObject(ref bounds, ref lt) => {
if !lt.is_elided() { if !lt.is_elided() {
self.record(&Some(*lt)); self.abort = true;
} }
for bound in bounds { for bound in bounds {
self.visit_poly_trait_ref(bound, TraitBoundModifier::None); self.visit_poly_trait_ref(bound, TraitBoundModifier::None);
@@ -329,10 +359,15 @@ fn has_where_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, where_clause: &
walk_ty_param_bound(&mut visitor, bound); walk_ty_param_bound(&mut visitor, bound);
} }
// and check that all lifetimes are allowed // and check that all lifetimes are allowed
for lt in visitor.into_vec() { match visitor.into_vec() {
if !allowed_lts.contains(&lt) { None => return false,
return true; Some(lts) => {
} for lt in lts {
if !allowed_lts.contains(&lt) {
return true;
}
}
},
} }
}, },
WherePredicate::EqPredicate(ref pred) => { WherePredicate::EqPredicate(ref pred) => {
@@ -384,3 +419,20 @@ fn report_extra_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, func: &'tcx
span_lint(cx, UNUSED_LIFETIMES, v, "this lifetime isn't used in the function definition"); span_lint(cx, UNUSED_LIFETIMES, v, "this lifetime isn't used in the function definition");
} }
} }
struct BodyLifetimeChecker {
lifetimes_used_in_body: bool,
}
impl<'tcx> Visitor<'tcx> for BodyLifetimeChecker {
// for lifetimes as parameters of generics
fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
if lifetime.name != keywords::Invalid.name() && lifetime.name != "'static" {
self.lifetimes_used_in_body = true;
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::None
}
}

View File

@@ -409,8 +409,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) { fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
if let StmtSemi(ref expr, _) = stmt.node { if let StmtSemi(ref expr, _) = stmt.node {
if let ExprMethodCall(ref method, _, ref args) = expr.node { if let ExprMethodCall(ref method, _, ref args) = expr.node {
if args.len() == 1 && method.node == "collect" && if args.len() == 1 && method.node == "collect" && match_trait_method(cx, expr, &paths::ITERATOR) {
match_trait_method(cx, expr, &paths::ITERATOR) {
span_lint(cx, span_lint(cx,
UNUSED_COLLECT, UNUSED_COLLECT,
expr.span, expr.span,

View File

@@ -499,9 +499,7 @@ fn is_used(cx: &LateContext, expr: &Expr) -> bool {
/// Test whether an expression is in a macro expansion (e.g. something generated by /// Test whether an expression is in a macro expansion (e.g. something generated by
/// `#[derive(...)`] or the like). /// `#[derive(...)`] or the like).
fn in_attributes_expansion(expr: &Expr) -> bool { fn in_attributes_expansion(expr: &Expr) -> bool {
expr.span.ctxt.outer().expn_info().map_or(false, |info| { expr.span.ctxt.outer().expn_info().map_or(false, |info| matches!(info.callee.format, ExpnFormat::MacroAttribute(_)))
matches!(info.callee.format, ExpnFormat::MacroAttribute(_))
})
} }
/// Test whether `def` is a variable defined outside a macro. /// Test whether `def` is a variable defined outside a macro.

View File

@@ -122,6 +122,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
hir::ItemStatic(..) => "a static", hir::ItemStatic(..) => "a static",
hir::ItemStruct(..) => "a struct", hir::ItemStruct(..) => "a struct",
hir::ItemTrait(..) => "a trait", hir::ItemTrait(..) => "a trait",
hir::ItemGlobalAsm(..) => "an assembly blob",
hir::ItemTy(..) => "a type alias", hir::ItemTy(..) => "a type alias",
hir::ItemUnion(..) => "a union", hir::ItemUnion(..) => "a union",
hir::ItemDefaultImpl(..) | hir::ItemDefaultImpl(..) |

View File

@@ -77,27 +77,27 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool {
|db| { db.span_suggestion(e.span, "you can reduce it to", hint); }); |db| { db.span_suggestion(e.span, "you can reduce it to", hint); });
}; };
if let ExprBlock(ref then_block) = then_block.node { if let ExprBlock(ref then_block) = then_block.node {
match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) { match (fetch_bool_block(then_block), fetch_bool_expr(else_expr)) {
(RetBool(true), RetBool(true)) | (RetBool(true), RetBool(true)) |
(Bool(true), Bool(true)) => { (Bool(true), Bool(true)) => {
span_lint(cx, span_lint(cx,
NEEDLESS_BOOL, NEEDLESS_BOOL,
e.span, e.span,
"this if-then-else expression will always return true"); "this if-then-else expression will always return true");
}, },
(RetBool(false), RetBool(false)) | (RetBool(false), RetBool(false)) |
(Bool(false), Bool(false)) => { (Bool(false), Bool(false)) => {
span_lint(cx, span_lint(cx,
NEEDLESS_BOOL, NEEDLESS_BOOL,
e.span, e.span,
"this if-then-else expression will always return false"); "this if-then-else expression will always return false");
}, },
(RetBool(true), RetBool(false)) => reduce(true, false), (RetBool(true), RetBool(false)) => reduce(true, false),
(Bool(true), Bool(false)) => reduce(false, false), (Bool(true), Bool(false)) => reduce(false, false),
(RetBool(false), RetBool(true)) => reduce(true, true), (RetBool(false), RetBool(true)) => reduce(true, true),
(Bool(false), Bool(true)) => reduce(false, true), (Bool(false), Bool(true)) => reduce(false, true),
_ => (), _ => (),
} }
} else { } else {
panic!("IfExpr 'then' node is not an ExprBlock"); panic!("IfExpr 'then' node is not an ExprBlock");
} }

View File

@@ -97,7 +97,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
}, },
(&ExprIndex(ref la, ref li), &ExprIndex(ref ra, ref ri)) => self.eq_expr(la, ra) && self.eq_expr(li, ri), (&ExprIndex(ref la, ref li), &ExprIndex(ref ra, ref ri)) => self.eq_expr(la, ra) && self.eq_expr(li, ri),
(&ExprIf(ref lc, ref lt, ref le), &ExprIf(ref rc, ref rt, ref re)) => { (&ExprIf(ref lc, ref lt, ref le), &ExprIf(ref rc, ref rt, ref re)) => {
self.eq_expr(lc, rc) && self.eq_expr(&**lt, &**rt) && both(le, re, |l, r| self.eq_expr(l, r)) self.eq_expr(lc, rc) && self.eq_expr(&**lt, &**rt) && both(le, re, |l, r| self.eq_expr(l, r))
}, },
(&ExprLit(ref l), &ExprLit(ref r)) => l.node == r.node, (&ExprLit(ref l), &ExprLit(ref r)) => l.node == r.node,
(&ExprLoop(ref lb, ref ll, ref lls), &ExprLoop(ref rb, ref rl, ref rls)) => { (&ExprLoop(ref lb, ref ll, ref lls), &ExprLoop(ref rb, ref rl, ref rls)) => {

View File

@@ -372,6 +372,7 @@ fn print_item(cx: &LateContext, item: &hir::Item) {
}, },
hir::ItemMod(..) => println!("module"), hir::ItemMod(..) => println!("module"),
hir::ItemForeignMod(ref fm) => println!("foreign module with abi: {}", fm.abi), hir::ItemForeignMod(ref fm) => println!("foreign module with abi: {}", fm.abi),
hir::ItemGlobalAsm(ref asm) => println!("global asm: {:?}", asm),
hir::ItemTy(..) => { hir::ItemTy(..) => {
println!("type alias for {:?}", cx.tcx.item_type(did)); println!("type alias for {:?}", cx.tcx.item_type(did));
}, },

View File

@@ -690,8 +690,10 @@ fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'
/// See also `is_direct_expn_of`. /// See also `is_direct_expn_of`.
pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> { pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
loop { loop {
let span_name_span = span.ctxt.outer() let span_name_span = span.ctxt
.expn_info().map(|ei| (ei.callee.name(), ei.call_site)); .outer()
.expn_info()
.map(|ei| (ei.callee.name(), ei.call_site));
match span_name_span { match span_name_span {
Some((mac_name, new_span)) if mac_name == name => return Some(new_span), Some((mac_name, new_span)) if mac_name == name => return Some(new_span),
@@ -709,8 +711,10 @@ pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
/// `42` is considered expanded from `foo!` and `bar!` by `is_expn_of` but only `bar!` by /// `42` is considered expanded from `foo!` and `bar!` by `is_expn_of` but only `bar!` by
/// `is_direct_expn_of`. /// `is_direct_expn_of`.
pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> { pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
let span_name_span = span.ctxt.outer() let span_name_span = span.ctxt
.expn_info().map(|ei| (ei.callee.name(), ei.call_site)); .outer()
.expn_info()
.map(|ei| (ei.callee.name(), ei.call_site));
match span_name_span { match span_name_span {
Some((mac_name, new_span)) if mac_name == name => Some(new_span), Some((mac_name, new_span)) if mac_name == name => Some(new_span),
@@ -900,7 +904,8 @@ pub fn opt_def_id(def: Def) -> Option<DefId> {
Def::AssociatedConst(id) | Def::AssociatedConst(id) |
Def::Local(id) | Def::Local(id) |
Def::Upvar(id, ..) | Def::Upvar(id, ..) |
Def::Macro(id, _) => Some(id), Def::Macro(id, ..) |
Def::GlobalAsm(id) => Some(id),
Def::Label(..) | Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => None, Def::Label(..) | Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => None,
} }

View File

@@ -12,8 +12,13 @@ extern crate clippy_lints;
#[plugin_registrar] #[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) { pub fn plugin_registrar(reg: &mut Registry) {
if let Ok(lint_store) = reg.sess.lint_store.try_borrow() { if let Ok(lint_store) = reg.sess.lint_store.try_borrow() {
if lint_store.get_lint_groups().iter().any(|&(s, _, _)| s == "clippy") { if lint_store
reg.sess.struct_warn("running cargo clippy on a crate that also imports the clippy plugin").emit(); .get_lint_groups()
.iter()
.any(|&(s, _, _)| s == "clippy") {
reg.sess
.struct_warn("running cargo clippy on a crate that also imports the clippy plugin")
.emit();
return; return;
} }
} }

View File

@@ -43,9 +43,10 @@ impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
sopts: &config::Options, sopts: &config::Options,
cfg: &ast::CrateConfig, cfg: &ast::CrateConfig,
descriptions: &rustc_errors::registry::Registry, descriptions: &rustc_errors::registry::Registry,
output: ErrorOutputType output: ErrorOutputType,
) -> Compilation { ) -> Compilation {
self.default.early_callback(matches, sopts, cfg, descriptions, output) self.default
.early_callback(matches, sopts, cfg, descriptions, output)
} }
fn no_input( fn no_input(
&mut self, &mut self,
@@ -54,9 +55,10 @@ impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
cfg: &ast::CrateConfig, cfg: &ast::CrateConfig,
odir: &Option<PathBuf>, odir: &Option<PathBuf>,
ofile: &Option<PathBuf>, ofile: &Option<PathBuf>,
descriptions: &rustc_errors::registry::Registry descriptions: &rustc_errors::registry::Registry,
) -> Option<(Input, Option<PathBuf>)> { ) -> Option<(Input, Option<PathBuf>)> {
self.default.no_input(matches, sopts, cfg, odir, ofile, descriptions) self.default
.no_input(matches, sopts, cfg, odir, ofile, descriptions)
} }
fn late_callback( fn late_callback(
&mut self, &mut self,
@@ -64,9 +66,10 @@ impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
sess: &Session, sess: &Session,
input: &Input, input: &Input,
odir: &Option<PathBuf>, odir: &Option<PathBuf>,
ofile: &Option<PathBuf> ofile: &Option<PathBuf>,
) -> Compilation { ) -> Compilation {
self.default.late_callback(matches, sess, input, odir, ofile) self.default
.late_callback(matches, sess, input, odir, ofile)
} }
fn build_controller(&mut self, sess: &Session, matches: &getopts::Matches) -> driver::CompileController<'a> { fn build_controller(&mut self, sess: &Session, matches: &getopts::Matches) -> driver::CompileController<'a> {
let mut control = self.default.build_controller(sess, matches); let mut control = self.default.build_controller(sess, matches);
@@ -76,7 +79,8 @@ impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
control.after_parse.callback = Box::new(move |state| { control.after_parse.callback = Box::new(move |state| {
{ {
let mut registry = rustc_plugin::registry::Registry::new(state.session, let mut registry = rustc_plugin::registry::Registry::new(state.session,
state.krate state
.krate
.as_ref() .as_ref()
.expect("at this compilation stage \ .expect("at this compilation stage \
the krate must be parsed") the krate must be parsed")
@@ -84,12 +88,14 @@ impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
registry.args_hidden = Some(Vec::new()); registry.args_hidden = Some(Vec::new());
clippy_lints::register_plugins(&mut registry); clippy_lints::register_plugins(&mut registry);
let rustc_plugin::registry::Registry { early_lint_passes, let rustc_plugin::registry::Registry {
late_lint_passes, early_lint_passes,
lint_groups, late_lint_passes,
llvm_passes, lint_groups,
attributes, llvm_passes,
.. } = registry; attributes,
..
} = registry;
let sess = &state.session; let sess = &state.session;
let mut ls = sess.lint_store.borrow_mut(); let mut ls = sess.lint_store.borrow_mut();
for pass in early_lint_passes { for pass in early_lint_passes {
@@ -172,29 +178,35 @@ pub fn main() {
if let Some("clippy") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) { if let Some("clippy") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
// this arm is executed on the initial call to `cargo clippy` // this arm is executed on the initial call to `cargo clippy`
let manifest_path_arg = std::env::args().skip(2).find(|val| val.starts_with("--manifest-path=")); let manifest_path_arg = std::env::args()
.skip(2)
.find(|val| val.starts_with("--manifest-path="));
let mut metadata = if let Ok(metadata) = cargo_metadata::metadata(manifest_path_arg.as_ref() let mut metadata =
.map(AsRef::as_ref)) { if let Ok(metadata) = cargo_metadata::metadata(manifest_path_arg.as_ref().map(AsRef::as_ref)) {
metadata metadata
} else { } else {
let _ = io::stderr().write_fmt(format_args!("error: Could not obtain cargo metadata.\n")); let _ = io::stderr().write_fmt(format_args!("error: Could not obtain cargo metadata.\n"));
process::exit(101); process::exit(101);
}; };
let manifest_path = manifest_path_arg.map(|arg| PathBuf::from(Path::new(&arg["--manifest-path=".len()..]))); let manifest_path = manifest_path_arg.map(|arg| PathBuf::from(Path::new(&arg["--manifest-path=".len()..])));
let current_dir = std::env::current_dir(); let current_dir = std::env::current_dir();
let package_index = metadata.packages let package_index = metadata
.packages
.iter() .iter()
.position(|package| { .position(|package| {
let package_manifest_path = Path::new(&package.manifest_path); let package_manifest_path = Path::new(&package.manifest_path);
if let Some(ref manifest_path) = manifest_path { if let Some(ref manifest_path) = manifest_path {
package_manifest_path == manifest_path package_manifest_path == manifest_path
} else { } else {
let current_dir = current_dir.as_ref().expect("could not read current directory"); let current_dir = current_dir
let package_manifest_directory = package_manifest_path.parent() .as_ref()
.expect("could not read current directory");
let package_manifest_directory = package_manifest_path
.parent()
.expect("could not find parent directory of package manifest"); .expect("could not find parent directory of package manifest");
package_manifest_directory == current_dir package_manifest_directory == current_dir
} }
@@ -209,7 +221,9 @@ pub fn main() {
std::process::exit(code); std::process::exit(code);
} }
} else if ["bin", "example", "test", "bench"].contains(&&**first) { } else if ["bin", "example", "test", "bench"].contains(&&**first) {
if let Err(code) = process(vec![format!("--{}", first), target.name].into_iter().chain(args)) { if let Err(code) = process(vec![format!("--{}", first), target.name]
.into_iter()
.chain(args)) {
std::process::exit(code); std::process::exit(code);
} }
} }
@@ -218,7 +232,8 @@ pub fn main() {
} }
} }
} else { } else {
// this arm is executed when cargo-clippy runs `cargo rustc` with the `RUSTC` env var set to itself // this arm is executed when cargo-clippy runs `cargo rustc` with the `RUSTC`
// env var set to itself
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
@@ -240,31 +255,36 @@ pub fn main() {
}; };
rustc_driver::in_rustc_thread(|| { rustc_driver::in_rustc_thread(|| {
// this conditional check for the --sysroot flag is there so users can call `cargo-clippy` directly // this conditional check for the --sysroot flag is there so users can call
// without having to pass --sysroot or anything // `cargo-clippy` directly
let mut args: Vec<String> = if env::args().any(|s| s == "--sysroot") { // without having to pass --sysroot or anything
env::args().collect() let mut args: Vec<String> = if env::args().any(|s| s == "--sysroot") {
} else { env::args().collect()
env::args().chain(Some("--sysroot".to_owned())).chain(Some(sys_root)).collect() } else {
}; env::args()
.chain(Some("--sysroot".to_owned()))
.chain(Some(sys_root))
.collect()
};
// this check ensures that dependencies are built but not linted and the final crate is // this check ensures that dependencies are built but not linted and the final
// linted but not built // crate is
let clippy_enabled = env::args().any(|s| s == "-Zno-trans"); // linted but not built
let clippy_enabled = env::args().any(|s| s == "-Zno-trans");
if clippy_enabled { if clippy_enabled {
args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]); args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]);
}
let mut ccc = ClippyCompilerCalls::new(clippy_enabled);
let (result, _) = rustc_driver::run_compiler(&args, &mut ccc, None, None);
if let Err(err_count) = result {
if err_count > 0 {
std::process::exit(1);
} }
}
let mut ccc = ClippyCompilerCalls::new(clippy_enabled); })
let (result, _) = rustc_driver::run_compiler(&args, &mut ccc, None, None); .expect("rustc_thread failed");
if let Err(err_count) = result {
if err_count > 0 {
std::process::exit(1);
}
}
})
.expect("rustc_thread failed");
} }
} }

View File

@@ -14,14 +14,14 @@ struct Test {
fn main() { fn main() {
use Baz::*; use Baz::*;
let x = Test { let x = Test { t: Some(0), b: One };
t: Some(0),
b: One,
};
match x { match x {
Test { t: Some(_), b: One } => unreachable!(), Test { t: Some(_), b: One } => unreachable!(),
Test { t: Some(42), b: Two } => unreachable!(), Test {
t: Some(42),
b: Two,
} => unreachable!(),
Test { t: None, .. } => unreachable!(), Test { t: None, .. } => unreachable!(),
Test { .. } => unreachable!(), Test { .. } => unreachable!(),
} }

View File

@@ -20,9 +20,13 @@ fn test_overlapping() {
assert_eq!(None, overlapping(&[sp(1, Bound::Included(4))])); assert_eq!(None, overlapping(&[sp(1, Bound::Included(4))]));
assert_eq!(None, overlapping(&[sp(1, Bound::Included(4)), sp(5, Bound::Included(6))])); assert_eq!(None, overlapping(&[sp(1, Bound::Included(4)), sp(5, Bound::Included(6))]));
assert_eq!(None, assert_eq!(None,
overlapping(&[sp(1, Bound::Included(4)), sp(5, Bound::Included(6)), sp(10, Bound::Included(11))])); overlapping(&[sp(1, Bound::Included(4)),
sp(5, Bound::Included(6)),
sp(10, Bound::Included(11))]));
assert_eq!(Some((&sp(1, Bound::Included(4)), &sp(3, Bound::Included(6)))), assert_eq!(Some((&sp(1, Bound::Included(4)), &sp(3, Bound::Included(6)))),
overlapping(&[sp(1, Bound::Included(4)), sp(3, Bound::Included(6))])); overlapping(&[sp(1, Bound::Included(4)), sp(3, Bound::Included(6))]));
assert_eq!(Some((&sp(5, Bound::Included(6)), &sp(6, Bound::Included(11)))), assert_eq!(Some((&sp(5, Bound::Included(6)), &sp(6, Bound::Included(11)))),
overlapping(&[sp(1, Bound::Included(4)), sp(5, Bound::Included(6)), sp(6, Bound::Included(11))])); overlapping(&[sp(1, Bound::Included(4)),
sp(5, Bound::Included(6)),
sp(6, Bound::Included(11))]));
} }

View File

@@ -19,10 +19,9 @@ error: integer arithmetic detected
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/arithmetic.rs:10:5 --> $DIR/arithmetic.rs:10:5
| |
10 | 1 % 10 | / 1 %
| _____^ starting here...
11 | | i / 2; // no error, this is part of the expression in the preceding line 11 | | i / 2; // no error, this is part of the expression in the preceding line
| |_________^ ...ending here | |_________^
error: integer arithmetic detected error: integer arithmetic detected
--> $DIR/arithmetic.rs:12:5 --> $DIR/arithmetic.rs:12:5

View File

@@ -2,11 +2,11 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; inste
--> $DIR/block_in_if_condition.rs:30:8 --> $DIR/block_in_if_condition.rs:30:8
| |
30 | if { 30 | if {
| ________^ starting here... | ________^
31 | | let x = 3; 31 | | let x = 3;
32 | | x == 3 32 | | x == 3
33 | | } { 33 | | } {
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/block_in_if_condition.rs:5:9 --> $DIR/block_in_if_condition.rs:5:9

View File

@@ -1,15 +1,14 @@
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:8:5 --> $DIR/collapsible_if.rs:8:5
| |
8 | if x == "hello" { 8 | / if x == "hello" {
| _____^ starting here...
9 | | 9 | |
10 | | 10 | |
11 | | 11 | |
... | ... |
14 | | } 14 | | }
15 | | } 15 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/collapsible_if.rs:4:8 --> $DIR/collapsible_if.rs:4:8
@@ -24,15 +23,14 @@ help: try
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:17:5 --> $DIR/collapsible_if.rs:17:5
| |
17 | if x == "hello" || x == "world" { 17 | / if x == "hello" || x == "world" {
| _____^ starting here...
18 | | 18 | |
19 | | 19 | |
20 | | 20 | |
... | ... |
23 | | } 23 | | }
24 | | } 24 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| if (x == "hello" || x == "world") && (y == "world" || y == "hello") { | if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
@@ -42,15 +40,14 @@ help: try
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:26:5 --> $DIR/collapsible_if.rs:26:5
| |
26 | if x == "hello" && x == "world" { 26 | / if x == "hello" && x == "world" {
| _____^ starting here...
27 | | 27 | |
28 | | 28 | |
29 | | 29 | |
... | ... |
32 | | } 32 | | }
33 | | } 33 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| if x == "hello" && x == "world" && (y == "world" || y == "hello") { | if x == "hello" && x == "world" && (y == "world" || y == "hello") {
@@ -60,15 +57,14 @@ help: try
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:35:5 --> $DIR/collapsible_if.rs:35:5
| |
35 | if x == "hello" || x == "world" { 35 | / if x == "hello" || x == "world" {
| _____^ starting here...
36 | | 36 | |
37 | | 37 | |
38 | | 38 | |
... | ... |
41 | | } 41 | | }
42 | | } 42 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| if (x == "hello" || x == "world") && y == "world" && y == "hello" { | if (x == "hello" || x == "world") && y == "world" && y == "hello" {
@@ -78,15 +74,14 @@ help: try
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:44:5 --> $DIR/collapsible_if.rs:44:5
| |
44 | if x == "hello" && x == "world" { 44 | / if x == "hello" && x == "world" {
| _____^ starting here...
45 | | 45 | |
46 | | 46 | |
47 | | 47 | |
... | ... |
50 | | } 50 | | }
51 | | } 51 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| if x == "hello" && x == "world" && y == "world" && y == "hello" { | if x == "hello" && x == "world" && y == "world" && y == "hello" {
@@ -96,15 +91,14 @@ help: try
error: this if statement can be collapsed error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:53:5 --> $DIR/collapsible_if.rs:53:5
| |
53 | if 42 == 1337 { 53 | / if 42 == 1337 {
| _____^ starting here...
54 | | 54 | |
55 | | 55 | |
56 | | 56 | |
... | ... |
59 | | } 59 | | }
60 | | } 60 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| if 42 == 1337 && 'a' != 'A' { | if 42 == 1337 && 'a' != 'A' {
@@ -115,14 +109,14 @@ error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:65:12 --> $DIR/collapsible_if.rs:65:12
| |
65 | } else { 65 | } else {
| ____________^ starting here... | ____________^
66 | | 66 | |
67 | | 67 | |
68 | | 68 | |
... | ... |
71 | | } 71 | | }
72 | | } 72 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| } else if y == "world" { | } else if y == "world" {
@@ -133,14 +127,14 @@ error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:76:12 --> $DIR/collapsible_if.rs:76:12
| |
76 | } else { 76 | } else {
| ____________^ starting here... | ____________^
77 | | 77 | |
78 | | 78 | |
79 | | 79 | |
... | ... |
82 | | } 82 | | }
83 | | } 83 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| } else if let Some(42) = Some(42) { | } else if let Some(42) = Some(42) {
@@ -151,14 +145,14 @@ error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:87:12 --> $DIR/collapsible_if.rs:87:12
| |
87 | } else { 87 | } else {
| ____________^ starting here... | ____________^
88 | | 88 | |
89 | | 89 | |
90 | | 90 | |
... | ... |
96 | | } 96 | | }
97 | | } 97 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| } else if y == "world" { | } else if y == "world" {
@@ -172,14 +166,14 @@ error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:101:12 --> $DIR/collapsible_if.rs:101:12
| |
101 | } else { 101 | } else {
| ____________^ starting here... | ____________^
102 | | 102 | |
103 | | 103 | |
104 | | 104 | |
... | ... |
110 | | } 110 | | }
111 | | } 111 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| } else if let Some(42) = Some(42) { | } else if let Some(42) = Some(42) {
@@ -193,14 +187,14 @@ error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:115:12 --> $DIR/collapsible_if.rs:115:12
| |
115 | } else { 115 | } else {
| ____________^ starting here... | ____________^
116 | | 116 | |
117 | | 117 | |
118 | | 118 | |
... | ... |
124 | | } 124 | | }
125 | | } 125 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| } else if let Some(42) = Some(42) { | } else if let Some(42) = Some(42) {
@@ -214,14 +208,14 @@ error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:129:12 --> $DIR/collapsible_if.rs:129:12
| |
129 | } else { 129 | } else {
| ____________^ starting here... | ____________^
130 | | 130 | |
131 | | 131 | |
132 | | 132 | |
... | ... |
138 | | } 138 | | }
139 | | } 139 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| } else if x == "hello" { | } else if x == "hello" {
@@ -235,14 +229,14 @@ error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:143:12 --> $DIR/collapsible_if.rs:143:12
| |
143 | } else { 143 | } else {
| ____________^ starting here... | ____________^
144 | | 144 | |
145 | | 145 | |
146 | | 146 | |
... | ... |
152 | | } 152 | | }
153 | | } 153 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| } else if let Some(42) = Some(42) { | } else if let Some(42) = Some(42) {

View File

@@ -42,14 +42,14 @@ error: this `if` has identical blocks
--> $DIR/copies.rs:40:10 --> $DIR/copies.rs:40:10
| |
40 | else { 40 | else {
| __________^ starting here... | __________^
41 | | Foo { bar: 42 }; 41 | | Foo { bar: 42 };
42 | | 0..10; 42 | | 0..10;
43 | | ..; 43 | | ..;
... | ... |
47 | | foo(); 47 | | foo();
48 | | } 48 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/copies.rs:27:8 --> $DIR/copies.rs:27:8
@@ -60,27 +60,27 @@ note: same as this
--> $DIR/copies.rs:30:13 --> $DIR/copies.rs:30:13
| |
30 | if true { 30 | if true {
| _____________^ starting here... | _____________^
31 | | 31 | |
32 | | Foo { bar: 42 }; 32 | | Foo { bar: 42 };
33 | | 0..10; 33 | | 0..10;
... | ... |
38 | | foo(); 38 | | foo();
39 | | } 39 | | }
| |_____^ ...ending here | |_____^
error: this `match` has identical arm bodies error: this `match` has identical arm bodies
--> $DIR/copies.rs:91:14 --> $DIR/copies.rs:91:14
| |
91 | _ => { 91 | _ => {
| ______________^ starting here... | ______________^
92 | | foo(); 92 | | foo();
93 | | let mut a = 42 + [23].len() as i32; 93 | | let mut a = 42 + [23].len() as i32;
94 | | if true { 94 | | if true {
... | ... |
98 | | a 98 | | a
99 | | } 99 | | }
| |_________^ ...ending here | |_________^
| |
note: lint level defined here note: lint level defined here
--> $DIR/copies.rs:28:8 --> $DIR/copies.rs:28:8
@@ -91,26 +91,26 @@ note: same as this
--> $DIR/copies.rs:80:15 --> $DIR/copies.rs:80:15
| |
80 | 42 => { 80 | 42 => {
| _______________^ starting here... | _______________^
81 | | 81 | |
82 | | 82 | |
83 | | foo(); 83 | | foo();
... | ... |
89 | | a 89 | | a
90 | | } 90 | | }
| |_________^ ...ending here | |_________^
note: `42` has the same arm body as the `_` wildcard, consider removing it` note: `42` has the same arm body as the `_` wildcard, consider removing it`
--> $DIR/copies.rs:80:15 --> $DIR/copies.rs:80:15
| |
80 | 42 => { 80 | 42 => {
| _______________^ starting here... | _______________^
81 | | 81 | |
82 | | 82 | |
83 | | foo(); 83 | | foo();
... | ... |
89 | | a 89 | | a
90 | | } 90 | | }
| |_________^ ...ending here | |_________^
error: this `match` has identical arm bodies error: this `match` has identical arm bodies
--> $DIR/copies.rs:107:14 --> $DIR/copies.rs:107:14
@@ -133,136 +133,136 @@ error: this `if` has identical blocks
--> $DIR/copies.rs:118:10 --> $DIR/copies.rs:118:10
| |
118 | else { 118 | else {
| __________^ starting here... | __________^
119 | | 42 119 | | 42
120 | | }; 120 | | };
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:114:21 --> $DIR/copies.rs:114:21
| |
114 | let _ = if true { 114 | let _ = if true {
| _____________________^ starting here... | _____________________^
115 | | 115 | |
116 | | 42 116 | | 42
117 | | } 117 | | }
| |_____^ ...ending here | |_____^
error: this `if` has identical blocks error: this `if` has identical blocks
--> $DIR/copies.rs:133:10 --> $DIR/copies.rs:133:10
| |
133 | else { 133 | else {
| __________^ starting here... | __________^
134 | | for _ in &[42] { 134 | | for _ in &[42] {
135 | | let foo: &Option<_> = &Some::<u8>(42); 135 | | let foo: &Option<_> = &Some::<u8>(42);
136 | | if true { 136 | | if true {
... | ... |
141 | | } 141 | | }
142 | | } 142 | | }
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:122:13 --> $DIR/copies.rs:122:13
| |
122 | if true { 122 | if true {
| _____________^ starting here... | _____________^
123 | | 123 | |
124 | | for _ in &[42] { 124 | | for _ in &[42] {
125 | | let foo: &Option<_> = &Some::<u8>(42); 125 | | let foo: &Option<_> = &Some::<u8>(42);
... | ... |
131 | | } 131 | | }
132 | | } 132 | | }
| |_____^ ...ending here | |_____^
error: this `if` has identical blocks error: this `if` has identical blocks
--> $DIR/copies.rs:156:10 --> $DIR/copies.rs:156:10
| |
156 | else { 156 | else {
| __________^ starting here... | __________^
157 | | let bar = if true { 157 | | let bar = if true {
158 | | 42 158 | | 42
159 | | } 159 | | }
... | ... |
165 | | bar + 1; 165 | | bar + 1;
166 | | } 166 | | }
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:144:13 --> $DIR/copies.rs:144:13
| |
144 | if true { 144 | if true {
| _____________^ starting here... | _____________^
145 | | 145 | |
146 | | let bar = if true { 146 | | let bar = if true {
147 | | 42 147 | | 42
... | ... |
154 | | bar + 1; 154 | | bar + 1;
155 | | } 155 | | }
| |_____^ ...ending here | |_____^
error: this `if` has identical blocks error: this `if` has identical blocks
--> $DIR/copies.rs:180:19 --> $DIR/copies.rs:180:19
| |
180 | else if foo() { 180 | else if foo() {
| ___________________^ starting here... | ___________________^
181 | | let _ = match 42 { 181 | | let _ = match 42 {
182 | | 42 => 1, 182 | | 42 => 1,
183 | | a if a > 0 => 2, 183 | | a if a > 0 => 2,
... | ... |
186 | | }; 186 | | };
187 | | } 187 | | }
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:168:13 --> $DIR/copies.rs:168:13
| |
168 | if true { 168 | if true {
| _____________^ starting here... | _____________^
169 | | 169 | |
170 | | let _ = match 42 { 170 | | let _ = match 42 {
171 | | 42 => 1, 171 | | 42 => 1,
... | ... |
175 | | }; 175 | | };
176 | | } 176 | | }
| |_____^ ...ending here | |_____^
error: this `if` has identical blocks error: this `if` has identical blocks
--> $DIR/copies.rs:193:10 --> $DIR/copies.rs:193:10
| |
193 | else { 193 | else {
| __________^ starting here... | __________^
194 | | if let Some(a) = Some(42) {} 194 | | if let Some(a) = Some(42) {}
195 | | } 195 | | }
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:189:13 --> $DIR/copies.rs:189:13
| |
189 | if true { 189 | if true {
| _____________^ starting here... | _____________^
190 | | 190 | |
191 | | if let Some(a) = Some(42) {} 191 | | if let Some(a) = Some(42) {}
192 | | } 192 | | }
| |_____^ ...ending here | |_____^
error: this `if` has identical blocks error: this `if` has identical blocks
--> $DIR/copies.rs:201:10 --> $DIR/copies.rs:201:10
| |
201 | else { 201 | else {
| __________^ starting here... | __________^
202 | | if let (1, .., 3) = (1, 2, 3) {} 202 | | if let (1, .., 3) = (1, 2, 3) {}
203 | | } 203 | | }
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:197:13 --> $DIR/copies.rs:197:13
| |
197 | if true { 197 | if true {
| _____________^ starting here... | _____________^
198 | | 198 | |
199 | | if let (1, .., 3) = (1, 2, 3) {} 199 | | if let (1, .., 3) = (1, 2, 3) {}
200 | | } 200 | | }
| |_____^ ...ending here | |_____^
error: this `match` has identical arm bodies error: this `match` has identical arm bodies
--> $DIR/copies.rs:258:15 --> $DIR/copies.rs:258:15
@@ -353,98 +353,98 @@ error: this `if` has identical blocks
--> $DIR/copies.rs:313:12 --> $DIR/copies.rs:313:12
| |
313 | } else { 313 | } else {
| ____________^ starting here... | ____________^
314 | | 0.0 314 | | 0.0
315 | | }; 315 | | };
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:310:21 --> $DIR/copies.rs:310:21
| |
310 | let _ = if true { 310 | let _ = if true {
| _____________________^ starting here... | _____________________^
311 | | 311 | |
312 | | 0.0 312 | | 0.0
313 | | } else { 313 | | } else {
| |_____^ ...ending here | |_____^
error: this `if` has identical blocks error: this `if` has identical blocks
--> $DIR/copies.rs:320:12 --> $DIR/copies.rs:320:12
| |
320 | } else { 320 | } else {
| ____________^ starting here... | ____________^
321 | | -0.0 321 | | -0.0
322 | | }; 322 | | };
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:317:21 --> $DIR/copies.rs:317:21
| |
317 | let _ = if true { 317 | let _ = if true {
| _____________________^ starting here... | _____________________^
318 | | 318 | |
319 | | -0.0 319 | | -0.0
320 | | } else { 320 | | } else {
| |_____^ ...ending here | |_____^
error: this `if` has identical blocks error: this `if` has identical blocks
--> $DIR/copies.rs:341:12 --> $DIR/copies.rs:341:12
| |
341 | } else { 341 | } else {
| ____________^ starting here... | ____________^
342 | | std::f32::NAN 342 | | std::f32::NAN
343 | | }; 343 | | };
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:338:21 --> $DIR/copies.rs:338:21
| |
338 | let _ = if true { 338 | let _ = if true {
| _____________________^ starting here... | _____________________^
339 | | 339 | |
340 | | std::f32::NAN 340 | | std::f32::NAN
341 | | } else { 341 | | } else {
| |_____^ ...ending here | |_____^
error: this `if` has identical blocks error: this `if` has identical blocks
--> $DIR/copies.rs:360:10 --> $DIR/copies.rs:360:10
| |
360 | else { 360 | else {
| __________^ starting here... | __________^
361 | | try!(Ok("foo")); 361 | | try!(Ok("foo"));
362 | | } 362 | | }
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:356:13 --> $DIR/copies.rs:356:13
| |
356 | if true { 356 | if true {
| _____________^ starting here... | _____________^
357 | | 357 | |
358 | | try!(Ok("foo")); 358 | | try!(Ok("foo"));
359 | | } 359 | | }
| |_____^ ...ending here | |_____^
error: this `if` has identical blocks error: this `if` has identical blocks
--> $DIR/copies.rs:373:10 --> $DIR/copies.rs:373:10
| |
373 | else { 373 | else {
| __________^ starting here... | __________^
374 | | let foo = ""; 374 | | let foo = "";
375 | | return Ok(&foo[0..]); 375 | | return Ok(&foo[0..]);
376 | | } 376 | | }
| |_____^ ...ending here | |_____^
| |
note: same as this note: same as this
--> $DIR/copies.rs:364:13 --> $DIR/copies.rs:364:13
| |
364 | if true { 364 | if true {
| _____________^ starting here... | _____________^
365 | | 365 | |
366 | | let foo = ""; 366 | | let foo = "";
367 | | return Ok(&foo[0..]); 367 | | return Ok(&foo[0..]);
368 | | } 368 | | }
| |_____^ ...ending here | |_____^
error: this `if` has the same condition as a previous if error: this `if` has the same condition as a previous if
--> $DIR/copies.rs:388:13 --> $DIR/copies.rs:388:13

View File

@@ -1,15 +1,14 @@
error: the function has a cyclomatic complexity of 28 error: the function has a cyclomatic complexity of 28
--> $DIR/cyclomatic_complexity.rs:7:1 --> $DIR/cyclomatic_complexity.rs:7:1
| |
7 | fn main() { 7 | / fn main() {
| _^ starting here...
8 | | if true { 8 | | if true {
9 | | println!("a"); 9 | | println!("a");
10 | | } 10 | | }
... | ... |
88 | | } 88 | | }
89 | | } 89 | | }
| |_^ ...ending here | |_^
| |
note: lint level defined here note: lint level defined here
--> $DIR/cyclomatic_complexity.rs:4:9 --> $DIR/cyclomatic_complexity.rs:4:9
@@ -21,52 +20,48 @@ note: lint level defined here
error: the function has a cyclomatic complexity of 7 error: the function has a cyclomatic complexity of 7
--> $DIR/cyclomatic_complexity.rs:92:1 --> $DIR/cyclomatic_complexity.rs:92:1
| |
92 | fn kaboom() { 92 | / fn kaboom() {
| _^ starting here...
93 | | let n = 0; 93 | | let n = 0;
94 | | 'a: for i in 0..20 { 94 | | 'a: for i in 0..20 {
95 | | 'b: for j in i..20 { 95 | | 'b: for j in i..20 {
... | ... |
110 | | } 110 | | }
111 | | } 111 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:138:1 --> $DIR/cyclomatic_complexity.rs:138:1
| |
138 | fn lots_of_short_circuits() -> bool { 138 | / fn lots_of_short_circuits() -> bool {
| _^ starting here...
139 | | true && false && true && false && true && false && true 139 | | true && false && true && false && true && false && true
140 | | } 140 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:143:1 --> $DIR/cyclomatic_complexity.rs:143:1
| |
143 | fn lots_of_short_circuits2() -> bool { 143 | / fn lots_of_short_circuits2() -> bool {
| _^ starting here...
144 | | true || false || true || false || true || false || true 144 | | true || false || true || false || true || false || true
145 | | } 145 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:148:1 --> $DIR/cyclomatic_complexity.rs:148:1
| |
148 | fn baa() { 148 | / fn baa() {
| _^ starting here...
149 | | let x = || match 99 { 149 | | let x = || match 99 {
150 | | 0 => 0, 150 | | 0 => 0,
151 | | 1 => 1, 151 | | 1 => 1,
... | ... |
162 | | } 162 | | }
163 | | } 163 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
@@ -74,221 +69,207 @@ error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:149:13 --> $DIR/cyclomatic_complexity.rs:149:13
| |
149 | let x = || match 99 { 149 | let x = || match 99 {
| _____________^ starting here... | _____________^
150 | | 0 => 0, 150 | | 0 => 0,
151 | | 1 => 1, 151 | | 1 => 1,
152 | | 2 => 2, 152 | | 2 => 2,
... | ... |
156 | | _ => 42, 156 | | _ => 42,
157 | | }; 157 | | };
| |_____^ ...ending here | |_____^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:166:1 --> $DIR/cyclomatic_complexity.rs:166:1
| |
166 | fn bar() { 166 | / fn bar() {
| _^ starting here...
167 | | match 99 { 167 | | match 99 {
168 | | 0 => println!("hi"), 168 | | 0 => println!("hi"),
169 | | _ => println!("bye"), 169 | | _ => println!("bye"),
170 | | } 170 | | }
171 | | } 171 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:185:1 --> $DIR/cyclomatic_complexity.rs:185:1
| |
185 | fn barr() { 185 | / fn barr() {
| _^ starting here...
186 | | match 99 { 186 | | match 99 {
187 | | 0 => println!("hi"), 187 | | 0 => println!("hi"),
188 | | 1 => println!("bla"), 188 | | 1 => println!("bla"),
... | ... |
191 | | } 191 | | }
192 | | } 192 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 3 error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity.rs:195:1 --> $DIR/cyclomatic_complexity.rs:195:1
| |
195 | fn barr2() { 195 | / fn barr2() {
| _^ starting here...
196 | | match 99 { 196 | | match 99 {
197 | | 0 => println!("hi"), 197 | | 0 => println!("hi"),
198 | | 1 => println!("bla"), 198 | | 1 => println!("bla"),
... | ... |
207 | | } 207 | | }
208 | | } 208 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:211:1 --> $DIR/cyclomatic_complexity.rs:211:1
| |
211 | fn barrr() { 211 | / fn barrr() {
| _^ starting here...
212 | | match 99 { 212 | | match 99 {
213 | | 0 => println!("hi"), 213 | | 0 => println!("hi"),
214 | | 1 => panic!("bla"), 214 | | 1 => panic!("bla"),
... | ... |
217 | | } 217 | | }
218 | | } 218 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 3 error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity.rs:221:1 --> $DIR/cyclomatic_complexity.rs:221:1
| |
221 | fn barrr2() { 221 | / fn barrr2() {
| _^ starting here...
222 | | match 99 { 222 | | match 99 {
223 | | 0 => println!("hi"), 223 | | 0 => println!("hi"),
224 | | 1 => panic!("bla"), 224 | | 1 => panic!("bla"),
... | ... |
233 | | } 233 | | }
234 | | } 234 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:237:1 --> $DIR/cyclomatic_complexity.rs:237:1
| |
237 | fn barrrr() { 237 | / fn barrrr() {
| _^ starting here...
238 | | match 99 { 238 | | match 99 {
239 | | 0 => println!("hi"), 239 | | 0 => println!("hi"),
240 | | 1 => println!("bla"), 240 | | 1 => println!("bla"),
... | ... |
243 | | } 243 | | }
244 | | } 244 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 3 error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity.rs:247:1 --> $DIR/cyclomatic_complexity.rs:247:1
| |
247 | fn barrrr2() { 247 | / fn barrrr2() {
| _^ starting here...
248 | | match 99 { 248 | | match 99 {
249 | | 0 => println!("hi"), 249 | | 0 => println!("hi"),
250 | | 1 => println!("bla"), 250 | | 1 => println!("bla"),
... | ... |
259 | | } 259 | | }
260 | | } 260 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2
--> $DIR/cyclomatic_complexity.rs:263:1 --> $DIR/cyclomatic_complexity.rs:263:1
| |
263 | fn cake() { 263 | / fn cake() {
| _^ starting here...
264 | | if 4 == 5 { 264 | | if 4 == 5 {
265 | | println!("yea"); 265 | | println!("yea");
266 | | } else { 266 | | } else {
... | ... |
269 | | println!("whee"); 269 | | println!("whee");
270 | | } 270 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 4 error: the function has a cyclomatic complexity of 4
--> $DIR/cyclomatic_complexity.rs:274:1 --> $DIR/cyclomatic_complexity.rs:274:1
| |
274 | pub fn read_file(input_path: &str) -> String { 274 | / pub fn read_file(input_path: &str) -> String {
| _^ starting here...
275 | | use std::fs::File; 275 | | use std::fs::File;
276 | | use std::io::{Read, Write}; 276 | | use std::io::{Read, Write};
277 | | use std::path::Path; 277 | | use std::path::Path;
... | ... |
299 | | } 299 | | }
300 | | } 300 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:305:1 --> $DIR/cyclomatic_complexity.rs:305:1
| |
305 | fn void(void: Void) { 305 | / fn void(void: Void) {
| _^ starting here...
306 | | if true { 306 | | if true {
307 | | match void { 307 | | match void {
308 | | } 308 | | }
309 | | } 309 | | }
310 | | } 310 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:319:1 --> $DIR/cyclomatic_complexity.rs:319:1
| |
319 | fn try() -> Result<i32, &'static str> { 319 | / fn try() -> Result<i32, &'static str> {
| _^ starting here...
320 | | match 5 { 320 | | match 5 {
321 | | 5 => Ok(5), 321 | | 5 => Ok(5),
322 | | _ => return Err("bla"), 322 | | _ => return Err("bla"),
323 | | } 323 | | }
324 | | } 324 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:327:1 --> $DIR/cyclomatic_complexity.rs:327:1
| |
327 | fn try_again() -> Result<i32, &'static str> { 327 | / fn try_again() -> Result<i32, &'static str> {
| _^ starting here...
328 | | let _ = try!(Ok(42)); 328 | | let _ = try!(Ok(42));
329 | | let _ = try!(Ok(43)); 329 | | let _ = try!(Ok(43));
330 | | let _ = try!(Ok(44)); 330 | | let _ = try!(Ok(44));
... | ... |
339 | | } 339 | | }
340 | | } 340 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1
--> $DIR/cyclomatic_complexity.rs:343:1 --> $DIR/cyclomatic_complexity.rs:343:1
| |
343 | fn early() -> Result<i32, &'static str> { 343 | / fn early() -> Result<i32, &'static str> {
| _^ starting here...
344 | | return Ok(5); 344 | | return Ok(5);
345 | | return Ok(5); 345 | | return Ok(5);
346 | | return Ok(5); 346 | | return Ok(5);
... | ... |
352 | | return Ok(5); 352 | | return Ok(5);
353 | | } 353 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions
error: the function has a cyclomatic complexity of 8 error: the function has a cyclomatic complexity of 8
--> $DIR/cyclomatic_complexity.rs:356:1 --> $DIR/cyclomatic_complexity.rs:356:1
| |
356 | fn early_ret() -> i32 { 356 | / fn early_ret() -> i32 {
| _^ starting here...
357 | | let a = if true { 42 } else { return 0; }; 357 | | let a = if true { 42 } else { return 0; };
358 | | let a = if a < 99 { 42 } else { return 0; }; 358 | | let a = if a < 99 { 42 } else { return 0; };
359 | | let a = if a < 99 { 42 } else { return 0; }; 359 | | let a = if a < 99 { 42 } else { return 0; };
... | ... |
372 | | } 372 | | }
373 | | } 373 | | }
| |_^ ...ending here | |_^
| |
= help: you could split it up into multiple smaller functions = help: you could split it up into multiple smaller functions

View File

@@ -1,15 +1,14 @@
error: the function has a cyclomatic complexity of 3 error: the function has a cyclomatic complexity of 3
--> $DIR/cyclomatic_complexity_attr_used.rs:11:1 --> $DIR/cyclomatic_complexity_attr_used.rs:11:1
| |
11 | fn kaboom() { 11 | / fn kaboom() {
| _^ starting here...
12 | | if 42 == 43 { 12 | | if 42 == 43 {
13 | | panic!(); 13 | | panic!();
14 | | } else if "cake" == "lie" { 14 | | } else if "cake" == "lie" {
15 | | println!("what?"); 15 | | println!("what?");
16 | | } 16 | | }
17 | | } 17 | | }
| |_^ ...ending here | |_^
| |
note: lint level defined here note: lint level defined here
--> $DIR/cyclomatic_complexity_attr_used.rs:3:9 --> $DIR/cyclomatic_complexity_attr_used.rs:3:9

View File

@@ -13,11 +13,10 @@ note: lint level defined here
note: `PartialEq` implemented here note: `PartialEq` implemented here
--> $DIR/derive.rs:22:1 --> $DIR/derive.rs:22:1
| |
22 | impl PartialEq for Bar { 22 | / impl PartialEq for Bar {
| _^ starting here...
23 | | fn eq(&self, _: &Bar) -> bool { true } 23 | | fn eq(&self, _: &Bar) -> bool { true }
24 | | } 24 | | }
| |_^ ...ending here | |_^
error: you are deriving `Hash` but have implemented `PartialEq` explicitly error: you are deriving `Hash` but have implemented `PartialEq` explicitly
--> $DIR/derive.rs:26:10 --> $DIR/derive.rs:26:10
@@ -29,21 +28,19 @@ error: you are deriving `Hash` but have implemented `PartialEq` explicitly
note: `PartialEq` implemented here note: `PartialEq` implemented here
--> $DIR/derive.rs:30:1 --> $DIR/derive.rs:30:1
| |
30 | impl PartialEq<Baz> for Baz { 30 | / impl PartialEq<Baz> for Baz {
| _^ starting here...
31 | | fn eq(&self, _: &Baz) -> bool { true } 31 | | fn eq(&self, _: &Baz) -> bool { true }
32 | | } 32 | | }
| |_^ ...ending here | |_^
error: you are implementing `Hash` explicitly but have derived `PartialEq` error: you are implementing `Hash` explicitly but have derived `PartialEq`
--> $DIR/derive.rs:37:1 --> $DIR/derive.rs:37:1
| |
37 | impl Hash for Bah { 37 | / impl Hash for Bah {
| _^ starting here...
38 | | 38 | |
39 | | fn hash<H: Hasher>(&self, _: &mut H) {} 39 | | fn hash<H: Hasher>(&self, _: &mut H) {}
40 | | } 40 | | }
| |_^ ...ending here | |_^
| |
= note: #[deny(derive_hash_xor_eq)] implied by #[deny(warnings)] = note: #[deny(derive_hash_xor_eq)] implied by #[deny(warnings)]
note: `PartialEq` implemented here note: `PartialEq` implemented here
@@ -55,12 +52,11 @@ note: `PartialEq` implemented here
error: you are implementing `Clone` explicitly on a `Copy` type error: you are implementing `Clone` explicitly on a `Copy` type
--> $DIR/derive.rs:45:1 --> $DIR/derive.rs:45:1
| |
45 | impl Clone for Qux { 45 | / impl Clone for Qux {
| _^ starting here...
46 | | 46 | |
47 | | fn clone(&self) -> Self { Qux } 47 | | fn clone(&self) -> Self { Qux }
48 | | } 48 | | }
| |_^ ...ending here | |_^
| |
= note: #[deny(expl_impl_clone_on_copy)] implied by #[deny(warnings)] = note: #[deny(expl_impl_clone_on_copy)] implied by #[deny(warnings)]
note: lint level defined here note: lint level defined here
@@ -71,33 +67,30 @@ note: lint level defined here
note: consider deriving `Clone` or removing `Copy` note: consider deriving `Clone` or removing `Copy`
--> $DIR/derive.rs:45:1 --> $DIR/derive.rs:45:1
| |
45 | impl Clone for Qux { 45 | / impl Clone for Qux {
| _^ starting here...
46 | | 46 | |
47 | | fn clone(&self) -> Self { Qux } 47 | | fn clone(&self) -> Self { Qux }
48 | | } 48 | | }
| |_^ ...ending here | |_^
error: you are implementing `Clone` explicitly on a `Copy` type error: you are implementing `Clone` explicitly on a `Copy` type
--> $DIR/derive.rs:70:1 --> $DIR/derive.rs:70:1
| |
70 | impl<'a> Clone for Lt<'a> { 70 | / impl<'a> Clone for Lt<'a> {
| _^ starting here...
71 | | 71 | |
72 | | fn clone(&self) -> Self { unimplemented!() } 72 | | fn clone(&self) -> Self { unimplemented!() }
73 | | } 73 | | }
| |_^ ...ending here | |_^
| |
= note: #[deny(expl_impl_clone_on_copy)] implied by #[deny(warnings)] = note: #[deny(expl_impl_clone_on_copy)] implied by #[deny(warnings)]
note: consider deriving `Clone` or removing `Copy` note: consider deriving `Clone` or removing `Copy`
--> $DIR/derive.rs:70:1 --> $DIR/derive.rs:70:1
| |
70 | impl<'a> Clone for Lt<'a> { 70 | / impl<'a> Clone for Lt<'a> {
| _^ starting here...
71 | | 71 | |
72 | | fn clone(&self) -> Self { unimplemented!() } 72 | | fn clone(&self) -> Self { unimplemented!() }
73 | | } 73 | | }
| |_^ ...ending here | |_^
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View File

@@ -38,13 +38,12 @@ error: Variant name starts with the enum's name
error: All variants have the same prefix: `Food` error: All variants have the same prefix: `Food`
--> $DIR/enum_variants.rs:24:1 --> $DIR/enum_variants.rs:24:1
| |
24 | enum Food { 24 | / enum Food {
| _^ starting here...
25 | | FoodGood, 25 | | FoodGood,
26 | | FoodMiddle, 26 | | FoodMiddle,
27 | | FoodBad, 27 | | FoodBad,
28 | | } 28 | | }
| |_^ ...ending here | |_^
| |
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)] = note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= help: remove the prefixes and use full paths to the variants instead of glob imports = help: remove the prefixes and use full paths to the variants instead of glob imports
@@ -52,13 +51,12 @@ error: All variants have the same prefix: `Food`
error: All variants have the same prefix: `CallType` error: All variants have the same prefix: `CallType`
--> $DIR/enum_variants.rs:34:1 --> $DIR/enum_variants.rs:34:1
| |
34 | enum BadCallType { 34 | / enum BadCallType {
| _^ starting here...
35 | | CallTypeCall, 35 | | CallTypeCall,
36 | | CallTypeCreate, 36 | | CallTypeCreate,
37 | | CallTypeDestroy, 37 | | CallTypeDestroy,
38 | | } 38 | | }
| |_^ ...ending here | |_^
| |
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)] = note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= help: remove the prefixes and use full paths to the variants instead of glob imports = help: remove the prefixes and use full paths to the variants instead of glob imports
@@ -66,13 +64,12 @@ error: All variants have the same prefix: `CallType`
error: All variants have the same prefix: `Constant` error: All variants have the same prefix: `Constant`
--> $DIR/enum_variants.rs:45:1 --> $DIR/enum_variants.rs:45:1
| |
45 | enum Consts { 45 | / enum Consts {
| _^ starting here...
46 | | ConstantInt, 46 | | ConstantInt,
47 | | ConstantCake, 47 | | ConstantCake,
48 | | ConstantLie, 48 | | ConstantLie,
49 | | } 49 | | }
| |_^ ...ending here | |_^
| |
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)] = note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= help: remove the prefixes and use full paths to the variants instead of glob imports = help: remove the prefixes and use full paths to the variants instead of glob imports
@@ -80,13 +77,12 @@ error: All variants have the same prefix: `Constant`
error: All variants have the same prefix: `With` error: All variants have the same prefix: `With`
--> $DIR/enum_variants.rs:78:1 --> $DIR/enum_variants.rs:78:1
| |
78 | enum Seallll { 78 | / enum Seallll {
| _^ starting here...
79 | | WithOutCake, 79 | | WithOutCake,
80 | | WithOutTea, 80 | | WithOutTea,
81 | | WithOut, 81 | | WithOut,
82 | | } 82 | | }
| |_^ ...ending here | |_^
| |
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)] = note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= help: remove the prefixes and use full paths to the variants instead of glob imports = help: remove the prefixes and use full paths to the variants instead of glob imports
@@ -94,13 +90,12 @@ error: All variants have the same prefix: `With`
error: All variants have the same prefix: `Prefix` error: All variants have the same prefix: `Prefix`
--> $DIR/enum_variants.rs:84:1 --> $DIR/enum_variants.rs:84:1
| |
84 | enum NonCaps { 84 | / enum NonCaps {
| _^ starting here...
85 | | Prefix的, 85 | | Prefix的,
86 | | PrefixTea, 86 | | PrefixTea,
87 | | PrefixCake, 87 | | PrefixCake,
88 | | } 88 | | }
| |_^ ...ending here | |_^
| |
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)] = note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
= help: remove the prefixes and use full paths to the variants instead of glob imports = help: remove the prefixes and use full paths to the variants instead of glob imports
@@ -108,13 +103,12 @@ error: All variants have the same prefix: `Prefix`
error: All variants have the same prefix: `With` error: All variants have the same prefix: `With`
--> $DIR/enum_variants.rs:90:1 --> $DIR/enum_variants.rs:90:1
| |
90 | pub enum PubSeall { 90 | / pub enum PubSeall {
| _^ starting here...
91 | | WithOutCake, 91 | | WithOutCake,
92 | | WithOutTea, 92 | | WithOutTea,
93 | | WithOut, 93 | | WithOut,
94 | | } 94 | | }
| |_^ ...ending here | |_^
| |
note: lint level defined here note: lint level defined here
--> $DIR/enum_variants.rs:3:17 --> $DIR/enum_variants.rs:3:17

View File

@@ -2,10 +2,10 @@ error: called `filter(p).map(q)` on an `Iterator`. This is more succinctly expre
--> $DIR/filter_methods.rs:8:21 --> $DIR/filter_methods.rs:8:21
| |
8 | let _: Vec<_> = vec![5; 6].into_iter() 8 | let _: Vec<_> = vec![5; 6].into_iter()
| _____________________^ starting here... | _____________________^
9 | | .filter(|&x| x == 0) 9 | | .filter(|&x| x == 0)
10 | | .map(|x| x * 2) 10 | | .map(|x| x * 2)
| |_____________________________________________^ ...ending here | |_____________________________________________^
| |
= note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)] = note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)]
note: lint level defined here note: lint level defined here
@@ -18,10 +18,10 @@ error: called `filter(p).flat_map(q)` on an `Iterator`. This is more succinctly
--> $DIR/filter_methods.rs:13:21 --> $DIR/filter_methods.rs:13:21
| |
13 | let _: Vec<_> = vec![5_i8; 6].into_iter() 13 | let _: Vec<_> = vec![5_i8; 6].into_iter()
| _____________________^ starting here... | _____________________^
14 | | .filter(|&x| x == 0) 14 | | .filter(|&x| x == 0)
15 | | .flat_map(|x| x.checked_mul(2)) 15 | | .flat_map(|x| x.checked_mul(2))
| |_______________________________________________________________^ ...ending here | |_______________________________________________________________^
| |
= note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)] = note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)]
@@ -29,10 +29,10 @@ error: called `filter_map(p).flat_map(q)` on an `Iterator`. This is more succinc
--> $DIR/filter_methods.rs:18:21 --> $DIR/filter_methods.rs:18:21
| |
18 | let _: Vec<_> = vec![5_i8; 6].into_iter() 18 | let _: Vec<_> = vec![5_i8; 6].into_iter()
| _____________________^ starting here... | _____________________^
19 | | .filter_map(|x| x.checked_mul(2)) 19 | | .filter_map(|x| x.checked_mul(2))
20 | | .flat_map(|x| x.checked_mul(2)) 20 | | .flat_map(|x| x.checked_mul(2))
| |_______________________________________________________________^ ...ending here | |_______________________________________________________________^
| |
= note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)] = note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)]
@@ -40,10 +40,10 @@ error: called `filter_map(p).map(q)` on an `Iterator`. This is more succinctly e
--> $DIR/filter_methods.rs:23:21 --> $DIR/filter_methods.rs:23:21
| |
23 | let _: Vec<_> = vec![5_i8; 6].into_iter() 23 | let _: Vec<_> = vec![5_i8; 6].into_iter()
| _____________________^ starting here... | _____________________^
24 | | .filter_map(|x| x.checked_mul(2)) 24 | | .filter_map(|x| x.checked_mul(2))
25 | | .map(|x| x.checked_mul(2)) 25 | | .map(|x| x.checked_mul(2))
| |__________________________________________________________^ ...ending here | |__________________________________________________________^
| |
= note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)] = note: #[deny(filter_map)] implied by #[deny(clippy_pedantic)]

View File

@@ -38,12 +38,11 @@ error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is
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:40:5 --> $DIR/for_loop.rs:40:5
| |
40 | for x in v.iter().next() { 40 | / for x in v.iter().next() {
| _____^ starting here...
41 | | 41 | |
42 | | println!("{}", x); 42 | | println!("{}", x);
43 | | } 43 | | }
| |_____^ ...ending here | |_____^
| |
= note: #[deny(iter_next_loop)] implied by #[deny(clippy)] = note: #[deny(iter_next_loop)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@@ -73,15 +72,14 @@ error: for loop over `v.iter().next().ok_or("x not found")`, which is a `Result`
error: the loop variable `i` is only used to index `vec`. error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:99:5 --> $DIR/for_loop.rs:99:5
| |
99 | for i in 0..vec.len() { 99 | / for i in 0..vec.len() {
| _____^ starting here...
100 | | 100 | |
101 | | 101 | |
102 | | 102 | |
103 | | 103 | |
104 | | println!("{}", vec[i]); 104 | | println!("{}", vec[i]);
105 | | } 105 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/for_loop.rs:90:8 --> $DIR/for_loop.rs:90:8
@@ -111,15 +109,14 @@ help: consider using an iterator
error: the loop variable `j` is only used to index `STATIC`. error: the loop variable `j` is only used to index `STATIC`.
--> $DIR/for_loop.rs:120:5 --> $DIR/for_loop.rs:120:5
| |
120 | for j in 0..4 { 120 | / for j in 0..4 {
| _____^ starting here...
121 | | 121 | |
122 | | 122 | |
123 | | 123 | |
124 | | 124 | |
125 | | println!("{:?}", STATIC[j]); 125 | | println!("{:?}", STATIC[j]);
126 | | } 126 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for <item> in STATIC.iter().take(4) { | for <item> in STATIC.iter().take(4) {
@@ -127,15 +124,14 @@ help: consider using an iterator
error: the loop variable `j` is only used to index `CONST`. error: the loop variable `j` is only used to index `CONST`.
--> $DIR/for_loop.rs:128:5 --> $DIR/for_loop.rs:128:5
| |
128 | for j in 0..4 { 128 | / for j in 0..4 {
| _____^ starting here...
129 | | 129 | |
130 | | 130 | |
131 | | 131 | |
132 | | 132 | |
133 | | println!("{:?}", CONST[j]); 133 | | println!("{:?}", CONST[j]);
134 | | } 134 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for <item> in CONST.iter().take(4) { | for <item> in CONST.iter().take(4) {
@@ -143,15 +139,14 @@ help: consider using an iterator
error: the loop variable `i` is used to index `vec` error: the loop variable `i` is used to index `vec`
--> $DIR/for_loop.rs:136:5 --> $DIR/for_loop.rs:136:5
| |
136 | for i in 0..vec.len() { 136 | / for i in 0..vec.len() {
| _____^ starting here...
137 | | 137 | |
138 | | 138 | |
139 | | 139 | |
140 | | 140 | |
141 | | println!("{} {}", vec[i], i); 141 | | println!("{} {}", vec[i], i);
142 | | } 142 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for (i, <item>) in vec.iter().enumerate() { | for (i, <item>) in vec.iter().enumerate() {
@@ -159,15 +154,14 @@ help: consider using an iterator
error: the loop variable `i` is only used to index `vec2`. error: the loop variable `i` is only used to index `vec2`.
--> $DIR/for_loop.rs:147:5 --> $DIR/for_loop.rs:147:5
| |
147 | for i in 0..vec.len() { 147 | / for i in 0..vec.len() {
| _____^ starting here...
148 | | 148 | |
149 | | 149 | |
150 | | 150 | |
151 | | 151 | |
152 | | println!("{}", vec2[i]); 152 | | println!("{}", vec2[i]);
153 | | } 153 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for <item> in vec2.iter().take(vec.len()) { | for <item> in vec2.iter().take(vec.len()) {
@@ -175,15 +169,14 @@ help: consider using an iterator
error: the loop variable `i` is only used to index `vec`. error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:155:5 --> $DIR/for_loop.rs:155:5
| |
155 | for i in 5..vec.len() { 155 | / for i in 5..vec.len() {
| _____^ starting here...
156 | | 156 | |
157 | | 157 | |
158 | | 158 | |
159 | | 159 | |
160 | | println!("{}", vec[i]); 160 | | println!("{}", vec[i]);
161 | | } 161 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for <item> in vec.iter().skip(5) { | for <item> in vec.iter().skip(5) {
@@ -191,15 +184,14 @@ help: consider using an iterator
error: the loop variable `i` is only used to index `vec`. error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:163:5 --> $DIR/for_loop.rs:163:5
| |
163 | for i in 0..MAX_LEN { 163 | / for i in 0..MAX_LEN {
| _____^ starting here...
164 | | 164 | |
165 | | 165 | |
166 | | 166 | |
167 | | 167 | |
168 | | println!("{}", vec[i]); 168 | | println!("{}", vec[i]);
169 | | } 169 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for <item> in vec.iter().take(MAX_LEN) { | for <item> in vec.iter().take(MAX_LEN) {
@@ -207,15 +199,14 @@ help: consider using an iterator
error: the loop variable `i` is only used to index `vec`. error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:171:5 --> $DIR/for_loop.rs:171:5
| |
171 | for i in 0...MAX_LEN { 171 | / for i in 0...MAX_LEN {
| _____^ starting here...
172 | | 172 | |
173 | | 173 | |
174 | | 174 | |
175 | | 175 | |
176 | | println!("{}", vec[i]); 176 | | println!("{}", vec[i]);
177 | | } 177 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for <item> in vec.iter().take(MAX_LEN + 1) { | for <item> in vec.iter().take(MAX_LEN + 1) {
@@ -223,15 +214,14 @@ help: consider using an iterator
error: the loop variable `i` is only used to index `vec`. error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:179:5 --> $DIR/for_loop.rs:179:5
| |
179 | for i in 5..10 { 179 | / for i in 5..10 {
| _____^ starting here...
180 | | 180 | |
181 | | 181 | |
182 | | 182 | |
183 | | 183 | |
184 | | println!("{}", vec[i]); 184 | | println!("{}", vec[i]);
185 | | } 185 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for <item> in vec.iter().take(10).skip(5) { | for <item> in vec.iter().take(10).skip(5) {
@@ -239,15 +229,14 @@ help: consider using an iterator
error: the loop variable `i` is only used to index `vec`. error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:187:5 --> $DIR/for_loop.rs:187:5
| |
187 | for i in 5...10 { 187 | / for i in 5...10 {
| _____^ starting here...
188 | | 188 | |
189 | | 189 | |
190 | | 190 | |
191 | | 191 | |
192 | | println!("{}", vec[i]); 192 | | println!("{}", vec[i]);
193 | | } 193 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for <item> in vec.iter().take(10 + 1).skip(5) { | for <item> in vec.iter().take(10 + 1).skip(5) {
@@ -255,15 +244,14 @@ help: consider using an iterator
error: the loop variable `i` is used to index `vec` error: the loop variable `i` is used to index `vec`
--> $DIR/for_loop.rs:195:5 --> $DIR/for_loop.rs:195:5
| |
195 | for i in 5..vec.len() { 195 | / for i in 5..vec.len() {
| _____^ starting here...
196 | | 196 | |
197 | | 197 | |
198 | | 198 | |
199 | | 199 | |
200 | | println!("{} {}", vec[i], i); 200 | | println!("{} {}", vec[i], i);
201 | | } 201 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for (i, <item>) in vec.iter().enumerate().skip(5) { | for (i, <item>) in vec.iter().enumerate().skip(5) {
@@ -271,15 +259,14 @@ help: consider using an iterator
error: the loop variable `i` is used to index `vec` error: the loop variable `i` is used to index `vec`
--> $DIR/for_loop.rs:203:5 --> $DIR/for_loop.rs:203:5
| |
203 | for i in 5..10 { 203 | / for i in 5..10 {
| _____^ starting here...
204 | | 204 | |
205 | | 205 | |
206 | | 206 | |
207 | | 207 | |
208 | | println!("{} {}", vec[i], i); 208 | | println!("{} {}", vec[i], i);
209 | | } 209 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using an iterator help: consider using an iterator
| for (i, <item>) in vec.iter().enumerate().take(10).skip(5) { | for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
@@ -287,14 +274,13 @@ help: consider using an iterator
error: this range is empty so this for loop will never run error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:211:5 --> $DIR/for_loop.rs:211:5
| |
211 | for i in 10..0 { 211 | / for i in 10..0 {
| _____^ starting here...
212 | | 212 | |
213 | | 213 | |
214 | | 214 | |
215 | | println!("{}", i); 215 | | println!("{}", i);
216 | | } 216 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/for_loop.rs:90:90 --> $DIR/for_loop.rs:90:90
@@ -307,14 +293,13 @@ help: consider using the following if you are attempting to iterate over this ra
error: this range is empty so this for loop will never run error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:218:5 --> $DIR/for_loop.rs:218:5
| |
218 | for i in 10...0 { 218 | / for i in 10...0 {
| _____^ starting here...
219 | | 219 | |
220 | | 220 | |
221 | | 221 | |
222 | | println!("{}", i); 222 | | println!("{}", i);
223 | | } 223 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using the following if you are attempting to iterate over this range in reverse help: consider using the following if you are attempting to iterate over this range in reverse
| for i in (0...10).rev() { | for i in (0...10).rev() {
@@ -322,13 +307,12 @@ help: consider using the following if you are attempting to iterate over this ra
error: this range is empty so this for loop will never run error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:225:5 --> $DIR/for_loop.rs:225:5
| |
225 | for i in MAX_LEN..0 { 225 | / for i in MAX_LEN..0 {
| _____^ starting here...
226 | | 226 | |
227 | | 227 | |
228 | | println!("{}", i); 228 | | println!("{}", i);
229 | | } 229 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using the following if you are attempting to iterate over this range in reverse help: consider using the following if you are attempting to iterate over this range in reverse
| for i in (0..MAX_LEN).rev() { | for i in (0..MAX_LEN).rev() {
@@ -336,23 +320,21 @@ help: consider using the following if you are attempting to iterate over this ra
error: this range is empty so this for loop will never run error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:231:5 --> $DIR/for_loop.rs:231:5
| |
231 | for i in 5..5 { 231 | / for i in 5..5 {
| _____^ starting here...
232 | | println!("{}", i); 232 | | println!("{}", i);
233 | | } 233 | | }
| |_____^ ...ending here | |_____^
error: this range is empty so this for loop will never run error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:252:5 --> $DIR/for_loop.rs:252:5
| |
252 | for i in 10..5+4 { 252 | / for i in 10..5+4 {
| _____^ starting here...
253 | | 253 | |
254 | | 254 | |
255 | | 255 | |
256 | | println!("{}", i); 256 | | println!("{}", i);
257 | | } 257 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using the following if you are attempting to iterate over this range in reverse help: consider using the following if you are attempting to iterate over this range in reverse
| for i in (5+4..10).rev() { | for i in (5+4..10).rev() {
@@ -360,14 +342,13 @@ help: consider using the following if you are attempting to iterate over this ra
error: this range is empty so this for loop will never run error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:259:5 --> $DIR/for_loop.rs:259:5
| |
259 | for i in (5+2)..(3-1) { 259 | / for i in (5+2)..(3-1) {
| _____^ starting here...
260 | | 260 | |
261 | | 261 | |
262 | | 262 | |
263 | | println!("{}", i); 263 | | println!("{}", i);
264 | | } 264 | | }
| |_____^ ...ending here | |_____^
| |
help: consider using the following if you are attempting to iterate over this range in reverse help: consider using the following if you are attempting to iterate over this range in reverse
| for i in ((3-1)..(5+2)).rev() { | for i in ((3-1)..(5+2)).rev() {
@@ -375,11 +356,10 @@ help: consider using the following if you are attempting to iterate over this ra
error: this range is empty so this for loop will never run error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:266:5 --> $DIR/for_loop.rs:266:5
| |
266 | for i in (5+2)..(8-1) { 266 | / for i in (5+2)..(8-1) {
| _____^ starting here...
267 | | println!("{}", i); 267 | | println!("{}", i);
268 | | } 268 | | }
| |_____^ ...ending here | |_____^
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:289:15 --> $DIR/for_loop.rs:289:15
@@ -553,15 +533,14 @@ error: the variable `_index` is used as a loop counter. Consider using `for (_in
error: you seem to want to iterate on a map's values error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:444:5 --> $DIR/for_loop.rs:444:5
| |
444 | for (_, v) in &m { 444 | / for (_, v) in &m {
| _____^ starting here...
445 | | 445 | |
446 | | 446 | |
447 | | 447 | |
448 | | 448 | |
449 | | let _v = v; 449 | | let _v = v;
450 | | } 450 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/for_loop.rs:90:133 --> $DIR/for_loop.rs:90:133
@@ -574,15 +553,14 @@ help: use the corresponding method
error: you seem to want to iterate on a map's values error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:453:5 --> $DIR/for_loop.rs:453:5
| |
453 | for (_, v) in &*m { 453 | / for (_, v) in &*m {
| _____^ starting here...
454 | | 454 | |
455 | | 455 | |
456 | | 456 | |
... | ... |
460 | | // `in *m.values()` as we used to 460 | | // `in *m.values()` as we used to
461 | | } 461 | | }
| |_____^ ...ending here | |_____^
| |
help: use the corresponding method help: use the corresponding method
| for v in (*m).values() { | for v in (*m).values() {
@@ -590,15 +568,14 @@ help: use the corresponding method
error: you seem to want to iterate on a map's values error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:464:5 --> $DIR/for_loop.rs:464:5
| |
464 | for (_, v) in &mut m { 464 | / for (_, v) in &mut m {
| _____^ starting here...
465 | | 465 | |
466 | | 466 | |
467 | | 467 | |
468 | | 468 | |
469 | | let _v = v; 469 | | let _v = v;
470 | | } 470 | | }
| |_____^ ...ending here | |_____^
| |
help: use the corresponding method help: use the corresponding method
| for v in m.values_mut() { | for v in m.values_mut() {
@@ -606,15 +583,14 @@ help: use the corresponding method
error: you seem to want to iterate on a map's values error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:473:5 --> $DIR/for_loop.rs:473:5
| |
473 | for (_, v) in &mut *m { 473 | / for (_, v) in &mut *m {
| _____^ starting here...
474 | | 474 | |
475 | | 475 | |
476 | | 476 | |
477 | | 477 | |
478 | | let _v = v; 478 | | let _v = v;
479 | | } 479 | | }
| |_____^ ...ending here | |_____^
| |
help: use the corresponding method help: use the corresponding method
| for v in (*m).values_mut() { | for v in (*m).values_mut() {
@@ -622,15 +598,14 @@ help: use the corresponding method
error: you seem to want to iterate on a map's keys error: you seem to want to iterate on a map's keys
--> $DIR/for_loop.rs:483:5 --> $DIR/for_loop.rs:483:5
| |
483 | for (k, _value) in rm { 483 | / for (k, _value) in rm {
| _____^ starting here...
484 | | 484 | |
485 | | 485 | |
486 | | 486 | |
487 | | 487 | |
488 | | let _k = k; 488 | | let _k = k;
489 | | } 489 | | }
| |_____^ ...ending here | |_____^
| |
help: use the corresponding method help: use the corresponding method
| for k in rm.keys() { | for k in rm.keys() {

View File

@@ -34,11 +34,11 @@ error: this is an `else if` but the formatting might hide it
--> $DIR/formatting.rs:45:6 --> $DIR/formatting.rs:45:6
| |
45 | } else 45 | } else
| ______^ starting here... | ______^
46 | | 46 | |
47 | | 47 | |
48 | | if foo() { // the span of the above error should continue here 48 | | if foo() { // the span of the above error should continue here
| |____^ ...ending here | |____^
| |
= note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)] = note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)]
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if` = note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
@@ -47,12 +47,12 @@ error: this is an `else if` but the formatting might hide it
--> $DIR/formatting.rs:52:6 --> $DIR/formatting.rs:52:6
| |
52 | } 52 | }
| ______^ starting here... | ______^
53 | | 53 | |
54 | | 54 | |
55 | | else 55 | | else
56 | | if foo() { // the span of the above error should continue here 56 | | if foo() { // the span of the above error should continue here
| |____^ ...ending here | |____^
| |
= note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)] = note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)]
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if` = note: to remove this lint, remove the `else` or remove the new line between `else` and `if`

View File

@@ -1,11 +1,10 @@
error: this function has too many arguments (8/7) error: this function has too many arguments (8/7)
--> $DIR/functions.rs:11:1 --> $DIR/functions.rs:11:1
| |
11 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) { 11 | / fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {
| _^ starting here...
12 | | 12 | |
13 | | } 13 | | }
| |_^ ...ending here | |_^
| |
= note: #[deny(too_many_arguments)] implied by #[deny(clippy)] = note: #[deny(too_many_arguments)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here

View File

@@ -1,13 +1,12 @@
error: Unnecessary boolean `not` operation error: Unnecessary boolean `not` operation
--> $DIR/if_not_else.rs:9:5 --> $DIR/if_not_else.rs:9:5
| |
9 | if !bla() { 9 | / if !bla() {
| _____^ starting here...
10 | | println!("Bugs"); 10 | | println!("Bugs");
11 | | } else { 11 | | } else {
12 | | println!("Bunny"); 12 | | println!("Bunny");
13 | | } 13 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/if_not_else.rs:4:9 --> $DIR/if_not_else.rs:4:9
@@ -19,13 +18,12 @@ note: lint level defined here
error: Unnecessary `!=` operation error: Unnecessary `!=` operation
--> $DIR/if_not_else.rs:14:5 --> $DIR/if_not_else.rs:14:5
| |
14 | if 4 != 5 { 14 | / if 4 != 5 {
| _____^ starting here...
15 | | println!("Bugs"); 15 | | println!("Bugs");
16 | | } else { 16 | | } else {
17 | | println!("Bunny"); 17 | | println!("Bunny");
18 | | } 18 | | }
| |_____^ ...ending here | |_____^
| |
= help: change to `==` and swap the blocks of the if/else = help: change to `==` and swap the blocks of the if/else

View File

@@ -1,13 +1,12 @@
error: item `PubOne` has a public `len` method but no corresponding `is_empty` method error: item `PubOne` has a public `len` method but no corresponding `is_empty` method
--> $DIR/len_zero.rs:9:1 --> $DIR/len_zero.rs:9:1
| |
9 | impl PubOne { 9 | / impl PubOne {
| _^ starting here...
10 | | pub fn len(self: &Self) -> isize { 10 | | pub fn len(self: &Self) -> isize {
11 | | 1 11 | | 1
12 | | } 12 | | }
13 | | } 13 | | }
| |_^ ...ending here | |_^
| |
note: lint level defined here note: lint level defined here
--> $DIR/len_zero.rs:4:9 --> $DIR/len_zero.rs:4:9
@@ -18,37 +17,34 @@ note: lint level defined here
error: trait `PubTraitsToo` has a `len` method but no `is_empty` method error: trait `PubTraitsToo` has a `len` method but no `is_empty` method
--> $DIR/len_zero.rs:55:1 --> $DIR/len_zero.rs:55:1
| |
55 | pub trait PubTraitsToo { 55 | / pub trait PubTraitsToo {
| _^ starting here...
56 | | fn len(self: &Self) -> isize; 56 | | fn len(self: &Self) -> isize;
57 | | } 57 | | }
| |_^ ...ending here | |_^
error: item `HasIsEmpty` has a public `len` method but a private `is_empty` method error: item `HasIsEmpty` has a public `len` method but a private `is_empty` method
--> $DIR/len_zero.rs:89:1 --> $DIR/len_zero.rs:89:1
| |
89 | impl HasIsEmpty { 89 | / impl HasIsEmpty {
| _^ starting here...
90 | | pub fn len(self: &Self) -> isize { 90 | | pub fn len(self: &Self) -> isize {
91 | | 1 91 | | 1
92 | | } 92 | | }
... | ... |
96 | | } 96 | | }
97 | | } 97 | | }
| |_^ ...ending here | |_^
error: item `HasWrongIsEmpty` has a public `len` method but no corresponding `is_empty` method error: item `HasWrongIsEmpty` has a public `len` method but no corresponding `is_empty` method
--> $DIR/len_zero.rs:118:1 --> $DIR/len_zero.rs:118:1
| |
118 | impl HasWrongIsEmpty { 118 | / impl HasWrongIsEmpty {
| _^ starting here...
119 | | pub fn len(self: &Self) -> isize { 119 | | pub fn len(self: &Self) -> isize {
120 | | 1 120 | | 1
121 | | } 121 | | }
... | ... |
125 | | } 125 | | }
126 | | } 126 | | }
| |_^ ...ending here | |_^
error: length comparison to zero error: length comparison to zero
--> $DIR/len_zero.rs:130:8 --> $DIR/len_zero.rs:130:8

View File

@@ -1,15 +1,14 @@
error: `if _ { .. } else { .. }` is an expression error: `if _ { .. } else { .. }` is an expression
--> $DIR/let_if_seq.rs:57:5 --> $DIR/let_if_seq.rs:57:5
| |
57 | let mut foo = 0; 57 | / let mut foo = 0;
| _____^ starting here...
58 | | 58 | |
59 | | 59 | |
60 | | 60 | |
61 | | if f() { 61 | | if f() {
62 | | foo = 42; 62 | | foo = 42;
63 | | } 63 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/let_if_seq.rs:5:9 --> $DIR/let_if_seq.rs:5:9
@@ -23,15 +22,14 @@ help: it is more idiomatic to write
error: `if _ { .. } else { .. }` is an expression error: `if _ { .. } else { .. }` is an expression
--> $DIR/let_if_seq.rs:65:5 --> $DIR/let_if_seq.rs:65:5
| |
65 | let mut bar = 0; 65 | / let mut bar = 0;
| _____^ starting here...
66 | | 66 | |
67 | | 67 | |
68 | | 68 | |
... | ... |
74 | | f(); 74 | | f();
75 | | } 75 | | }
| |_____^ ...ending here | |_____^
| |
help: it is more idiomatic to write help: it is more idiomatic to write
| let <mut> bar = if f() { ..; 42 } else { ..; 0 }; | let <mut> bar = if f() { ..; 42 } else { ..; 0 };
@@ -40,15 +38,14 @@ help: it is more idiomatic to write
error: `if _ { .. } else { .. }` is an expression error: `if _ { .. } else { .. }` is an expression
--> $DIR/let_if_seq.rs:77:5 --> $DIR/let_if_seq.rs:77:5
| |
77 | let quz; 77 | / let quz;
| _____^ starting here...
78 | | 78 | |
79 | | 79 | |
80 | | 80 | |
... | ... |
85 | | quz = 0; 85 | | quz = 0;
86 | | } 86 | | }
| |_____^ ...ending here | |_____^
| |
help: it is more idiomatic to write help: it is more idiomatic to write
| let quz = if f() { 42 } else { 0 }; | let quz = if f() { 42 } else { 0 };
@@ -56,15 +53,14 @@ help: it is more idiomatic to write
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
| |
111 | let mut baz = 0; 111 | / let mut baz = 0;
| _____^ starting here...
112 | | 112 | |
113 | | 113 | |
114 | | 114 | |
115 | | if f() { 115 | | if f() {
116 | | baz = 42; 116 | | baz = 42;
117 | | } 117 | | }
| |_____^ ...ending here | |_____^
| |
help: it is more idiomatic to write help: it is more idiomatic to write
| let <mut> baz = if f() { 42 } else { 0 }; | let <mut> baz = if f() { 42 } else { 0 };

View File

@@ -128,5 +128,29 @@ fn elided_input_named_output<'a>(_arg: &str) -> &'a str { unimplemented!() }
fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() } fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() }
fn trait_bound<'a, T: WithLifetime<'a>>(_: &'a u8, _: T) { unimplemented!() } fn trait_bound<'a, T: WithLifetime<'a>>(_: &'a u8, _: T) { unimplemented!() }
// don't warn on these, see #292
fn trait_bound_bug<'a, T: WithLifetime<'a>>() { unimplemented!() }
// #740
struct Test {
vec: Vec<usize>,
}
impl Test {
fn iter<'a>(&'a self) -> Box<Iterator<Item = usize> + 'a> {
unimplemented!()
}
}
trait LintContext<'a> {}
fn f<'a, T: LintContext<'a>>(_: &T) {}
fn test<'a>(x: &'a [u8]) -> u8 {
let y: &'a u8 = &x[5];
*y
}
fn main() { fn main() {
} }

View File

@@ -43,11 +43,10 @@ error: explicit lifetimes given in parameter types where they could be elided
error: explicit lifetimes given in parameter types where they could be elided error: explicit lifetimes given in parameter types where they could be elided
--> $DIR/lifetimes.rs:58:1 --> $DIR/lifetimes.rs:58:1
| |
58 | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> 58 | / fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I>
| _^ starting here...
59 | | where for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I> 59 | | where for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I>
60 | | { unreachable!() } 60 | | { unreachable!() }
| |__________________^ ...ending here | |__________________^
error: explicit lifetimes given in parameter types where they could be elided error: explicit lifetimes given in parameter types where they could be elided
--> $DIR/lifetimes.rs:67:5 --> $DIR/lifetimes.rs:67:5

View File

@@ -1,15 +1,14 @@
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:26:5 --> $DIR/matches.rs:26:5
| |
26 | match ExprNode::Butterflies { 26 | / match ExprNode::Butterflies {
| _____^ starting here...
27 | | 27 | |
28 | | 28 | |
29 | | 29 | |
30 | | ExprNode::ExprAddrOf => Some(&NODE), 30 | | ExprNode::ExprAddrOf => Some(&NODE),
31 | | _ => { let x = 5; None }, 31 | | _ => { let x = 5; None },
32 | | } 32 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/matches.rs:7:9 --> $DIR/matches.rs:7:9
@@ -22,15 +21,14 @@ help: try this
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
| |
38 | match x { 38 | / match x {
| _____^ starting here...
39 | | 39 | |
40 | | 40 | |
41 | | 41 | |
42 | | Some(y) => { println!("{:?}", y); } 42 | | Some(y) => { println!("{:?}", y); }
43 | | _ => () 43 | | _ => ()
44 | | }; 44 | | };
| |_____^ ...ending here | |_____^
| |
= 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
@@ -44,15 +42,14 @@ help: try this
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
| |
47 | match z { 47 | / match z {
| _____^ starting here...
48 | | 48 | |
49 | | 49 | |
50 | | 50 | |
51 | | (2...3, 7...9) => dummy(), 51 | | (2...3, 7...9) => dummy(),
52 | | _ => {} 52 | | _ => {}
53 | | }; 53 | | };
| |_____^ ...ending here | |_____^
| |
= note: #[deny(single_match)] implied by #[deny(clippy)] = note: #[deny(single_match)] implied by #[deny(clippy)]
help: try this help: try this
@@ -61,15 +58,14 @@ help: try this
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
| |
72 | match x { 72 | / match x {
| _____^ starting here...
73 | | 73 | |
74 | | 74 | |
75 | | 75 | |
76 | | Some(y) => dummy(), 76 | | Some(y) => dummy(),
77 | | None => () 77 | | None => ()
78 | | }; 78 | | };
| |_____^ ...ending here | |_____^
| |
= note: #[deny(single_match)] implied by #[deny(clippy)] = note: #[deny(single_match)] implied by #[deny(clippy)]
help: try this help: try this
@@ -78,15 +74,14 @@ help: try this
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
| |
80 | match y { 80 | / match y {
| _____^ starting here...
81 | | 81 | |
82 | | 82 | |
83 | | 83 | |
84 | | Ok(y) => dummy(), 84 | | Ok(y) => dummy(),
85 | | Err(..) => () 85 | | Err(..) => ()
86 | | }; 86 | | };
| |_____^ ...ending here | |_____^
| |
= note: #[deny(single_match)] implied by #[deny(clippy)] = note: #[deny(single_match)] implied by #[deny(clippy)]
help: try this help: try this
@@ -95,15 +90,14 @@ help: try this
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
| |
90 | match c { 90 | / match c {
| _____^ starting here...
91 | | 91 | |
92 | | 92 | |
93 | | 93 | |
94 | | Cow::Borrowed(..) => dummy(), 94 | | Cow::Borrowed(..) => dummy(),
95 | | Cow::Owned(..) => (), 95 | | Cow::Owned(..) => (),
96 | | }; 96 | | };
| |_____^ ...ending here | |_____^
| |
= note: #[deny(single_match)] implied by #[deny(clippy)] = note: #[deny(single_match)] implied by #[deny(clippy)]
help: try this help: try this
@@ -112,15 +106,14 @@ help: try this
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
| |
114 | match test { 114 | / match test {
| _____^ starting here...
115 | | 115 | |
116 | | 116 | |
117 | | 117 | |
118 | | true => 0, 118 | | true => 0,
119 | | false => 42, 119 | | false => 42,
120 | | }; 120 | | };
| |_____^ ...ending here | |_____^
| |
= 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
@@ -134,15 +127,14 @@ help: consider using an if/else expression
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
| |
123 | match option == 1 { 123 | / match option == 1 {
| _____^ starting here...
124 | | 124 | |
125 | | 125 | |
126 | | 126 | |
127 | | true => 1, 127 | | true => 1,
128 | | false => 0, 128 | | false => 0,
129 | | }; 129 | | };
| |_____^ ...ending here | |_____^
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = note: #[deny(match_bool)] implied by #[deny(clippy)]
help: consider using an if/else expression help: consider using an if/else expression
@@ -151,15 +143,14 @@ help: consider using an if/else expression
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
| |
131 | match test { 131 | / match test {
| _____^ starting here...
132 | | 132 | |
133 | | 133 | |
134 | | 134 | |
135 | | true => (), 135 | | true => (),
136 | | false => { println!("Noooo!"); } 136 | | false => { println!("Noooo!"); }
137 | | }; 137 | | };
| |_____^ ...ending here | |_____^
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = note: #[deny(match_bool)] implied by #[deny(clippy)]
help: consider using an if/else expression help: consider using an if/else expression
@@ -168,15 +159,14 @@ help: consider using an if/else expression
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
| |
139 | match test { 139 | / match test {
| _____^ starting here...
140 | | 140 | |
141 | | 141 | |
142 | | 142 | |
143 | | false => { println!("Noooo!"); } 143 | | false => { println!("Noooo!"); }
144 | | _ => (), 144 | | _ => (),
145 | | }; 145 | | };
| |_____^ ...ending here | |_____^
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = note: #[deny(match_bool)] implied by #[deny(clippy)]
help: consider using an if/else expression help: consider using an if/else expression
@@ -185,15 +175,14 @@ help: consider using an if/else expression
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
| |
147 | match test && test { 147 | / match test && test {
| _____^ starting here...
148 | | 148 | |
149 | | 149 | |
150 | | 150 | |
... | ... |
153 | | _ => (), 153 | | _ => (),
154 | | }; 154 | | };
| |_____^ ...ending here | |_____^
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = note: #[deny(match_bool)] implied by #[deny(clippy)]
help: consider using an if/else expression help: consider using an if/else expression
@@ -215,15 +204,14 @@ note: lint level defined here
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:156:5 --> $DIR/matches.rs:156:5
| |
156 | match test { 156 | / match test {
| _____^ starting here...
157 | | 157 | |
158 | | 158 | |
159 | | 159 | |
160 | | false => { println!("Noooo!"); } 160 | | false => { println!("Noooo!"); }
161 | | true => { println!("Yes!"); } 161 | | true => { println!("Yes!"); }
162 | | }; 162 | | };
| |_____^ ...ending here | |_____^
| |
= note: #[deny(match_bool)] implied by #[deny(clippy)] = note: #[deny(match_bool)] implied by #[deny(clippy)]
help: consider using an if/else expression help: consider using an if/else expression
@@ -232,15 +220,14 @@ help: consider using an if/else expression
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
| |
175 | match v { 175 | / match v {
| _________^ starting here...
176 | | 176 | |
177 | | 177 | |
178 | | 178 | |
179 | | &Some(v) => println!("{:?}", v), 179 | | &Some(v) => println!("{:?}", v),
180 | | &None => println!("none"), 180 | | &None => println!("none"),
181 | | } 181 | | }
| |_________^ ...ending here | |_________^
| |
= note: #[deny(match_ref_pats)] implied by #[deny(clippy)] = note: #[deny(match_ref_pats)] implied by #[deny(clippy)]
note: lint level defined here note: lint level defined here
@@ -254,15 +241,14 @@ help: instead of prefixing all patterns with `&`, you can dereference the expres
error: you don't need to add `&` to all patterns error: you don't need to add `&` to all patterns
--> $DIR/matches.rs:188:5 --> $DIR/matches.rs:188:5
| |
188 | match tup { 188 | / match tup {
| _____^ starting here...
189 | | 189 | |
190 | | 190 | |
191 | | 191 | |
192 | | &(v, 1) => println!("{}", v), 192 | | &(v, 1) => println!("{}", v),
193 | | _ => println!("none"), 193 | | _ => println!("none"),
194 | | } 194 | | }
| |_____^ ...ending here | |_____^
| |
= note: #[deny(match_ref_pats)] implied by #[deny(clippy)] = note: #[deny(match_ref_pats)] implied by #[deny(clippy)]
help: instead of prefixing all patterns with `&`, you can dereference the expression help: instead of prefixing all patterns with `&`, you can dereference the expression
@@ -271,15 +257,14 @@ help: instead of prefixing all patterns with `&`, you can dereference the expres
error: you don't need to add `&` to both the expression and the patterns error: you don't need to add `&` to both the expression and the patterns
--> $DIR/matches.rs:197:5 --> $DIR/matches.rs:197:5
| |
197 | match &w { 197 | / match &w {
| _____^ starting here...
198 | | 198 | |
199 | | 199 | |
200 | | 200 | |
201 | | &Some(v) => println!("{:?}", v), 201 | | &Some(v) => println!("{:?}", v),
202 | | &None => println!("none"), 202 | | &None => println!("none"),
203 | | } 203 | | }
| |_____^ ...ending here | |_____^
| |
= note: #[deny(match_ref_pats)] implied by #[deny(clippy)] = note: #[deny(match_ref_pats)] implied by #[deny(clippy)]
help: try help: try
@@ -288,14 +273,13 @@ help: try
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
| |
211 | if let &None = a { 211 | / if let &None = a {
| _____^ starting here...
212 | | 212 | |
213 | | 213 | |
214 | | 214 | |
215 | | println!("none"); 215 | | println!("none");
216 | | } 216 | | }
| |_____^ ...ending here | |_____^
| |
= note: #[deny(match_ref_pats)] implied by #[deny(clippy)] = note: #[deny(match_ref_pats)] implied by #[deny(clippy)]
help: instead of prefixing all patterns with `&`, you can dereference the expression help: instead of prefixing all patterns with `&`, you can dereference the expression
@@ -304,14 +288,13 @@ help: instead of prefixing all patterns with `&`, you can dereference the expres
error: you don't need to add `&` to both the expression and the patterns error: you don't need to add `&` to both the expression and the patterns
--> $DIR/matches.rs:219:5 --> $DIR/matches.rs:219:5
| |
219 | if let &None = &b { 219 | / if let &None = &b {
| _____^ starting here...
220 | | 220 | |
221 | | 221 | |
222 | | 222 | |
223 | | println!("none"); 223 | | println!("none");
224 | | } 224 | | }
| |_____^ ...ending here | |_____^
| |
= note: #[deny(match_ref_pats)] implied by #[deny(clippy)] = note: #[deny(match_ref_pats)] implied by #[deny(clippy)]
help: try help: try

View File

@@ -65,10 +65,10 @@ error: called `map(f).unwrap_or(a)` on an Option value. This can be done more di
--> $DIR/methods.rs:99:13 --> $DIR/methods.rs:99:13
| |
99 | let _ = opt.map(|x| x + 1) 99 | let _ = opt.map(|x| x + 1)
| _____________^ starting here... | _____________^
100 | | 100 | |
101 | | .unwrap_or(0); // should lint even though this call is on a separate line 101 | | .unwrap_or(0); // should lint even though this call is on a separate line
| |____________________________^ ...ending here | |____________________________^
| |
= note: #[deny(option_map_unwrap_or)] implied by #[deny(clippy_pedantic)] = note: #[deny(option_map_unwrap_or)] implied by #[deny(clippy_pedantic)]
note: lint level defined here note: lint level defined here
@@ -82,11 +82,11 @@ error: called `map(f).unwrap_or(a)` on an Option value. This can be done more di
--> $DIR/methods.rs:103:13 --> $DIR/methods.rs:103:13
| |
103 | let _ = opt.map(|x| { 103 | let _ = opt.map(|x| {
| _____________^ starting here... | _____________^
104 | | x + 1 104 | | x + 1
105 | | } 105 | | }
106 | | ).unwrap_or(0); 106 | | ).unwrap_or(0);
| |____________________________^ ...ending here | |____________________________^
| |
= note: #[deny(option_map_unwrap_or)] implied by #[deny(clippy_pedantic)] = note: #[deny(option_map_unwrap_or)] implied by #[deny(clippy_pedantic)]
@@ -94,11 +94,11 @@ error: called `map(f).unwrap_or(a)` on an Option value. This can be done more di
--> $DIR/methods.rs:107:13 --> $DIR/methods.rs:107:13
| |
107 | let _ = opt.map(|x| x + 1) 107 | let _ = opt.map(|x| x + 1)
| _____________^ starting here... | _____________^
108 | | .unwrap_or({ 108 | | .unwrap_or({
109 | | 0 109 | | 0
110 | | }); 110 | | });
| |__________________^ ...ending here | |__________________^
| |
= note: #[deny(option_map_unwrap_or)] implied by #[deny(clippy_pedantic)] = note: #[deny(option_map_unwrap_or)] implied by #[deny(clippy_pedantic)]
@@ -106,10 +106,10 @@ error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done mo
--> $DIR/methods.rs:116:13 --> $DIR/methods.rs:116:13
| |
116 | let _ = opt.map(|x| x + 1) 116 | let _ = opt.map(|x| x + 1)
| _____________^ starting here... | _____________^
117 | | 117 | |
118 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line 118 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line
| |____________________________________^ ...ending here | |____________________________________^
| |
= note: #[deny(option_map_unwrap_or_else)] implied by #[deny(clippy_pedantic)] = note: #[deny(option_map_unwrap_or_else)] implied by #[deny(clippy_pedantic)]
note: lint level defined here note: lint level defined here
@@ -123,11 +123,11 @@ error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done mo
--> $DIR/methods.rs:120:13 --> $DIR/methods.rs:120:13
| |
120 | let _ = opt.map(|x| { 120 | let _ = opt.map(|x| {
| _____________^ starting here... | _____________^
121 | | x + 1 121 | | x + 1
122 | | } 122 | | }
123 | | ).unwrap_or_else(|| 0); 123 | | ).unwrap_or_else(|| 0);
| |____________________________________^ ...ending here | |____________________________________^
| |
= note: #[deny(option_map_unwrap_or_else)] implied by #[deny(clippy_pedantic)] = note: #[deny(option_map_unwrap_or_else)] implied by #[deny(clippy_pedantic)]
@@ -135,11 +135,11 @@ error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done mo
--> $DIR/methods.rs:124:13 --> $DIR/methods.rs:124:13
| |
124 | let _ = opt.map(|x| x + 1) 124 | let _ = opt.map(|x| x + 1)
| _____________^ starting here... | _____________^
125 | | .unwrap_or_else(|| 125 | | .unwrap_or_else(||
126 | | 0 126 | | 0
127 | | ); 127 | | );
| |_________________^ ...ending here | |_________________^
| |
= note: #[deny(option_map_unwrap_or_else)] implied by #[deny(clippy_pedantic)] = note: #[deny(option_map_unwrap_or_else)] implied by #[deny(clippy_pedantic)]
@@ -161,11 +161,11 @@ error: called `filter(p).next()` on an `Iterator`. This is more succinctly expre
--> $DIR/methods.rs:201:13 --> $DIR/methods.rs:201:13
| |
201 | let _ = v.iter().filter(|&x| { 201 | let _ = v.iter().filter(|&x| {
| _____________^ starting here... | _____________^
202 | | *x < 0 202 | | *x < 0
203 | | } 203 | | }
204 | | ).next(); 204 | | ).next();
| |___________________________^ ...ending here | |___________________________^
| |
= note: #[deny(filter_next)] implied by #[deny(clippy)] = note: #[deny(filter_next)] implied by #[deny(clippy)]
@@ -187,11 +187,11 @@ error: called `is_some()` after searching an `Iterator` with find. This is more
--> $DIR/methods.rs:221:13 --> $DIR/methods.rs:221:13
| |
221 | let _ = v.iter().find(|&x| { 221 | let _ = v.iter().find(|&x| {
| _____________^ starting here... | _____________^
222 | | *x < 0 222 | | *x < 0
223 | | } 223 | | }
224 | | ).is_some(); 224 | | ).is_some();
| |______________________________^ ...ending here | |______________________________^
| |
= note: #[deny(search_is_some)] implied by #[deny(clippy)] = note: #[deny(search_is_some)] implied by #[deny(clippy)]
@@ -208,11 +208,11 @@ error: called `is_some()` after searching an `Iterator` with position. This is m
--> $DIR/methods.rs:232:13 --> $DIR/methods.rs:232:13
| |
232 | let _ = v.iter().position(|&x| { 232 | let _ = v.iter().position(|&x| {
| _____________^ starting here... | _____________^
233 | | x < 0 233 | | x < 0
234 | | } 234 | | }
235 | | ).is_some(); 235 | | ).is_some();
| |______________________________^ ...ending here | |______________________________^
| |
= note: #[deny(search_is_some)] implied by #[deny(clippy)] = note: #[deny(search_is_some)] implied by #[deny(clippy)]
@@ -229,11 +229,11 @@ error: called `is_some()` after searching an `Iterator` with rposition. This is
--> $DIR/methods.rs:243:13 --> $DIR/methods.rs:243:13
| |
243 | let _ = v.iter().rposition(|&x| { 243 | let _ = v.iter().rposition(|&x| {
| _____________^ starting here... | _____________^
244 | | x < 0 244 | | x < 0
245 | | } 245 | | }
246 | | ).is_some(); 246 | | ).is_some();
| |______________________________^ ...ending here | |______________________________^
| |
= note: #[deny(search_is_some)] implied by #[deny(clippy)] = note: #[deny(search_is_some)] implied by #[deny(clippy)]

View File

@@ -19,12 +19,11 @@ error: missing documentation for a type alias
error: missing documentation for a struct error: missing documentation for a struct
--> $DIR/missing-doc.rs:29:1 --> $DIR/missing-doc.rs:29:1
| |
29 | struct Foo { 29 | / struct Foo {
| _^ starting here...
30 | | a: isize, 30 | | a: isize,
31 | | b: isize, 31 | | b: isize,
32 | | } 32 | | }
| |_^ ...ending here | |_^
error: missing documentation for a struct field error: missing documentation for a struct field
--> $DIR/missing-doc.rs:30:5 --> $DIR/missing-doc.rs:30:5
@@ -41,12 +40,11 @@ error: missing documentation for a struct field
error: missing documentation for a struct error: missing documentation for a struct
--> $DIR/missing-doc.rs:34:1 --> $DIR/missing-doc.rs:34:1
| |
34 | pub struct PubFoo { 34 | / pub struct PubFoo {
| _^ starting here...
35 | | pub a: isize, 35 | | pub a: isize,
36 | | b: isize, 36 | | b: isize,
37 | | } 37 | | }
| |_^ ...ending here | |_^
error: missing documentation for a struct field error: missing documentation for a struct field
--> $DIR/missing-doc.rs:35:5 --> $DIR/missing-doc.rs:35:5
@@ -87,12 +85,11 @@ error: missing documentation for a function
error: missing documentation for a trait error: missing documentation for a trait
--> $DIR/missing-doc.rs:68:1 --> $DIR/missing-doc.rs:68:1
| |
68 | pub trait C { 68 | / pub trait C {
| _^ starting here...
69 | | fn foo(&self); 69 | | fn foo(&self);
70 | | fn foo_with_impl(&self) {} 70 | | fn foo_with_impl(&self) {}
71 | | } 71 | | }
| |_^ ...ending here | |_^
error: missing documentation for a trait method error: missing documentation for a trait method
--> $DIR/missing-doc.rs:69:5 --> $DIR/missing-doc.rs:69:5
@@ -145,25 +142,23 @@ error: missing documentation for a method
error: missing documentation for an enum error: missing documentation for an enum
--> $DIR/missing-doc.rs:126:1 --> $DIR/missing-doc.rs:126:1
| |
126 | enum Baz { 126 | / enum Baz {
| _^ starting here...
127 | | BazA { 127 | | BazA {
128 | | a: isize, 128 | | a: isize,
129 | | b: isize 129 | | b: isize
130 | | }, 130 | | },
131 | | BarB 131 | | BarB
132 | | } 132 | | }
| |_^ ...ending here | |_^
error: missing documentation for a variant error: missing documentation for a variant
--> $DIR/missing-doc.rs:127:5 --> $DIR/missing-doc.rs:127:5
| |
127 | BazA { 127 | / BazA {
| _____^ starting here...
128 | | a: isize, 128 | | a: isize,
129 | | b: isize 129 | | b: isize
130 | | }, 130 | | },
| |_____^ ...ending here | |_____^
error: missing documentation for a struct field error: missing documentation for a struct field
--> $DIR/missing-doc.rs:128:9 --> $DIR/missing-doc.rs:128:9
@@ -186,22 +181,20 @@ error: missing documentation for a variant
error: missing documentation for an enum error: missing documentation for an enum
--> $DIR/missing-doc.rs:134:1 --> $DIR/missing-doc.rs:134:1
| |
134 | pub enum PubBaz { 134 | / pub enum PubBaz {
| _^ starting here...
135 | | PubBazA { 135 | | PubBazA {
136 | | a: isize, 136 | | a: isize,
137 | | }, 137 | | },
138 | | } 138 | | }
| |_^ ...ending here | |_^
error: missing documentation for a variant error: missing documentation for a variant
--> $DIR/missing-doc.rs:135:5 --> $DIR/missing-doc.rs:135:5
| |
135 | PubBazA { 135 | / PubBazA {
| _____^ starting here...
136 | | a: isize, 136 | | a: isize,
137 | | }, 137 | | },
| |_____^ ...ending here | |_____^
error: missing documentation for a struct field error: missing documentation for a struct field
--> $DIR/missing-doc.rs:136:9 --> $DIR/missing-doc.rs:136:9
@@ -236,15 +229,14 @@ error: missing documentation for a static
error: missing documentation for a module error: missing documentation for a module
--> $DIR/missing-doc.rs:180:1 --> $DIR/missing-doc.rs:180:1
| |
180 | mod internal_impl { 180 | / mod internal_impl {
| _^ starting here...
181 | | /// dox 181 | | /// dox
182 | | pub fn documented() {} 182 | | pub fn documented() {}
183 | | pub fn undocumented1() {} 183 | | pub fn undocumented1() {}
... | ... |
192 | | } 192 | | }
193 | | } 193 | | }
| |_^ ...ending here | |_^
error: missing documentation for a function error: missing documentation for a function
--> $DIR/missing-doc.rs:183:5 --> $DIR/missing-doc.rs:183:5

View File

@@ -1,11 +1,10 @@
error: module has the same name as its containing module error: module has the same name as its containing module
--> $DIR/module_inception.rs:7:9 --> $DIR/module_inception.rs:7:9
| |
7 | mod bar { 7 | / mod bar {
| _________^ starting here...
8 | | mod foo {} 8 | | mod foo {}
9 | | } 9 | | }
| |_________^ ...ending here | |_________^
| |
note: lint level defined here note: lint level defined here
--> $DIR/module_inception.rs:3:9 --> $DIR/module_inception.rs:3:9
@@ -16,11 +15,10 @@ note: lint level defined here
error: module has the same name as its containing module error: module has the same name as its containing module
--> $DIR/module_inception.rs:12:5 --> $DIR/module_inception.rs:12:5
| |
12 | mod foo { 12 | / mod foo {
| _____^ starting here...
13 | | mod bar {} 13 | | mod bar {}
14 | | } 14 | | }
| |_____^ ...ending here | |_____^
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@@ -1,12 +1,11 @@
error: this loop never actually loops error: this loop never actually loops
--> $DIR/never_loop.rs:8:5 --> $DIR/never_loop.rs:8:5
| |
8 | loop { 8 | / loop {
| _____^ starting here...
9 | | println!("This is only ever printed once"); 9 | | println!("This is only ever printed once");
10 | | break; 10 | | break;
11 | | } 11 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/never_loop.rs:4:9 --> $DIR/never_loop.rs:4:9
@@ -17,25 +16,23 @@ note: lint level defined here
error: this loop never actually loops error: this loop never actually loops
--> $DIR/never_loop.rs:21:5 --> $DIR/never_loop.rs:21:5
| |
21 | loop { 21 | / loop {
| _____^ starting here...
22 | | loop { 22 | | loop {
23 | | // another one 23 | | // another one
24 | | break; 24 | | break;
25 | | } 25 | | }
26 | | break; 26 | | break;
27 | | } 27 | | }
| |_____^ ...ending here | |_____^
error: this loop never actually loops error: this loop never actually loops
--> $DIR/never_loop.rs:22:9 --> $DIR/never_loop.rs:22:9
| |
22 | loop { 22 | / loop {
| _________^ starting here...
23 | | // another one 23 | | // another one
24 | | break; 24 | | break;
25 | | } 25 | | }
| |_________^ ...ending here | |_________^
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View File

@@ -1,14 +1,13 @@
error: Matching on `Some` with `ok()` is redundant error: Matching on `Some` with `ok()` is redundant
--> $DIR/ok_if_let.rs:7:5 --> $DIR/ok_if_let.rs:7:5
| |
7 | if let Some(y) = x.parse().ok() { 7 | / if let Some(y) = x.parse().ok() {
| _____^ starting here...
8 | | 8 | |
9 | | y 9 | | y
10 | | } else { 10 | | } else {
11 | | 0 11 | | 0
12 | | } 12 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/ok_if_let.rs:4:9 --> $DIR/ok_if_let.rs:4:9

View File

@@ -1,14 +1,13 @@
error: you should not implement `visit_string` without also implementing `visit_str` error: you should not implement `visit_string` without also implementing `visit_str`
--> $DIR/serde.rs:39:5 --> $DIR/serde.rs:39:5
| |
39 | fn visit_string<E>(self, _v: String) -> Result<Self::Value, E> 39 | / fn visit_string<E>(self, _v: String) -> Result<Self::Value, E>
| _____^ starting here...
40 | | 40 | |
41 | | where E: serde::de::Error, 41 | | where E: serde::de::Error,
42 | | { 42 | | {
43 | | unimplemented!() 43 | | unimplemented!()
44 | | } 44 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/serde.rs:3:9 --> $DIR/serde.rs:3:9

View File

@@ -1,11 +1,10 @@
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:11:5 --> $DIR/swap.rs:11:5
| |
11 | let temp = foo[0]; 11 | / let temp = foo[0];
| _____^ starting here...
12 | | foo[0] = foo[1]; 12 | | foo[0] = foo[1];
13 | | foo[1] = temp; 13 | | foo[1] = temp;
| |_________________^ ...ending here | |_________________^
| |
= 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
@@ -19,11 +18,10 @@ help: try
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
| |
23 | let temp = foo[0]; 23 | / let temp = foo[0];
| _____^ starting here...
24 | | foo[0] = foo[1]; 24 | | foo[0] = foo[1];
25 | | foo[1] = temp; 25 | | foo[1] = temp;
| |_________________^ ...ending here | |_________________^
| |
= note: #[deny(manual_swap)] implied by #[deny(clippy)] = note: #[deny(manual_swap)] implied by #[deny(clippy)]
help: try help: try
@@ -32,11 +30,10 @@ help: try
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
| |
35 | let temp = foo[0]; 35 | / let temp = foo[0];
| _____^ starting here...
36 | | foo[0] = foo[1]; 36 | | foo[0] = foo[1];
37 | | foo[1] = temp; 37 | | foo[1] = temp;
| |_________________^ ...ending here | |_________________^
| |
= note: #[deny(manual_swap)] implied by #[deny(clippy)] = note: #[deny(manual_swap)] implied by #[deny(clippy)]
help: try help: try
@@ -46,10 +43,10 @@ error: this looks like you are swapping `a` and `b` manually
--> $DIR/swap.rs:60:7 --> $DIR/swap.rs:60:7
| |
60 | ; let t = a; 60 | ; let t = a;
| _______^ starting here... | _______^
61 | | a = b; 61 | | a = b;
62 | | b = t; 62 | | b = t;
| |_________^ ...ending here | |_________^
| |
= note: #[deny(manual_swap)] implied by #[deny(clippy)] = note: #[deny(manual_swap)] implied by #[deny(clippy)]
help: try help: try
@@ -60,10 +57,10 @@ error: this looks like you are swapping `c.0` and `a` manually
--> $DIR/swap.rs:77:7 --> $DIR/swap.rs:77:7
| |
77 | ; let t = c.0; 77 | ; let t = c.0;
| _______^ starting here... | _______^
78 | | c.0 = a; 78 | | c.0 = a;
79 | | a = t; 79 | | a = t;
| |_________^ ...ending here | |_________^
| |
= note: #[deny(manual_swap)] implied by #[deny(clippy)] = note: #[deny(manual_swap)] implied by #[deny(clippy)]
help: try help: try
@@ -73,10 +70,9 @@ help: try
error: this looks like you are trying to swap `a` and `b` error: this looks like you are trying to swap `a` and `b`
--> $DIR/swap.rs:53:5 --> $DIR/swap.rs:53:5
| |
53 | a = b; 53 | / a = b;
| _____^ starting here...
54 | | b = a; 54 | | b = a;
| |_________^ ...ending here | |_________^
| |
= 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
@@ -91,10 +87,9 @@ help: try
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`
--> $DIR/swap.rs:70:5 --> $DIR/swap.rs:70:5
| |
70 | c.0 = a; 70 | / c.0 = a;
| _____^ starting here...
71 | | a = c.0; 71 | | a = c.0;
| |___________^ ...ending here | |___________^
| |
= note: #[deny(almost_swapped)] implied by #[deny(clippy)] = note: #[deny(almost_swapped)] implied by #[deny(clippy)]
help: try help: try

View File

@@ -1,11 +1,10 @@
error: unused label `'label` error: unused label `'label`
--> $DIR/unused_labels.rs:8:5 --> $DIR/unused_labels.rs:8:5
| |
8 | 'label: for i in 1..2 { 8 | / 'label: for i in 1..2 {
| _____^ starting here...
9 | | if i > 4 { continue } 9 | | if i > 4 { continue }
10 | | } 10 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/unused_labels.rs:5:9 --> $DIR/unused_labels.rs:5:9
@@ -22,11 +21,10 @@ error: unused label `'a`
error: unused label `'same_label_in_two_fns` error: unused label `'same_label_in_two_fns`
--> $DIR/unused_labels.rs:32:5 --> $DIR/unused_labels.rs:32:5
| |
32 | 'same_label_in_two_fns: loop { 32 | / 'same_label_in_two_fns: loop {
| _____^ starting here...
33 | | let _ = 1; 33 | | let _ = 1;
34 | | } 34 | | }
| |_____^ ...ending here | |_____^
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View File

@@ -1,15 +1,14 @@
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:9:5 --> $DIR/while_loop.rs:9:5
| |
9 | loop { 9 | / loop {
| _____^ starting here...
10 | | 10 | |
11 | | 11 | |
12 | | 12 | |
... | ... |
17 | | } 17 | | }
18 | | } 18 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/while_loop.rs:4:9 --> $DIR/while_loop.rs:4:9
@@ -22,15 +21,14 @@ help: try
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
| |
25 | loop { 25 | / loop {
| _____^ starting here...
26 | | 26 | |
27 | | 27 | |
28 | | 28 | |
... | ... |
32 | | }; 32 | | };
33 | | } 33 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| while let Some(_x) = y { .. } | while let Some(_x) = y { .. }
@@ -38,15 +36,14 @@ help: try
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
| |
34 | loop { 34 | / loop {
| _____^ starting here...
35 | | 35 | |
36 | | 36 | |
37 | | 37 | |
... | ... |
43 | | let _str = "foo"; 43 | | let _str = "foo";
44 | | } 44 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| while let Some(x) = y { .. } | while let Some(x) = y { .. }
@@ -54,15 +51,14 @@ help: try
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
| |
45 | loop { 45 | / loop {
| _____^ starting here...
46 | | 46 | |
47 | | 47 | |
48 | | 48 | |
... | ... |
54 | | { let _b = "foobar"; } 54 | | { let _b = "foobar"; }
55 | | } 55 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| while let Some(x) = y { .. } | while let Some(x) = y { .. }
@@ -70,15 +66,14 @@ help: try
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
| |
70 | loop { 70 | / loop {
| _____^ starting here...
71 | | 71 | |
72 | | 72 | |
73 | | 73 | |
... | ... |
79 | | let _ = (e, l); 79 | | let _ = (e, l);
80 | | } 80 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| while let Some(word) = "".split_whitespace().next() { .. } | while let Some(word) = "".split_whitespace().next() { .. }
@@ -86,14 +81,13 @@ help: try
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
| |
83 | while let Option::Some(x) = iter.next() { 83 | / while let Option::Some(x) = iter.next() {
| _____^ starting here...
84 | | 84 | |
85 | | 85 | |
86 | | 86 | |
87 | | println!("{}", x); 87 | | println!("{}", x);
88 | | } 88 | | }
| |_____^ ...ending here | |_____^
| |
note: lint level defined here note: lint level defined here
--> $DIR/while_loop.rs:4:37 --> $DIR/while_loop.rs:4:37
@@ -106,14 +100,13 @@ help: try
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
| |
91 | while let Some(x) = iter.next() { 91 | / while let Some(x) = iter.next() {
| _____^ starting here...
92 | | 92 | |
93 | | 93 | |
94 | | 94 | |
95 | | println!("{}", x); 95 | | println!("{}", x);
96 | | } 96 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| for x in iter { .. } | for x in iter { .. }
@@ -130,15 +123,14 @@ help: try
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
| |
142 | loop { 142 | / loop {
| _____^ starting here...
143 | | 143 | |
144 | | 144 | |
145 | | 145 | |
... | ... |
150 | | loop {} 150 | | loop {}
151 | | } 151 | | }
| |_____^ ...ending here | |_____^
| |
help: try help: try
| while let Some(ele) = iter.next() { .. } | while let Some(ele) = iter.next() { .. }

View File

@@ -4,7 +4,8 @@
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;
/// Test that we do not lint for unused underscores in a `MacroAttribute` expansion /// Test that we do not lint for unused underscores in a `MacroAttribute`
/// expansion
#[deny(used_underscore_binding)] #[deny(used_underscore_binding)]
#[derive(Deserialize)] #[derive(Deserialize)]
struct MacroAttributesTest { struct MacroAttributesTest {