From f52dd2b8f7555bf197101214361614bd0eaf00a5 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Wed, 25 Jul 2018 22:49:25 +0200 Subject: [PATCH 01/53] Further automate pre_publish.sh --- pre_publish.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pre_publish.sh b/pre_publish.sh index aca17b968a8..d8a9105c67e 100755 --- a/pre_publish.sh +++ b/pre_publish.sh @@ -17,7 +17,13 @@ git commit -m "Bump the version" set +e +echo "Running \`cargo fmt\`.." + cd clippy_lints && cargo fmt -- --write-mode=overwrite && cd .. cargo fmt -- --write-mode=overwrite -echo "remember to add a git tag and running 'cargo test' before committing the rustfmt changes" +echo "Running tests to make sure \`cargo fmt\` did not break anything.." + +cargo test + +echo "If the tests passed, review and commit the formatting changes and remember to add a git tag." From ed1667b7bc0d49fef8cfff75fea22c60c545a233 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 9 Aug 2018 09:41:32 +0200 Subject: [PATCH 02/53] Version checks are useless now that we ride the trains --- Cargo.toml | 4 --- build.rs | 87 ------------------------------------------------- min_version.txt | 7 ---- 3 files changed, 98 deletions(-) delete mode 100644 min_version.txt diff --git a/Cargo.toml b/Cargo.toml index 5b690040902..798b713a07f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,9 +59,5 @@ derive-new = "0.5" # for more information. rustc-workspace-hack = "1.0.0" -[build-dependencies] -rustc_version = "0.2.2" -ansi_term = "0.11" - [features] debugging = [] diff --git a/build.rs b/build.rs index 9d05678f718..3b9f217c884 100644 --- a/build.rs +++ b/build.rs @@ -13,98 +13,11 @@ //! This build script was originally taken from the Rocket web framework: //! https://github.com/SergioBenitez/Rocket -use ansi_term::Colour::Red; -use rustc_version::{version_meta, version_meta_for, Channel, Version, VersionMeta}; use std::env; fn main() { - check_rustc_version(); - // Forward the profile to the main compilation println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap()); // Don't rebuild even if nothing changed println!("cargo:rerun-if-changed=build.rs"); } - -fn check_rustc_version() { - let string = include_str!("min_version.txt"); - let min_version_meta = version_meta_for(string).expect("Could not parse version string in min_version.txt"); - let current_version_meta = version_meta().expect("Could not retrieve current rustc version information from ENV"); - - let min_version = min_version_meta.clone().semver; - let min_date_str = min_version_meta - .clone() - .commit_date - .expect("min_version.txt does not contain a rustc commit date"); - - // Dev channel (rustc built from git) does not have any date or commit information in rustc -vV - // `current_version_meta.commit_date` would crash, so we return early here. - if current_version_meta.channel == Channel::Dev { - return; - } - - let current_version = current_version_meta.clone().semver; - let current_date_str = current_version_meta - .clone() - .commit_date - .expect("current rustc version information does not contain a rustc commit date"); - - let print_version_err = |version: &Version, date: &str| { - eprintln!( - "> {} {}. {} {}.\n", - "Installed rustc version is:", - format!("{} ({})", version, date), - "Minimum required rustc version:", - format!("{} ({})", min_version, min_date_str) - ); - }; - - if !correct_channel(¤t_version_meta) { - eprintln!( - "\n{} {}", - Red.bold().paint("error:"), - "Clippy requires a nightly version of Rust." - ); - print_version_err(¤t_version, &*current_date_str); - eprintln!( - "{}{}{}", - "See the README (", "https://github.com/rust-lang-nursery/rust-clippy#usage", ") for more information." - ); - panic!("Aborting compilation due to incompatible compiler.") - } - - let current_date = str_to_ymd(¤t_date_str).unwrap(); - let min_date = str_to_ymd(&min_date_str).unwrap(); - - if current_date < min_date { - eprintln!( - "\n{} {}", - Red.bold().paint("error:"), - "Clippy does not support this version of rustc nightly." - ); - eprintln!( - "> {}{}{}", - "Use `", "rustup update", "` or your preferred method to update Rust." - ); - print_version_err(¤t_version, &*current_date_str); - panic!("Aborting compilation due to incompatible compiler.") - } -} - -fn correct_channel(version_meta: &VersionMeta) -> bool { - match version_meta.channel { - Channel::Stable | Channel::Beta => false, - Channel::Nightly | Channel::Dev => true, - } -} - -/// Convert a string of %Y-%m-%d to a single u32 maintaining ordering. -fn str_to_ymd(ymd: &str) -> Option { - let ymd: Vec = ymd.split("-").filter_map(|s| s.parse::().ok()).collect(); - if ymd.len() != 3 { - return None; - } - - let (y, m, d) = (ymd[0], ymd[1], ymd[2]); - Some((y << 9) | (m << 5) | d) -} diff --git a/min_version.txt b/min_version.txt deleted file mode 100644 index bd6a57973fc..00000000000 --- a/min_version.txt +++ /dev/null @@ -1,7 +0,0 @@ -rustc 1.28.0-nightly (e3bf634e0 2018-06-28) -binary: rustc -commit-hash: e3bf634e060bc2f8665878288bcea02008ca346e -commit-date: 2018-06-28 -host: x86_64-unknown-linux-gnu -release: 1.28.0-nightly -LLVM version: 6.0 From 160b41dae358e0ec81973db686a0278037211fdb Mon Sep 17 00:00:00 2001 From: Jonathan Goodman Date: Thu, 9 Aug 2018 14:14:12 -0500 Subject: [PATCH 03/53] deprecate assign_ops lint --- clippy_lints/src/assign_ops.rs | 31 +----- clippy_lints/src/deprecated_lints.rs | 10 ++ clippy_lints/src/lib.rs | 5 +- tests/ui/assign_ops.rs | 24 +---- tests/ui/assign_ops.stderr | 150 +++++++-------------------- 5 files changed, 51 insertions(+), 169 deletions(-) diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 1ce690abcfe..7d4f4e7cbc3 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -7,25 +7,6 @@ use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::ast; -/// **What it does:** Checks for compound assignment operations (`+=` and -/// similar). -/// -/// **Why is this bad?** Projects with many developers from languages without -/// those operations may find them unreadable and not worth their weight. -/// -/// **Known problems:** Types implementing `OpAssign` don't necessarily -/// implement `Op`. -/// -/// **Example:** -/// ```rust -/// a += 1; -/// ``` -declare_clippy_lint! { - pub ASSIGN_OPS, - restriction, - "any compound assignment operation" -} - /// **What it does:** Checks for `a = a op b` or `a = b commutative_op a` /// patterns. /// @@ -73,7 +54,7 @@ pub struct AssignOps; impl LintPass for AssignOps { fn get_lints(&self) -> LintArray { - lint_array!(ASSIGN_OPS, ASSIGN_OP_PATTERN, MISREFACTORED_ASSIGN_OP) + lint_array!(ASSIGN_OP_PATTERN, MISREFACTORED_ASSIGN_OP) } } @@ -81,16 +62,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { match expr.node { hir::ExprKind::AssignOp(op, ref lhs, ref rhs) => { - span_lint_and_then(cx, ASSIGN_OPS, expr.span, "assign operation detected", |db| { - let lhs = &sugg::Sugg::hir(cx, lhs, ".."); - let rhs = &sugg::Sugg::hir(cx, rhs, ".."); - - db.span_suggestion( - expr.span, - "replace it with", - format!("{} = {}", lhs, sugg::make_binop(higher::binop(op.node), lhs, rhs)), - ); - }); if let hir::ExprKind::Binary(binop, ref l, ref r) = rhs.node { if op.node == binop.node { let lint = |assignee: &hir::Expr, rhs_other: &hir::Expr| { diff --git a/clippy_lints/src/deprecated_lints.rs b/clippy_lints/src/deprecated_lints.rs index 1edeb30560c..983f347c56f 100644 --- a/clippy_lints/src/deprecated_lints.rs +++ b/clippy_lints/src/deprecated_lints.rs @@ -82,3 +82,13 @@ declare_deprecated_lint! { pub MISALIGNED_TRANSMUTE, "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr" } + +/// **What it does:** Nothing. This lint has been deprecated. +/// +/// **Deprecation reason:** This lint is too subjective, not having a good reason for being in clippy. +/// Additionally, compound assignment operators may be overloaded separately from their non-assigning +/// counterparts, so this lint may suggest a change in behavior or the code may not compile. +declare_deprecated_lint! { + pub ASSIGN_OPS, + "using compound assignment operators (e.g. `+=`) is harmless" +} diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index e0ef87938f9..66abacdf6e8 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -261,6 +261,10 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>) { "misaligned_transmute", "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr", ); + store.register_removed( + "assign_ops", + "using compound assignment operators (e.g. `+=`) is harmless", + ); // end deprecated lints, do not remove this comment, it’s used in `update_lints` reg.register_late_lint_pass(box serde_api::Serde); @@ -406,7 +410,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>) { reg.register_lint_group("clippy_restriction", vec![ arithmetic::FLOAT_ARITHMETIC, arithmetic::INTEGER_ARITHMETIC, - assign_ops::ASSIGN_OPS, else_if_without_else::ELSE_IF_WITHOUT_ELSE, indexing_slicing::INDEXING_SLICING, inherent_impl::MULTIPLE_INHERENT_IMPL, diff --git a/tests/ui/assign_ops.rs b/tests/ui/assign_ops.rs index 2b49f2146ba..7332b41fa0b 100644 --- a/tests/ui/assign_ops.rs +++ b/tests/ui/assign_ops.rs @@ -1,28 +1,6 @@ - - - -#[warn(assign_ops)] -#[allow(unused_assignments)] -fn main() { - let mut i = 1i32; - i += 2; - i += 2 + 17; - i -= 6; - i -= 2 - 1; - i *= 5; - i *= 1+5; - i /= 32; - i /= 32 | 5; - i /= 32 / 5; - i %= 42; - i >>= i; - i <<= 9 + 6 - 7; - i += 1 << 5; -} - #[allow(dead_code, unused_assignments)] #[warn(assign_op_pattern)] -fn bla() { +fn main() { let mut a = 5; a = a + 1; a = 1 + a; diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index 2123507e2ef..826dacc53a9 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -1,138 +1,58 @@ -error: assign operation detected +error: manual implementation of an assign operation + --> $DIR/assign_ops.rs:5:5 + | +5 | a = a + 1; + | ^^^^^^^^^ help: replace it with: `a += 1` + | + = note: `-D assign-op-pattern` implied by `-D warnings` + +error: manual implementation of an assign operation + --> $DIR/assign_ops.rs:6:5 + | +6 | a = 1 + a; + | ^^^^^^^^^ help: replace it with: `a += 1` + +error: manual implementation of an assign operation + --> $DIR/assign_ops.rs:7:5 + | +7 | a = a - 1; + | ^^^^^^^^^ help: replace it with: `a -= 1` + +error: manual implementation of an assign operation --> $DIR/assign_ops.rs:8:5 | -8 | i += 2; - | ^^^^^^ help: replace it with: `i = i + 2` - | - = note: `-D assign-ops` implied by `-D warnings` +8 | a = a * 99; + | ^^^^^^^^^^ help: replace it with: `a *= 99` -error: assign operation detected +error: manual implementation of an assign operation --> $DIR/assign_ops.rs:9:5 | -9 | i += 2 + 17; - | ^^^^^^^^^^^ help: replace it with: `i = i + 2 + 17` +9 | a = 42 * a; + | ^^^^^^^^^^ help: replace it with: `a *= 42` -error: assign operation detected +error: manual implementation of an assign operation --> $DIR/assign_ops.rs:10:5 | -10 | i -= 6; - | ^^^^^^ help: replace it with: `i = i - 6` - -error: assign operation detected - --> $DIR/assign_ops.rs:11:5 - | -11 | i -= 2 - 1; - | ^^^^^^^^^^ help: replace it with: `i = i - (2 - 1)` - -error: assign operation detected - --> $DIR/assign_ops.rs:12:5 - | -12 | i *= 5; - | ^^^^^^ help: replace it with: `i = i * 5` - -error: assign operation detected - --> $DIR/assign_ops.rs:13:5 - | -13 | i *= 1+5; - | ^^^^^^^^ help: replace it with: `i = i * (1+5)` - -error: assign operation detected - --> $DIR/assign_ops.rs:14:5 - | -14 | i /= 32; - | ^^^^^^^ help: replace it with: `i = i / 32` - -error: assign operation detected - --> $DIR/assign_ops.rs:15:5 - | -15 | i /= 32 | 5; - | ^^^^^^^^^^^ help: replace it with: `i = i / (32 | 5)` - -error: assign operation detected - --> $DIR/assign_ops.rs:16:5 - | -16 | i /= 32 / 5; - | ^^^^^^^^^^^ help: replace it with: `i = i / (32 / 5)` - -error: assign operation detected - --> $DIR/assign_ops.rs:17:5 - | -17 | i %= 42; - | ^^^^^^^ help: replace it with: `i = i % 42` - -error: assign operation detected - --> $DIR/assign_ops.rs:18:5 - | -18 | i >>= i; - | ^^^^^^^ help: replace it with: `i = i >> i` - -error: assign operation detected - --> $DIR/assign_ops.rs:19:5 - | -19 | i <<= 9 + 6 - 7; - | ^^^^^^^^^^^^^^^ help: replace it with: `i = i << (9 + 6 - 7)` - -error: assign operation detected - --> $DIR/assign_ops.rs:20:5 - | -20 | i += 1 << 5; - | ^^^^^^^^^^^ help: replace it with: `i = i + (1 << 5)` - -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:27:5 - | -27 | a = a + 1; - | ^^^^^^^^^ help: replace it with: `a += 1` - | - = note: `-D assign-op-pattern` implied by `-D warnings` - -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:28:5 - | -28 | a = 1 + a; - | ^^^^^^^^^ help: replace it with: `a += 1` - -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:29:5 - | -29 | a = a - 1; - | ^^^^^^^^^ help: replace it with: `a -= 1` - -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:30:5 - | -30 | a = a * 99; - | ^^^^^^^^^^ help: replace it with: `a *= 99` - -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:31:5 - | -31 | a = 42 * a; - | ^^^^^^^^^^ help: replace it with: `a *= 42` - -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:32:5 - | -32 | a = a / 2; +10 | a = a / 2; | ^^^^^^^^^ help: replace it with: `a /= 2` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:33:5 + --> $DIR/assign_ops.rs:11:5 | -33 | a = a % 5; +11 | a = a % 5; | ^^^^^^^^^ help: replace it with: `a %= 5` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:34:5 + --> $DIR/assign_ops.rs:12:5 | -34 | a = a & 1; +12 | a = a & 1; | ^^^^^^^^^ help: replace it with: `a &= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:40:5 + --> $DIR/assign_ops.rs:18:5 | -40 | s = s + "bla"; +18 | s = s + "bla"; | ^^^^^^^^^^^^^ help: replace it with: `s += "bla"` -error: aborting due to 22 previous errors +error: aborting due to 9 previous errors From 6cb94630fb6220240730e2bed8d82f80a107696d Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Thu, 16 Aug 2018 18:20:06 +0200 Subject: [PATCH 04/53] WIP of #3016 for hardocded suggestion for writeln on empty string --- clippy_lints/src/write.rs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index e8c7225041f..9b0b25f3921 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -179,7 +179,7 @@ impl EarlyLintPass for Pass { fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &Mac) { if mac.node.path == "println" { span_lint(cx, PRINT_STDOUT, mac.span, "use of `println!`"); - if let Some(fmtstr) = check_tts(cx, &mac.node.tts, false) { + if let Some(fmtstr) = check_tts(cx, &mac.node.tts, false).0 { if fmtstr == "" { span_lint_and_sugg( cx, @@ -193,7 +193,7 @@ impl EarlyLintPass for Pass { } } else if mac.node.path == "print" { span_lint(cx, PRINT_STDOUT, mac.span, "use of `print!`"); - if let Some(fmtstr) = check_tts(cx, &mac.node.tts, false) { + if let Some(fmtstr) = check_tts(cx, &mac.node.tts, false).0 { if fmtstr.ends_with("\\n") && !fmtstr.ends_with("\\n\\n") { span_lint(cx, PRINT_WITH_NEWLINE, mac.span, "using `print!()` with a format string that ends in a \ @@ -201,7 +201,7 @@ impl EarlyLintPass for Pass { } } } else if mac.node.path == "write" { - if let Some(fmtstr) = check_tts(cx, &mac.node.tts, true) { + if let Some(fmtstr) = check_tts(cx, &mac.node.tts, true).0 { if fmtstr.ends_with("\\n") && !fmtstr.ends_with("\\n\\n") { span_lint(cx, WRITE_WITH_NEWLINE, mac.span, "using `write!()` with a format string that ends in a \ @@ -209,15 +209,16 @@ impl EarlyLintPass for Pass { } } } else if mac.node.path == "writeln" { - if let Some(fmtstr) = check_tts(cx, &mac.node.tts, true) { + let check_tts = check_tts(cx, &mac.node.tts, true); + if let Some(fmtstr) = check_tts.0 { if fmtstr == "" { span_lint_and_sugg( cx, WRITELN_EMPTY_STRING, mac.span, - "using `writeln!(v, \"\")`", + format!("using `writeln!({}, \"\")`", check_tts.1).as_str(), "replace it with", - "writeln!(v)".to_string(), + format!("using `writeln!({})`", check_tts.1), ); } } @@ -225,7 +226,7 @@ impl EarlyLintPass for Pass { } } -fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) -> Option { +fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) -> (Option, Option) { let tts = TokenStream::from(tts.clone()); let mut parser = parser::Parser::new( &cx.sess.parse_sess, @@ -234,12 +235,14 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - false, false, ); - if is_write { - // skip the initial write target - parser.parse_expr().map_err(|mut err| err.cancel()).ok()?; - // might be `writeln!(foo)` - parser.expect(&token::Comma).map_err(|mut err| err.cancel()).ok()?; - } + // skip the initial write target + let expr: Option = match parser.parse_expr().map_err(|mut err| err.cancel()).ok() { + Some(p) => Some(p.into_vec().0), + None => None, + }; + // might be `writeln!(foo)` + parser.expect(&token::Comma).map_err(|mut err| err.cancel()).ok()?; + let fmtstr = parser.parse_str().map_err(|mut err| err.cancel()).ok()?.0.to_string(); use fmt_macros::*; let tmp = fmtstr.clone(); @@ -247,7 +250,7 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - let mut fmt_parser = Parser::new(&tmp, None); while let Some(piece) = fmt_parser.next() { if !fmt_parser.errors.is_empty() { - return None; + return (None, expr); } if let Piece::NextArgument(arg) = piece { if arg.format.ty == "?" { @@ -266,7 +269,7 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - loop { if !parser.eat(&token::Comma) { assert!(parser.eat(&token::Eof)); - return Some(fmtstr); + return (Some(fmtstr), expr); } let expr = parser.parse_expr().map_err(|mut err| err.cancel()).ok()?; const SIMPLE: FormatSpec<'_> = FormatSpec { From 3015987f279b414eea37d719c8e35ed2d8d7704a Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Mon, 20 Aug 2018 14:03:13 +0200 Subject: [PATCH 05/53] #3016 [WIP] Implement feedback and suggestions --- clippy_lints/src/write.rs | 41 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 9b0b25f3921..3c912756d2d 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -3,7 +3,7 @@ use rustc::{declare_lint, lint_array}; use syntax::ast::*; use syntax::tokenstream::{ThinTokenStream, TokenStream}; use syntax::parse::{token, parser}; -use crate::utils::{span_lint, span_lint_and_sugg}; +use crate::utils::{span_lint, span_lint_and_sugg, snippet}; /// **What it does:** This lint warns when you use `println!("")` to /// print a newline. @@ -212,13 +212,15 @@ impl EarlyLintPass for Pass { let check_tts = check_tts(cx, &mac.node.tts, true); if let Some(fmtstr) = check_tts.0 { if fmtstr == "" { + let suggestion = check_tts.1.map_or("v", |expr| snippet(cx, expr.span, "v").into_owned().as_str()); + span_lint_and_sugg( cx, WRITELN_EMPTY_STRING, mac.span, - format!("using `writeln!({}, \"\")`", check_tts.1).as_str(), + format!("using writeln!({}, \"\")", suggestion).as_str(), "replace it with", - format!("using `writeln!({})`", check_tts.1), + format!("writeln!({})", "v"), ); } } @@ -235,15 +237,23 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - false, false, ); - // skip the initial write target - let expr: Option = match parser.parse_expr().map_err(|mut err| err.cancel()).ok() { - Some(p) => Some(p.into_vec().0), - None => None, - }; - // might be `writeln!(foo)` - parser.expect(&token::Comma).map_err(|mut err| err.cancel()).ok()?; + let mut expr: Option = None; + if is_write { + // skip the initial write target + expr = match parser.parse_expr().map_err(|mut err| err.cancel()).ok() { + Some(p) => Some(p.and_then(|expr| expr)), + None => return (None, None), + }; + // might be `writeln!(foo)` + if let None = parser.expect(&token::Comma).map_err(|mut err| err.cancel()).ok() { + return (None, expr); + } + } - let fmtstr = parser.parse_str().map_err(|mut err| err.cancel()).ok()?.0.to_string(); + let fmtstr = match parser.parse_str().map_err(|mut err| err.cancel()).ok() { + Some(token) => token.0.to_string(), + None => return (None, expr), + }; use fmt_macros::*; let tmp = fmtstr.clone(); let mut args = vec![]; @@ -271,7 +281,10 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - assert!(parser.eat(&token::Eof)); return (Some(fmtstr), expr); } - let expr = parser.parse_expr().map_err(|mut err| err.cancel()).ok()?; + let token_expr = match parser.parse_expr().map_err(|mut err| err.cancel()).ok() { + Some(expr) => expr, + None => return (Some(fmtstr), None), + }; const SIMPLE: FormatSpec<'_> = FormatSpec { fill: None, align: AlignUnknown, @@ -280,7 +293,7 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - width: CountImplied, ty: "", }; - match &expr.node { + match &token_expr.node { ExprKind::Lit(_) => { let mut all_simple = true; let mut seen = false; @@ -296,7 +309,7 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - } } if all_simple && seen { - span_lint(cx, lint, expr.span, "literal with an empty format string"); + span_lint(cx, lint, token_expr.span, "literal with an empty format string"); } idx += 1; }, From c292b8078302a47dc47f6e772be3fb8f887dbf7a Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Mon, 20 Aug 2018 15:33:43 +0200 Subject: [PATCH 06/53] #3016 Add feedback and implement test for fixed hardcoded suggestion --- clippy_lints/src/write.rs | 26 +++++++++++++------------- tests/ui/writeln_empty_string.rs | 5 ++++- tests/ui/writeln_empty_string.stderr | 12 +++++++++--- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 3c912756d2d..2231715c8d2 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -3,6 +3,7 @@ use rustc::{declare_lint, lint_array}; use syntax::ast::*; use syntax::tokenstream::{ThinTokenStream, TokenStream}; use syntax::parse::{token, parser}; +use std::borrow::Cow; use crate::utils::{span_lint, span_lint_and_sugg, snippet}; /// **What it does:** This lint warns when you use `println!("")` to @@ -212,7 +213,7 @@ impl EarlyLintPass for Pass { let check_tts = check_tts(cx, &mac.node.tts, true); if let Some(fmtstr) = check_tts.0 { if fmtstr == "" { - let suggestion = check_tts.1.map_or("v", |expr| snippet(cx, expr.span, "v").into_owned().as_str()); + let suggestion = check_tts.1.map_or(Cow::Borrowed("v"), |expr| snippet(cx, expr.span, "v")); span_lint_and_sugg( cx, @@ -220,7 +221,7 @@ impl EarlyLintPass for Pass { mac.span, format!("using writeln!({}, \"\")", suggestion).as_str(), "replace it with", - format!("writeln!({})", "v"), + format!("writeln!({})", suggestion), ); } } @@ -239,20 +240,19 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - ); let mut expr: Option = None; if is_write { - // skip the initial write target - expr = match parser.parse_expr().map_err(|mut err| err.cancel()).ok() { - Some(p) => Some(p.and_then(|expr| expr)), - None => return (None, None), + expr = match parser.parse_expr().map_err(|mut err| err.cancel()) { + Ok(p) => Some(p.into_inner()), + Err(_) => return (None, None), }; // might be `writeln!(foo)` - if let None = parser.expect(&token::Comma).map_err(|mut err| err.cancel()).ok() { + if parser.expect(&token::Comma).map_err(|mut err| err.cancel()).is_err() { return (None, expr); } } - let fmtstr = match parser.parse_str().map_err(|mut err| err.cancel()).ok() { - Some(token) => token.0.to_string(), - None => return (None, expr), + let fmtstr = match parser.parse_str().map_err(|mut err| err.cancel()) { + Ok(token) => token.0.to_string(), + Err(_) => return (None, expr), }; use fmt_macros::*; let tmp = fmtstr.clone(); @@ -281,9 +281,9 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - assert!(parser.eat(&token::Eof)); return (Some(fmtstr), expr); } - let token_expr = match parser.parse_expr().map_err(|mut err| err.cancel()).ok() { - Some(expr) => expr, - None => return (Some(fmtstr), None), + let token_expr = match parser.parse_expr().map_err(|mut err| err.cancel()) { + Ok(expr) => expr, + Err(_) => return (Some(fmtstr), None), }; const SIMPLE: FormatSpec<'_> = FormatSpec { fill: None, diff --git a/tests/ui/writeln_empty_string.rs b/tests/ui/writeln_empty_string.rs index c7092eb8c4b..faccfd8291c 100644 --- a/tests/ui/writeln_empty_string.rs +++ b/tests/ui/writeln_empty_string.rs @@ -5,9 +5,12 @@ use std::io::Write; fn main() { let mut v = Vec::new(); - // This should fail + // These should fail writeln!(&mut v, ""); + let mut suggestion = Vec::new(); + writeln!(&mut suggestion, ""); + // These should be fine writeln!(&mut v); writeln!(&mut v, " "); diff --git a/tests/ui/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr index 16a8e0a203d..8bfec673c4a 100644 --- a/tests/ui/writeln_empty_string.stderr +++ b/tests/ui/writeln_empty_string.stderr @@ -1,10 +1,16 @@ -error: using `writeln!(v, "")` +error: using writeln!(&mut v, "") --> $DIR/writeln_empty_string.rs:9:5 | 9 | writeln!(&mut v, ""); - | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(v)` + | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut v)` | = note: `-D writeln-empty-string` implied by `-D warnings` -error: aborting due to previous error +error: using writeln!(&mut suggestion, "") + --> $DIR/writeln_empty_string.rs:12:5 + | +12 | writeln!(&mut suggestion, ""); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut suggestion)` + +error: aborting due to 2 previous errors From 76f7bfcefd6c7ad16b01864a3e616eb66fbfae2f Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Mon, 20 Aug 2018 15:50:15 +0200 Subject: [PATCH 07/53] #3016 Add backticks for the msg --- clippy_lints/src/write.rs | 2 +- tests/ui/writeln_empty_string.stderr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 2231715c8d2..97fe12f2330 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -219,7 +219,7 @@ impl EarlyLintPass for Pass { cx, WRITELN_EMPTY_STRING, mac.span, - format!("using writeln!({}, \"\")", suggestion).as_str(), + format!("using `writeln!({}, \"\")`", suggestion).as_str(), "replace it with", format!("writeln!({})", suggestion), ); diff --git a/tests/ui/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr index 8bfec673c4a..7bb6350ecd2 100644 --- a/tests/ui/writeln_empty_string.stderr +++ b/tests/ui/writeln_empty_string.stderr @@ -1,4 +1,4 @@ -error: using writeln!(&mut v, "") +error: using `writeln!(&mut v, "")` --> $DIR/writeln_empty_string.rs:9:5 | 9 | writeln!(&mut v, ""); @@ -6,7 +6,7 @@ error: using writeln!(&mut v, "") | = note: `-D writeln-empty-string` implied by `-D warnings` -error: using writeln!(&mut suggestion, "") +error: using `writeln!(&mut suggestion, "")` --> $DIR/writeln_empty_string.rs:12:5 | 12 | writeln!(&mut suggestion, ""); From 712d2d4fa106e9713f9578e120439892efed289b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 22 Aug 2018 23:34:52 +0200 Subject: [PATCH 08/53] rustup, fix breakage introduced by https://github.com/rust-lang/rust/pull/53581 --- clippy_lints/src/bytecount.rs | 2 +- clippy_lints/src/consts.rs | 32 ++++++------- clippy_lints/src/cyclomatic_complexity.rs | 4 +- clippy_lints/src/default_trait_access.rs | 4 +- clippy_lints/src/derive.rs | 8 ++-- clippy_lints/src/drop_forget_ref.rs | 2 +- clippy_lints/src/enum_clike.rs | 6 +-- clippy_lints/src/eta_reduction.rs | 4 +- clippy_lints/src/eval_order_dependence.rs | 4 +- clippy_lints/src/excessive_precision.rs | 4 +- clippy_lints/src/fallible_impl_from.rs | 2 +- clippy_lints/src/format.rs | 2 +- clippy_lints/src/identity_op.rs | 4 +- clippy_lints/src/indexing_slicing.rs | 4 +- clippy_lints/src/invalid_ref.rs | 2 +- clippy_lints/src/len_zero.rs | 8 ++-- clippy_lints/src/loops.rs | 18 ++++---- clippy_lints/src/map_clone.rs | 2 +- clippy_lints/src/map_unit_fn.rs | 6 +-- clippy_lints/src/matches.rs | 4 +- clippy_lints/src/methods.rs | 34 +++++++------- clippy_lints/src/misc.rs | 2 +- clippy_lints/src/mut_mut.rs | 2 +- clippy_lints/src/mut_reference.rs | 6 +-- clippy_lints/src/mutex_atomic.rs | 14 +++--- clippy_lints/src/needless_borrow.rs | 6 +-- clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/needless_update.rs | 2 +- clippy_lints/src/new_without_default.rs | 2 +- clippy_lints/src/ptr.rs | 2 +- clippy_lints/src/shadow.rs | 2 +- clippy_lints/src/swap.rs | 4 +- clippy_lints/src/transmute.rs | 40 ++++++++-------- .../src/trivially_copy_pass_by_ref.rs | 11 +++-- clippy_lints/src/types.rs | 46 +++++++++---------- clippy_lints/src/utils/higher.rs | 2 +- clippy_lints/src/utils/mod.rs | 10 ++-- clippy_lints/src/vec.rs | 6 +-- 38 files changed, 158 insertions(+), 157 deletions(-) diff --git a/clippy_lints/src/bytecount.rs b/clippy_lints/src/bytecount.rs index 2d4279d3cc1..6d086c13ff8 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount { _ => { return; } } }; - if ty::TyUint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).sty { + if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables.expr_ty(needle)).sty { return; } let haystack = if let ExprKind::MethodCall(ref path, _, ref args) = diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 7bccdd7778b..ff189d6e893 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -123,12 +123,12 @@ impl Hash for Constant { } impl Constant { - pub fn partial_cmp(tcx: TyCtxt<'_, '_, '_>, cmp_type: &ty::TypeVariants<'_>, left: &Self, right: &Self) -> Option { + pub fn partial_cmp(tcx: TyCtxt<'_, '_, '_>, cmp_type: &ty::TyKind<'_>, left: &Self, right: &Self) -> Option { match (left, right) { (&Constant::Str(ref ls), &Constant::Str(ref rs)) => Some(ls.cmp(rs)), (&Constant::Char(ref l), &Constant::Char(ref r)) => Some(l.cmp(r)), (&Constant::Int(l), &Constant::Int(r)) => { - if let ty::TyInt(int_ty) = *cmp_type { + if let ty::Int(int_ty) = *cmp_type { Some(sext(tcx, l, int_ty).cmp(&sext(tcx, r, int_ty))) } else { Some(l.cmp(&r)) @@ -166,8 +166,8 @@ pub fn lit_to_constant<'tcx>(lit: &LitKind, ty: Ty<'tcx>) -> Constant { LitKind::Int(n, _) => Constant::Int(n), LitKind::Float(ref is, _) | LitKind::FloatUnsuffixed(ref is) => match ty.sty { - ty::TyFloat(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()), - ty::TyFloat(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()), + ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()), + ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()), _ => bug!(), }, LitKind::Bool(b) => Constant::Bool(b), @@ -220,7 +220,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { ExprKind::Tup(ref tup) => self.multi(tup).map(Constant::Tuple), ExprKind::Repeat(ref value, _) => { let n = match self.tables.expr_ty(e).sty { - ty::TyArray(_, n) => n.assert_usize(self.tcx).expect("array length"), + ty::Array(_, n) => n.assert_usize(self.tcx).expect("array length"), _ => span_bug!(e.span, "typeck error"), }; self.expr(value).map(|v| Constant::Repeat(Box::new(v), n as u64)) @@ -243,8 +243,8 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { Int(value) => { let value = !value; match ty.sty { - ty::TyInt(ity) => Some(Int(unsext(self.tcx, value as i128, ity))), - ty::TyUint(ity) => Some(Int(clip(self.tcx, value, ity))), + ty::Int(ity) => Some(Int(unsext(self.tcx, value as i128, ity))), + ty::Uint(ity) => Some(Int(clip(self.tcx, value, ity))), _ => None, } }, @@ -257,7 +257,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { match *o { Int(value) => { let ity = match ty.sty { - ty::TyInt(ity) => ity, + ty::Int(ity) => ity, _ => return None, }; // sign extend @@ -336,7 +336,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { match (l, r) { (Constant::Int(l), Some(Constant::Int(r))) => { match self.tables.expr_ty(left).sty { - ty::TyInt(ity) => { + ty::Int(ity) => { let l = sext(self.tcx, l, ity); let r = sext(self.tcx, r, ity); let zext = |n: i128| Constant::Int(unsext(self.tcx, n, ity)); @@ -360,7 +360,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { _ => None, } } - ty::TyUint(_) => { + ty::Uint(_) => { match op.node { BinOpKind::Add => l.checked_add(r).map(Constant::Int), BinOpKind::Sub => l.checked_sub(r).map(Constant::Int), @@ -429,18 +429,18 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<' use rustc::mir::interpret::{Scalar, ScalarMaybeUndef, ConstValue}; match result.val { ConstValue::Scalar(Scalar::Bits{ bits: b, ..}) => match result.ty.sty { - ty::TyBool => Some(Constant::Bool(b == 1)), - ty::TyUint(_) | ty::TyInt(_) => Some(Constant::Int(b)), - ty::TyFloat(FloatTy::F32) => Some(Constant::F32(f32::from_bits(b as u32))), - ty::TyFloat(FloatTy::F64) => Some(Constant::F64(f64::from_bits(b as u64))), + ty::Bool => Some(Constant::Bool(b == 1)), + ty::Uint(_) | ty::Int(_) => Some(Constant::Int(b)), + ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(b as u32))), + ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits(b as u64))), // FIXME: implement other conversion _ => None, }, ConstValue::ScalarPair(Scalar::Ptr(ptr), ScalarMaybeUndef::Scalar( Scalar::Bits { bits: n, .. })) => match result.ty.sty { - ty::TyRef(_, tam, _) => match tam.sty { - ty::TyStr => { + ty::Ref(_, tam, _) => match tam.sty { + ty::Str => { let alloc = tcx .alloc_map .lock() diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index 67cd37bee37..93074eadd65 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -159,9 +159,9 @@ impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> { walk_expr(self, e); let ty = self.cx.tables.node_id_to_type(callee.hir_id); match ty.sty { - ty::TyFnDef(..) | ty::TyFnPtr(_) => { + ty::FnDef(..) | ty::FnPtr(_) => { let sig = ty.fn_sig(self.cx.tcx); - if sig.skip_binder().output().sty == ty::TyNever { + if sig.skip_binder().output().sty == ty::Never { self.divergence += 1; } }, diff --git a/clippy_lints/src/default_trait_access.rs b/clippy_lints/src/default_trait_access.rs index 4078237e8aa..f01e106df26 100644 --- a/clippy_lints/src/default_trait_access.rs +++ b/clippy_lints/src/default_trait_access.rs @@ -2,7 +2,7 @@ use rustc::hir::*; use rustc::lint::*; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; -use rustc::ty::TypeVariants; +use rustc::ty::TyKind; use crate::utils::{any_parent_is_automatically_derived, match_def_path, opt_def_id, paths, span_lint_and_sugg}; @@ -51,7 +51,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess { // TODO: Work out a way to put "whatever the imported way of referencing // this type in this file" rather than a fully-qualified type. let expr_ty = cx.tables.expr_ty(expr); - if let TypeVariants::TyAdt(..) = expr_ty.sty { + if let TyKind::Adt(..) = expr_ty.sty { let replacement = format!("{}::default()", expr_ty); span_lint_and_sugg( cx, diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 5aeca29f6d8..e3abfe93810 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -141,18 +141,18 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref } match ty.sty { - ty::TyAdt(def, _) if def.is_union() => return, + ty::Adt(def, _) if def.is_union() => return, // Some types are not Clone by default but could be cloned “by hand” if necessary - ty::TyAdt(def, substs) => for variant in &def.variants { + ty::Adt(def, substs) => for variant in &def.variants { for field in &variant.fields { - if let ty::TyFnDef(..) = field.ty(cx.tcx, substs).sty { + if let ty::FnDef(..) = field.ty(cx.tcx, substs).sty { return; } } for subst in substs { if let ty::subst::UnpackedKind::Type(subst) = subst.unpack() { - if let ty::TyParam(_) = subst.sty { + if let ty::Param(_) = subst.sty { return; } } diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index 071afde986a..1e6189e3839 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -128,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let arg = &args[0]; let arg_ty = cx.tables.expr_ty(arg); - if let ty::TyRef(..) = arg_ty.sty { + if let ty::Ref(..) = arg_ty.sty { if match_def_path(cx.tcx, def_id, &paths::DROP) { lint = DROP_REF; msg = DROP_REF_SUMMARY.to_string(); diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index 62cbead1929..2551f624cb1 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -63,19 +63,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant { let constant = cx.tcx.const_eval(param_env.and(cid)).ok(); if let Some(Constant::Int(val)) = constant.and_then(|c| miri_to_const(cx.tcx, c)) { let mut ty = cx.tcx.type_of(did); - if let ty::TyAdt(adt, _) = ty.sty { + if let ty::Adt(adt, _) = ty.sty { if adt.is_enum() { ty = adt.repr.discr_type().to_ty(cx.tcx); } } match ty.sty { - ty::TyInt(IntTy::Isize) => { + ty::Int(IntTy::Isize) => { let val = ((val as i128) << 64) >> 64; if val <= i128::from(i32::max_value()) && val >= i128::from(i32::min_value()) { continue; } } - ty::TyUint(UintTy::Usize) if val > u128::from(u32::max_value()) => {}, + ty::Uint(UintTy::Usize) if val > u128::from(u32::max_value()) => {}, _ => continue, } span_lint( diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 0e9532276f3..260cca76c8c 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -67,9 +67,9 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) { let fn_ty = cx.tables.expr_ty(caller); match fn_ty.sty { // Is it an unsafe function? They don't implement the closure traits - ty::TyFnDef(..) | ty::TyFnPtr(_) => { + ty::FnDef(..) | ty::FnPtr(_) => { let sig = fn_ty.fn_sig(cx.tcx); - if sig.skip_binder().unsafety == Unsafety::Unsafe || sig.skip_binder().output().sty == ty::TyNever { + if sig.skip_binder().unsafety == Unsafety::Unsafe || sig.skip_binder().output().sty == ty::Never { return; } }, diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 7ccf8c31569..9ddc3ddbfe7 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -130,9 +130,9 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { ExprKind::Call(ref func, _) => { let typ = self.cx.tables.expr_ty(func); match typ.sty { - ty::TyFnDef(..) | ty::TyFnPtr(_) => { + ty::FnDef(..) | ty::FnPtr(_) => { let sig = typ.fn_sig(self.cx.tcx); - if let ty::TyNever = self.cx.tcx.erase_late_bound_regions(&sig).output().sty { + if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().sty { self.report_diverging_sub_expr(e); } }, diff --git a/clippy_lints/src/excessive_precision.rs b/clippy_lints/src/excessive_precision.rs index 2c673fdfe3f..52af7e129ab 100644 --- a/clippy_lints/src/excessive_precision.rs +++ b/clippy_lints/src/excessive_precision.rs @@ -2,7 +2,7 @@ use rustc::hir; use rustc::lint::*; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; -use rustc::ty::TypeVariants; +use rustc::ty::TyKind; use std::f32; use std::f64; use std::fmt; @@ -46,7 +46,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { if_chain! { let ty = cx.tables.expr_ty(expr); - if let TypeVariants::TyFloat(fty) = ty.sty; + if let TyKind::Float(fty) = ty.sty; if let hir::ExprKind::Lit(ref lit) = expr.node; if let LitKind::Float(sym, _) | LitKind::FloatUnsuffixed(sym) = lit.node; if let Some(sugg) = self.check(sym, fty); diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 3db644911d7..22f6df65506 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -130,7 +130,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it fn match_type(tcx: ty::TyCtxt<'_, '_, '_>, ty: ty::Ty<'_>, path: &[&str]) -> bool { match ty.sty { - ty::TyAdt(adt, _) => match_def_path(tcx, adt.did, path), + ty::Adt(adt, _) => match_def_path(tcx, adt.did, path), _ => false, } } diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 80fc4c3acfe..4f83caa43dd 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -122,7 +122,7 @@ fn get_single_string_arg(cx: &LateContext<'_, '_>, expr: &Expr) -> Option if match_def_path(cx.tcx, fun_def_id, &paths::DISPLAY_FMT_METHOD); then { let ty = walk_ptrs_ty(cx.tables.pat_ty(&pat[0])); - if ty.sty == ty::TyStr || match_type(cx, ty, &paths::STRING) { + if ty.sty == ty::Str || match_type(cx, ty, &paths::STRING) { if let ExprKind::Tup(ref values) = match_expr.node { return Some(values[0].span); } diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index 939039e93ca..31e955dc570 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -63,8 +63,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp { fn check(cx: &LateContext<'_, '_>, e: &Expr, m: i8, span: Span, arg: Span) { if let Some(Constant::Int(v)) = constant_simple(cx, cx.tables, e) { let check = match cx.tables.expr_ty(e).sty { - ty::TyInt(ity) => unsext(cx.tcx, -1_i128, ity), - ty::TyUint(uty) => clip(cx.tcx, !0, uty), + ty::Int(ity) => unsext(cx.tcx, -1_i128, ity), + ty::Uint(uty) => clip(cx.tcx, !0, uty), _ => return, }; if match m { diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index 2ad31de0a17..9ec9c9f83b4 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -99,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing { let ty = cx.tables.expr_ty(array); if let Some(range) = higher::range(cx, index) { // Ranged indexes, i.e. &x[n..m], &x[n..], &x[..n] and &x[..] - if let ty::TyArray(_, s) = ty.sty { + if let ty::Array(_, s) = ty.sty { let size: u128 = s.assert_usize(cx.tcx).unwrap().into(); // Index is a constant range. if let Some((start, end)) = to_const_range(cx, range, size) { @@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IndexingSlicing { ); } else { // Catchall non-range index, i.e. [n] or [n << m] - if let ty::TyArray(..) = ty.sty { + if let ty::Array(..) = ty.sty { // Index is a constant uint. if let Some(..) = constant(cx, cx.tables, index) { // Let rustc's `const_err` lint handle constant `usize` indexing on arrays. diff --git a/clippy_lints/src/invalid_ref.rs b/clippy_lints/src/invalid_ref.rs index b529cb3ac38..9c7d4626e0a 100644 --- a/clippy_lints/src/invalid_ref.rs +++ b/clippy_lints/src/invalid_ref.rs @@ -40,7 +40,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidRef { if let ExprKind::Call(ref path, ref args) = expr.node; if let ExprKind::Path(ref qpath) = path.node; if args.len() == 0; - if let ty::TyRef(..) = cx.tables.expr_ty(expr).sty; + if let ty::Ref(..) = cx.tables.expr_ty(expr).sty; if let Some(def_id) = opt_def_id(cx.tables.qpath_def(qpath, path.hir_id)); then { let msg = if match_def_path(cx.tcx, def_id, &paths::MEM_ZEROED) | diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index ce063518880..2fb4c691ce8 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -265,12 +265,12 @@ fn has_is_empty(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr)); match ty.sty { - ty::TyDynamic(ref tt, ..) => cx.tcx + ty::Dynamic(ref tt, ..) => cx.tcx .associated_items(tt.principal().expect("trait impl not found").def_id()) .any(|item| is_is_empty(cx, &item)), - ty::TyProjection(ref proj) => has_is_empty_impl(cx, proj.item_def_id), - ty::TyAdt(id, _) => has_is_empty_impl(cx, id.did), - ty::TyArray(..) | ty::TySlice(..) | ty::TyStr => true, + ty::Projection(ref proj) => has_is_empty_impl(cx, proj.item_def_id), + ty::Adt(id, _) => has_is_empty_impl(cx, id.did), + ty::Array(..) | ty::Slice(..) | ty::Str => true, _ => false, } } diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 3dacb3cd422..973b706801a 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -759,8 +759,8 @@ struct FixedOffsetVar { fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool { let is_slice = match ty.sty { - ty::TyRef(_, subty, _) => is_slice_like(cx, subty), - ty::TySlice(..) | ty::TyArray(..) => true, + ty::Ref(_, subty, _) => is_slice_like(cx, subty), + ty::Slice(..) | ty::Array(..) => true, _ => false, }; @@ -1149,8 +1149,8 @@ fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx Constant::Int(start_idx), Constant::Int(end_idx), ) => (match ty.sty { - ty::TyInt(ity) => sext(cx.tcx, start_idx, ity) > sext(cx.tcx, end_idx, ity), - ty::TyUint(_) => start_idx > end_idx, + ty::Int(ity) => sext(cx.tcx, start_idx, ity) > sext(cx.tcx, end_idx, ity), + ty::Uint(_) => start_idx > end_idx, _ => false, }, start_idx == end_idx), _ => (false, false), @@ -1239,7 +1239,7 @@ fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat, arg: &Expr, expr: &Ex match cx.tables.expr_ty(&args[0]).sty { // If the length is greater than 32 no traits are implemented for array and // therefore we cannot use `&`. - ty::TypeVariants::TyArray(_, size) if size.assert_usize(cx.tcx).expect("array size") > 32 => (), + ty::TyKind::Array(_, size) if size.assert_usize(cx.tcx).expect("array size") > 32 => (), _ => lint_iter_method(cx, args, arg, method_name), }; } else { @@ -1381,7 +1381,7 @@ fn check_for_loop_over_map_kv<'a, 'tcx>( if pat.len() == 2 { let arg_span = arg.span; let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).sty { - ty::TyRef(_, ty, mutbl) => match (&pat[0].node, &pat[1].node) { + ty::Ref(_, ty, mutbl) => match (&pat[0].node, &pat[1].node) { (key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl), (_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, MutImmutable), _ => return, @@ -1721,7 +1721,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { for expr in args { let ty = self.cx.tables.expr_ty_adjusted(expr); self.prefer_mutable = false; - if let ty::TyRef(_, _, mutbl) = ty.sty { + if let ty::Ref(_, _, mutbl) = ty.sty { if mutbl == MutMutable { self.prefer_mutable = true; } @@ -1733,7 +1733,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { let def_id = self.cx.tables.type_dependent_defs()[expr.hir_id].def_id(); for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) { self.prefer_mutable = false; - if let ty::TyRef(_, _, mutbl) = ty.sty { + if let ty::Ref(_, _, mutbl) = ty.sty { if mutbl == MutMutable { self.prefer_mutable = true; } @@ -1814,7 +1814,7 @@ fn is_ref_iterable_type(cx: &LateContext<'_, '_>, e: &Expr) -> bool { fn is_iterable_array(ty: Ty<'_>, cx: &LateContext<'_, '_>) -> bool { // IntoIterator is currently only implemented for array sizes <= 32 in rustc match ty.sty { - ty::TyArray(_, n) => (0..=32).contains(&n.assert_usize(cx.tcx).expect("array length")), + ty::Array(_, n) => (0..=32).contains(&n.assert_usize(cx.tcx).expect("array length")), _ => false, } } diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index d8b14db605f..c570f0b32bf 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -54,7 +54,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { walk_ptrs_ty_depth(cx.tables.pat_ty(&first_arg.pat)).1 == 1 { // the argument is not an &mut T - if let ty::TyRef(_, _, mutbl) = ty.sty { + if let ty::Ref(_, _, mutbl) = ty.sty { if mutbl == MutImmutable { span_help_and_lint(cx, MAP_CLONE, expr.span, &format!( "you seem to be using .map() to clone the contents of an {}, consider \ diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 7cbed82d5c7..eff00896c7f 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -86,8 +86,8 @@ impl LintPass for Pass { fn is_unit_type(ty: ty::Ty<'_>) -> bool { match ty.sty { - ty::TyTuple(slice) => slice.is_empty(), - ty::TyNever => true, + ty::Tuple(slice) => slice.is_empty(), + ty::Never => true, _ => false, } } @@ -95,7 +95,7 @@ fn is_unit_type(ty: ty::Ty<'_>) -> bool { fn is_unit_function(cx: &LateContext<'_, '_>, expr: &hir::Expr) -> bool { let ty = cx.tables.expr_ty(expr); - if let ty::TyFnDef(id, _) = ty.sty { + if let ty::FnDef(id, _) = ty.sty { if let Some(fn_type) = cx.tcx.fn_sig(id).no_late_bound_regions() { return is_unit_type(fn_type.output()); } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 84ab72777e4..691d61f55ba 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -224,7 +224,7 @@ fn check_single_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: & return; }; let ty = cx.tables.expr_ty(ex); - if ty.sty != ty::TyBool || is_allowed(cx, MATCH_BOOL, ex.id) { + if ty.sty != ty::Bool || is_allowed(cx, MATCH_BOOL, ex.id) { check_single_match_single_pattern(cx, ex, arms, expr, els); check_single_match_opt_like(cx, ex, arms, expr, ty, els); } @@ -295,7 +295,7 @@ fn check_single_match_opt_like(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm] fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Expr) { // type of expression == bool - if cx.tables.expr_ty(ex).sty == ty::TyBool { + if cx.tables.expr_ty(ex).sty == ty::Bool { span_lint_and_then( cx, MATCH_BOOL, diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index ceb1307dfed..1c31c414d2b 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -784,7 +784,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { } match self_ty.sty { - ty::TyRef(_, ty, _) if ty.sty == ty::TyStr => for &(method, pos) in &PATTERN_METHODS { + ty::Ref(_, ty, _) if ty.sty == ty::Str => for &(method, pos) in &PATTERN_METHODS { if method_call.ident.name == method && args.len() > pos { lint_single_char_pattern(cx, expr, &args[pos]); } @@ -1113,8 +1113,8 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: /// Checks for the `CLONE_ON_COPY` lint. fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Expr, arg_ty: Ty<'_>) { let ty = cx.tables.expr_ty(expr); - if let ty::TyRef(_, inner, _) = arg_ty.sty { - if let ty::TyRef(_, innermost, _) = inner.sty { + if let ty::Ref(_, inner, _) = arg_ty.sty { + if let ty::Ref(_, innermost, _) = inner.sty { span_lint_and_then( cx, CLONE_DOUBLE_REF, @@ -1124,7 +1124,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp |db| if let Some(snip) = sugg::Sugg::hir_opt(cx, arg) { let mut ty = innermost; let mut n = 0; - while let ty::TyRef(_, inner, _) = ty.sty { + while let ty::Ref(_, inner, _) = ty.sty { ty = inner; n += 1; } @@ -1142,7 +1142,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp if is_copy(cx, ty) { let snip; if let Some(snippet) = sugg::Sugg::hir_opt(cx, arg) { - if let ty::TyRef(..) = cx.tables.expr_ty(arg).sty { + if let ty::Ref(..) = cx.tables.expr_ty(arg).sty { let parent = cx.tcx.hir.get_parent_node(expr.id); match cx.tcx.hir.get(parent) { hir::map::NodeExpr(parent) => match parent.node { @@ -1182,7 +1182,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp fn lint_clone_on_ref_ptr(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Expr) { let obj_ty = walk_ptrs_ty(cx.tables.expr_ty(arg)); - if let ty::TyAdt(_, subst) = obj_ty.sty { + if let ty::Adt(_, subst) = obj_ty.sty { let caller_type = if match_type(cx, obj_ty, &paths::RC) { "Rc" } else if match_type(cx, obj_ty, &paths::ARC) { @@ -1210,7 +1210,7 @@ fn lint_string_extend(cx: &LateContext<'_, '_>, expr: &hir::Expr, args: &[hir::E if let Some(arglists) = method_chain_args(arg, &["chars"]) { let target = &arglists[0][0]; let self_ty = walk_ptrs_ty(cx.tables.expr_ty(target)); - let ref_str = if self_ty.sty == ty::TyStr { + let ref_str = if self_ty.sty == ty::Str { "" } else if match_type(cx, self_ty, &paths::STRING) { "&" @@ -1442,11 +1442,11 @@ fn lint_iter_skip_next(cx: &LateContext<'_, '_>, expr: &hir::Expr) { fn derefs_to_slice(cx: &LateContext<'_, '_>, expr: &hir::Expr, ty: Ty<'_>) -> Option> { fn may_slice(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> bool { match ty.sty { - ty::TySlice(_) => true, - ty::TyAdt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()), - ty::TyAdt(..) => match_type(cx, ty, &paths::VEC), - ty::TyArray(_, size) => size.assert_usize(cx.tcx).expect("array length") < 32, - ty::TyRef(_, inner, _) => may_slice(cx, inner), + ty::Slice(_) => true, + ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()), + ty::Adt(..) => match_type(cx, ty, &paths::VEC), + ty::Array(_, size) => size.assert_usize(cx.tcx).expect("array length") < 32, + ty::Ref(_, inner, _) => may_slice(cx, inner), _ => false, } } @@ -1459,9 +1459,9 @@ fn derefs_to_slice(cx: &LateContext<'_, '_>, expr: &hir::Expr, ty: Ty<'_>) -> Op } } else { match ty.sty { - ty::TySlice(_) => sugg::Sugg::hir_opt(cx, expr), - ty::TyAdt(def, _) if def.is_box() && may_slice(cx, ty.boxed_ty()) => sugg::Sugg::hir_opt(cx, expr), - ty::TyRef(_, inner, _) => if may_slice(cx, inner) { + ty::Slice(_) => sugg::Sugg::hir_opt(cx, expr), + ty::Adt(def, _) if def.is_box() && may_slice(cx, ty.boxed_ty()) => sugg::Sugg::hir_opt(cx, expr), + ty::Ref(_, inner, _) => if may_slice(cx, inner) { sugg::Sugg::hir_opt(cx, expr) } else { None @@ -1812,7 +1812,7 @@ fn lint_chars_cmp( then { let self_ty = walk_ptrs_ty(cx.tables.expr_ty_adjusted(&args[0][0])); - if self_ty.sty != ty::TyStr { + if self_ty.sty != ty::Str { return false; } @@ -1939,7 +1939,7 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re /// Given a `Result` type, return its error type (`E`). fn get_error_type<'a>(cx: &LateContext<'_, '_>, ty: Ty<'a>) -> Option> { - if let ty::TyAdt(_, substs) = ty.sty { + if let ty::Adt(_, substs) = ty.sty { if match_type(cx, ty, &paths::RESULT) { substs.types().nth(1) } else { diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index fc9b72ba949..a43c60f111f 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -465,7 +465,7 @@ fn is_allowed<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) -> bool { } fn is_float(cx: &LateContext<'_, '_>, expr: &Expr) -> bool { - matches!(walk_ptrs_ty(cx.tables.expr_ty(expr)).sty, ty::TyFloat(_)) + matches!(walk_ptrs_ty(cx.tables.expr_ty(expr)).sty, ty::Float(_)) } fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index 0413f1ab603..d8561241001 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -71,7 +71,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> { expr.span, "generally you want to avoid `&mut &mut _` if possible", ); - } else if let ty::TyRef( + } else if let ty::Ref( _, _, hir::MutMutable, diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index de4c5444440..02a80a19e79 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -58,16 +58,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed { fn check_arguments<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arguments: &[Expr], type_definition: Ty<'tcx>, name: &str) { match type_definition.sty { - ty::TyFnDef(..) | ty::TyFnPtr(_) => { + ty::FnDef(..) | ty::FnPtr(_) => { let parameters = type_definition.fn_sig(cx.tcx).skip_binder().inputs(); for (argument, parameter) in arguments.iter().zip(parameters.iter()) { match parameter.sty { - ty::TyRef( + ty::Ref( _, _, MutImmutable, ) | - ty::TyRawPtr(ty::TypeAndMut { + ty::RawPtr(ty::TypeAndMut { mutbl: MutImmutable, .. }) => if let ExprKind::AddrOf(MutMutable, _) = argument.node { diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index 50ef9f268f2..8b56526f495 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -60,7 +60,7 @@ pub struct MutexAtomic; impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutexAtomic { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { let ty = cx.tables.expr_ty(expr); - if let ty::TyAdt(_, subst) = ty.sty { + if let ty::Adt(_, subst) = ty.sty { if match_type(cx, ty, &paths::MUTEX) { let mutex_param = subst.type_at(0); if let Some(atomic_name) = get_atomic_name(mutex_param) { @@ -70,8 +70,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutexAtomic { atomic_name ); match mutex_param.sty { - ty::TyUint(t) if t != ast::UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), - ty::TyInt(t) if t != ast::IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), + ty::Uint(t) if t != ast::UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), + ty::Int(t) if t != ast::IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), _ => span_lint(cx, MUTEX_ATOMIC, expr.span, &msg), }; } @@ -82,10 +82,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutexAtomic { fn get_atomic_name(ty: Ty<'_>) -> Option<(&'static str)> { match ty.sty { - ty::TyBool => Some("AtomicBool"), - ty::TyUint(_) => Some("AtomicUsize"), - ty::TyInt(_) => Some("AtomicIsize"), - ty::TyRawPtr(_) => Some("AtomicPtr"), + ty::Bool => Some("AtomicBool"), + ty::Uint(_) => Some("AtomicUsize"), + ty::Int(_) => Some("AtomicIsize"), + ty::RawPtr(_) => Some("AtomicPtr"), _ => None, } } diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index cb2c572743d..ae931e58326 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -54,7 +54,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { return; } if let ExprKind::AddrOf(MutImmutable, ref inner) = e.node { - if let ty::TyRef(..) = cx.tables.expr_ty(inner).sty { + if let ty::Ref(..) = cx.tables.expr_ty(inner).sty { for adj3 in cx.tables.expr_adjustments(e).windows(3) { if let [Adjustment { kind: Adjust::Deref(_), @@ -90,9 +90,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { } if_chain! { if let PatKind::Binding(BindingAnnotation::Ref, _, name, _) = pat.node; - if let ty::TyRef(_, tam, mutbl) = cx.tables.pat_ty(pat).sty; + if let ty::Ref(_, tam, mutbl) = cx.tables.pat_ty(pat).sty; if mutbl == MutImmutable; - if let ty::TyRef(_, _, mutbl) = tam.sty; + if let ty::Ref(_, _, mutbl) = tam.sty; // only lint immutable refs, because borrowed `&mut T` cannot be moved out if mutbl == MutImmutable; then { diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 82e85f3453a..c93cda55724 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -205,7 +205,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { // Dereference suggestion let sugg = |db: &mut DiagnosticBuilder<'_>| { - if let ty::TypeVariants::TyAdt(def, ..) = ty.sty { + if let ty::TyKind::Adt(def, ..) = ty.sty { if let Some(span) = cx.tcx.hir.span_if_local(def.did) { if cx.param_env.can_type_implement_copy(cx.tcx, ty).is_ok() { db.span_help(span, "consider marking this type as Copy"); diff --git a/clippy_lints/src/needless_update.rs b/clippy_lints/src/needless_update.rs index 52c4c6e5237..90a1ee14a6d 100644 --- a/clippy_lints/src/needless_update.rs +++ b/clippy_lints/src/needless_update.rs @@ -35,7 +35,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { if let ExprKind::Struct(_, ref fields, Some(ref base)) = expr.node { let ty = cx.tables.expr_ty(expr); - if let ty::TyAdt(def, _) = ty.sty { + if let ty::Adt(def, _) = ty.sty { if fields.len() == def.non_enum_variant().fields.len() { span_lint( cx, diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 77b945f48fd..224326b3d17 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -169,7 +169,7 @@ fn create_new_without_default_suggest_msg(ty: Ty<'_>) -> String { fn can_derive_default<'t, 'c>(ty: Ty<'t>, cx: &LateContext<'c, 't>, default_trait_id: DefId) -> Option { match ty.sty { - ty::TyAdt(adt_def, substs) if adt_def.is_struct() => { + ty::Adt(adt_def, substs) if adt_def.is_struct() => { for field in adt_def.all_fields() { let f_ty = field.ty(cx.tcx, substs); if !implements_trait(cx, f_ty, default_trait_id, &[]) { diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index cbf17138137..b040bd91f8d 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -152,7 +152,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id: let fn_ty = sig.skip_binder(); for (idx, (arg, ty)) in decl.inputs.iter().zip(fn_ty.inputs()).enumerate() { - if let ty::TyRef( + if let ty::Ref( _, ty, MutImmutable diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index f5c25737993..cc4aa129870 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -155,7 +155,7 @@ fn check_decl<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx Decl, bindings: fn is_binding(cx: &LateContext<'_, '_>, pat_id: HirId) -> bool { let var_ty = cx.tables.node_id_to_type(pat_id); match var_ty.sty { - ty::TyAdt(..) => false, + ty::Adt(..) => false, _ => true, } } diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 38369d05676..8b10396443f 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -93,8 +93,8 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { if SpanlessEq::new(cx).ignore_fn().eq_expr(lhs1, lhs2) { let ty = walk_ptrs_ty(cx.tables.expr_ty(lhs1)); - if matches!(ty.sty, ty::TySlice(_)) || - matches!(ty.sty, ty::TyArray(_, _)) || + if matches!(ty.sty, ty::Slice(_)) || + matches!(ty.sty, ty::Array(_, _)) || match_type(cx, ty, &paths::VEC) || match_type(cx, ty, &paths::VEC_DEQUE) { return Some((lhs1, idx1, idx2)); diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index 403aeb47402..28c5971e852 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -231,7 +231,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { e.span, &format!("transmute from a type (`{}`) to itself", from_ty), ), - (&ty::TyRef(_, rty, rty_mutbl), &ty::TyRawPtr(ptr_ty)) => span_lint_and_then( + (&ty::Ref(_, rty, rty_mutbl), &ty::RawPtr(ptr_ty)) => span_lint_and_then( cx, USELESS_TRANSMUTE, e.span, @@ -248,7 +248,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { db.span_suggestion(e.span, "try", sugg.to_string()); }, ), - (&ty::TyInt(_), &ty::TyRawPtr(_)) | (&ty::TyUint(_), &ty::TyRawPtr(_)) => { + (&ty::Int(_), &ty::RawPtr(_)) | (&ty::Uint(_), &ty::RawPtr(_)) => { span_lint_and_then( cx, USELESS_TRANSMUTE, @@ -259,16 +259,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { }, ) }, - (&ty::TyFloat(_), &ty::TyRef(..)) | - (&ty::TyFloat(_), &ty::TyRawPtr(_)) | - (&ty::TyChar, &ty::TyRef(..)) | - (&ty::TyChar, &ty::TyRawPtr(_)) => span_lint( + (&ty::Float(_), &ty::Ref(..)) | + (&ty::Float(_), &ty::RawPtr(_)) | + (&ty::Char, &ty::Ref(..)) | + (&ty::Char, &ty::RawPtr(_)) => span_lint( cx, WRONG_TRANSMUTE, e.span, &format!("transmute from a `{}` to a pointer", from_ty), ), - (&ty::TyRawPtr(from_ptr), _) if from_ptr.ty == to_ty => span_lint( + (&ty::RawPtr(from_ptr), _) if from_ptr.ty == to_ty => span_lint( cx, CROSSPOINTER_TRANSMUTE, e.span, @@ -278,7 +278,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { to_ty ), ), - (_, &ty::TyRawPtr(to_ptr)) if to_ptr.ty == from_ty => span_lint( + (_, &ty::RawPtr(to_ptr)) if to_ptr.ty == from_ty => span_lint( cx, CROSSPOINTER_TRANSMUTE, e.span, @@ -288,7 +288,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { to_ty ), ), - (&ty::TyRawPtr(from_pty), &ty::TyRef(_, to_ref_ty, mutbl)) => span_lint_and_then( + (&ty::RawPtr(from_pty), &ty::Ref(_, to_ref_ty, mutbl)) => span_lint_and_then( cx, TRANSMUTE_PTR_TO_REF, e.span, @@ -315,16 +315,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { db.span_suggestion(e.span, "try", sugg::make_unop(deref, arg).to_string()); }, ), - (&ty::TyInt(ast::IntTy::I32), &ty::TyChar) | - (&ty::TyUint(ast::UintTy::U32), &ty::TyChar) => span_lint_and_then( + (&ty::Int(ast::IntTy::I32), &ty::Char) | + (&ty::Uint(ast::UintTy::U32), &ty::Char) => span_lint_and_then( cx, TRANSMUTE_INT_TO_CHAR, e.span, &format!("transmute from a `{}` to a `char`", from_ty), |db| { let arg = sugg::Sugg::hir(cx, &args[0], ".."); - let arg = if let ty::TyInt(_) = from_ty.sty { - arg.as_ty(ty::TyUint(ast::UintTy::U32)) + let arg = if let ty::Int(_) = from_ty.sty { + arg.as_ty(ty::Uint(ast::UintTy::U32)) } else { arg }; @@ -335,10 +335,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { ); }, ), - (&ty::TyRef(_, ty_from, from_mutbl), &ty::TyRef(_, ty_to, to_mutbl)) => { + (&ty::Ref(_, ty_from, from_mutbl), &ty::Ref(_, ty_to, to_mutbl)) => { if_chain! { - if let (&ty::TySlice(slice_ty), &ty::TyStr) = (&ty_from.sty, &ty_to.sty); - if let ty::TyUint(ast::UintTy::U8) = slice_ty.sty; + if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.sty, &ty_to.sty); + if let ty::Uint(ast::UintTy::U8) = slice_ty.sty; if from_mutbl == to_mutbl; then { let postfix = if from_mutbl == Mutability::MutMutable { @@ -387,7 +387,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { } } }, - (&ty::TyRawPtr(_), &ty::TyRawPtr(to_ty)) => span_lint_and_then( + (&ty::RawPtr(_), &ty::RawPtr(to_ty)) => span_lint_and_then( cx, TRANSMUTE_PTR_TO_PTR, e.span, @@ -397,7 +397,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { db.span_suggestion(e.span, "try", sugg.to_string()); }, ), - (&ty::TyInt(ast::IntTy::I8), &ty::TyBool) | (&ty::TyUint(ast::UintTy::U8), &ty::TyBool) => { + (&ty::Int(ast::IntTy::I8), &ty::Bool) | (&ty::Uint(ast::UintTy::U8), &ty::Bool) => { span_lint_and_then( cx, TRANSMUTE_INT_TO_BOOL, @@ -414,7 +414,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { }, ) }, - (&ty::TyInt(_), &ty::TyFloat(_)) | (&ty::TyUint(_), &ty::TyFloat(_)) => { + (&ty::Int(_), &ty::Float(_)) | (&ty::Uint(_), &ty::Float(_)) => { span_lint_and_then( cx, TRANSMUTE_INT_TO_FLOAT, @@ -422,7 +422,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { &format!("transmute from a `{}` to a `{}`", from_ty, to_ty), |db| { let arg = sugg::Sugg::hir(cx, &args[0], ".."); - let arg = if let ty::TyInt(int_ty) = from_ty.sty { + let arg = if let ty::Int(int_ty) = from_ty.sty { arg.as_ty(format!( "u{}", int_ty diff --git a/clippy_lints/src/trivially_copy_pass_by_ref.rs b/clippy_lints/src/trivially_copy_pass_by_ref.rs index a01a1c5ae31..d88a970db75 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -1,13 +1,14 @@ use std::cmp; use matches::matches; +use rustc::hir; use rustc::hir::*; use rustc::hir::map::*; use rustc::hir::intravisit::FnKind; use rustc::lint::*; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; -use rustc::ty::TypeVariants; +use rustc::ty::TyKind; use rustc::session::config::Config as SessionConfig; use rustc_target::spec::abi::Abi; use rustc_target::abi::LayoutOf; @@ -125,8 +126,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef { // argument. In that case we can't switch to pass-by-value as the // argument will not live long enough. let output_lts = match fn_sig.output().sty { - TypeVariants::TyRef(output_lt, _, _) => vec![output_lt], - TypeVariants::TyAdt(_, substs) => substs.regions().collect(), + TyKind::Ref(output_lt, _, _) => vec![output_lt], + TyKind::Adt(_, substs) => substs.regions().collect(), _ => vec![], }; @@ -137,12 +138,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef { } if_chain! { - if let TypeVariants::TyRef(input_lt, ty, Mutability::MutImmutable) = ty.sty; + if let TyKind::Ref(input_lt, ty, Mutability::MutImmutable) = ty.sty; if !output_lts.contains(&input_lt); if is_copy(cx, ty); if let Some(size) = cx.layout_of(ty).ok().map(|l| l.size.bytes()); if size <= self.limit; - if let TyKind::Rptr(_, MutTy { ty: ref decl_ty, .. }) = input.node; + if let hir::TyKind::Rptr(_, MutTy { ty: ref decl_ty, .. }) = input.node; then { let value_type = if is_self(arg) { "self".into() diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 3b311847795..024aba7e85e 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -550,7 +550,7 @@ fn is_questionmark_desugar_marked_call(expr: &Expr) -> bool { fn is_unit(ty: Ty<'_>) -> bool { match ty.sty { - ty::TyTuple(slice) if slice.is_empty() => true, + ty::Tuple(slice) if slice.is_empty() => true, _ => false, } } @@ -755,7 +755,7 @@ declare_clippy_lint! { /// Will return 0 if the type is not an int or uint variant fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_, '_, '_>) -> u64 { match typ.sty { - ty::TyInt(i) => match i { + ty::Int(i) => match i { IntTy::Isize => tcx.data_layout.pointer_size.bits(), IntTy::I8 => 8, IntTy::I16 => 16, @@ -763,7 +763,7 @@ fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_, '_, '_>) -> u64 { IntTy::I64 => 64, IntTy::I128 => 128, }, - ty::TyUint(i) => match i { + ty::Uint(i) => match i { UintTy::Usize => tcx.data_layout.pointer_size.bits(), UintTy::U8 => 8, UintTy::U16 => 16, @@ -777,7 +777,7 @@ fn int_ty_to_nbits(typ: Ty<'_>, tcx: TyCtxt<'_, '_, '_>) -> u64 { fn is_isize_or_usize(typ: Ty<'_>) -> bool { match typ.sty { - ty::TyInt(IntTy::Isize) | ty::TyUint(UintTy::Usize) => true, + ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize) => true, _ => false, } } @@ -973,7 +973,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass { match (cast_from.is_integral(), cast_to.is_integral()) { (true, false) => { let from_nbits = int_ty_to_nbits(cast_from, cx.tcx); - let to_nbits = if let ty::TyFloat(FloatTy::F32) = cast_to.sty { + let to_nbits = if let ty::Float(FloatTy::F32) = cast_to.sty { 32 } else { 64 @@ -1014,7 +1014,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass { check_lossless(cx, expr, ex, cast_from, cast_to); }, (false, false) => { - if let (&ty::TyFloat(FloatTy::F64), &ty::TyFloat(FloatTy::F32)) = (&cast_from.sty, &cast_to.sty) + if let (&ty::Float(FloatTy::F64), &ty::Float(FloatTy::F32)) = (&cast_from.sty, &cast_to.sty) { span_lint( cx, @@ -1023,7 +1023,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass { "casting f64 to f32 may truncate the value", ); } - if let (&ty::TyFloat(FloatTy::F32), &ty::TyFloat(FloatTy::F64)) = (&cast_from.sty, &cast_to.sty) + if let (&ty::Float(FloatTy::F32), &ty::Float(FloatTy::F64)) = (&cast_from.sty, &cast_to.sty) { span_lossless_lint(cx, expr, ex, cast_from, cast_to); } @@ -1032,9 +1032,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass { } match &cast_from.sty { - ty::TyFnDef(..) | - ty::TyFnPtr(..) => { - if cast_to.is_numeric() && cast_to.sty != ty::TyUint(UintTy::Usize){ + ty::FnDef(..) | + ty::FnPtr(..) => { + if cast_to.is_numeric() && cast_to.sty != ty::Uint(UintTy::Usize){ let to_nbits = int_ty_to_nbits(cast_to, cx.tcx); let pointer_nbits = cx.tcx.data_layout.pointer_size.bits(); if to_nbits < pointer_nbits || (to_nbits == pointer_nbits && cast_to.is_signed()) { @@ -1063,8 +1063,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass { } if_chain!{ - if let ty::TyRawPtr(from_ptr_ty) = &cast_from.sty; - if let ty::TyRawPtr(to_ptr_ty) = &cast_to.sty; + if let ty::RawPtr(from_ptr_ty) = &cast_from.sty; + if let ty::RawPtr(to_ptr_ty) = &cast_to.sty; if let Some(from_align) = cx.layout_of(from_ptr_ty.ty).ok().map(|a| a.align.abi()); if let Some(to_align) = cx.layout_of(to_ptr_ty.ty).ok().map(|a| a.align.abi()); if from_align < to_align; @@ -1294,7 +1294,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CharLitAsU8 { if let ExprKind::Cast(ref e, _) = expr.node { if let ExprKind::Lit(ref l) = e.node { if let LitKind::Char(_) = l.node { - if ty::TyUint(UintTy::U8) == cx.tables.expr_ty(expr).sty && !in_macro(expr.span) { + if ty::Uint(UintTy::U8) == cx.tables.expr_ty(expr).sty && !in_macro(expr.span) { let msg = "casting character literal to u8. `char`s \ are 4 bytes wide in rust, so casting to u8 \ truncates them"; @@ -1434,13 +1434,13 @@ fn detect_extreme_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) - let cv = constant(cx, cx.tables, expr)?.0; let which = match (&ty.sty, cv) { - (&ty::TyBool, Constant::Bool(false)) | - (&ty::TyUint(_), Constant::Int(0)) => Minimum, - (&ty::TyInt(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::min_value() >> (128 - int_bits(cx.tcx, ity)), ity) => Minimum, + (&ty::Bool, Constant::Bool(false)) | + (&ty::Uint(_), Constant::Int(0)) => Minimum, + (&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::min_value() >> (128 - int_bits(cx.tcx, ity)), ity) => Minimum, - (&ty::TyBool, Constant::Bool(true)) => Maximum, - (&ty::TyInt(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::max_value() >> (128 - int_bits(cx.tcx, ity)), ity) => Maximum, - (&ty::TyUint(uty), Constant::Int(i)) if clip(cx.tcx, u128::max_value(), uty) == i => Maximum, + (&ty::Bool, Constant::Bool(true)) => Maximum, + (&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::max_value() >> (128 - int_bits(cx.tcx, ity)), ity) => Maximum, + (&ty::Uint(uty), Constant::Int(i)) if clip(cx.tcx, u128::max_value(), uty) == i => Maximum, _ => return None, }; @@ -1574,7 +1574,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> return None; } match pre_cast_ty.sty { - ty::TyInt(int_ty) => Some(match int_ty { + ty::Int(int_ty) => Some(match int_ty { IntTy::I8 => (FullInt::S(i128::from(i8::min_value())), FullInt::S(i128::from(i8::max_value()))), IntTy::I16 => ( FullInt::S(i128::from(i16::min_value())), @@ -1591,7 +1591,7 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr) -> IntTy::I128 => (FullInt::S(i128::min_value() as i128), FullInt::S(i128::max_value() as i128)), IntTy::Isize => (FullInt::S(isize::min_value() as i128), FullInt::S(isize::max_value() as i128)), }), - ty::TyUint(uint_ty) => Some(match uint_ty { + ty::Uint(uint_ty) => Some(match uint_ty { UintTy::U8 => (FullInt::U(u128::from(u8::min_value())), FullInt::U(u128::from(u8::max_value()))), UintTy::U16 => ( FullInt::U(u128::from(u16::min_value())), @@ -1619,8 +1619,8 @@ fn node_as_const_fullint<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) let val = constant(cx, cx.tables, expr)?.0; if let Constant::Int(const_int) = val { match cx.tables.expr_ty(expr).sty { - ty::TyInt(ity) => Some(FullInt::S(sext(cx.tcx, const_int, ity))), - ty::TyUint(_) => Some(FullInt::U(const_int)), + ty::Int(ity) => Some(FullInt::S(sext(cx.tcx, const_int, ity))), + ty::Uint(_) => Some(FullInt::U(const_int)), _ => None, } } else { diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 3931f6c55f9..65d58c4e55b 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -48,7 +48,7 @@ pub struct Range<'a> { pub fn range<'a, 'b, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'b hir::Expr) -> Option> { let def_path = match cx.tables.expr_ty(expr).sty { - ty::TyAdt(def, _) => cx.tcx.def_path(def.did), + ty::Adt(def, _) => cx.tcx.def_path(def.did), _ => return None, }; diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 0182ae6a1a0..b753f8072d0 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -101,7 +101,7 @@ pub fn match_def_path(tcx: TyCtxt<'_, '_, '_>, def_id: DefId, path: &[&str]) -> /// Check if type is struct, enum or union type with given def path. pub fn match_type(cx: &LateContext<'_, '_>, ty: Ty<'_>, path: &[&str]) -> bool { match ty.sty { - ty::TyAdt(adt, _) => match_def_path(cx.tcx, adt.did, path), + ty::Adt(adt, _) => match_def_path(cx.tcx, adt.did, path), _ => false, } } @@ -631,7 +631,7 @@ pub fn walk_ptrs_hir_ty(ty: &hir::Ty) -> &hir::Ty { /// Return the base type for references and raw pointers. pub fn walk_ptrs_ty(ty: Ty<'_>) -> Ty<'_> { match ty.sty { - ty::TyRef(_, ty, _) => walk_ptrs_ty(ty), + ty::Ref(_, ty, _) => walk_ptrs_ty(ty), _ => ty, } } @@ -641,7 +641,7 @@ pub fn walk_ptrs_ty(ty: Ty<'_>) -> Ty<'_> { pub fn walk_ptrs_ty_depth(ty: Ty<'_>) -> (Ty<'_>, usize) { fn inner(ty: Ty<'_>, depth: usize) -> (Ty<'_>, usize) { match ty.sty { - ty::TyRef(_, ty, _) => inner(ty, depth + 1), + ty::Ref(_, ty, _) => inner(ty, depth + 1), _ => (ty, depth), } } @@ -842,7 +842,7 @@ pub fn same_tys<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) /// Return whether the given type is an `unsafe` function. pub fn type_is_unsafe_function<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool { match ty.sty { - ty::TyFnDef(..) | ty::TyFnPtr(_) => ty.fn_sig(cx.tcx).unsafety() == Unsafety::Unsafe, + ty::FnDef(..) | ty::FnPtr(_) => ty.fn_sig(cx.tcx).unsafety() == Unsafety::Unsafe, _ => false, } } @@ -927,7 +927,7 @@ pub fn opt_def_id(def: Def) -> Option { Def::TyAlias(id) | Def::AssociatedTy(id) | Def::TyParam(id) | - Def::TyForeign(id) | + Def::ForeignTy(id) | Def::Struct(id) | Def::StructCtor(id, ..) | Def::Union(id) | diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index 9e0cd06134b..f86ce5ab786 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -37,8 +37,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { // search for `&vec![_]` expressions where the adjusted type is `&[_]` if_chain! { - if let ty::TyRef(_, ty, _) = cx.tables.expr_ty_adjusted(expr).sty; - if let ty::TySlice(..) = ty.sty; + if let ty::Ref(_, ty, _) = cx.tables.expr_ty_adjusted(expr).sty; + if let ty::Slice(..) = ty.sty; if let ExprKind::AddrOf(_, ref addressee) = expr.node; if let Some(vec_args) = higher::vec_macro(cx, addressee); then { @@ -95,7 +95,7 @@ fn check_vec_macro<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, vec_args: &higher::VecA /// Return the item type of the vector (ie. the `T` in `Vec`). fn vec_type(ty: Ty<'_>) -> Ty<'_> { - if let ty::TyAdt(_, substs) = ty.sty { + if let ty::Adt(_, substs) = ty.sty { substs.type_at(0) } else { panic!("The type of `vec!` is a not a struct?"); From 37099ae0348b1fc8d369f30df7887d775b5a1b99 Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Thu, 23 Aug 2018 15:36:07 +0200 Subject: [PATCH 09/53] Remove now stable tool_attributes feature --- clippy_lints/src/lib.rs | 2 -- tests/needless_continue_helpers.rs | 2 +- tests/trim_multiline.rs | 2 +- tests/ui/author.rs | 2 +- tests/ui/author/call.rs | 2 +- tests/ui/author/for_loop.rs | 2 +- tests/ui/cyclomatic_complexity.rs | 2 +- tests/ui/cyclomatic_complexity_attr_used.rs | 2 +- tests/ui/trailing_zeros.rs | 2 +- 9 files changed, 8 insertions(+), 10 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 76649d8a145..c8e5aabc00a 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -8,10 +8,8 @@ #![feature(macro_vis_matcher)] #![allow(unknown_lints, shadow_reuse, missing_docs_in_private_items)] #![recursion_limit = "256"] -#![allow(stable_features)] #![feature(iterator_find_map)] #![feature(macro_at_most_once_rep)] -#![feature(tool_attributes)] #![warn(rust_2018_idioms)] use toml; diff --git a/tests/needless_continue_helpers.rs b/tests/needless_continue_helpers.rs index f608ef1ad02..2f6f5c0a81c 100644 --- a/tests/needless_continue_helpers.rs +++ b/tests/needless_continue_helpers.rs @@ -1,4 +1,4 @@ -#![feature(tool_attributes)] + // Tests for the various helper functions used by the needless_continue // lint that don't belong in utils. diff --git a/tests/trim_multiline.rs b/tests/trim_multiline.rs index a61eee40928..a0db2e59a29 100644 --- a/tests/trim_multiline.rs +++ b/tests/trim_multiline.rs @@ -1,4 +1,4 @@ -#![feature(tool_attributes)] + /// test the multiline-trim function extern crate clippy_lints; diff --git a/tests/ui/author.rs b/tests/ui/author.rs index eec26bcce3c..e8a04bb7b13 100644 --- a/tests/ui/author.rs +++ b/tests/ui/author.rs @@ -1,4 +1,4 @@ -#![feature(tool_attributes)] + fn main() { diff --git a/tests/ui/author/call.rs b/tests/ui/author/call.rs index 8d085112f3b..c3e9846e21c 100755 --- a/tests/ui/author/call.rs +++ b/tests/ui/author/call.rs @@ -1,4 +1,4 @@ -#![feature(tool_attributes)] + fn main() { #[clippy::author] diff --git a/tests/ui/author/for_loop.rs b/tests/ui/author/for_loop.rs index 026aee4746d..b3dec876535 100644 --- a/tests/ui/author/for_loop.rs +++ b/tests/ui/author/for_loop.rs @@ -1,4 +1,4 @@ -#![feature(tool_attributes, stmt_expr_attributes)] +#![feature(stmt_expr_attributes)] fn main() { #[clippy::author] diff --git a/tests/ui/cyclomatic_complexity.rs b/tests/ui/cyclomatic_complexity.rs index 3214505ba1e..7166ed25948 100644 --- a/tests/ui/cyclomatic_complexity.rs +++ b/tests/ui/cyclomatic_complexity.rs @@ -1,4 +1,4 @@ -#![feature(tool_attributes)] + #![allow(clippy)] #![warn(cyclomatic_complexity)] diff --git a/tests/ui/cyclomatic_complexity_attr_used.rs b/tests/ui/cyclomatic_complexity_attr_used.rs index 50b19f9d7ba..dbd4e438a12 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.rs +++ b/tests/ui/cyclomatic_complexity_attr_used.rs @@ -1,4 +1,4 @@ -#![feature(tool_attributes)] + #![warn(cyclomatic_complexity)] #![warn(unused)] diff --git a/tests/ui/trailing_zeros.rs b/tests/ui/trailing_zeros.rs index 5494e780628..58c04d292bc 100644 --- a/tests/ui/trailing_zeros.rs +++ b/tests/ui/trailing_zeros.rs @@ -1,4 +1,4 @@ -#![feature(stmt_expr_attributes, tool_attributes)] +#![feature(stmt_expr_attributes)] #![allow(unused_parens)] From 8ab16b678c0473b29d034cad5ab1fccb1b35944e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 23 Aug 2018 13:12:27 +0200 Subject: [PATCH 10/53] remove macro_vis_matcher feature gate since it is stable now. Warning was: warning: the feature `macro_vis_matcher` has been stable since 1.29.0 and no longer requires an attribute to enable --> src/lib.rs:4:12 | 4 | #![feature(macro_vis_matcher)] | ^^^^^^^^^^^^^^^^^ | = note: #[warn(stable_features)] on by default --- clippy_lints/src/lib.rs | 1 - src/lib.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index c8e5aabc00a..6064601fd80 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -5,7 +5,6 @@ #![feature(slice_patterns)] #![feature(stmt_expr_attributes)] #![feature(range_contains)] -#![feature(macro_vis_matcher)] #![allow(unknown_lints, shadow_reuse, missing_docs_in_private_items)] #![recursion_limit = "256"] #![feature(iterator_find_map)] diff --git a/src/lib.rs b/src/lib.rs index e6aaff1b2a9..1525dbda4ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ // error-pattern:cargo-clippy #![feature(plugin_registrar)] #![feature(rustc_private)] -#![feature(macro_vis_matcher)] #![allow(unknown_lints)] #![allow(missing_docs_in_private_items)] #![warn(rust_2018_idioms)] From 6a0703664b5f57b797a44d9552d660ec4177611b Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 23 Aug 2018 08:38:41 -0700 Subject: [PATCH 11/53] Remove incorrect note from string_add_assign docs The docs claim that `String::push_str` is better than `String::add` because `String::add` allocates a new string and drops the old one, but this is not true. In fact, `add` reuses the existing string and grows it only if its capacity is exceeded, exactly like `push_str`. Their performance is identical since `add` is just a wrapper for `push_str`: ``` fn add(mut self, other: &str) -> String { self.push_str(other); self } ``` https://github.com/rust-lang/rust/blob/35bf1ae25799a4e62131159f052e0a3cbd27c960/src/liballoc/string.rs#L1922-L1925 --- clippy_lints/src/strings.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index d66163984aa..1b6f65046a0 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -9,8 +9,7 @@ use crate::utils::{get_parent_expr, is_allowed, match_type, paths, span_lint, sp /// `let`!). /// /// **Why is this bad?** It's not really bad, but some people think that the -/// `.push_str(_)` method is more readable. Also creates a new heap allocation and throws -/// away the old one. +/// `.push_str(_)` method is more readable. /// /// **Known problems:** None. /// From c98987f39016cdceca56cdbe2bfac758d460b8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 23 Aug 2018 21:41:30 +0200 Subject: [PATCH 12/53] fix clippy breakage due to https://github.com/rust-lang/rust/pull/52602 --- clippy_lints/src/utils/sugg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index d513fb8bced..3d587a72eec 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -105,7 +105,6 @@ impl<'a> Sugg<'a> { ast::ExprKind::Block(..) | ast::ExprKind::Break(..) | ast::ExprKind::Call(..) | - ast::ExprKind::Catch(..) | ast::ExprKind::Continue(..) | ast::ExprKind::Yield(..) | ast::ExprKind::Field(..) | @@ -122,6 +121,7 @@ impl<'a> Sugg<'a> { ast::ExprKind::Ret(..) | ast::ExprKind::Struct(..) | ast::ExprKind::Try(..) | + ast::ExprKind::TryBlock(..) | ast::ExprKind::Tup(..) | ast::ExprKind::Array(..) | ast::ExprKind::While(..) | From afdf3500600b27b1a54ac54e042eb4370d796837 Mon Sep 17 00:00:00 2001 From: Niklas Fiekas Date: Tue, 17 Jul 2018 19:22:55 +0200 Subject: [PATCH 13/53] Add copy_iterator lint (#1534) --- clippy_lints/src/copy_iterator.rs | 57 +++++++++++++++++++++++++++++++ clippy_lints/src/lib.rs | 3 ++ tests/ui/copy_iterator.rs | 23 +++++++++++++ tests/ui/copy_iterator.stderr | 17 +++++++++ 4 files changed, 100 insertions(+) create mode 100644 clippy_lints/src/copy_iterator.rs create mode 100644 tests/ui/copy_iterator.rs create mode 100644 tests/ui/copy_iterator.stderr diff --git a/clippy_lints/src/copy_iterator.rs b/clippy_lints/src/copy_iterator.rs new file mode 100644 index 00000000000..ac0c2ed32c6 --- /dev/null +++ b/clippy_lints/src/copy_iterator.rs @@ -0,0 +1,57 @@ +use crate::utils::{is_copy, match_path, paths, span_note_and_lint}; +use rustc::hir::{Item, ItemKind}; +use rustc::lint::*; +use rustc::{declare_lint, lint_array}; + +/// **What it does:** Checks for types that implement `Copy` as well as +/// `Iterator`. +/// +/// **Why is this bad?** Implicit copies can be confusing when working with +/// iterator combinators. +/// +/// **Known problems:** None. +/// +/// **Example:** +/// ```rust +/// #[derive(Copy, Clone)] +/// struct Countdown(u8); +/// +/// impl Iterator for Countdown { +/// // ... +/// } +/// +/// let a: Vec<_> = my_iterator.take(1).collect(); +/// let b: Vec<_> = my_iterator.collect(); +/// ``` +declare_clippy_lint! { + pub COPY_ITERATOR, + pedantic, + "implementing `Iterator` on a `Copy` type" +} + +pub struct CopyIterator; + +impl LintPass for CopyIterator { + fn get_lints(&self) -> LintArray { + lint_array![COPY_ITERATOR] + } +} + +impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator { + fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { + if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node { + let ty = cx.tcx.type_of(cx.tcx.hir.local_def_id(item.id)); + + if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) { + span_note_and_lint( + cx, + COPY_ITERATOR, + item.span, + "you are implementing `Iterator` on a `Copy` type", + item.span, + "consider implementing `IntoIterator` instead", + ); + } + } + } +} diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 6064601fd80..ee2f0ca5406 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -66,6 +66,7 @@ pub mod bytecount; pub mod collapsible_if; pub mod const_static_lifetime; pub mod copies; +pub mod copy_iterator; pub mod cyclomatic_complexity; pub mod default_trait_access; pub mod derive; @@ -338,6 +339,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { reg.register_late_lint_pass(box types::InvalidUpcastComparisons); reg.register_late_lint_pass(box regex::Pass::default()); reg.register_late_lint_pass(box copies::CopyAndPaste); + reg.register_late_lint_pass(box copy_iterator::CopyIterator); reg.register_late_lint_pass(box format::Pass); reg.register_early_lint_pass(box formatting::Formatting); reg.register_late_lint_pass(box swap::Swap); @@ -431,6 +433,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { reg.register_lint_group("clippy_pedantic", vec![ attrs::INLINE_ALWAYS, copies::MATCH_SAME_ARMS, + copy_iterator::COPY_ITERATOR, default_trait_access::DEFAULT_TRAIT_ACCESS, derive::EXPL_IMPL_CLONE_ON_COPY, doc::DOC_MARKDOWN, diff --git a/tests/ui/copy_iterator.rs b/tests/ui/copy_iterator.rs new file mode 100644 index 00000000000..1b65cc4f8cc --- /dev/null +++ b/tests/ui/copy_iterator.rs @@ -0,0 +1,23 @@ +#![warn(copy_iterator)] + +#[derive(Copy, Clone)] +struct Countdown(u8); + +impl Iterator for Countdown { + type Item = u8; + + fn next(&mut self) -> Option { + self.0.checked_sub(1).map(|c| { + self.0 = c; + c + }) + } +} + +fn main() { + let my_iterator = Countdown(5); + let a: Vec<_> = my_iterator.take(1).collect(); + assert_eq!(a.len(), 1); + let b: Vec<_> = my_iterator.collect(); + assert_eq!(b.len(), 5); +} diff --git a/tests/ui/copy_iterator.stderr b/tests/ui/copy_iterator.stderr new file mode 100644 index 00000000000..f520156b01e --- /dev/null +++ b/tests/ui/copy_iterator.stderr @@ -0,0 +1,17 @@ +error: you are implementing `Iterator` on a `Copy` type + --> $DIR/copy_iterator.rs:6:1 + | +6 | / impl Iterator for Countdown { +7 | | type Item = u8; +8 | | +9 | | fn next(&mut self) -> Option { +... | +14 | | } +15 | | } + | |_^ + | + = note: `-D copy-iterator` implied by `-D warnings` + = note: consider implementing `IntoIterator` instead + +error: aborting due to previous error + From 2224fbb5f7df9f80e91dd86e1732c4ef8e5ab58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 24 Aug 2018 18:14:49 +0200 Subject: [PATCH 14/53] deps: update cargo_metadata from 0.5 to 0.6. --- Cargo.toml | 2 +- clippy_lints/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5b690040902..5ee7e609af2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ regex = "1" semver = "0.9" [dev-dependencies] -cargo_metadata = "0.5" +cargo_metadata = "0.6" compiletest_rs = "0.3.7" lazy_static = "1.0" serde_derive = "1.0" diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index 5c3af20bde8..b168f86f56a 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -19,7 +19,7 @@ keywords = ["clippy", "lint", "plugin"] edition = "2018" [dependencies] -cargo_metadata = "0.5" +cargo_metadata = "0.6" itertools = "0.7" lazy_static = "1.0.2" matches = "0.1.7" From f7be2a041658ca7ba00d75ea0524a88772e00eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 24 Aug 2018 18:41:49 +0200 Subject: [PATCH 15/53] add how-to example for std::mem::transmute() usage instead of manual swap --- clippy_lints/src/swap.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 8b10396443f..14c8e94d30c 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -20,6 +20,10 @@ use crate::utils::sugg::Sugg; /// b = a; /// a = t; /// ``` +/// Use std::mem::swap(): +/// ```rust +/// std::mem::swap(&mut a, &mut b); +/// ``` declare_clippy_lint! { pub MANUAL_SWAP, complexity, From 45ceecc79ccf6f6e1718c4e0b358c2268865b43e Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Sat, 25 Aug 2018 14:49:56 +0200 Subject: [PATCH 16/53] Fix #3078 --- clippy_lints/src/non_expressive_names.rs | 3 +++ tests/ui/non_expressive_names.rs | 7 +++++++ tests/ui/non_expressive_names.stderr | 12 ++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index acfa341ed1f..daccc4bde03 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -114,6 +114,9 @@ impl<'a, 'tcx: 'a, 'b> Visitor<'tcx> for SimilarNamesNameVisitor<'a, 'tcx, 'b> { _ => walk_pat(self, pat), } } + fn visit_mac(&mut self, _mac: &Mac) { + // do not check macs + } } fn get_whitelist(interned_name: &str) -> Option<&'static [&'static str]> { diff --git a/tests/ui/non_expressive_names.rs b/tests/ui/non_expressive_names.rs index 7149bf8f3e7..bf0aea5c450 100644 --- a/tests/ui/non_expressive_names.rs +++ b/tests/ui/non_expressive_names.rs @@ -147,6 +147,13 @@ fn issue2927() { format!("{:?}", 2); } +fn issue3078() { + match "a" { + stringify!(a) => {}, + _ => {} + } +} + struct Bar; impl Bar { diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index b4927e69e67..667b631fb93 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -150,21 +150,21 @@ error: consider choosing a more descriptive name | ^^^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:154:13 + --> $DIR/non_expressive_names.rs:161:13 | -154 | let _1 = 1; +161 | let _1 = 1; | ^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:155:13 + --> $DIR/non_expressive_names.rs:162:13 | -155 | let ____1 = 1; +162 | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:156:13 + --> $DIR/non_expressive_names.rs:163:13 | -156 | let __1___2 = 12; +163 | let __1___2 = 12; | ^^^^^^^ error: aborting due to 17 previous errors From 6256ad05bac1f708298f827fdfa7b54042961294 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Sat, 25 Aug 2018 22:35:06 +0200 Subject: [PATCH 17/53] fix-3078: verify test case Check the crash test case by commenting out the fix --- clippy_lints/src/non_expressive_names.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index daccc4bde03..f92538cd097 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -114,9 +114,11 @@ impl<'a, 'tcx: 'a, 'b> Visitor<'tcx> for SimilarNamesNameVisitor<'a, 'tcx, 'b> { _ => walk_pat(self, pat), } } + /* fn visit_mac(&mut self, _mac: &Mac) { // do not check macs } + */ } fn get_whitelist(interned_name: &str) -> Option<&'static [&'static str]> { From cc87dc753987c580d05cdc24ef06d7d0ac43ced2 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Sun, 26 Aug 2018 10:57:04 +0200 Subject: [PATCH 18/53] Move some range lints to complexity Recategorize `range_plus_one` and `range_minus_one` to `complexity`. This moves `range_plus_one` out of the nursery as the inclusive range syntax is now stable. Both are moved to `complexity` as it is more consistent with other lints such as `int_plus_one`. --- clippy_lints/src/lib.rs | 5 +++-- clippy_lints/src/ranges.rs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index da6db4cfe45..af87655e65c 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -635,6 +635,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { question_mark::QUESTION_MARK, ranges::ITERATOR_STEP_BY_ZERO, ranges::RANGE_MINUS_ONE, + ranges::RANGE_PLUS_ONE, ranges::RANGE_ZIP_WITH_LEN, redundant_field_names::REDUNDANT_FIELD_NAMES, reference::DEREF_ADDROF, @@ -756,7 +757,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { ptr::CMP_NULL, ptr::PTR_ARG, question_mark::QUESTION_MARK, - ranges::RANGE_MINUS_ONE, redundant_field_names::REDUNDANT_FIELD_NAMES, regex::REGEX_MACRO, regex::TRIVIAL_REGEX, @@ -816,6 +816,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL, partialeq_ne_impl::PARTIALEQ_NE_IMPL, precedence::PRECEDENCE, + ranges::RANGE_MINUS_ONE, + ranges::RANGE_PLUS_ONE, ranges::RANGE_ZIP_WITH_LEN, reference::DEREF_ADDROF, reference::REF_IN_DEREF, @@ -921,7 +923,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { fallible_impl_from::FALLIBLE_IMPL_FROM, mutex_atomic::MUTEX_INTEGER, needless_borrow::NEEDLESS_BORROW, - ranges::RANGE_PLUS_ONE, unwrap::PANICKING_UNWRAP, unwrap::UNNECESSARY_UNWRAP, ]); diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 27620ede5b0..ba25e50d7c0 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -57,7 +57,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub RANGE_PLUS_ONE, - nursery, + complexity, "`x..(y+1)` reads better as `x..=y`" } @@ -75,7 +75,7 @@ declare_clippy_lint! { /// ``` declare_clippy_lint! { pub RANGE_MINUS_ONE, - style, + complexity, "`x..=(y-1)` reads better as `x..y`" } From eef3ffab35cd91f343e32af340050ddfb70a7dd7 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Sun, 26 Aug 2018 11:11:47 +0200 Subject: [PATCH 19/53] Remove `iterator_find_map` feature attribute Closes #3083 --- clippy_lints/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index da6db4cfe45..a48452f1a2c 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -7,7 +7,6 @@ #![feature(range_contains)] #![allow(unknown_lints, shadow_reuse, missing_docs_in_private_items)] #![recursion_limit = "256"] -#![feature(iterator_find_map)] #![feature(macro_at_most_once_rep)] #![warn(rust_2018_idioms)] From caa59e2e277128767023cfe867f54dae943af6ca Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Sun, 26 Aug 2018 15:49:08 +0200 Subject: [PATCH 20/53] Use the compilers exit code computation instead of rolling our own --- src/driver.rs | 222 +++++++++++++++++++++++++------------------------- 1 file changed, 110 insertions(+), 112 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 659287daed5..6854ccbbddc 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -13,125 +13,123 @@ fn show_version() { } pub fn main() { - use std::env; + exit(rustc_driver::run(move || { + use std::env; - if std::env::args().any(|a| a == "--version" || a == "-V") { - show_version(); - return; - } - - let sys_root = option_env!("SYSROOT") - .map(String::from) - .or_else(|| std::env::var("SYSROOT").ok()) - .or_else(|| { - let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); - let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); - home.and_then(|home| toolchain.map(|toolchain| format!("{}/toolchains/{}", home, toolchain))) - }) - .or_else(|| { - Command::new("rustc") - .arg("--print") - .arg("sysroot") - .output() - .ok() - .and_then(|out| String::from_utf8(out.stdout).ok()) - .map(|s| s.trim().to_owned()) - }) - .expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust"); - - // Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument. - // We're invoking the compiler programmatically, so we ignore this/ - let mut orig_args: Vec = env::args().collect(); - if orig_args.len() <= 1 { - std::process::exit(1); - } - if orig_args[1] == "rustc" { - // we still want to be able to invoke it normally though - orig_args.remove(1); - } - // this conditional check for the --sysroot flag is there so users can call - // `clippy_driver` directly - // without having to pass --sysroot or anything - let mut args: Vec = if orig_args.iter().any(|s| s == "--sysroot") { - orig_args.clone() - } else { - orig_args - .clone() - .into_iter() - .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 - // linted but not built - let clippy_enabled = env::var("CLIPPY_TESTS").ok().map_or(false, |val| val == "true") - || orig_args.iter().any(|s| s == "--emit=dep-info,metadata"); - - if clippy_enabled { - args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]); - if let Ok(extra_args) = env::var("CLIPPY_ARGS") { - args.extend( - extra_args - .split("__CLIPPY_HACKERY__") - .filter(|s| !s.is_empty()) - .map(str::to_owned), - ); + if std::env::args().any(|a| a == "--version" || a == "-V") { + show_version(); + exit(0); } - } - let mut controller = CompileController::basic(); - if clippy_enabled { - controller.after_parse.callback = Box::new(move |state| { - let mut registry = rustc_plugin::registry::Registry::new( - state.session, - state - .krate - .as_ref() - .expect( - "at this compilation stage \ - the crate must be parsed", - ) - .span, - ); - registry.args_hidden = Some(Vec::new()); + let sys_root = option_env!("SYSROOT") + .map(String::from) + .or_else(|| std::env::var("SYSROOT").ok()) + .or_else(|| { + let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); + let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); + home.and_then(|home| toolchain.map(|toolchain| format!("{}/toolchains/{}", home, toolchain))) + }) + .or_else(|| { + Command::new("rustc") + .arg("--print") + .arg("sysroot") + .output() + .ok() + .and_then(|out| String::from_utf8(out.stdout).ok()) + .map(|s| s.trim().to_owned()) + }) + .expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust"); - let conf = clippy_lints::read_conf(®istry); - clippy_lints::register_plugins(&mut registry, &conf); + // Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument. + // We're invoking the compiler programmatically, so we ignore this/ + let mut orig_args: Vec = env::args().collect(); + if orig_args.len() <= 1 { + std::process::exit(1); + } + if orig_args[1] == "rustc" { + // we still want to be able to invoke it normally though + orig_args.remove(1); + } + // this conditional check for the --sysroot flag is there so users can call + // `clippy_driver` directly + // without having to pass --sysroot or anything + let mut args: Vec = if orig_args.iter().any(|s| s == "--sysroot") { + orig_args.clone() + } else { + orig_args + .clone() + .into_iter() + .chain(Some("--sysroot".to_owned())) + .chain(Some(sys_root)) + .collect() + }; - let rustc_plugin::registry::Registry { - early_lint_passes, - late_lint_passes, - lint_groups, - llvm_passes, - attributes, - .. - } = registry; - let sess = &state.session; - let mut ls = sess.lint_store.borrow_mut(); - for pass in early_lint_passes { - ls.register_early_pass(Some(sess), true, pass); - } - for pass in late_lint_passes { - ls.register_late_pass(Some(sess), true, pass); + // this check ensures that dependencies are built but not linted and the final + // crate is + // linted but not built + let clippy_enabled = env::var("CLIPPY_TESTS").ok().map_or(false, |val| val == "true") + || orig_args.iter().any(|s| s == "--emit=dep-info,metadata"); + + if clippy_enabled { + args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]); + if let Ok(extra_args) = env::var("CLIPPY_ARGS") { + args.extend( + extra_args + .split("__CLIPPY_HACKERY__") + .filter(|s| !s.is_empty()) + .map(str::to_owned), + ); } + } - for (name, to) in lint_groups { - ls.register_group(Some(sess), true, name, to); - } - clippy_lints::register_pre_expansion_lints(sess, &mut ls, &conf); + let mut controller = CompileController::basic(); + if clippy_enabled { + controller.after_parse.callback = Box::new(move |state| { + let mut registry = rustc_plugin::registry::Registry::new( + state.session, + state + .krate + .as_ref() + .expect( + "at this compilation stage \ + the crate must be parsed", + ) + .span, + ); + registry.args_hidden = Some(Vec::new()); - sess.plugin_llvm_passes.borrow_mut().extend(llvm_passes); - sess.plugin_attributes.borrow_mut().extend(attributes); - }); - } - controller.compilation_done.stop = Compilation::Stop; + let conf = clippy_lints::read_conf(®istry); + clippy_lints::register_plugins(&mut registry, &conf); - if rustc_driver::run_compiler(&args, Box::new(controller), None, None) - .0 - .is_err() - { - exit(101); - } + let rustc_plugin::registry::Registry { + early_lint_passes, + late_lint_passes, + lint_groups, + llvm_passes, + attributes, + .. + } = registry; + let sess = &state.session; + let mut ls = sess.lint_store.borrow_mut(); + for pass in early_lint_passes { + ls.register_early_pass(Some(sess), true, pass); + } + for pass in late_lint_passes { + ls.register_late_pass(Some(sess), true, pass); + } + + for (name, to) in lint_groups { + ls.register_group(Some(sess), true, name, to); + } + clippy_lints::register_pre_expansion_lints(sess, &mut ls, &conf); + + sess.plugin_llvm_passes.borrow_mut().extend(llvm_passes); + sess.plugin_attributes.borrow_mut().extend(attributes); + }); + } + controller.compilation_done.stop = Compilation::Stop; + + let args = args; + rustc_driver::run_compiler(&args, Box::new(controller), None, None) + }) as i32) } From fc31dc01def04c1db782c4e6ed0457f9047dfcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 27 Aug 2018 17:35:30 +0200 Subject: [PATCH 21/53] docs: make example in new_without_default lint syntax highlighted --- clippy_lints/src/new_without_default.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 224326b3d17..820e76f886e 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -21,7 +21,7 @@ use crate::utils::sugg::DiagnosticBuilderExt; /// /// **Example:** /// -/// ```rust,ignore +/// ```rust /// struct Foo(Bar); /// /// impl Foo { @@ -63,7 +63,7 @@ declare_clippy_lint! { /// /// **Example:** /// -/// ```rust,ignore +/// ```rust /// struct Foo; /// /// impl Foo { From 340500ede595d0498bf8f13fd489d5c5478fa48d Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Tue, 28 Aug 2018 10:24:21 +0800 Subject: [PATCH 22/53] Fix typo for panel cursor --- util/gh-pages/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/gh-pages/index.html b/util/gh-pages/index.html index 0088ecc3d89..656a7341257 100644 --- a/util/gh-pages/index.html +++ b/util/gh-pages/index.html @@ -14,7 +14,7 @@ .form-inline .checkbox { margin-right: 0.6em } - .panel-heading { pointer: cursor; } + .panel-heading { cursor: pointer; } .panel-heading:hover { background-color: #eee; } .panel-title { display: flex; } From d99cea0f16633556871a59500c610782b07233b9 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 28 Aug 2018 13:13:42 +0200 Subject: [PATCH 23/53] Update imports and rustup --- CONTRIBUTING.md | 2 +- clippy_lints/src/approx_const.rs | 2 +- clippy_lints/src/arithmetic.rs | 2 +- clippy_lints/src/assign_ops.rs | 4 ++-- clippy_lints/src/attrs.rs | 2 +- clippy_lints/src/bit_mask.rs | 2 +- clippy_lints/src/blacklisted_name.rs | 2 +- clippy_lints/src/bytecount.rs | 2 +- clippy_lints/src/collapsible_if.rs | 2 +- clippy_lints/src/copies.rs | 2 +- clippy_lints/src/copy_iterator.rs | 2 +- clippy_lints/src/cyclomatic_complexity.rs | 2 +- clippy_lints/src/default_trait_access.rs | 2 +- clippy_lints/src/derive.rs | 2 +- clippy_lints/src/doc.rs | 2 +- clippy_lints/src/double_comparison.rs | 2 +- clippy_lints/src/drop_forget_ref.rs | 2 +- clippy_lints/src/duration_subsec.rs | 2 +- clippy_lints/src/else_if_without_else.rs | 2 +- clippy_lints/src/empty_enum.rs | 2 +- clippy_lints/src/entry.rs | 2 +- clippy_lints/src/enum_clike.rs | 2 +- clippy_lints/src/enum_variants.rs | 2 +- clippy_lints/src/eq_op.rs | 2 +- clippy_lints/src/erasing_op.rs | 2 +- clippy_lints/src/escape.rs | 7 +++---- clippy_lints/src/eta_reduction.rs | 2 +- clippy_lints/src/eval_order_dependence.rs | 8 ++++---- clippy_lints/src/excessive_precision.rs | 2 +- clippy_lints/src/explicit_write.rs | 2 +- clippy_lints/src/fallible_impl_from.rs | 2 +- clippy_lints/src/format.rs | 2 +- clippy_lints/src/formatting.rs | 2 +- clippy_lints/src/functions.rs | 6 ++---- clippy_lints/src/identity_conversion.rs | 2 +- clippy_lints/src/identity_op.rs | 2 +- .../src/if_let_redundant_pattern_matching.rs | 2 +- clippy_lints/src/if_not_else.rs | 2 +- clippy_lints/src/indexing_slicing.rs | 2 +- .../src/infallible_destructuring_match.rs | 2 +- clippy_lints/src/infinite_iter.rs | 2 +- clippy_lints/src/inherent_impl.rs | 14 ++++++++++---- clippy_lints/src/inline_fn_without_body.rs | 2 +- clippy_lints/src/int_plus_one.rs | 2 +- clippy_lints/src/invalid_ref.rs | 2 +- clippy_lints/src/items_after_statements.rs | 2 +- clippy_lints/src/large_enum_variant.rs | 2 +- clippy_lints/src/len_zero.rs | 2 +- clippy_lints/src/let_if_seq.rs | 2 +- clippy_lints/src/lifetimes.rs | 2 +- clippy_lints/src/literal_representation.rs | 2 +- clippy_lints/src/loops.rs | 15 +++++++-------- clippy_lints/src/map_clone.rs | 2 +- clippy_lints/src/map_unit_fn.rs | 2 +- clippy_lints/src/matches.rs | 2 +- clippy_lints/src/mem_forget.rs | 2 +- clippy_lints/src/methods.rs | 6 +++--- clippy_lints/src/minmax.rs | 2 +- clippy_lints/src/misc.rs | 4 ++-- clippy_lints/src/misc_early.rs | 2 +- clippy_lints/src/missing_doc.rs | 7 ++++--- clippy_lints/src/missing_inline.rs | 6 ++++-- clippy_lints/src/multiple_crate_versions.rs | 9 ++++++--- clippy_lints/src/mut_mut.rs | 2 +- clippy_lints/src/mut_reference.rs | 2 +- clippy_lints/src/needless_bool.rs | 2 +- clippy_lints/src/needless_borrow.rs | 2 +- clippy_lints/src/needless_borrowed_ref.rs | 2 +- clippy_lints/src/needless_continue.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 9 ++++----- clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 4 ++-- clippy_lints/src/neg_multiply.rs | 2 +- clippy_lints/src/new_without_default.rs | 2 +- clippy_lints/src/non_copy_const.rs | 2 +- clippy_lints/src/non_expressive_names.rs | 2 +- clippy_lints/src/ok_if_let.rs | 2 +- clippy_lints/src/open_options.rs | 2 +- clippy_lints/src/overflow_check_conditional.rs | 2 +- clippy_lints/src/panic_unimplemented.rs | 2 +- clippy_lints/src/partialeq_ne_impl.rs | 2 +- clippy_lints/src/precedence.rs | 2 +- clippy_lints/src/ptr.rs | 5 ++--- clippy_lints/src/question_mark.rs | 2 +- clippy_lints/src/ranges.rs | 2 +- clippy_lints/src/redundant_field_names.rs | 2 +- clippy_lints/src/reference.rs | 2 +- clippy_lints/src/regex.rs | 2 +- clippy_lints/src/replace_consts.rs | 2 +- clippy_lints/src/returns.rs | 2 +- clippy_lints/src/serde_api.rs | 2 +- clippy_lints/src/shadow.rs | 2 +- clippy_lints/src/strings.rs | 2 +- clippy_lints/src/suspicious_trait_impl.rs | 6 +++--- clippy_lints/src/swap.rs | 2 +- clippy_lints/src/transmute.rs | 2 +- clippy_lints/src/trivially_copy_pass_by_ref.rs | 5 ++--- clippy_lints/src/types.rs | 6 +++--- clippy_lints/src/unicode.rs | 2 +- clippy_lints/src/unsafe_removed_from_name.rs | 2 +- clippy_lints/src/unused_io_amount.rs | 2 +- clippy_lints/src/unused_label.rs | 2 +- clippy_lints/src/unwrap.rs | 2 +- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/hir_utils.rs | 2 +- clippy_lints/src/utils/inspector.rs | 2 +- clippy_lints/src/utils/internal_lints.rs | 2 +- clippy_lints/src/utils/mod.rs | 16 ++++++++-------- clippy_lints/src/utils/usage.rs | 2 +- clippy_lints/src/vec.rs | 2 +- clippy_lints/src/write.rs | 2 +- clippy_lints/src/zero_div_zero.rs | 2 +- 111 files changed, 164 insertions(+), 159 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 232752c2025..7de4f850c1c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -185,7 +185,7 @@ It's worth noting that the majority of `clippy_lints/src/lib.rs` is autogenerate ```rust // ./clippy_lints/src/else_if_without_else.rs -use rustc::lint::*; +use rustc::lint::{EarlyLintPass, LintArray, LintPass}; // ... diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index cd2444ff31f..fe00d325f77 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -1,6 +1,6 @@ use crate::utils::span_lint; use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use std::f64::consts as f64; use syntax::ast::{FloatTy, Lit, LitKind}; diff --git a/clippy_lints/src/arithmetic.rs b/clippy_lints/src/arithmetic.rs index 90f72d3d184..209963e0688 100644 --- a/clippy_lints/src/arithmetic.rs +++ b/clippy_lints/src/arithmetic.rs @@ -1,6 +1,6 @@ use crate::utils::span_lint; use rustc::hir; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::source_map::Span; diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 7d4f4e7cbc3..28fd96e3aac 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -2,7 +2,7 @@ use crate::utils::{get_trait_def_id, implements_trait, snippet_opt, span_lint_an use crate::utils::{higher, sugg}; use rustc::hir; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::ast; @@ -133,7 +133,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { // the crate node is the only one that is not in the map if_chain! { if parent_impl != ast::CRATE_NODE_ID; - if let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl); + if let hir::Node::Item(item) = cx.tcx.hir.get(parent_impl); if let hir::ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node; if trait_ref.path.def.def_id() == trait_id; diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 9804d3a0f07..66144706816 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -6,7 +6,7 @@ use crate::utils::{ without_block_comments, }; use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, TyCtxt}; diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 12de4faa753..86788fded05 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::ast::LitKind; diff --git a/clippy_lints/src/blacklisted_name.rs b/clippy_lints/src/blacklisted_name.rs index cfec01d14ae..e5af0789064 100644 --- a/clippy_lints/src/blacklisted_name.rs +++ b/clippy_lints/src/blacklisted_name.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use crate::utils::span_lint; diff --git a/clippy_lints/src/bytecount.rs b/clippy_lints/src/bytecount.rs index 6d086c13ff8..5c9b571c78c 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty; diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 2771006aad3..09fcf47c920 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -12,7 +12,7 @@ //! //! This lint is **warn** by default -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::ast; diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 49518d1bb4e..42788e77d6e 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::ty::Ty; use rustc::hir::*; diff --git a/clippy_lints/src/copy_iterator.rs b/clippy_lints/src/copy_iterator.rs index ac0c2ed32c6..031b088bf9e 100644 --- a/clippy_lints/src/copy_iterator.rs +++ b/clippy_lints/src/copy_iterator.rs @@ -1,6 +1,6 @@ use crate::utils::{is_copy, match_path, paths, span_note_and_lint}; use rustc::hir::{Item, ItemKind}; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; /// **What it does:** Checks for types that implement `Copy` as well as diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index 93074eadd65..ee53fca9f70 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -1,7 +1,7 @@ //! calculate cyclomatic complexity and warn about overly complex functions use rustc::cfg::CFG; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, LintContext}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use rustc::ty; diff --git a/clippy_lints/src/default_trait_access.rs b/clippy_lints/src/default_trait_access.rs index f01e106df26..09c60760076 100644 --- a/clippy_lints/src/default_trait_access.rs +++ b/clippy_lints/src/default_trait_access.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::TyKind; diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index e3abfe93810..9df2e257b1e 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 12128eda258..957ede66698 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -1,6 +1,6 @@ use itertools::Itertools; use pulldown_cmark; -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast; use syntax::source_map::{BytePos, Span}; diff --git a/clippy_lints/src/double_comparison.rs b/clippy_lints/src/double_comparison.rs index 013a75e6457..70dc532e55b 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -1,7 +1,7 @@ //! Lint on unnecessary double comparisons. Some examples: use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::source_map::Span; diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index 1e6189e3839..5aca7d734e2 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty; diff --git a/clippy_lints/src/duration_subsec.rs b/clippy_lints/src/duration_subsec.rs index ef5d18f081a..77d3014d9fd 100644 --- a/clippy_lints/src/duration_subsec.rs +++ b/clippy_lints/src/duration_subsec.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::source_map::Spanned; diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs index 39404bbafcc..1259b49d93a 100644 --- a/clippy_lints/src/else_if_without_else.rs +++ b/clippy_lints/src/else_if_without_else.rs @@ -1,6 +1,6 @@ //! lint on if expressions with an else if, but without a final else branch -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use syntax::ast::*; diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs index f95ae32d561..86f9fbdba9b 100644 --- a/clippy_lints/src/empty_enum.rs +++ b/clippy_lints/src/empty_enum.rs @@ -1,6 +1,6 @@ //! lint when there is an enum with no variants -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use crate::utils::span_lint_and_then; diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 142a099f539..46ef16ddc73 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::source_map::Span; diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index 2551f624cb1..2402cfde5b3 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -1,7 +1,7 @@ //! lint on C-like enums that are `repr(isize/usize)` and have values that //! don't fit into an `i32` -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use rustc::ty; diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index ca38d497df4..51277516571 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -1,6 +1,6 @@ //! lint on enum variants that are prefixed or suffixed by the same characters -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, Lint}; use rustc::{declare_lint, lint_array}; use syntax::ast::*; use syntax::source_map::Span; diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index dfbc3b12633..a08d9f39382 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use crate::utils::{in_macro, implements_trait, is_copy, multispan_sugg, snippet, span_lint, span_lint_and_then, SpanlessEq}; diff --git a/clippy_lints/src/erasing_op.rs b/clippy_lints/src/erasing_op.rs index 2976700428c..e6d70b22fde 100644 --- a/clippy_lints/src/erasing_op.rs +++ b/clippy_lints/src/erasing_op.rs @@ -1,6 +1,6 @@ use crate::consts::{constant_simple, Constant}; use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::source_map::Span; use crate::utils::{in_macro, span_lint}; diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 2cd2a46cbab..3c61509d1f7 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -1,7 +1,6 @@ use rustc::hir::*; use rustc::hir::intravisit as visit; -use rustc::hir::map::Node::{NodeExpr, NodeStmt}; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::middle::expr_use_visitor::*; use rustc::middle::mem_categorization::{cmt_, Categorization}; @@ -100,7 +99,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { let map = &self.cx.tcx.hir; if map.is_argument(consume_pat.id) { // Skip closure arguments - if let Some(NodeExpr(..)) = map.find(map.get_parent_node(consume_pat.id)) { + if let Some(Node::Expr(..)) = map.find(map.get_parent_node(consume_pat.id)) { return; } if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) { @@ -110,7 +109,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { } if let Categorization::Rvalue(..) = cmt.cat { let id = map.hir_to_node_id(cmt.hir_id); - if let Some(NodeStmt(st)) = map.find(map.get_parent_node(id)) { + if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(id)) { if let StmtKind::Decl(ref decl, _) = st.node { if let DeclKind::Local(ref loc) = decl.node { if let Some(ref ex) = loc.init { diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 260cca76c8c..f60785662dd 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::ty; use rustc::hir::*; diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 9ddc3ddbfe7..f1c31d095e1 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -1,7 +1,7 @@ use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc::hir::*; use rustc::ty; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::ast; @@ -189,9 +189,9 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) { }; let stop_early = match parent_node { - map::Node::NodeExpr(expr) => check_expr(vis, expr), - map::Node::NodeStmt(stmt) => check_stmt(vis, stmt), - map::Node::NodeItem(_) => { + Node::Expr(expr) => check_expr(vis, expr), + Node::Stmt(stmt) => check_stmt(vis, stmt), + Node::Item(_) => { // We reached the top of the function, stop. break; }, diff --git a/clippy_lints/src/excessive_precision.rs b/clippy_lints/src/excessive_precision.rs index 52af7e129ab..df540cad931 100644 --- a/clippy_lints/src/excessive_precision.rs +++ b/clippy_lints/src/excessive_precision.rs @@ -1,5 +1,5 @@ use rustc::hir; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::TyKind; diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index 22e6834ee88..f0cee563a2e 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use crate::utils::{is_expn_of, match_def_path, resolve_node, span_lint}; diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 22f6df65506..f541abee8a7 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir; diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 4f83caa43dd..f967b9ce58e 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty; diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 60001c792c0..2f46891e6a1 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast; use crate::utils::{differing_macro_contexts, in_macro, snippet_opt, span_note_and_lint}; diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index b86e3332188..2f076dc1f6e 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -1,7 +1,7 @@ use matches::matches; use rustc::hir::intravisit; use rustc::hir; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::ty; use rustc::hir::def::Def; @@ -85,9 +85,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { span: Span, nodeid: ast::NodeId, ) { - use rustc::hir::map::Node::*; - - let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) { + let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) { matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _)) } else { false diff --git a/clippy_lints/src/identity_conversion.rs b/clippy_lints/src/identity_conversion.rs index 1909f2f8ff4..3fa30dee988 100644 --- a/clippy_lints/src/identity_conversion.rs +++ b/clippy_lints/src/identity_conversion.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use syntax::ast::NodeId; diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index 31e955dc570..b0c290ffc0e 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -1,6 +1,6 @@ use crate::consts::{constant_simple, Constant}; use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::source_map::Span; use crate::utils::{in_macro, snippet, span_lint, unsext, clip}; diff --git a/clippy_lints/src/if_let_redundant_pattern_matching.rs b/clippy_lints/src/if_let_redundant_pattern_matching.rs index bc97584a23d..f1b8aadef67 100644 --- a/clippy_lints/src/if_let_redundant_pattern_matching.rs +++ b/clippy_lints/src/if_let_redundant_pattern_matching.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use crate::utils::{match_qpath, paths, snippet, span_lint_and_then}; diff --git a/clippy_lints/src/if_not_else.rs b/clippy_lints/src/if_not_else.rs index fea3069f37d..153bfbb9779 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -1,7 +1,7 @@ //! lint on if branches that could be swapped so no `!` operation is necessary //! on the condition -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use syntax::ast::*; diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index 9ec9c9f83b4..01a659473c1 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -5,7 +5,7 @@ use crate::utils; use crate::utils::higher; use crate::utils::higher::Range; use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::ty; use syntax::ast::RangeLimits; diff --git a/clippy_lints/src/infallible_destructuring_match.rs b/clippy_lints/src/infallible_destructuring_match.rs index 8b8cb32deb1..a085f32ed84 100644 --- a/clippy_lints/src/infallible_destructuring_match.rs +++ b/clippy_lints/src/infallible_destructuring_match.rs @@ -1,6 +1,6 @@ use super::utils::{get_arg_name, match_var, remove_blocks, snippet, span_lint_and_sugg}; use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index eaa93cb62f8..d42a2380ec4 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use crate::utils::{get_trait_def_id, higher, implements_trait, match_qpath, paths, span_lint}; diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index fc06af81574..46dbb5bc39f 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -1,11 +1,12 @@ //! lint on inherent implementations use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use std::collections::HashMap; use std::default::Default; use syntax_pos::Span; +use crate::utils::span_lint_and_then; /// **What it does:** Checks for multiple inherent implementations of a struct /// @@ -81,12 +82,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { .map(|(span, _)| span); if let Some(initial_span) = impl_spans.nth(0) { impl_spans.for_each(|additional_span| { - cx.span_lint_note( + span_lint_and_then( + cx, MULTIPLE_INHERENT_IMPL, *additional_span, "Multiple implementations of this structure", - *initial_span, - "First implementation here", + |db| { + db.span_note( + *initial_span, + "First implementation here", + ); + }, ) }) } diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index 70f88a76f45..b879d734929 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -1,6 +1,6 @@ //! checks for `#[inline]` on trait methods without bodies -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use syntax::ast::{Attribute, Name}; diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index 9b6fc579a31..086567ac531 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -1,6 +1,6 @@ //! lint on blocks unnecessarily using >= with a + 1 or - 1 -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast::*; diff --git a/clippy_lints/src/invalid_ref.rs b/clippy_lints/src/invalid_ref.rs index 9c7d4626e0a..58f1575abb6 100644 --- a/clippy_lints/src/invalid_ref.rs +++ b/clippy_lints/src/invalid_ref.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty; diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index 07ef086d694..2ea6c0e0447 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -1,7 +1,7 @@ //! lint when items are used after statements use matches::matches; -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast::*; use crate::utils::{in_macro, span_lint}; diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index 2c03b6b5f68..3e49f866170 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -1,6 +1,6 @@ //! lint when there is a large size difference between variants on an enum -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use crate::utils::{snippet_opt, span_lint_and_then}; diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 2fb4c691ce8..e14f3bc24b7 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -1,6 +1,6 @@ use rustc::hir::def_id::DefId; use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::ty; use std::collections::HashSet; diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 57ca5eff955..494efc22538 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir; diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index d8e6a43f864..7da62b9d458 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -1,6 +1,6 @@ use crate::reexport::*; use matches::matches; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use rustc::hir::def::Def; use rustc::hir::*; diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index 45f9af49a15..9437b243cbb 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -1,7 +1,7 @@ //! Lints concerned with the grouping of digits with underscores in integral or //! floating-point literal expressions. -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::ast::*; diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 973b706801a..988256ab29e 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -4,8 +4,7 @@ use rustc::hir::*; use rustc::hir::def::Def; use rustc::hir::def_id; use rustc::hir::intravisit::{walk_block, walk_decl, walk_expr, walk_pat, walk_stmt, NestedVisitorMap, Visitor}; -use rustc::hir::map::Node::{NodeBlock, NodeExpr, NodeStmt}; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::middle::region; @@ -1330,7 +1329,7 @@ fn check_for_loop_explicit_counter<'a, 'tcx>( let parent_scope = map.get_enclosing_scope(expr.id) .and_then(|id| map.get_enclosing_scope(id)); if let Some(parent_id) = parent_scope { - if let NodeBlock(block) = map.get(parent_id) { + if let Node::Block(block) = map.get(parent_id) { for (id, _) in visitor .states .iter() @@ -1506,7 +1505,7 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option bool { fn is_nested(cx: &LateContext<'_, '_>, match_expr: &Expr, iter_expr: &Expr) -> bool { if_chain! { if let Some(loop_block) = get_enclosing_block(cx, match_expr.id); - if let Some(map::Node::NodeExpr(loop_expr)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(loop_block.id)); + if let Some(Node::Expr(loop_expr)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(loop_block.id)); then { return is_loop_nested(cx, loop_expr, iter_expr) } @@ -2068,13 +2067,13 @@ fn is_loop_nested(cx: &LateContext<'_, '_>, loop_expr: &Expr, iter_expr: &Expr) return false; } match cx.tcx.hir.find(parent) { - Some(NodeExpr(expr)) => match expr.node { + Some(Node::Expr(expr)) => match expr.node { ExprKind::Loop(..) | ExprKind::While(..) => { return true; }, _ => (), }, - Some(NodeBlock(block)) => { + Some(Node::Block(block)) => { let mut block_visitor = LoopNestVisitor { id, iterator: iter_name, @@ -2085,7 +2084,7 @@ fn is_loop_nested(cx: &LateContext<'_, '_>, loop_expr: &Expr, iter_expr: &Expr) return false; } }, - Some(NodeStmt(_)) => (), + Some(Node::Stmt(_)) => (), _ => { return false; }, diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index c570f0b32bf..bd304db2dd5 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index eff00896c7f..2376b1a2b48 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -1,5 +1,5 @@ use rustc::hir; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty; diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 691d61f55ba..6dc16e623a4 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index 80130de15d7..76df98727f9 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::{Expr, ExprKind}; use crate::utils::{match_def_path, opt_def_id, paths, span_lint}; diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 1c31c414d2b..3bc1282fa15 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1,6 +1,6 @@ use matches::matches; use rustc::hir; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, Lint, LintContext}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; @@ -1145,14 +1145,14 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp if let ty::Ref(..) = cx.tables.expr_ty(arg).sty { let parent = cx.tcx.hir.get_parent_node(expr.id); match cx.tcx.hir.get(parent) { - hir::map::NodeExpr(parent) => match parent.node { + hir::Node::Expr(parent) => match parent.node { // &*x is a nop, &x.clone() is not hir::ExprKind::AddrOf(..) | // (*x).func() is useless, x.clone().func() can work in case func borrows mutably hir::ExprKind::MethodCall(..) => return, _ => {}, } - hir::map::NodeStmt(stmt) => { + hir::Node::Stmt(stmt) => { if let hir::StmtKind::Decl(ref decl, _) = stmt.node { if let hir::DeclKind::Local(ref loc) = decl.node { if let hir::PatKind::Ref(..) = loc.pat.node { diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index bc573841cc8..b187c28def6 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -1,7 +1,7 @@ use crate::consts::{constant_simple, Constant}; use crate::utils::{match_def_path, opt_def_id, paths, span_lint}; use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use std::cmp::Ordering; diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index a43c60f111f..7fab12bd9d9 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -2,7 +2,7 @@ use crate::reexport::*; use matches::matches; use rustc::hir::*; use rustc::hir::intravisit::FnKind; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty; @@ -522,7 +522,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { let parent_fn = cx.tcx.hir.get_parent(expr.id); let parent_impl = cx.tcx.hir.get_parent(parent_fn); if parent_impl != CRATE_NODE_ID { - if let map::NodeItem(item) = cx.tcx.hir.get(parent_impl) { + if let Node::Item(item) = cx.tcx.hir.get(parent_impl) { if let ItemKind::Impl(.., Some(ref trait_ref), _, _) = item.node { if trait_ref.path.def.def_id() == partial_eq_trait_id { // we are implementing PartialEq, don't suggest not doing `to_owned`, otherwise diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index 6c82fa58e8d..4edb6a9133a 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, LintContext, in_external_macro}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use std::collections::HashMap; diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 9735799d136..339ab757702 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -19,13 +19,13 @@ // use rustc::hir; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, LintContext}; use rustc::{declare_lint, lint_array}; use rustc::ty; use syntax::ast; use syntax::attr; use syntax::source_map::Span; -use crate::utils::in_macro; +use crate::utils::{span_lint, in_macro}; /// **What it does:** Warns if there is missing doc for any documentable item /// (public or private). @@ -87,7 +87,8 @@ impl MissingDoc { .iter() .any(|a| a.is_value_str() && a.name() == "doc"); if !has_doc { - cx.span_lint( + span_lint( + cx, MISSING_DOCS_IN_PRIVATE_ITEMS, sp, &format!("missing documentation for {}", desc), diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 8e2b08b5152..c0f12bd3f7e 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -10,10 +10,11 @@ // use rustc::hir; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast; use syntax::source_map::Span; +use crate::utils::span_lint; /// **What it does:** it lints if an exported function, method, trait method with default impl, /// or trait method impl is not `#[inline]`. @@ -74,7 +75,8 @@ fn check_missing_inline_attrs(cx: &LateContext<'_, '_>, .iter() .any(|a| a.name() == "inline" ); if !has_inline { - cx.span_lint( + span_lint( + cx, MISSING_INLINE_IN_PUBLIC_ITEMS, sp, &format!("missing `#[inline]` for {}", desc), diff --git a/clippy_lints/src/multiple_crate_versions.rs b/clippy_lints/src/multiple_crate_versions.rs index d4246045506..78458843ffc 100644 --- a/clippy_lints/src/multiple_crate_versions.rs +++ b/clippy_lints/src/multiple_crate_versions.rs @@ -1,8 +1,9 @@ //! lint on multiple versions of a crate being used -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast::*; +use crate::utils::span_lint; use cargo_metadata; use itertools::Itertools; @@ -43,7 +44,8 @@ impl EarlyLintPass for Pass { let metadata = match cargo_metadata::metadata_deps(None, true) { Ok(metadata) => metadata, Err(_) => { - cx.span_lint( + span_lint( + cx, MULTIPLE_CRATE_VERSIONS, krate.span, "could not read cargo metadata" @@ -62,7 +64,8 @@ impl EarlyLintPass for Pass { if group.len() > 1 { let versions = group.into_iter().map(|p| p.version).join(", "); - cx.span_lint( + span_lint( + cx, MULTIPLE_CRATE_VERSIONS, krate.span, &format!("multiple versions for dependency `{}`: {}", name, versions), diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index d8561241001..5c8a2648a18 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -1,6 +1,6 @@ use rustc::hir; use rustc::hir::intravisit; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use rustc::ty; use crate::utils::{higher, span_lint}; diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 02a80a19e79..5b562f3dd34 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::ty::{self, Ty}; use rustc::ty::subst::Subst; diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 19d860dab36..90b38440a83 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -2,7 +2,7 @@ //! //! This lint is **warn** by default -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use syntax::ast::LitKind; diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index ae931e58326..b8ac425fd59 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -2,7 +2,7 @@ //! //! This lint is **warn** by default -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir::{BindingAnnotation, Expr, ExprKind, MutImmutable, Pat, PatKind}; diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index 1679a9007b4..d5a16f2122f 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -2,7 +2,7 @@ //! //! This lint is **warn** by default -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir::{BindingAnnotation, MutImmutable, Pat, PatKind}; diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index 0c9b354035f..e5f01847ed1 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -27,7 +27,7 @@ //! ``` //! //! This lint is **warn** by default. -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast; use syntax::source_map::{original_sp, DUMMY_SP}; diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index c93cda55724..06baf895c93 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -1,8 +1,7 @@ use matches::matches; use rustc::hir::*; -use rustc::hir::map::*; use rustc::hir::intravisit::FnKind; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, RegionKind, TypeFoldable}; @@ -90,7 +89,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { } // Exclude non-inherent impls - if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) { + if let Some(Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) { if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) | ItemKind::Trait(..)) { @@ -340,7 +339,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> { if let Some(node) = self.cx.tcx.hir.find(id) { match node { - map::Node::NodeExpr(e) => { + Node::Expr(e) => { // `match` and `if let` if let ExprKind::Match(ref c, ..) = e.node { self.spans_need_deref @@ -350,7 +349,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> { } }, - map::Node::NodeStmt(s) => { + Node::Stmt(s) => { // `let = x;` if_chain! { if let StmtKind::Decl(ref decl, _) = s.node; diff --git a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs index f53e2cb0cce..bec875d16d6 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; @@ -20,7 +20,7 @@ use crate::utils::{self, paths, span_lint}; /// /// ```rust /// use std::cmp::Ordering; -/// +/// /// // Bad /// let a = 1.0; /// let b = std::f64::NAN; diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index 2b0c021ea03..5246e62aecb 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::source_map::{Span, Spanned}; diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 820e76f886e..4dd2ea98399 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -1,6 +1,6 @@ use rustc::hir::def_id::DefId; use rustc::hir; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 119b4c2d861..c2692f88187 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -212,7 +212,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst { if parent_id == cur_expr.id { break; } - if let Some(map::NodeExpr(parent_expr)) = cx.tcx.hir.find(parent_id) { + if let Some(Node::Expr(parent_expr)) = cx.tcx.hir.find(parent_id) { match &parent_expr.node { ExprKind::AddrOf(..) => { // `&e` => `e` must be referenced diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index acfa341ed1f..14aba635c1a 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LintArray, LintPass, EarlyContext, EarlyLintPass}; use rustc::{declare_lint, lint_array}; use syntax::source_map::Span; use syntax::symbol::LocalInternedString; diff --git a/clippy_lints/src/ok_if_let.rs b/clippy_lints/src/ok_if_let.rs index 2a7f71c7145..52eb86a0bc0 100644 --- a/clippy_lints/src/ok_if_let.rs +++ b/clippy_lints/src/ok_if_let.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index ac399e238b6..bfb88449fba 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -1,5 +1,5 @@ use rustc::hir::{Expr, ExprKind}; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast::LitKind; use syntax::source_map::{Span, Spanned}; diff --git a/clippy_lints/src/overflow_check_conditional.rs b/clippy_lints/src/overflow_check_conditional.rs index 5714bdb521c..cb230bc9fc5 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index e603773f7ba..e21c0718612 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::ast::LitKind; diff --git a/clippy_lints/src/partialeq_ne_impl.rs b/clippy_lints/src/partialeq_ne_impl.rs index 675d014c527..fe93a8bbe99 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index c4e802adaee..42bbe687832 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast::*; use syntax::source_map::Spanned; diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index b040bd91f8d..cedb6e0b26b 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -2,9 +2,8 @@ use std::borrow::Cow; use rustc::hir::*; -use rustc::hir::map::NodeItem; use rustc::hir::QPath; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty; @@ -112,7 +111,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PointerPass { fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) { if let ImplItemKind::Method(ref sig, body_id) = item.node { - if let Some(NodeItem(it)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(item.id)) { + if let Some(Node::Item(it)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(item.id)) { if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.node { return; // ignore trait impls } diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index 630dd1b57be..cb98ecd3dec 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index ba25e50d7c0..bef4532bbe5 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index ba8b11e55df..3021ef2dc47 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast::*; use crate::utils::{span_lint_and_sugg}; diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs index f349f46d926..f5bc03c6d6e 100644 --- a/clippy_lints/src/reference.rs +++ b/clippy_lints/src/reference.rs @@ -1,5 +1,5 @@ use syntax::ast::{Expr, ExprKind, UnOp}; -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use crate::utils::{snippet, span_lint_and_sugg}; diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 4553b08e747..5fe37e16484 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -1,6 +1,6 @@ use regex_syntax; use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use std::collections::HashSet; diff --git a/clippy_lints/src/replace_consts.rs b/clippy_lints/src/replace_consts.rs index b9a4c6ebb19..093ad0358bc 100644 --- a/clippy_lints/src/replace_consts.rs +++ b/clippy_lints/src/replace_consts.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir; diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 8125cc4153b..694433a8b92 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use syntax::ast; diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs index ce326ea72ca..41d8b1f7d24 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use crate::utils::{get_trait_def_id, paths, span_lint}; diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index cc4aa129870..4964b7e79ef 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -1,5 +1,5 @@ use crate::reexport::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use rustc::hir::intravisit::FnKind; diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index d66163984aa..2b915f46175 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::source_map::Spanned; use crate::utils::SpanlessEq; diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index b0a8a2d0061..7e0684e7f16 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir; @@ -76,7 +76,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl { // as a child node let mut parent_expr = cx.tcx.hir.get_parent_node(expr.id); while parent_expr != ast::CRATE_NODE_ID { - if let hir::map::Node::NodeExpr(e) = cx.tcx.hir.get(parent_expr) { + if let hir::Node::Expr(e) = cx.tcx.hir.get(parent_expr) { match e.node { hir::ExprKind::Binary(..) | hir::ExprKind::Unary(hir::UnOp::UnNot, _) @@ -187,7 +187,7 @@ fn check_binop<'a>( if_chain! { if parent_impl != ast::CRATE_NODE_ID; - if let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl); + if let hir::Node::Item(item) = cx.tcx.hir.get(parent_impl); if let hir::ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node; if let Some(idx) = trait_ids.iter().position(|&tid| tid == trait_ref.path.def.def_id()); if binop != expected_ops[idx]; diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 14c8e94d30c..7fd72cbea32 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -1,6 +1,6 @@ use matches::matches; use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty; diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index 28c5971e852..9fe22b7dafc 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; diff --git a/clippy_lints/src/trivially_copy_pass_by_ref.rs b/clippy_lints/src/trivially_copy_pass_by_ref.rs index d88a970db75..8f417861ca9 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -3,9 +3,8 @@ use std::cmp; use matches::matches; use rustc::hir; use rustc::hir::*; -use rustc::hir::map::*; use rustc::hir::intravisit::FnKind; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::TyKind; @@ -109,7 +108,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef { } // Exclude non-inherent impls - if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) { + if let Some(Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) { if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) | ItemKind::Trait(..)) { diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 024aba7e85e..a38d232d3e1 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -2,7 +2,7 @@ use crate::reexport::*; use rustc::hir; use rustc::hir::*; use rustc::hir::intravisit::{walk_body, walk_expr, walk_ty, FnKind, NestedVisitorMap, Visitor}; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty, TyCtxt, TypeckTables}; @@ -140,7 +140,7 @@ impl LintPass for TypePass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypePass { fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body, _: Span, id: NodeId) { // skip trait implementations, see #605 - if let Some(map::NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(id)) { + if let Some(hir::Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent(id)) { if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node { return; } @@ -514,7 +514,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitArg { if !is_questionmark_desugar_marked_call(expr) { if_chain!{ let opt_parent_node = map.find(map.get_parent_node(expr.id)); - if let Some(hir::map::NodeExpr(parent_expr)) = opt_parent_node; + if let Some(hir::Node::Expr(parent_expr)) = opt_parent_node; if is_questionmark_desugar_marked_call(parent_expr); then {} else { diff --git a/clippy_lints/src/unicode.rs b/clippy_lints/src/unicode.rs index 2768efca88e..4e5c9a94424 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use syntax::ast::{LitKind, NodeId}; diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index 37a5836f153..753ee40be7f 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast::*; use syntax::source_map::Span; diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index a9a7e102ab2..e388ca93888 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir; use crate::utils::{is_try, match_qpath, match_trait_method, paths, span_lint}; diff --git a/clippy_lints/src/unused_label.rs b/clippy_lints/src/unused_label.rs index 04b4fcabdd8..1fd143d6d03 100644 --- a/clippy_lints/src/unused_label.rs +++ b/clippy_lints/src/unused_label.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir; use rustc::hir::intravisit::{walk_expr, walk_fn, FnKind, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 2a557ed8e43..0435db93ee6 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 4310325475a..f45ec75aedc 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -3,7 +3,7 @@ #![allow(print_stdout, use_debug)] -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir; use rustc::hir::{Expr, ExprKind, QPath, TyKind, Pat, PatKind, BindingAnnotation, StmtKind, DeclKind, Stmt}; diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 57486b30d34..30c6db977f7 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -1,5 +1,5 @@ use crate::consts::{constant_simple, constant_context}; -use rustc::lint::*; +use rustc::lint::LateContext; use rustc::hir::*; use rustc::ty::{TypeckTables}; use std::hash::{Hash, Hasher}; diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index b6c241a6825..73c86d8bf67 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -2,7 +2,7 @@ //! checks for attributes -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir; use rustc::hir::print; diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index 6df41f1cd41..39a3d9b3b74 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, EarlyContext, EarlyLintPass}; use rustc::{declare_lint, lint_array}; use rustc::hir::*; use rustc::hir; diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index b753f8072d0..976161a40a9 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -6,7 +6,7 @@ use rustc::hir::*; use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX}; use rustc::hir::def::Def; use rustc::hir::intravisit::{NestedVisitorMap, Visitor}; -use rustc::hir::map::Node; +use rustc::hir::Node; use rustc::lint::{LateContext, Level, Lint, LintContext}; use rustc::session::Session; use rustc::traits; @@ -309,9 +309,9 @@ pub fn method_chain_args<'a>(expr: &'a Expr, methods: &[&str]) -> Option, expr: &Expr) -> Option { let parent_id = cx.tcx.hir.get_parent(expr.id); match cx.tcx.hir.find(parent_id) { - Some(Node::NodeItem(&Item { ref name, .. })) => Some(*name), - Some(Node::NodeTraitItem(&TraitItem { ident, .. })) | - Some(Node::NodeImplItem(&ImplItem { ident, .. })) => Some(ident.name), + Some(Node::Item(&Item { ref name, .. })) => Some(*name), + Some(Node::TraitItem(&TraitItem { ident, .. })) | + Some(Node::ImplItem(&ImplItem { ident, .. })) => Some(ident.name), _ => None, } } @@ -464,7 +464,7 @@ pub fn get_parent_expr<'c>(cx: &'c LateContext<'_, '_>, e: &Expr) -> Option<&'c return None; } map.find(parent_id).and_then(|node| { - if let Node::NodeExpr(parent) = node { + if let Node::Expr(parent) = node { Some(parent) } else { None @@ -478,11 +478,11 @@ pub fn get_enclosing_block<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, node: NodeI .and_then(|enclosing_id| map.find(enclosing_id)); if let Some(node) = enclosing_node { match node { - Node::NodeBlock(block) => Some(block), - Node::NodeItem(&Item { + Node::Block(block) => Some(block), + Node::Item(&Item { node: ItemKind::Fn(_, _, _, eid), .. - }) | Node::NodeImplItem(&ImplItem { + }) | Node::ImplItem(&ImplItem { node: ImplItemKind::Method(_, eid), .. }) => match cx.tcx.hir.body(eid).value.node { diff --git a/clippy_lints/src/utils/usage.rs b/clippy_lints/src/utils/usage.rs index 95199b9f208..2661bc945f3 100644 --- a/clippy_lints/src/utils/usage.rs +++ b/clippy_lints/src/utils/usage.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::LateContext; use rustc::hir::def::Def; use rustc::hir::*; diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index f86ce5ab786..8e49a3d4326 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -1,5 +1,5 @@ use rustc::hir::*; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 97fe12f2330..bc9fa09c932 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -1,4 +1,4 @@ -use rustc::lint::*; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use syntax::ast::*; use syntax::tokenstream::{ThinTokenStream, TokenStream}; diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index 7c8af7880ba..77bc4802742 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -1,5 +1,5 @@ use crate::consts::{constant_simple, Constant}; -use rustc::lint::*; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; From 05f637cf88a4555ac8e521811feb6c598c5dbee1 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 28 Aug 2018 21:32:20 -0500 Subject: [PATCH 24/53] Make clippy_lints::{utils,consts} modules private, remove unused items. --- ci/base-tests.sh | 1 + clippy_lints/src/consts.rs | 16 --- clippy_lints/src/lib.rs | 4 +- clippy_lints/src/utils/camel_case.rs | 114 +++++++++++++++++++ clippy_lints/src/utils/conf.rs | 15 --- clippy_lints/src/utils/mod.rs | 161 ++++++++++++++------------- clippy_lints/src/utils/paths.rs | 9 -- clippy_lints/src/utils/sugg.rs | 9 -- tests/camel_case.rs | 50 --------- tests/trim_multiline.rs | 57 ---------- tests/without_block_comments.rs | 27 ----- 11 files changed, 201 insertions(+), 262 deletions(-) create mode 100644 clippy_lints/src/utils/camel_case.rs delete mode 100644 tests/camel_case.rs delete mode 100644 tests/trim_multiline.rs delete mode 100644 tests/without_block_comments.rs diff --git a/ci/base-tests.sh b/ci/base-tests.sh index 13b652c0f7d..f7c3342fe38 100755 --- a/ci/base-tests.sh +++ b/ci/base-tests.sh @@ -7,6 +7,7 @@ remark -f *.md > /dev/null # build clippy in debug mode and run tests cargo build --features debugging cargo test --features debugging +cd clippy_lints && cargo test && cd .. mkdir -p ~/rust/cargo/bin cp target/debug/cargo-clippy ~/rust/cargo/bin/cargo-clippy cp target/debug/clippy-driver ~/rust/cargo/bin/clippy-driver diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index ff189d6e893..cf3ea0414da 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -16,22 +16,6 @@ use syntax::ast::{FloatTy, LitKind}; use syntax::ptr::P; use crate::utils::{sext, unsext, clip}; -#[derive(Debug, Copy, Clone)] -pub enum FloatWidth { - F32, - F64, - Any, -} - -impl From for FloatWidth { - fn from(ty: FloatTy) -> Self { - match ty { - FloatTy::F32 => FloatWidth::F32, - FloatTy::F64 => FloatWidth::F64, - } - } -} - /// A `LitKind`-like enum to fold constant `Expr`s into. #[derive(Debug, Clone)] pub enum Constant { diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 84db58b8971..7aa41e80126 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -48,9 +48,9 @@ macro_rules! declare_clippy_lint { }; } -pub mod consts; +mod consts; #[macro_use] -pub mod utils; +mod utils; // begin lints modules, do not remove this comment, it’s used in `update_lints` pub mod approx_const; diff --git a/clippy_lints/src/utils/camel_case.rs b/clippy_lints/src/utils/camel_case.rs new file mode 100644 index 00000000000..e8a8d510fe5 --- /dev/null +++ b/clippy_lints/src/utils/camel_case.rs @@ -0,0 +1,114 @@ +/// Return the index of the character after the first camel-case component of +/// `s`. +pub fn camel_case_until(s: &str) -> usize { + let mut iter = s.char_indices(); + if let Some((_, first)) = iter.next() { + if !first.is_uppercase() { + return 0; + } + } else { + return 0; + } + let mut up = true; + let mut last_i = 0; + for (i, c) in iter { + if up { + if c.is_lowercase() { + up = false; + } else { + return last_i; + } + } else if c.is_uppercase() { + up = true; + last_i = i; + } else if !c.is_lowercase() { + return i; + } + } + if up { + last_i + } else { + s.len() + } +} + +/// Return index of the last camel-case component of `s`. +pub fn camel_case_from(s: &str) -> usize { + let mut iter = s.char_indices().rev(); + if let Some((_, first)) = iter.next() { + if !first.is_lowercase() { + return s.len(); + } + } else { + return s.len(); + } + let mut down = true; + let mut last_i = s.len(); + for (i, c) in iter { + if down { + if c.is_uppercase() { + down = false; + last_i = i; + } else if !c.is_lowercase() { + return last_i; + } + } else if c.is_lowercase() { + down = true; + } else { + return last_i; + } + } + last_i +} + +#[cfg(test)] +mod test { + use super::{camel_case_from, camel_case_until}; + + #[test] + fn from_full() { + assert_eq!(camel_case_from("AbcDef"), 0); + assert_eq!(camel_case_from("Abc"), 0); + } + + #[test] + fn from_partial() { + assert_eq!(camel_case_from("abcDef"), 3); + assert_eq!(camel_case_from("aDbc"), 1); + } + + #[test] + fn from_not() { + assert_eq!(camel_case_from("AbcDef_"), 7); + assert_eq!(camel_case_from("AbcDD"), 5); + } + + #[test] + fn from_caps() { + assert_eq!(camel_case_from("ABCD"), 4); + } + + #[test] + fn until_full() { + assert_eq!(camel_case_until("AbcDef"), 6); + assert_eq!(camel_case_until("Abc"), 3); + } + + #[test] + fn until_not() { + assert_eq!(camel_case_until("abcDef"), 0); + assert_eq!(camel_case_until("aDbc"), 0); + } + + #[test] + fn until_partial() { + assert_eq!(camel_case_until("AbcDef_"), 6); + assert_eq!(camel_case_until("CallTypeC"), 8); + assert_eq!(camel_case_until("AbcDD"), 3); + } + + #[test] + fn until_caps() { + assert_eq!(camel_case_until("ABCD"), 0); + } +} \ No newline at end of file diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index 1567bd9ffb6..f910080c229 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -38,17 +38,6 @@ pub enum Error { Io(io::Error), /// Not valid toml or doesn't fit the expected conf format Toml(String), - /// Type error. - Type( - /// The name of the key. - &'static str, - /// The expected type. - &'static str, - /// The type we got instead. - &'static str, - ), - /// There is an unknown key is the file. - UnknownKey(String), } impl fmt::Display for Error { @@ -56,10 +45,6 @@ impl fmt::Display for Error { match *self { Error::Io(ref err) => err.fmt(f), Error::Toml(ref err) => err.fmt(f), - Error::Type(key, expected, got) => { - write!(f, "`{}` is expected to be a `{}` but is a `{}`", key, expected, got) - }, - Error::UnknownKey(ref key) => write!(f, "unknown key `{}`", key), } } } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 976161a40a9..650ea373d97 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -21,9 +21,11 @@ use syntax::ast::{self, LitKind}; use syntax::attr; use syntax::source_map::{Span, DUMMY_SP}; use syntax::errors::DiagnosticBuilder; -use syntax::ptr::P; use syntax::symbol::keywords; +mod camel_case; +pub use self::camel_case::{camel_case_from, camel_case_until}; + pub mod comparisons; pub mod conf; pub mod constants; @@ -37,8 +39,6 @@ pub mod ptr; pub mod usage; pub use self::hir_utils::{SpanlessEq, SpanlessHash}; -pub type MethodArgs = HirVec>; - pub mod higher; /// Returns true if the two spans come from differing expansions (i.e. one is @@ -106,17 +106,6 @@ pub fn match_type(cx: &LateContext<'_, '_>, ty: Ty<'_>, path: &[&str]) -> bool { } } -/// Check if the method call given in `expr` belongs to given type. -pub fn match_impl_method(cx: &LateContext<'_, '_>, expr: &Expr, path: &[&str]) -> bool { - let method_call = cx.tables.type_dependent_defs()[expr.hir_id]; - let trt_id = cx.tcx.impl_of_method(method_call.def_id()); - if let Some(trt_id) = trt_id { - match_def_path(cx.tcx, trt_id, path) - } else { - false - } -} - /// Check if the method call given in `expr` belongs to given trait. pub fn match_trait_method(cx: &LateContext<'_, '_>, expr: &Expr, path: &[&str]) -> bool { let method_call = cx.tables.type_dependent_defs()[expr.hir_id]; @@ -755,69 +744,6 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option { } } -/// Return the index of the character after the first camel-case component of -/// `s`. -pub fn camel_case_until(s: &str) -> usize { - let mut iter = s.char_indices(); - if let Some((_, first)) = iter.next() { - if !first.is_uppercase() { - return 0; - } - } else { - return 0; - } - let mut up = true; - let mut last_i = 0; - for (i, c) in iter { - if up { - if c.is_lowercase() { - up = false; - } else { - return last_i; - } - } else if c.is_uppercase() { - up = true; - last_i = i; - } else if !c.is_lowercase() { - return i; - } - } - if up { - last_i - } else { - s.len() - } -} - -/// Return index of the last camel-case component of `s`. -pub fn camel_case_from(s: &str) -> usize { - let mut iter = s.char_indices().rev(); - if let Some((_, first)) = iter.next() { - if !first.is_lowercase() { - return s.len(); - } - } else { - return s.len(); - } - let mut down = true; - let mut last_i = s.len(); - for (i, c) in iter { - if down { - if c.is_uppercase() { - down = false; - last_i = i; - } else if !c.is_lowercase() { - return last_i; - } - } else if c.is_lowercase() { - down = true; - } else { - return last_i; - } - } - last_i -} - /// Convenience function to get the return type of a function pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> Ty<'tcx> { let fn_def_id = cx.tcx.hir.local_def_id(fn_item); @@ -1109,3 +1035,84 @@ pub fn any_parent_is_automatically_derived(tcx: TyCtxt<'_, '_, '_>, node: NodeId } false } + +#[cfg(test)] +mod test { + use super::{trim_multiline, without_block_comments}; + + #[test] + fn test_trim_multiline_single_line() { + assert_eq!("", trim_multiline("".into(), false)); + assert_eq!("...", trim_multiline("...".into(), false)); + assert_eq!("...", trim_multiline(" ...".into(), false)); + assert_eq!("...", trim_multiline("\t...".into(), false)); + assert_eq!("...", trim_multiline("\t\t...".into(), false)); + } + + #[test] + #[rustfmt::skip] + fn test_trim_multiline_block() { + assert_eq!("\ + if x { + y + } else { + z + }", trim_multiline(" if x { + y + } else { + z + }".into(), false)); + assert_eq!("\ + if x { + \ty + } else { + \tz + }", trim_multiline(" if x { + \ty + } else { + \tz + }".into(), false)); + } + + #[test] + #[rustfmt::skip] + fn test_trim_multiline_empty_line() { + assert_eq!("\ + if x { + y + + } else { + z + }", trim_multiline(" if x { + y + + } else { + z + }".into(), false)); + } + + #[test] + fn test_without_block_comments_lines_without_block_comments() { + let result = without_block_comments(vec!["/*", "", "*/"]); + println!("result: {:?}", result); + assert!(result.is_empty()); + + let result = without_block_comments(vec!["", "/*", "", "*/", "#[crate_type = \"lib\"]", "/*", "", "*/", ""]); + assert_eq!(result, vec!["", "#[crate_type = \"lib\"]", ""]); + + let result = without_block_comments(vec!["/* rust", "", "*/"]); + assert!(result.is_empty()); + + let result = without_block_comments(vec!["/* one-line comment */"]); + assert!(result.is_empty()); + + let result = without_block_comments(vec!["/* nested", "/* multi-line", "comment", "*/", "test", "*/"]); + assert!(result.is_empty()); + + let result = without_block_comments(vec!["/* nested /* inline /* comment */ test */ */"]); + assert!(result.is_empty()); + + let result = without_block_comments(vec!["foo", "bar", "baz"]); + assert_eq!(result, vec!["foo", "bar", "baz"]); + } +} \ No newline at end of file diff --git a/clippy_lints/src/utils/paths.rs b/clippy_lints/src/utils/paths.rs index 4d89f8ddffb..3c03645cc1b 100644 --- a/clippy_lints/src/utils/paths.rs +++ b/clippy_lints/src/utils/paths.rs @@ -9,8 +9,6 @@ pub const BEGIN_PANIC: [&str; 3] = ["std", "panicking", "begin_panic"]; pub const BEGIN_PANIC_FMT: [&str; 3] = ["std", "panicking", "begin_panic_fmt"]; pub const BINARY_HEAP: [&str; 4] = ["alloc", "collections", "binary_heap", "BinaryHeap"]; pub const BORROW_TRAIT: [&str; 3] = ["core", "borrow", "Borrow"]; -pub const BOX: [&str; 3] = ["std", "boxed", "Box"]; -pub const BOX_NEW: [&str; 4] = ["std", "boxed", "Box", "new"]; pub const BTREEMAP: [&str; 5] = ["alloc", "collections", "btree", "map", "BTreeMap"]; pub const BTREEMAP_ENTRY: [&str; 5] = ["alloc", "collections", "btree", "map", "Entry"]; pub const BTREESET: [&str; 5] = ["alloc", "collections", "btree", "set", "BTreeSet"]; @@ -22,16 +20,13 @@ pub const COW: [&str; 3] = ["alloc", "borrow", "Cow"]; pub const CSTRING_NEW: [&str; 5] = ["std", "ffi", "c_str", "CString", "new"]; pub const C_VOID: [&str; 4] = ["std", "os", "raw", "c_void"]; pub const C_VOID_LIBC: [&str; 2] = ["libc", "c_void"]; -pub const DEBUG_FMT_METHOD: [&str; 4] = ["core", "fmt", "Debug", "fmt"]; pub const DEFAULT_TRAIT: [&str; 3] = ["core", "default", "Default"]; pub const DEFAULT_TRAIT_METHOD: [&str; 4] = ["core", "default", "Default", "default"]; pub const DISPLAY_FMT_METHOD: [&str; 4] = ["core", "fmt", "Display", "fmt"]; pub const DOUBLE_ENDED_ITERATOR: [&str; 4] = ["core", "iter", "traits", "DoubleEndedIterator"]; pub const DROP: [&str; 3] = ["core", "mem", "drop"]; pub const DURATION: [&str; 3] = ["core", "time", "Duration"]; -pub const FMT_ARGUMENTS_NEWV1: [&str; 4] = ["core", "fmt", "Arguments", "new_v1"]; pub const FMT_ARGUMENTS_NEWV1FORMATTED: [&str; 4] = ["core", "fmt", "Arguments", "new_v1_formatted"]; -pub const FMT_ARGUMENTV1_NEW: [&str; 4] = ["core", "fmt", "ArgumentV1", "new"]; pub const FROM_FROM: [&str; 4] = ["core", "convert", "From", "from"]; pub const FROM_TRAIT: [&str; 3] = ["core", "convert", "From"]; pub const HASH: [&str; 2] = ["hash", "Hash"]; @@ -43,7 +38,6 @@ pub const INDEX_MUT: [&str; 3] = ["core", "ops", "IndexMut"]; pub const INIT: [&str; 4] = ["core", "intrinsics", "", "init"]; pub const INTO: [&str; 3] = ["core", "convert", "Into"]; pub const INTO_ITERATOR: [&str; 4] = ["core", "iter", "traits", "IntoIterator"]; -pub const IO_PRINT: [&str; 4] = ["std", "io", "stdio", "_print"]; pub const IO_READ: [&str; 3] = ["std", "io", "Read"]; pub const IO_WRITE: [&str; 3] = ["std", "io", "Write"]; pub const ITERATOR: [&str; 4] = ["core", "iter", "iterator", "Iterator"]; @@ -69,9 +63,7 @@ pub const RANGE_FROM: [&str; 3] = ["core", "ops", "RangeFrom"]; pub const RANGE_FROM_STD: [&str; 3] = ["std", "ops", "RangeFrom"]; pub const RANGE_FULL: [&str; 3] = ["core", "ops", "RangeFull"]; pub const RANGE_FULL_STD: [&str; 3] = ["std", "ops", "RangeFull"]; -pub const RANGE_INCLUSIVE: [&str; 3] = ["core", "ops", "RangeInclusive"]; pub const RANGE_INCLUSIVE_NEW: [&str; 4] = ["core", "ops", "RangeInclusive", "new"]; -pub const RANGE_INCLUSIVE_STD: [&str; 3] = ["std", "ops", "RangeInclusive"]; pub const RANGE_INCLUSIVE_STD_NEW: [&str; 4] = ["std", "ops", "RangeInclusive", "new"]; pub const RANGE_STD: [&str; 3] = ["std", "ops", "Range"]; pub const RANGE_TO: [&str; 3] = ["core", "ops", "RangeTo"]; @@ -81,7 +73,6 @@ pub const RANGE_TO_STD: [&str; 3] = ["std", "ops", "RangeTo"]; pub const RC: [&str; 3] = ["alloc", "rc", "Rc"]; pub const REGEX: [&str; 3] = ["regex", "re_unicode", "Regex"]; pub const REGEX_BUILDER_NEW: [&str; 5] = ["regex", "re_builder", "unicode", "RegexBuilder", "new"]; -pub const REGEX_BYTES: [&str; 3] = ["regex", "re_bytes", "Regex"]; pub const REGEX_BYTES_BUILDER_NEW: [&str; 5] = ["regex", "re_builder", "bytes", "RegexBuilder", "new"]; pub const REGEX_BYTES_NEW: [&str; 4] = ["regex", "re_bytes", "Regex", "new"]; pub const REGEX_BYTES_SET_NEW: [&str; 5] = ["regex", "re_set", "bytes", "RegexSet", "new"]; diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index 3d587a72eec..a02e0144791 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -175,15 +175,6 @@ impl<'a> Sugg<'a> { make_unop("&mut *", self) } - /// Convenience method to create the `..` or `...` - /// suggestion. - pub fn range(self, end: &Self, limit: ast::RangeLimits) -> Sugg<'static> { - match limit { - ast::RangeLimits::HalfOpen => make_assoc(AssocOp::DotDot, &self, end), - ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotEq, &self, end), - } - } - /// Add parenthesis to any expression that might need them. Suitable to the /// `self` argument of /// a method call (eg. to build `bar.foo()` or `(1 + 2).foo()`). diff --git a/tests/camel_case.rs b/tests/camel_case.rs deleted file mode 100644 index b7efbde6596..00000000000 --- a/tests/camel_case.rs +++ /dev/null @@ -1,50 +0,0 @@ -extern crate clippy_lints; - -use clippy_lints::utils::{camel_case_from, camel_case_until}; - -#[test] -fn from_full() { - assert_eq!(camel_case_from("AbcDef"), 0); - assert_eq!(camel_case_from("Abc"), 0); -} - -#[test] -fn from_partial() { - assert_eq!(camel_case_from("abcDef"), 3); - assert_eq!(camel_case_from("aDbc"), 1); -} - -#[test] -fn from_not() { - assert_eq!(camel_case_from("AbcDef_"), 7); - assert_eq!(camel_case_from("AbcDD"), 5); -} - -#[test] -fn from_caps() { - assert_eq!(camel_case_from("ABCD"), 4); -} - -#[test] -fn until_full() { - assert_eq!(camel_case_until("AbcDef"), 6); - assert_eq!(camel_case_until("Abc"), 3); -} - -#[test] -fn until_not() { - assert_eq!(camel_case_until("abcDef"), 0); - assert_eq!(camel_case_until("aDbc"), 0); -} - -#[test] -fn until_partial() { - assert_eq!(camel_case_until("AbcDef_"), 6); - assert_eq!(camel_case_until("CallTypeC"), 8); - assert_eq!(camel_case_until("AbcDD"), 3); -} - -#[test] -fn until_caps() { - assert_eq!(camel_case_until("ABCD"), 0); -} diff --git a/tests/trim_multiline.rs b/tests/trim_multiline.rs deleted file mode 100644 index a0db2e59a29..00000000000 --- a/tests/trim_multiline.rs +++ /dev/null @@ -1,57 +0,0 @@ - - -/// test the multiline-trim function -extern crate clippy_lints; - -use clippy_lints::utils::trim_multiline; - -#[test] -fn test_single_line() { - assert_eq!("", trim_multiline("".into(), false)); - assert_eq!("...", trim_multiline("...".into(), false)); - assert_eq!("...", trim_multiline(" ...".into(), false)); - assert_eq!("...", trim_multiline("\t...".into(), false)); - assert_eq!("...", trim_multiline("\t\t...".into(), false)); -} - -#[test] -#[rustfmt::skip] -fn test_block() { - assert_eq!("\ -if x { - y -} else { - z -}", trim_multiline(" if x { - y - } else { - z - }".into(), false)); - assert_eq!("\ -if x { -\ty -} else { -\tz -}", trim_multiline(" if x { - \ty - } else { - \tz - }".into(), false)); -} - -#[test] -#[rustfmt::skip] -fn test_empty_line() { - assert_eq!("\ -if x { - y - -} else { - z -}", trim_multiline(" if x { - y - - } else { - z - }".into(), false)); -} diff --git a/tests/without_block_comments.rs b/tests/without_block_comments.rs deleted file mode 100644 index 730c5cb128f..00000000000 --- a/tests/without_block_comments.rs +++ /dev/null @@ -1,27 +0,0 @@ -extern crate clippy_lints; -use clippy_lints::utils::without_block_comments; - -#[test] -fn test_lines_without_block_comments() { - let result = without_block_comments(vec!["/*", "", "*/"]); - println!("result: {:?}", result); - assert!(result.is_empty()); - - let result = without_block_comments(vec!["", "/*", "", "*/", "#[crate_type = \"lib\"]", "/*", "", "*/", ""]); - assert_eq!(result, vec!["", "#[crate_type = \"lib\"]", ""]); - - let result = without_block_comments(vec!["/* rust", "", "*/"]); - assert!(result.is_empty()); - - let result = without_block_comments(vec!["/* one-line comment */"]); - assert!(result.is_empty()); - - let result = without_block_comments(vec!["/* nested", "/* multi-line", "comment", "*/", "test", "*/"]); - assert!(result.is_empty()); - - let result = without_block_comments(vec!["/* nested /* inline /* comment */ test */ */"]); - assert!(result.is_empty()); - - let result = without_block_comments(vec!["foo", "bar", "baz"]); - assert_eq!(result, vec!["foo", "bar", "baz"]); -} From 5ebae01c1eb7beafb455d432bd4d4f8f612ead2a Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 27 Aug 2018 09:49:54 -0400 Subject: [PATCH 25/53] New lint: Suggest `ptr.add([usize])` over `ptr.offset([usize] as isize)`. First part of #3047. --- clippy_lints/src/lib.rs | 4 + clippy_lints/src/ptr_offset_with_cast.rs | 130 +++++++++++++++++++++++ tests/ui/ptr_offset_with_cast.rs | 14 +++ tests/ui/ptr_offset_with_cast.stderr | 10 ++ 4 files changed, 158 insertions(+) create mode 100644 clippy_lints/src/ptr_offset_with_cast.rs create mode 100644 tests/ui/ptr_offset_with_cast.rs create mode 100644 tests/ui/ptr_offset_with_cast.stderr diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 84db58b8971..ccb849a0c06 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -142,6 +142,7 @@ pub mod panic_unimplemented; pub mod partialeq_ne_impl; pub mod precedence; pub mod ptr; +pub mod ptr_offset_with_cast; pub mod question_mark; pub mod ranges; pub mod redundant_field_names; @@ -408,6 +409,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { reg.register_late_lint_pass(box default_trait_access::DefaultTraitAccess); reg.register_late_lint_pass(box indexing_slicing::IndexingSlicing); reg.register_late_lint_pass(box non_copy_const::NonCopyConst); + reg.register_late_lint_pass(box ptr_offset_with_cast::Pass); reg.register_lint_group("clippy_restriction", vec![ arithmetic::FLOAT_ARITHMETIC, @@ -631,6 +633,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { ptr::CMP_NULL, ptr::MUT_FROM_REF, ptr::PTR_ARG, + ptr_offset_with_cast::PTR_OFFSET_WITH_CAST, question_mark::QUESTION_MARK, ranges::ITERATOR_STEP_BY_ZERO, ranges::RANGE_MINUS_ONE, @@ -755,6 +758,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { panic_unimplemented::PANIC_PARAMS, ptr::CMP_NULL, ptr::PTR_ARG, + ptr_offset_with_cast::PTR_OFFSET_WITH_CAST, question_mark::QUESTION_MARK, redundant_field_names::REDUNDANT_FIELD_NAMES, regex::REGEX_MACRO, diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs new file mode 100644 index 00000000000..4a6bc8215ef --- /dev/null +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -0,0 +1,130 @@ +use rustc::{declare_lint, hir, lint, lint_array, ty}; +use syntax::ast; +use crate::utils; + +/// **What it does:** Checks for usage of the `offset` pointer method with a `usize` casted to an +/// `isize`. +/// +/// **Why is this bad?** If we’re always increasing the pointer address, we can avoid the numeric +/// cast by using the `add` method instead. +/// +/// **Known problems:** None +/// +/// **Example:** +/// ```rust +/// let vec = vec![b'a', b'b', b'c']; +/// let ptr = vec.as_ptr(); +/// let offset = 1_usize; +/// +/// unsafe { ptr.offset(offset as isize); } +/// ``` +/// +/// Could be written: +/// +/// ```rust +/// let vec = vec![b'a', b'b', b'c']; +/// let ptr = vec.as_ptr(); +/// let offset = 1_usize; +/// +/// unsafe { ptr.add(offset); } +/// ``` +declare_clippy_lint! { + pub PTR_OFFSET_WITH_CAST, + style, + "uneeded pointer offset cast" +} + +#[derive(Copy, Clone, Debug)] +pub struct Pass; + +impl lint::LintPass for Pass { + fn get_lints(&self) -> lint::LintArray { + lint_array!(PTR_OFFSET_WITH_CAST) + } +} + +impl<'a, 'tcx> lint::LateLintPass<'a, 'tcx> for Pass { + fn check_expr(&mut self, cx: &lint::LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { + // Check if the expressions is a ptr.offset method call + let [receiver_expr, arg_expr] = match expr_as_ptr_offset_call(cx, expr) { + Some(call_arg) => call_arg, + None => return, + }; + + // Check if the parameter to ptr.offset is a cast from usize to isize + let cast_lhs_expr = match expr_as_cast_from_usize(cx, arg_expr) { + Some(cast_lhs_expr) => cast_lhs_expr, + None => return, + }; + + utils::span_lint_and_sugg( + cx, + PTR_OFFSET_WITH_CAST, + expr.span, + "use of `offset` with a `usize` casted to an `isize`", + "try", + build_suggestion(cx, receiver_expr, cast_lhs_expr), + ); + } +} + +// If the given expression is a cast from a usize, return the lhs of the cast +fn expr_as_cast_from_usize<'a, 'tcx>( + cx: &lint::LateContext<'a, 'tcx>, + expr: &'tcx hir::Expr, +) -> Option<&'tcx hir::Expr> { + if let hir::ExprKind::Cast(ref cast_lhs_expr, _) = expr.node { + if is_expr_ty_usize(cx, &cast_lhs_expr) { + return Some(cast_lhs_expr); + } + } + None +} + +// If the given expression is a ptr::offset method call, return the receiver and the arg of the +// method call. +fn expr_as_ptr_offset_call<'a, 'tcx>( + cx: &lint::LateContext<'a, 'tcx>, + expr: &'tcx hir::Expr, +) -> Option<[&'tcx hir::Expr; 2]> { + if let hir::ExprKind::MethodCall(ref path_segment, _, ref args) = expr.node { + if path_segment.ident.name == "offset" && is_expr_ty_raw_ptr(cx, &args[0]) { + return Some([&args[0], &args[1]]); + } + } + None +} + +// Is the type of the expression a usize? +fn is_expr_ty_usize<'a, 'tcx>( + cx: &lint::LateContext<'a, 'tcx>, + expr: &hir::Expr, +) -> bool { + cx.tables.expr_ty(expr).sty == ty::TyKind::Uint(ast::UintTy::Usize) +} + +// Is the type of the expression a raw pointer? +fn is_expr_ty_raw_ptr<'a, 'tcx>( + cx: &lint::LateContext<'a, 'tcx>, + expr: &hir::Expr, +) -> bool { + if let ty::RawPtr(..) = cx.tables.expr_ty(expr).sty { + true + } else { + false + } +} + +fn build_suggestion<'a, 'tcx>( + cx: &lint::LateContext<'a, 'tcx>, + receiver_expr: &hir::Expr, + cast_lhs_expr: &hir::Expr, +) -> String { + match ( + utils::snippet_opt(cx, receiver_expr.span), + utils::snippet_opt(cx, cast_lhs_expr.span) + ) { + (Some(receiver), Some(cast_lhs)) => format!("{}.add({})", receiver, cast_lhs), + _ => String::new(), + } +} diff --git a/tests/ui/ptr_offset_with_cast.rs b/tests/ui/ptr_offset_with_cast.rs new file mode 100644 index 00000000000..947021aaf8e --- /dev/null +++ b/tests/ui/ptr_offset_with_cast.rs @@ -0,0 +1,14 @@ +fn main() { + let vec = vec![b'a', b'b', b'c']; + let ptr = vec.as_ptr(); + + let offset_u8 = 1_u8; + let offset_usize = 1_usize; + let offset_isize = 1_isize; + + unsafe { + ptr.offset(offset_usize as isize); + ptr.offset(offset_isize as isize); + ptr.offset(offset_u8 as isize); + } +} diff --git a/tests/ui/ptr_offset_with_cast.stderr b/tests/ui/ptr_offset_with_cast.stderr new file mode 100644 index 00000000000..1658f5f5366 --- /dev/null +++ b/tests/ui/ptr_offset_with_cast.stderr @@ -0,0 +1,10 @@ +error: use of `offset` with a `usize` casted to an `isize` + --> $DIR/ptr_offset_with_cast.rs:10:9 + | +10 | ptr.offset(offset_usize as isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)` + | + = note: `-D ptr-offset-with-cast` implied by `-D warnings` + +error: aborting due to previous error + From feb3e9fd5f8b24bcbe1a470b65dac66acb265721 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 07:02:26 -0500 Subject: [PATCH 26/53] switch lint from 'style' to 'complexity' --- clippy_lints/src/lib.rs | 2 +- clippy_lints/src/ptr_offset_with_cast.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index ccb849a0c06..7d429ce4923 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -758,7 +758,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { panic_unimplemented::PANIC_PARAMS, ptr::CMP_NULL, ptr::PTR_ARG, - ptr_offset_with_cast::PTR_OFFSET_WITH_CAST, question_mark::QUESTION_MARK, redundant_field_names::REDUNDANT_FIELD_NAMES, regex::REGEX_MACRO, @@ -819,6 +818,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL, partialeq_ne_impl::PARTIALEQ_NE_IMPL, precedence::PRECEDENCE, + ptr_offset_with_cast::PTR_OFFSET_WITH_CAST, ranges::RANGE_MINUS_ONE, ranges::RANGE_PLUS_ONE, ranges::RANGE_ZIP_WITH_LEN, diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 4a6bc8215ef..9c8382e43f2 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -30,7 +30,7 @@ use crate::utils; /// ``` declare_clippy_lint! { pub PTR_OFFSET_WITH_CAST, - style, + complexity, "uneeded pointer offset cast" } From a7c1ea96c4a6dc3c6614331124200ac4c5588b6b Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 07:03:50 -0500 Subject: [PATCH 27/53] tweak comment --- clippy_lints/src/ptr_offset_with_cast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 9c8382e43f2..756f8dfe2e5 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -51,7 +51,7 @@ impl<'a, 'tcx> lint::LateLintPass<'a, 'tcx> for Pass { None => return, }; - // Check if the parameter to ptr.offset is a cast from usize to isize + // Check if the argument to ptr.offset is a cast from usize let cast_lhs_expr = match expr_as_cast_from_usize(cx, arg_expr) { Some(cast_lhs_expr) => cast_lhs_expr, None => return, From a48a6ef10f76b02a88927198f4e06d7e81b89027 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 07:07:23 -0500 Subject: [PATCH 28/53] utilize cx.tcx.types.usize --- clippy_lints/src/ptr_offset_with_cast.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 756f8dfe2e5..af9989a161c 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -1,5 +1,4 @@ use rustc::{declare_lint, hir, lint, lint_array, ty}; -use syntax::ast; use crate::utils; /// **What it does:** Checks for usage of the `offset` pointer method with a `usize` casted to an @@ -100,7 +99,7 @@ fn is_expr_ty_usize<'a, 'tcx>( cx: &lint::LateContext<'a, 'tcx>, expr: &hir::Expr, ) -> bool { - cx.tables.expr_ty(expr).sty == ty::TyKind::Uint(ast::UintTy::Usize) + cx.tables.expr_ty(expr) == cx.tcx.types.usize } // Is the type of the expression a raw pointer? From f7d1ef90a04ad40148dc0db4ccf739e8178b11b1 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 07:08:59 -0500 Subject: [PATCH 29/53] utilize .is_unsafe_ptr --- clippy_lints/src/ptr_offset_with_cast.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index af9989a161c..75451565510 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -1,4 +1,4 @@ -use rustc::{declare_lint, hir, lint, lint_array, ty}; +use rustc::{declare_lint, hir, lint, lint_array}; use crate::utils; /// **What it does:** Checks for usage of the `offset` pointer method with a `usize` casted to an @@ -107,11 +107,7 @@ fn is_expr_ty_raw_ptr<'a, 'tcx>( cx: &lint::LateContext<'a, 'tcx>, expr: &hir::Expr, ) -> bool { - if let ty::RawPtr(..) = cx.tables.expr_ty(expr).sty { - true - } else { - false - } + cx.tables.expr_ty(expr).is_unsafe_ptr() } fn build_suggestion<'a, 'tcx>( From 61c20c148e926310f011895693f88cafb5a26539 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 07:12:22 -0500 Subject: [PATCH 30/53] if no suggestion, dont add suggestion --- clippy_lints/src/ptr_offset_with_cast.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 75451565510..5fb31c4aefb 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -56,14 +56,13 @@ impl<'a, 'tcx> lint::LateLintPass<'a, 'tcx> for Pass { None => return, }; - utils::span_lint_and_sugg( - cx, - PTR_OFFSET_WITH_CAST, - expr.span, - "use of `offset` with a `usize` casted to an `isize`", - "try", - build_suggestion(cx, receiver_expr, cast_lhs_expr), - ); + let msg = "use of `offset` with a `usize` casted to an `isize`"; + if let Some(sugg) = build_suggestion(cx, receiver_expr, cast_lhs_expr) { + utils::span_lint_and_sugg(cx, PTR_OFFSET_WITH_CAST, expr.span, msg, "try", sugg); + } else { + utils::span_lint(cx, PTR_OFFSET_WITH_CAST, expr.span, msg); + } + } } @@ -114,12 +113,12 @@ fn build_suggestion<'a, 'tcx>( cx: &lint::LateContext<'a, 'tcx>, receiver_expr: &hir::Expr, cast_lhs_expr: &hir::Expr, -) -> String { +) -> Option { match ( utils::snippet_opt(cx, receiver_expr.span), utils::snippet_opt(cx, cast_lhs_expr.span) ) { - (Some(receiver), Some(cast_lhs)) => format!("{}.add({})", receiver, cast_lhs), - _ => String::new(), + (Some(receiver), Some(cast_lhs)) => Some(format!("{}.add({})", receiver, cast_lhs)), + _ => None, } } From 2fa7351c1e0ca482ae13ca969be5975f1603a2b1 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 07:40:00 -0500 Subject: [PATCH 31/53] suggest wrapping_offset as well --- clippy_lints/src/ptr_offset_with_cast.rs | 58 ++++++++++++++++++------ tests/ui/ptr_offset_with_cast.rs | 4 ++ tests/ui/ptr_offset_with_cast.stderr | 8 +++- 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 5fb31c4aefb..20934573f09 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -1,5 +1,6 @@ use rustc::{declare_lint, hir, lint, lint_array}; use crate::utils; +use std::fmt; /// **What it does:** Checks for usage of the `offset` pointer method with a `usize` casted to an /// `isize`. @@ -44,23 +45,23 @@ impl lint::LintPass for Pass { impl<'a, 'tcx> lint::LateLintPass<'a, 'tcx> for Pass { fn check_expr(&mut self, cx: &lint::LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { - // Check if the expressions is a ptr.offset method call - let [receiver_expr, arg_expr] = match expr_as_ptr_offset_call(cx, expr) { + // Check if the expressions is a ptr.offset or ptr.wrapping_offset method call + let (receiver_expr, arg_expr, method) = match expr_as_ptr_offset_call(cx, expr) { Some(call_arg) => call_arg, None => return, }; - // Check if the argument to ptr.offset is a cast from usize + // Check if the argument to the method call is a cast from usize let cast_lhs_expr = match expr_as_cast_from_usize(cx, arg_expr) { Some(cast_lhs_expr) => cast_lhs_expr, None => return, }; - let msg = "use of `offset` with a `usize` casted to an `isize`"; - if let Some(sugg) = build_suggestion(cx, receiver_expr, cast_lhs_expr) { - utils::span_lint_and_sugg(cx, PTR_OFFSET_WITH_CAST, expr.span, msg, "try", sugg); + let msg = format!("use of `{}` with a `usize` casted to an `isize`", method); + if let Some(sugg) = build_suggestion(cx, method, receiver_expr, cast_lhs_expr) { + utils::span_lint_and_sugg(cx, PTR_OFFSET_WITH_CAST, expr.span, &msg, "try", sugg); } else { - utils::span_lint(cx, PTR_OFFSET_WITH_CAST, expr.span, msg); + utils::span_lint(cx, PTR_OFFSET_WITH_CAST, expr.span, &msg); } } @@ -79,15 +80,20 @@ fn expr_as_cast_from_usize<'a, 'tcx>( None } -// If the given expression is a ptr::offset method call, return the receiver and the arg of the -// method call. +// If the given expression is a ptr::offset or ptr::wrapping_offset method call, return the +// receiver, the arg of the method call, and the method. fn expr_as_ptr_offset_call<'a, 'tcx>( cx: &lint::LateContext<'a, 'tcx>, expr: &'tcx hir::Expr, -) -> Option<[&'tcx hir::Expr; 2]> { +) -> Option<(&'tcx hir::Expr, &'tcx hir::Expr, Method)> { if let hir::ExprKind::MethodCall(ref path_segment, _, ref args) = expr.node { - if path_segment.ident.name == "offset" && is_expr_ty_raw_ptr(cx, &args[0]) { - return Some([&args[0], &args[1]]); + if is_expr_ty_raw_ptr(cx, &args[0]) { + if path_segment.ident.name == "offset" { + return Some((&args[0], &args[1], Method::Offset)); + } + if path_segment.ident.name == "wrapping_offset" { + return Some((&args[0], &args[1], Method::WrappingOffset)); + } } } None @@ -111,6 +117,7 @@ fn is_expr_ty_raw_ptr<'a, 'tcx>( fn build_suggestion<'a, 'tcx>( cx: &lint::LateContext<'a, 'tcx>, + method: Method, receiver_expr: &hir::Expr, cast_lhs_expr: &hir::Expr, ) -> Option { @@ -118,7 +125,32 @@ fn build_suggestion<'a, 'tcx>( utils::snippet_opt(cx, receiver_expr.span), utils::snippet_opt(cx, cast_lhs_expr.span) ) { - (Some(receiver), Some(cast_lhs)) => Some(format!("{}.add({})", receiver, cast_lhs)), + (Some(receiver), Some(cast_lhs)) => { + Some(format!("{}.{}({})", receiver, method.suggestion(), cast_lhs)) + }, _ => None, } } + +enum Method { + Offset, + WrappingOffset, +} + +impl Method { + fn suggestion(&self) -> &'static str { + match *self { + Method::Offset => "add", + Method::WrappingOffset => "wrapping_add", + } + } +} + +impl fmt::Display for Method { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + Method::Offset => write!(f, "offset"), + Method::WrappingOffset => write!(f, "wrapping_offset"), + } + } +} \ No newline at end of file diff --git a/tests/ui/ptr_offset_with_cast.rs b/tests/ui/ptr_offset_with_cast.rs index 947021aaf8e..4549f960ca0 100644 --- a/tests/ui/ptr_offset_with_cast.rs +++ b/tests/ui/ptr_offset_with_cast.rs @@ -10,5 +10,9 @@ fn main() { ptr.offset(offset_usize as isize); ptr.offset(offset_isize as isize); ptr.offset(offset_u8 as isize); + + ptr.wrapping_offset(offset_usize as isize); + ptr.wrapping_offset(offset_isize as isize); + ptr.wrapping_offset(offset_u8 as isize); } } diff --git a/tests/ui/ptr_offset_with_cast.stderr b/tests/ui/ptr_offset_with_cast.stderr index 1658f5f5366..16bbf328b33 100644 --- a/tests/ui/ptr_offset_with_cast.stderr +++ b/tests/ui/ptr_offset_with_cast.stderr @@ -6,5 +6,11 @@ error: use of `offset` with a `usize` casted to an `isize` | = note: `-D ptr-offset-with-cast` implied by `-D warnings` -error: aborting due to previous error +error: use of `wrapping_offset` with a `usize` casted to an `isize` + --> $DIR/ptr_offset_with_cast.rs:14:9 + | +14 | ptr.wrapping_offset(offset_usize as isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)` + +error: aborting due to 2 previous errors From 2a486528ee13c861679c62a5451f7118591c3531 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 07:42:43 -0500 Subject: [PATCH 32/53] utilize carrier --- clippy_lints/src/ptr_offset_with_cast.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 20934573f09..08ae92d255e 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -121,15 +121,9 @@ fn build_suggestion<'a, 'tcx>( receiver_expr: &hir::Expr, cast_lhs_expr: &hir::Expr, ) -> Option { - match ( - utils::snippet_opt(cx, receiver_expr.span), - utils::snippet_opt(cx, cast_lhs_expr.span) - ) { - (Some(receiver), Some(cast_lhs)) => { - Some(format!("{}.{}({})", receiver, method.suggestion(), cast_lhs)) - }, - _ => None, - } + let receiver = utils::snippet_opt(cx, receiver_expr.span)?; + let cast_lhs = utils::snippet_opt(cx, cast_lhs_expr.span)?; + Some(format!("{}.{}({})", receiver, method.suggestion(), cast_lhs)) } enum Method { From 9a8f206662d63d0218e7f8318c8ddbfccca6bfa8 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 07:43:40 -0500 Subject: [PATCH 33/53] eof newline --- clippy_lints/src/ptr_offset_with_cast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 08ae92d255e..f8e35f84db1 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -147,4 +147,4 @@ impl fmt::Display for Method { Method::WrappingOffset => write!(f, "wrapping_offset"), } } -} \ No newline at end of file +} From d5534ca9db4f18a707ee7bc3edc1eb70647dca3b Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 07:46:03 -0500 Subject: [PATCH 34/53] bring back sugg::range --- clippy_lints/src/utils/sugg.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index a02e0144791..8b1b8a31ac2 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -175,6 +175,16 @@ impl<'a> Sugg<'a> { make_unop("&mut *", self) } + /// Convenience method to create the `..` or `...` + /// suggestion. + #[allow(dead_code)] + pub fn range(self, end: &Self, limit: ast::RangeLimits) -> Sugg<'static> { + match limit { + ast::RangeLimits::HalfOpen => make_assoc(AssocOp::DotDot, &self, end), + ast::RangeLimits::Closed => make_assoc(AssocOp::DotDotEq, &self, end), + } + } + /// Add parenthesis to any expression that might need them. Suitable to the /// `self` argument of /// a method call (eg. to build `bar.foo()` or `(1 + 2).foo()`). From 6445a5d79d642d38ea2efba3e8c08cf87ba40920 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 08:01:05 -0500 Subject: [PATCH 35/53] derive copy/clone --- clippy_lints/src/ptr_offset_with_cast.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index f8e35f84db1..7f34aca27f0 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -126,6 +126,7 @@ fn build_suggestion<'a, 'tcx>( Some(format!("{}.{}({})", receiver, method.suggestion(), cast_lhs)) } +#[derive(Copy, Clone)] enum Method { Offset, WrappingOffset, From 53928d53673303a2147eccb34918234886ac0e26 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 08:27:32 -0500 Subject: [PATCH 36/53] clippy suggestion --- clippy_lints/src/ptr_offset_with_cast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 7f34aca27f0..6f589a7d1d7 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -133,7 +133,7 @@ enum Method { } impl Method { - fn suggestion(&self) -> &'static str { + fn suggestion(self) -> &'static str { match *self { Method::Offset => "add", Method::WrappingOffset => "wrapping_add", From f42442b6e07a8eafc711d708bb70d6065b4f8c5d Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 29 Aug 2018 08:59:38 -0500 Subject: [PATCH 37/53] dont deref --- clippy_lints/src/ptr_offset_with_cast.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 6f589a7d1d7..9f475473c61 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -134,7 +134,7 @@ enum Method { impl Method { fn suggestion(self) -> &'static str { - match *self { + match self { Method::Offset => "add", Method::WrappingOffset => "wrapping_add", } @@ -143,7 +143,7 @@ impl Method { impl fmt::Display for Method { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self { + match self { Method::Offset => write!(f, "offset"), Method::WrappingOffset => write!(f, "wrapping_offset"), } From 392235d6e1eec4ab67dd4c14169f134b0ef49118 Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Sat, 28 Jul 2018 17:34:24 +0200 Subject: [PATCH 38/53] Switch to tool_lints --- clippy_lints/src/lib.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 7d429ce4923..87a906ad83d 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -17,34 +17,34 @@ use rustc; macro_rules! declare_clippy_lint { { pub $name:tt, style, $description:tt } => { - declare_lint! { pub $name, Warn, $description, report_in_external_macro: true } + declare_lint! { pub $name, Warn, $description, report_in_external_macro: true, clippy } }; { pub $name:tt, correctness, $description:tt } => { - declare_lint! { pub $name, Deny, $description, report_in_external_macro: true } + declare_lint! { pub $name, Deny, $description, report_in_external_macro: true, clippy } }; { pub $name:tt, complexity, $description:tt } => { - declare_lint! { pub $name, Warn, $description, report_in_external_macro: true } + declare_lint! { pub $name, Warn, $description, report_in_external_macro: true, clippy } }; { pub $name:tt, perf, $description:tt } => { - declare_lint! { pub $name, Warn, $description, report_in_external_macro: true } + declare_lint! { pub $name, Warn, $description, report_in_external_macro: true, clippy } }; { pub $name:tt, pedantic, $description:tt } => { - declare_lint! { pub $name, Allow, $description, report_in_external_macro: true } + declare_lint! { pub $name, Allow, $description, report_in_external_macro: true, clippy } }; { pub $name:tt, restriction, $description:tt } => { - declare_lint! { pub $name, Allow, $description, report_in_external_macro: true } + declare_lint! { pub $name, Allow, $description, report_in_external_macro: true, clippy } }; { pub $name:tt, cargo, $description:tt } => { - declare_lint! { pub $name, Allow, $description, report_in_external_macro: true } + declare_lint! { pub $name, Allow, $description, report_in_external_macro: true, clippy } }; { pub $name:tt, nursery, $description:tt } => { - declare_lint! { pub $name, Allow, $description, report_in_external_macro: true } + declare_lint! { pub $name, Allow, $description, report_in_external_macro: true, clippy } }; { pub $name:tt, internal, $description:tt } => { - declare_lint! { pub $name, Allow, $description, report_in_external_macro: true } + declare_lint! { pub $name, Allow, $description, report_in_external_macro: true, clippy } }; { pub $name:tt, internal_warn, $description:tt } => { - declare_lint! { pub $name, Warn, $description, report_in_external_macro: true } + declare_lint! { pub $name, Warn, $description, report_in_external_macro: true, clippy } }; } @@ -411,7 +411,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { reg.register_late_lint_pass(box non_copy_const::NonCopyConst); reg.register_late_lint_pass(box ptr_offset_with_cast::Pass); - reg.register_lint_group("clippy_restriction", vec![ + reg.register_lint_group("clippy::restriction", vec![ arithmetic::FLOAT_ARITHMETIC, arithmetic::INTEGER_ARITHMETIC, else_if_without_else::ELSE_IF_WITHOUT_ELSE, @@ -434,7 +434,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { write::USE_DEBUG, ]); - reg.register_lint_group("clippy_pedantic", vec![ + reg.register_lint_group("clippy::pedantic", vec![ attrs::INLINE_ALWAYS, copies::MATCH_SAME_ARMS, copy_iterator::COPY_ITERATOR, @@ -472,13 +472,13 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { use_self::USE_SELF, ]); - reg.register_lint_group("clippy_internal", vec![ + reg.register_lint_group("clippy::internal", vec![ utils::internal_lints::CLIPPY_LINTS_INTERNAL, utils::internal_lints::LINT_WITHOUT_LINT_PASS, utils::internal_lints::DEFAULT_HASH_TYPES, ]); - reg.register_lint_group("clippy", vec![ + reg.register_lint_group("clippy::all", vec![ approx_const::APPROX_CONSTANT, assign_ops::ASSIGN_OP_PATTERN, assign_ops::MISREFACTORED_ASSIGN_OP, @@ -693,7 +693,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { zero_div_zero::ZERO_DIVIDED_BY_ZERO, ]); - reg.register_lint_group("clippy_style", vec![ + reg.register_lint_group("clippy::style", vec![ assign_ops::ASSIGN_OP_PATTERN, bit_mask::VERBOSE_BIT_MASK, blacklisted_name::BLACKLISTED_NAME, @@ -777,7 +777,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { write::WRITELN_EMPTY_STRING, ]); - reg.register_lint_group("clippy_complexity", vec![ + reg.register_lint_group("clippy::complexity", vec![ assign_ops::MISREFACTORED_ASSIGN_OP, booleans::NONMINIMAL_BOOL, cyclomatic_complexity::CYCLOMATIC_COMPLEXITY, @@ -845,7 +845,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { zero_div_zero::ZERO_DIVIDED_BY_ZERO, ]); - reg.register_lint_group("clippy_correctness", vec![ + reg.register_lint_group("clippy::correctness", vec![ approx_const::APPROX_CONSTANT, attrs::DEPRECATED_SEMVER, attrs::USELESS_ATTRIBUTE, @@ -899,7 +899,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { unused_io_amount::UNUSED_IO_AMOUNT, ]); - reg.register_lint_group("clippy_perf", vec![ + reg.register_lint_group("clippy::perf", vec![ bytecount::NAIVE_BYTECOUNT, entry::MAP_ENTRY, escape::BOXED_LOCAL, @@ -917,11 +917,11 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { vec::USELESS_VEC, ]); - reg.register_lint_group("clippy_cargo", vec![ + reg.register_lint_group("clippy::cargo", vec![ multiple_crate_versions::MULTIPLE_CRATE_VERSIONS, ]); - reg.register_lint_group("clippy_nursery", vec![ + reg.register_lint_group("clippy::nursery", vec![ attrs::EMPTY_LINE_AFTER_OUTER_ATTR, fallible_impl_from::FALLIBLE_IMPL_FROM, mutex_atomic::MUTEX_INTEGER, From 8c07772dbb817114f338692188dd7733bcd741cb Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Sun, 29 Jul 2018 11:04:40 +0200 Subject: [PATCH 39/53] Switch to declare_tool_lint macro --- clippy_lints/src/approx_const.rs | 2 +- clippy_lints/src/arithmetic.rs | 2 +- clippy_lints/src/assign_ops.rs | 2 +- clippy_lints/src/attrs.rs | 2 +- clippy_lints/src/bit_mask.rs | 2 +- clippy_lints/src/blacklisted_name.rs | 2 +- clippy_lints/src/block_in_if_condition.rs | 2 +- clippy_lints/src/booleans.rs | 2 +- clippy_lints/src/bytecount.rs | 2 +- clippy_lints/src/collapsible_if.rs | 2 +- clippy_lints/src/const_static_lifetime.rs | 2 +- clippy_lints/src/copies.rs | 2 +- clippy_lints/src/cyclomatic_complexity.rs | 2 +- clippy_lints/src/default_trait_access.rs | 2 +- clippy_lints/src/derive.rs | 2 +- clippy_lints/src/doc.rs | 2 +- clippy_lints/src/double_comparison.rs | 2 +- clippy_lints/src/double_parens.rs | 2 +- clippy_lints/src/drop_forget_ref.rs | 2 +- clippy_lints/src/duration_subsec.rs | 2 +- clippy_lints/src/else_if_without_else.rs | 2 +- clippy_lints/src/empty_enum.rs | 2 +- clippy_lints/src/entry.rs | 2 +- clippy_lints/src/enum_clike.rs | 2 +- clippy_lints/src/enum_glob_use.rs | 2 +- clippy_lints/src/enum_variants.rs | 2 +- clippy_lints/src/eq_op.rs | 2 +- clippy_lints/src/erasing_op.rs | 2 +- clippy_lints/src/escape.rs | 2 +- clippy_lints/src/eta_reduction.rs | 2 +- clippy_lints/src/eval_order_dependence.rs | 2 +- clippy_lints/src/excessive_precision.rs | 2 +- clippy_lints/src/explicit_write.rs | 2 +- clippy_lints/src/fallible_impl_from.rs | 2 +- clippy_lints/src/format.rs | 2 +- clippy_lints/src/formatting.rs | 2 +- clippy_lints/src/functions.rs | 2 +- clippy_lints/src/identity_conversion.rs | 2 +- clippy_lints/src/identity_op.rs | 2 +- .../src/if_let_redundant_pattern_matching.rs | 2 +- clippy_lints/src/if_not_else.rs | 2 +- clippy_lints/src/indexing_slicing.rs | 2 +- .../src/infallible_destructuring_match.rs | 2 +- clippy_lints/src/infinite_iter.rs | 2 +- clippy_lints/src/inherent_impl.rs | 2 +- clippy_lints/src/inline_fn_without_body.rs | 2 +- clippy_lints/src/int_plus_one.rs | 2 +- clippy_lints/src/invalid_ref.rs | 2 +- clippy_lints/src/items_after_statements.rs | 2 +- clippy_lints/src/large_enum_variant.rs | 2 +- clippy_lints/src/len_zero.rs | 2 +- clippy_lints/src/let_if_seq.rs | 2 +- clippy_lints/src/lib.rs | 20 +++++++++---------- clippy_lints/src/lifetimes.rs | 2 +- clippy_lints/src/literal_representation.rs | 2 +- clippy_lints/src/loops.rs | 2 +- clippy_lints/src/map_clone.rs | 2 +- clippy_lints/src/map_unit_fn.rs | 2 +- clippy_lints/src/matches.rs | 2 +- clippy_lints/src/mem_forget.rs | 2 +- clippy_lints/src/methods.rs | 2 +- clippy_lints/src/minmax.rs | 2 +- clippy_lints/src/misc.rs | 2 +- clippy_lints/src/misc_early.rs | 2 +- clippy_lints/src/missing_doc.rs | 2 +- clippy_lints/src/missing_inline.rs | 2 +- clippy_lints/src/multiple_crate_versions.rs | 2 +- clippy_lints/src/mut_mut.rs | 2 +- clippy_lints/src/mut_reference.rs | 2 +- clippy_lints/src/mutex_atomic.rs | 2 +- clippy_lints/src/needless_bool.rs | 2 +- clippy_lints/src/needless_borrow.rs | 2 +- clippy_lints/src/needless_borrowed_ref.rs | 2 +- clippy_lints/src/needless_continue.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/needless_update.rs | 2 +- clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 2 +- clippy_lints/src/neg_multiply.rs | 2 +- clippy_lints/src/new_without_default.rs | 2 +- clippy_lints/src/no_effect.rs | 2 +- clippy_lints/src/non_copy_const.rs | 2 +- clippy_lints/src/non_expressive_names.rs | 2 +- clippy_lints/src/ok_if_let.rs | 2 +- clippy_lints/src/open_options.rs | 2 +- .../src/overflow_check_conditional.rs | 2 +- clippy_lints/src/panic_unimplemented.rs | 2 +- clippy_lints/src/partialeq_ne_impl.rs | 2 +- clippy_lints/src/precedence.rs | 2 +- clippy_lints/src/ptr.rs | 2 +- clippy_lints/src/question_mark.rs | 2 +- clippy_lints/src/ranges.rs | 2 +- clippy_lints/src/redundant_field_names.rs | 2 +- clippy_lints/src/reference.rs | 2 +- clippy_lints/src/regex.rs | 2 +- clippy_lints/src/replace_consts.rs | 2 +- clippy_lints/src/returns.rs | 2 +- clippy_lints/src/serde_api.rs | 2 +- clippy_lints/src/shadow.rs | 2 +- clippy_lints/src/strings.rs | 2 +- clippy_lints/src/suspicious_trait_impl.rs | 2 +- clippy_lints/src/swap.rs | 2 +- clippy_lints/src/temporary_assignment.rs | 2 +- clippy_lints/src/transmute.rs | 2 +- .../src/trivially_copy_pass_by_ref.rs | 2 +- clippy_lints/src/types.rs | 2 +- clippy_lints/src/unicode.rs | 2 +- clippy_lints/src/unsafe_removed_from_name.rs | 2 +- clippy_lints/src/unused_io_amount.rs | 2 +- clippy_lints/src/unused_label.rs | 2 +- clippy_lints/src/unwrap.rs | 2 +- clippy_lints/src/use_self.rs | 2 +- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/inspector.rs | 2 +- clippy_lints/src/utils/internal_lints.rs | 6 +++--- clippy_lints/src/vec.rs | 2 +- clippy_lints/src/write.rs | 2 +- clippy_lints/src/zero_div_zero.rs | 2 +- 117 files changed, 128 insertions(+), 128 deletions(-) diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index fe00d325f77..99b9e79463a 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -1,7 +1,7 @@ use crate::utils::span_lint; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use std::f64::consts as f64; use syntax::ast::{FloatTy, Lit, LitKind}; use syntax::symbol; diff --git a/clippy_lints/src/arithmetic.rs b/clippy_lints/src/arithmetic.rs index 209963e0688..fa48b2b5506 100644 --- a/clippy_lints/src/arithmetic.rs +++ b/clippy_lints/src/arithmetic.rs @@ -1,7 +1,7 @@ use crate::utils::span_lint; use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::source_map::Span; /// **What it does:** Checks for plain integer arithmetic. diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 28fd96e3aac..5a27f6a2c36 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -3,7 +3,7 @@ use crate::utils::{higher, sugg}; use rustc::hir; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::ast; diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 66144706816..034c2cc241a 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -7,7 +7,7 @@ use crate::utils::{ }; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, TyCtxt}; use semver::Version; diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 86788fded05..ecac7f8250b 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::ast::LitKind; use syntax::source_map::Span; diff --git a/clippy_lints/src/blacklisted_name.rs b/clippy_lints/src/blacklisted_name.rs index e5af0789064..97749e6f997 100644 --- a/clippy_lints/src/blacklisted_name.rs +++ b/clippy_lints/src/blacklisted_name.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use crate::utils::span_lint; diff --git a/clippy_lints/src/block_in_if_condition.rs b/clippy_lints/src/block_in_if_condition.rs index f57a3571b57..752d640fa9e 100644 --- a/clippy_lints/src/block_in_if_condition.rs +++ b/clippy_lints/src/block_in_if_condition.rs @@ -1,6 +1,6 @@ use matches::matches; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use crate::utils::*; diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index eda6a045cba..f867dc56c3c 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use rustc::hir::intravisit::*; use syntax::ast::{LitKind, NodeId, DUMMY_NODE_ID}; diff --git a/clippy_lints/src/bytecount.rs b/clippy_lints/src/bytecount.rs index 5c9b571c78c..ddc017c27df 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty; use syntax::ast::{Name, UintTy}; diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 09fcf47c920..55cc94f399f 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -13,7 +13,7 @@ //! This lint is **warn** by default use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::ast; diff --git a/clippy_lints/src/const_static_lifetime.rs b/clippy_lints/src/const_static_lifetime.rs index 1af0741d67f..83dd4c0509e 100644 --- a/clippy_lints/src/const_static_lifetime.rs +++ b/clippy_lints/src/const_static_lifetime.rs @@ -1,6 +1,6 @@ use syntax::ast::*; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use crate::utils::{in_macro, snippet, span_lint_and_then}; /// **What it does:** Checks for constants with an explicit `'static` lifetime. diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 42788e77d6e..8f1823be15a 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty::Ty; use rustc::hir::*; use std::collections::HashMap; diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index ee53fca9f70..6195db7b482 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -2,7 +2,7 @@ use rustc::cfg::CFG; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use rustc::ty; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/default_trait_access.rs b/clippy_lints/src/default_trait_access.rs index 09c60760076..cb79883372a 100644 --- a/clippy_lints/src/default_trait_access.rs +++ b/clippy_lints/src/default_trait_access.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::TyKind; diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 9df2e257b1e..2a26cca21ac 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; use rustc::hir::*; diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 957ede66698..2db950b3365 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -1,7 +1,7 @@ use itertools::Itertools; use pulldown_cmark; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast; use syntax::source_map::{BytePos, Span}; use syntax_pos::Pos; diff --git a/clippy_lints/src/double_comparison.rs b/clippy_lints/src/double_comparison.rs index 70dc532e55b..1f38be4d7b7 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -2,7 +2,7 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::source_map::Span; use crate::utils::{snippet, span_lint_and_sugg, SpanlessEq}; diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index abd5666385d..42d6720d96c 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -1,6 +1,6 @@ use syntax::ast::*; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; /// **What it does:** Checks for unnecessary double parentheses. /// diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index 5aca7d734e2..be804780ff5 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty; use rustc::hir::*; diff --git a/clippy_lints/src/duration_subsec.rs b/clippy_lints/src/duration_subsec.rs index 77d3014d9fd..5853983dcf0 100644 --- a/clippy_lints/src/duration_subsec.rs +++ b/clippy_lints/src/duration_subsec.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::source_map::Spanned; diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs index 1259b49d93a..1c026713a5d 100644 --- a/clippy_lints/src/else_if_without_else.rs +++ b/clippy_lints/src/else_if_without_else.rs @@ -1,7 +1,7 @@ //! lint on if expressions with an else if, but without a final else branch use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use crate::utils::span_lint_and_sugg; diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs index 86f9fbdba9b..195a78a89e5 100644 --- a/clippy_lints/src/empty_enum.rs +++ b/clippy_lints/src/empty_enum.rs @@ -1,7 +1,7 @@ //! lint when there is an enum with no variants use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use crate::utils::span_lint_and_then; diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 46ef16ddc73..8a2fcbaea46 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -1,7 +1,7 @@ use rustc::hir::*; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::source_map::Span; use crate::utils::SpanlessEq; diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index 2402cfde5b3..3a7f884b784 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -2,7 +2,7 @@ //! don't fit into an `i32` use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use rustc::ty; use rustc::ty::subst::Substs; diff --git a/clippy_lints/src/enum_glob_use.rs b/clippy_lints/src/enum_glob_use.rs index 90cc1716cc1..042a4765e2b 100644 --- a/clippy_lints/src/enum_glob_use.rs +++ b/clippy_lints/src/enum_glob_use.rs @@ -3,7 +3,7 @@ use rustc::hir::*; use rustc::hir::def::Def; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::NodeId; use syntax::source_map::Span; use crate::utils::span_lint; diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index 51277516571..85b133cbd03 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -1,7 +1,7 @@ //! lint on enum variants that are prefixed or suffixed by the same characters use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, Lint}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use syntax::source_map::Span; use syntax::symbol::LocalInternedString; diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index a08d9f39382..de1b5b77e6e 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use crate::utils::{in_macro, implements_trait, is_copy, multispan_sugg, snippet, span_lint, span_lint_and_then, SpanlessEq}; /// **What it does:** Checks for equal operands to comparison, logical and diff --git a/clippy_lints/src/erasing_op.rs b/clippy_lints/src/erasing_op.rs index e6d70b22fde..5b61a9fd883 100644 --- a/clippy_lints/src/erasing_op.rs +++ b/clippy_lints/src/erasing_op.rs @@ -1,7 +1,7 @@ use crate::consts::{constant_simple, Constant}; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::source_map::Span; use crate::utils::{in_macro, span_lint}; diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 3c61509d1f7..282149f81f9 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -1,7 +1,7 @@ use rustc::hir::*; use rustc::hir::intravisit as visit; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::middle::expr_use_visitor::*; use rustc::middle::mem_categorization::{cmt_, Categorization}; use rustc::ty::{self, Ty}; diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index f60785662dd..c4ffc70dbfd 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty; use rustc::hir::*; use crate::utils::{is_adjusted, iter_input_pats, snippet_opt, span_lint_and_then}; diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index f1c31d095e1..72abbddf141 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -2,7 +2,7 @@ use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc::hir::*; use rustc::ty; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::ast; use crate::utils::{get_parent_expr, span_lint, span_note_and_lint}; diff --git a/clippy_lints/src/excessive_precision.rs b/clippy_lints/src/excessive_precision.rs index df540cad931..e5809371e83 100644 --- a/clippy_lints/src/excessive_precision.rs +++ b/clippy_lints/src/excessive_precision.rs @@ -1,6 +1,6 @@ use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::TyKind; use std::f32; diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index f0cee563a2e..77c6c1a4ad7 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use crate::utils::{is_expn_of, match_def_path, resolve_node, span_lint}; use crate::utils::opt_def_id; diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index f541abee8a7..88eb880311e 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir; use rustc::ty; diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index f967b9ce58e..c10d554660a 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty; use syntax::ast::LitKind; diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 2f46891e6a1..8b20aeed108 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -1,5 +1,5 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast; use crate::utils::{differing_macro_contexts, in_macro, snippet_opt, span_note_and_lint}; use syntax::ptr::P; diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 2f076dc1f6e..c170b0a1e15 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -2,7 +2,7 @@ use matches::matches; use rustc::hir::intravisit; use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty; use rustc::hir::def::Def; use std::collections::HashSet; diff --git a/clippy_lints/src/identity_conversion.rs b/clippy_lints/src/identity_conversion.rs index 3fa30dee988..6adf2cd6814 100644 --- a/clippy_lints/src/identity_conversion.rs +++ b/clippy_lints/src/identity_conversion.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use syntax::ast::NodeId; use crate::utils::{in_macro, match_def_path, match_trait_method, same_tys, snippet, span_lint_and_then}; diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index b0c290ffc0e..bb3741088cf 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -1,7 +1,7 @@ use crate::consts::{constant_simple, Constant}; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::source_map::Span; use crate::utils::{in_macro, snippet, span_lint, unsext, clip}; use rustc::ty; diff --git a/clippy_lints/src/if_let_redundant_pattern_matching.rs b/clippy_lints/src/if_let_redundant_pattern_matching.rs index f1b8aadef67..253d295567c 100644 --- a/clippy_lints/src/if_let_redundant_pattern_matching.rs +++ b/clippy_lints/src/if_let_redundant_pattern_matching.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use crate::utils::{match_qpath, paths, snippet, span_lint_and_then}; diff --git a/clippy_lints/src/if_not_else.rs b/clippy_lints/src/if_not_else.rs index 153bfbb9779..3bfde1fd20d 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -2,7 +2,7 @@ //! on the condition use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use crate::utils::span_help_and_lint; diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index 01a659473c1..bca4844aae7 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -6,7 +6,7 @@ use crate::utils::higher; use crate::utils::higher::Range; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty; use syntax::ast::RangeLimits; diff --git a/clippy_lints/src/infallible_destructuring_match.rs b/clippy_lints/src/infallible_destructuring_match.rs index a085f32ed84..208f2ec5379 100644 --- a/clippy_lints/src/infallible_destructuring_match.rs +++ b/clippy_lints/src/infallible_destructuring_match.rs @@ -1,7 +1,7 @@ use super::utils::{get_arg_name, match_var, remove_blocks, snippet, span_lint_and_sugg}; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; /// **What it does:** Checks for matches being used to destructure a single-variant enum diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index d42a2380ec4..bb33c48fc3f 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use crate::utils::{get_trait_def_id, higher, implements_trait, match_qpath, paths, span_lint}; /// **What it does:** Checks for iteration that is guaranteed to be infinite. diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index 46dbb5bc39f..4ca812e56bd 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -2,7 +2,7 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use std::collections::HashMap; use std::default::Default; use syntax_pos::Span; diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index b879d734929..4dcc4ed473d 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -1,7 +1,7 @@ //! checks for `#[inline]` on trait methods without bodies use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use syntax::ast::{Attribute, Name}; use crate::utils::span_lint_and_then; diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index 086567ac531..b640eff2c5d 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -1,7 +1,7 @@ //! lint on blocks unnecessarily using >= with a + 1 or - 1 use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use crate::utils::{snippet_opt, span_lint_and_then}; diff --git a/clippy_lints/src/invalid_ref.rs b/clippy_lints/src/invalid_ref.rs index 58f1575abb6..34a8939e104 100644 --- a/clippy_lints/src/invalid_ref.rs +++ b/clippy_lints/src/invalid_ref.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty; use rustc::hir::*; diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index 2ea6c0e0447..9fe70882c86 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -2,7 +2,7 @@ use matches::matches; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use crate::utils::{in_macro, span_lint}; diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index 3e49f866170..63201bb2e45 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -1,7 +1,7 @@ //! lint when there is a large size difference between variants on an enum use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use crate::utils::{snippet_opt, span_lint_and_then}; use rustc::ty::layout::LayoutOf; diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index e14f3bc24b7..4c9c219828d 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -1,7 +1,7 @@ use rustc::hir::def_id::DefId; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty; use std::collections::HashSet; use syntax::ast::{Lit, LitKind, Name}; diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 494efc22538..8b4e2b0dec8 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir; use rustc::hir::BindingAnnotation; diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 87a906ad83d..32c3dca6357 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -17,34 +17,34 @@ use rustc; macro_rules! declare_clippy_lint { { pub $name:tt, style, $description:tt } => { - declare_lint! { pub $name, Warn, $description, report_in_external_macro: true, clippy } + declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true } }; { pub $name:tt, correctness, $description:tt } => { - declare_lint! { pub $name, Deny, $description, report_in_external_macro: true, clippy } + declare_tool_lint! { pub clippy::$name, Deny, $description, report_in_external_macro: true } }; { pub $name:tt, complexity, $description:tt } => { - declare_lint! { pub $name, Warn, $description, report_in_external_macro: true, clippy } + declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true } }; { pub $name:tt, perf, $description:tt } => { - declare_lint! { pub $name, Warn, $description, report_in_external_macro: true, clippy } + declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true } }; { pub $name:tt, pedantic, $description:tt } => { - declare_lint! { pub $name, Allow, $description, report_in_external_macro: true, clippy } + declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true } }; { pub $name:tt, restriction, $description:tt } => { - declare_lint! { pub $name, Allow, $description, report_in_external_macro: true, clippy } + declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true } }; { pub $name:tt, cargo, $description:tt } => { - declare_lint! { pub $name, Allow, $description, report_in_external_macro: true, clippy } + declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true } }; { pub $name:tt, nursery, $description:tt } => { - declare_lint! { pub $name, Allow, $description, report_in_external_macro: true, clippy } + declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true } }; { pub $name:tt, internal, $description:tt } => { - declare_lint! { pub $name, Allow, $description, report_in_external_macro: true, clippy } + declare_tool_lint! { pub clippy::$name, Allow, $description, report_in_external_macro: true } }; { pub $name:tt, internal_warn, $description:tt } => { - declare_lint! { pub $name, Warn, $description, report_in_external_macro: true, clippy } + declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true } }; } diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 7da62b9d458..beec9bac940 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -1,7 +1,7 @@ use crate::reexport::*; use matches::matches; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::def::Def; use rustc::hir::*; use rustc::hir::intravisit::*; diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index 9437b243cbb..dcffba80b3b 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -2,7 +2,7 @@ //! floating-point literal expressions. use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::ast::*; use syntax_pos; diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 988256ab29e..51e6327e728 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -5,7 +5,7 @@ use rustc::hir::def::Def; use rustc::hir::def_id; use rustc::hir::intravisit::{walk_block, walk_decl, walk_expr, walk_pat, walk_stmt, NestedVisitorMap, Visitor}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::middle::region; // use rustc::middle::region::CodeExtent; diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index bd304db2dd5..1a501b39eb5 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; use rustc::ty; diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 2376b1a2b48..90f149a1c01 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -1,6 +1,6 @@ use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty; use rustc_errors::Applicability; diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 6dc16e623a4..3ecf5d3b5b8 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; use std::cmp::Ordering; diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index 76df98727f9..8a56dccad2d 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::{Expr, ExprKind}; use crate::utils::{match_def_path, opt_def_id, paths, span_lint}; diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 3bc1282fa15..4f6cb64dd4f 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1,7 +1,7 @@ use matches::matches; use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, Lint, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; use rustc::hir::def::Def; diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index b187c28def6..bbbc022f08d 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -2,7 +2,7 @@ use crate::consts::{constant_simple, Constant}; use crate::utils::{match_def_path, opt_def_id, paths, span_lint}; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use std::cmp::Ordering; /// **What it does:** Checks for expressions where `std::cmp::min` and `max` are diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 7fab12bd9d9..302af13630b 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -3,7 +3,7 @@ use matches::matches; use rustc::hir::*; use rustc::hir::intravisit::FnKind; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty; use syntax::source_map::{ExpnFormat, Span}; diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index 4edb6a9133a..c00b3d93c47 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -1,5 +1,5 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, LintContext, in_external_macro}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use std::collections::HashMap; use std::char; diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 339ab757702..f56a8fcd8b5 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -20,7 +20,7 @@ use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty; use syntax::ast; use syntax::attr; diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index c0f12bd3f7e..bf88caa6ab9 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -11,7 +11,7 @@ use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast; use syntax::source_map::Span; use crate::utils::span_lint; diff --git a/clippy_lints/src/multiple_crate_versions.rs b/clippy_lints/src/multiple_crate_versions.rs index 78458843ffc..a2ed6a1dea1 100644 --- a/clippy_lints/src/multiple_crate_versions.rs +++ b/clippy_lints/src/multiple_crate_versions.rs @@ -1,7 +1,7 @@ //! lint on multiple versions of a crate being used use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use crate::utils::span_lint; diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index 5c8a2648a18..ea3d68dfc83 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -1,7 +1,7 @@ use rustc::hir; use rustc::hir::intravisit; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty; use crate::utils::{higher, span_lint}; diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 5b562f3dd34..97287aa833f 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty::{self, Ty}; use rustc::ty::subst::Subst; use rustc::hir::*; diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index 8b56526f495..cb400ee4ee3 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -3,7 +3,7 @@ //! This lint is **warn** by default use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty::{self, Ty}; use rustc::hir::Expr; use syntax::ast; diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 90b38440a83..5b9a479c1fc 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -3,7 +3,7 @@ //! This lint is **warn** by default use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use syntax::ast::LitKind; use syntax::source_map::Spanned; diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index b8ac425fd59..a194cb2c61b 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -3,7 +3,7 @@ //! This lint is **warn** by default use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir::{BindingAnnotation, Expr, ExprKind, MutImmutable, Pat, PatKind}; use rustc::ty; diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index d5a16f2122f..4905dbc8e6b 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -3,7 +3,7 @@ //! This lint is **warn** by default use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir::{BindingAnnotation, MutImmutable, Pat, PatKind}; use crate::utils::{in_macro, snippet, span_lint_and_then}; diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index e5f01847ed1..e14cd0fea89 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -28,7 +28,7 @@ //! //! This lint is **warn** by default. use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast; use syntax::source_map::{original_sp, DUMMY_SP}; use std::borrow::Cow; diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 06baf895c93..340fa4d0ee0 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -2,7 +2,7 @@ use matches::matches; use rustc::hir::*; use rustc::hir::intravisit::FnKind; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, RegionKind, TypeFoldable}; use rustc::traits; diff --git a/clippy_lints/src/needless_update.rs b/clippy_lints/src/needless_update.rs index 90a1ee14a6d..dccb7f2e037 100644 --- a/clippy_lints/src/needless_update.rs +++ b/clippy_lints/src/needless_update.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty; use rustc::hir::{Expr, ExprKind}; use crate::utils::span_lint; diff --git a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs index bec875d16d6..db61ea375c3 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use crate::utils::{self, paths, span_lint}; diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index 5246e62aecb..8df33b1e99a 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::source_map::{Span, Spanned}; diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 4dd2ea98399..493e8d0f4ce 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -1,7 +1,7 @@ use rustc::hir::def_id::DefId; use rustc::hir; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; use syntax::source_map::Span; diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index cacb5d6a9ff..09a27330750 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::def::Def; use rustc::hir::{BinOpKind, BlockCheckMode, Expr, ExprKind, Stmt, StmtKind, UnsafeSource}; use crate::utils::{has_drop, in_macro, snippet_opt, span_lint, span_lint_and_sugg}; diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index c2692f88187..deb088d3ea4 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -3,7 +3,7 @@ //! This lint is **deny** by default. use rustc::lint::{LateContext, LateLintPass, Lint, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use rustc::hir::def::Def; use rustc::ty::{self, TypeFlags}; diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 14aba635c1a..0b0fe28a90b 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -1,5 +1,5 @@ use rustc::lint::{LintArray, LintPass, EarlyContext, EarlyLintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::source_map::Span; use syntax::symbol::LocalInternedString; use syntax::ast::*; diff --git a/clippy_lints/src/ok_if_let.rs b/clippy_lints/src/ok_if_let.rs index 52eb86a0bc0..651ed44110f 100644 --- a/clippy_lints/src/ok_if_let.rs +++ b/clippy_lints/src/ok_if_let.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; use crate::utils::{match_type, method_chain_args, paths, snippet, span_help_and_lint}; diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index bfb88449fba..b5459059e90 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -1,6 +1,6 @@ use rustc::hir::{Expr, ExprKind}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::LitKind; use syntax::source_map::{Span, Spanned}; use crate::utils::{match_type, paths, span_lint, walk_ptrs_ty}; diff --git a/clippy_lints/src/overflow_check_conditional.rs b/clippy_lints/src/overflow_check_conditional.rs index cb230bc9fc5..d33ef5e05d6 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; use crate::utils::{span_lint, SpanlessEq}; diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index e21c0718612..7a7fa3c456d 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::ast::LitKind; use syntax::ptr::P; diff --git a/clippy_lints/src/partialeq_ne_impl.rs b/clippy_lints/src/partialeq_ne_impl.rs index fe93a8bbe99..8b2e5f9c356 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; use crate::utils::{is_automatically_derived, span_lint}; diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index 42bbe687832..0978a6b7d94 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -1,5 +1,5 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use syntax::source_map::Spanned; use crate::utils::{in_macro, snippet, span_lint_and_sugg}; diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index cedb6e0b26b..94bbfb0e5b9 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -4,7 +4,7 @@ use std::borrow::Cow; use rustc::hir::*; use rustc::hir::QPath; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty; use syntax::ast::NodeId; diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index cb98ecd3dec..3134f14b194 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; use rustc::hir::def::Def; diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index bef4532bbe5..95fd14162ac 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; use syntax::ast::RangeLimits; diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index 3021ef2dc47..579d2ad1423 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -1,5 +1,5 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use crate::utils::{span_lint_and_sugg}; diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs index f5bc03c6d6e..98de8989597 100644 --- a/clippy_lints/src/reference.rs +++ b/clippy_lints/src/reference.rs @@ -1,6 +1,6 @@ use syntax::ast::{Expr, ExprKind, UnOp}; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use crate::utils::{snippet, span_lint_and_sugg}; diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 5fe37e16484..6ac40c5a1d2 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -1,7 +1,7 @@ use regex_syntax; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use std::collections::HashSet; use syntax::ast::{LitKind, NodeId, StrStyle}; diff --git a/clippy_lints/src/replace_consts.rs b/clippy_lints/src/replace_consts.rs index 093ad0358bc..aaea8b6dd0e 100644 --- a/clippy_lints/src/replace_consts.rs +++ b/clippy_lints/src/replace_consts.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir; use rustc::hir::def::Def; diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 694433a8b92..ddc0a9719a8 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -1,5 +1,5 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::ast; use syntax::source_map::Span; diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs index 41d8b1f7d24..0f09988c250 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use crate::utils::{get_trait_def_id, paths, span_lint}; diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 4964b7e79ef..d552c01679a 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -1,6 +1,6 @@ use crate::reexport::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use rustc::hir::intravisit::FnKind; use rustc::ty; diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 2b915f46175..b306c18f531 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::source_map::Spanned; use crate::utils::SpanlessEq; use crate::utils::{get_parent_expr, is_allowed, match_type, paths, span_lint, span_lint_and_sugg, walk_ptrs_ty}; diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index 7e0684e7f16..9f9b279a6c5 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 7fd72cbea32..9ae6ec48383 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -1,7 +1,7 @@ use matches::matches; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty; use crate::utils::{differing_macro_contexts, match_type, paths, snippet, span_lint_and_then, walk_ptrs_ty, SpanlessEq}; diff --git a/clippy_lints/src/temporary_assignment.rs b/clippy_lints/src/temporary_assignment.rs index 56e705ad0a7..cb922302964 100644 --- a/clippy_lints/src/temporary_assignment.rs +++ b/clippy_lints/src/temporary_assignment.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::{Expr, ExprKind}; use crate::utils::is_adjusted; use crate::utils::span_lint; diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index 9fe22b7dafc..6e82bee277f 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; use rustc::hir::*; diff --git a/clippy_lints/src/trivially_copy_pass_by_ref.rs b/clippy_lints/src/trivially_copy_pass_by_ref.rs index 8f417861ca9..70a93e7f78a 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -5,7 +5,7 @@ use rustc::hir; use rustc::hir::*; use rustc::hir::intravisit::FnKind; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::TyKind; use rustc::session::config::Config as SessionConfig; diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index a38d232d3e1..81842421fa3 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -3,7 +3,7 @@ use rustc::hir; use rustc::hir::*; use rustc::hir::intravisit::{walk_body, walk_expr, walk_ty, FnKind, NestedVisitorMap, Visitor}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty, TyCtxt, TypeckTables}; use rustc::ty::layout::LayoutOf; diff --git a/clippy_lints/src/unicode.rs b/clippy_lints/src/unicode.rs index 4e5c9a94424..01c4cd83ce0 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use syntax::ast::{LitKind, NodeId}; use syntax::source_map::Span; diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index 753ee40be7f..7ef235e9297 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -1,5 +1,5 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use syntax::source_map::Span; use syntax::symbol::LocalInternedString; diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index e388ca93888..c5507fcaca4 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir; use crate::utils::{is_try, match_qpath, match_trait_method, paths, span_lint}; diff --git a/clippy_lints/src/unused_label.rs b/clippy_lints/src/unused_label.rs index 1fd143d6d03..71d9520c05b 100644 --- a/clippy_lints/src/unused_label.rs +++ b/clippy_lints/src/unused_label.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir; use rustc::hir::intravisit::{walk_expr, walk_fn, FnKind, NestedVisitorMap, Visitor}; use std::collections::HashMap; diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 0435db93ee6..a1d24f64300 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use crate::utils::{in_macro, match_type, paths, span_lint_and_then, usage::is_potentially_mutated}; diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index eb2b4e801eb..550f88c895e 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -4,7 +4,7 @@ use rustc::hir::intravisit::{walk_path, walk_ty, NestedVisitorMap, Visitor}; use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::ty; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax_pos::symbol::keywords::SelfType; /// **What it does:** Checks for unnecessary repetition of structure name when a diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index f45ec75aedc..fe8123d288d 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -4,7 +4,7 @@ #![allow(print_stdout, use_debug)] use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir; use rustc::hir::{Expr, ExprKind, QPath, TyKind, Pat, PatKind, BindingAnnotation, StmtKind, DeclKind, Stmt}; use rustc::hir::intravisit::{NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 73c86d8bf67..12b4f55e432 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -3,7 +3,7 @@ //! checks for attributes use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir; use rustc::hir::print; use syntax::ast::Attribute; diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index 39a3d9b3b74..7b2d2f15996 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -1,5 +1,5 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, EarlyContext, EarlyLintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use rustc::hir; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; @@ -149,13 +149,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass { fn check_crate_post(&mut self, cx: &LateContext<'a, 'tcx>, _: &'tcx Crate) { for (lint_name, &lint_span) in &self.declared_lints { - // When using the `declare_lint!` macro, the original `lint_span`'s + // When using the `declare_tool_lint!` macro, the original `lint_span`'s // file points to "". // `compiletest-rs` thinks that's an error in a different file and // just ignores it. This causes the test in compile-fail/lint_pass // not able to capture the error. // Therefore, we need to climb the macro expansion tree and find the - // actual span that invoked `declare_lint!`: + // actual span that invoked `declare_tool_lint!`: let lint_span = lint_span .ctxt() .outer() diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index 8e49a3d4326..4cbefc29b9c 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -1,6 +1,6 @@ use rustc::hir::*; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; use syntax::source_map::Span; diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index bc9fa09c932..5d32157238b 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -1,5 +1,5 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use syntax::tokenstream::{ThinTokenStream, TokenStream}; use syntax::parse::{token, parser}; diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index 77bc4802742..73c9e64d2cb 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -1,6 +1,6 @@ use crate::consts::{constant_simple, Constant}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; use crate::utils::span_help_and_lint; From 83baf8f5fe32fab5dc5e0190cf16ca1d281d4fd5 Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Sat, 28 Jul 2018 17:35:24 +0200 Subject: [PATCH 40/53] Adapt documentation to the tool_lints --- CONTRIBUTING.md | 2 +- README.md | 32 ++++++++++++-------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7de4f850c1c..3d1385244a6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -170,7 +170,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse); // ... - reg.register_lint_group("clippy_restriction", vec![ + reg.register_lint_group("clippy::restriction", vec![ // ... else_if_without_else::ELSE_IF_WITHOUT_ELSE, // ... diff --git a/README.md b/README.md index 41eacdba1a4..98f712c28d8 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,14 @@ A collection of lints to catch common mistakes and improve your [Rust](https://g We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you: -* `clippy` (everything that has no false positives) -* `clippy_pedantic` (everything) -* `clippy_nursery` (new lints that aren't quite ready yet) -* `clippy_style` (code that should be written in a more idiomatic way) -* `clippy_complexity` (code that does something simple but in a complex way) -* `clippy_perf` (code that can be written in a faster way) -* `clippy_cargo` (checks against the cargo manifest) -* **`clippy_correctness`** (code that is just outright wrong or very very useless) +* `clippy::all` (everything that has no false positives) +* `clippy::pedantic` (everything) +* `clippy::nursery` (new lints that aren't quite ready yet) +* `clippy::style` (code that should be written in a more idiomatic way) +* `clippy::complexity` (code that does something simple but in a complex way) +* `clippy::perf` (code that can be written in a faster way) +* `clippy::cargo` (checks against the cargo manifest) +* **`clippy::correctness`** (code that is just outright wrong or very very useless) More to come, please [file an issue](https://github.com/rust-lang-nursery/rust-clippy/issues) if you have ideas! @@ -106,26 +106,18 @@ define the `CLIPPY_DISABLE_DOCS_LINKS` environment variable. You can add options to `allow`/`warn`/`deny`: -* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy)]`) +* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`) -* all lints using both the `clippy` and `clippy_pedantic` lint groups (`#![deny(clippy)]`, - `#![deny(clippy_pedantic)]`). Note that `clippy_pedantic` contains some very aggressive +* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`, + `#![deny(clippy::pedantic)]`). Note that `clippy::pedantic` contains some very aggressive lints prone to false positives. -* only some lints (`#![deny(single_match, box_vec)]`, etc) +* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc) * `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc Note: `deny` produces errors instead of warnings. -For convenience, `cargo clippy` automatically defines a `cargo-clippy` -feature. This lets you set lint levels and compile with or without Clippy -transparently: - -```rust -#[cfg_attr(feature = "cargo-clippy", allow(needless_lifetimes))] -``` - ## Updating rustc Sometimes, rustc moves forward without Clippy catching up. Therefore updating From bb49b31254e0bf5ad973a1d0548fc877614b9e30 Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Sat, 28 Jul 2018 17:35:41 +0200 Subject: [PATCH 41/53] Adapt scripts to the tool_lints --- util/dogfood.sh | 2 +- util/update_lints.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/util/dogfood.sh b/util/dogfood.sh index 358fc46c8db..bebe0e82a7f 100755 --- a/util/dogfood.sh +++ b/util/dogfood.sh @@ -1,5 +1,5 @@ #!/bin/sh rm -rf target*/*so -cargo build --lib && cp -R target target_recur && cargo rustc --lib -- -Zextra-plugins=clippy -Ltarget_recur/debug -Dclippy_pedantic -Dclippy || exit 1 +cargo build --lib && cp -R target target_recur && cargo rustc --lib -- -Zextra-plugins=clippy -Ltarget_recur/debug -Dclippy::pedantic -Dclippy::all || exit 1 rm -rf target_recur diff --git a/util/update_lints.py b/util/update_lints.py index abc8e5dee98..ea7b992abb7 100755 --- a/util/update_lints.py +++ b/util/update_lints.py @@ -218,16 +218,16 @@ def main(print_only=False, check=False): lambda: gen_mods(all_lints), replace_start=False, write_back=not check) - # same for "clippy_*" lint collections + # same for "clippy::*" lint collections changed |= replace_region( - 'clippy_lints/src/lib.rs', r'reg.register_lint_group\("clippy"', r'\]\);', + 'clippy_lints/src/lib.rs', r'reg.register_lint_group\("clippy::all"', r'\]\);', lambda: gen_group(clippy_lint_list), replace_start=False, write_back=not check) for key, value in clippy_lints.iteritems(): - # same for "clippy_*" lint collections + # same for "clippy::*" lint collections changed |= replace_region( - 'clippy_lints/src/lib.rs', r'reg.register_lint_group\("clippy_' + key + r'"', r'\]\);', + 'clippy_lints/src/lib.rs', r'reg.register_lint_group\("clippy::' + key + r'"', r'\]\);', lambda: gen_group(value), replace_start=False, write_back=not check) From 1b6f6051a8b62f966d28d63fe3c3637a29c410a4 Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Sat, 28 Jul 2018 17:34:52 +0200 Subject: [PATCH 42/53] Adapt ui-tests to the tool_lints --- tests/ui/absurd-extreme-comparisons.rs | 8 +++--- tests/ui/approx_const.rs | 6 ++--- tests/ui/arithmetic.rs | 6 ++--- tests/ui/assign_ops.rs | 4 ++- tests/ui/assign_ops2.rs | 4 +-- tests/ui/attrs.rs | 4 +-- tests/ui/bit_masks.rs | 10 +++---- tests/ui/blacklisted_name.rs | 6 ++--- tests/ui/block_in_if_condition.rs | 10 +++---- tests/ui/bool_comparison.rs | 4 +-- tests/ui/booleans.rs | 14 +++++----- tests/ui/borrow_box.rs | 6 ++--- tests/ui/box_vec.rs | 8 +++--- tests/ui/builtin-type-shadow.rs | 4 +-- tests/ui/bytecount.rs | 4 +-- tests/ui/cast.rs | 18 ++++++------- tests/ui/cast_alignment.rs | 6 +++-- tests/ui/cast_lossless_float.rs | 8 +++--- tests/ui/cast_lossless_integer.rs | 8 +++--- tests/ui/cast_size.rs | 6 +++-- tests/ui/char_lit_as_u8.rs | 4 +-- tests/ui/checked_unwrap.rs | 6 +++-- tests/ui/clone_on_copy_mut.rs | 4 ++- tests/ui/cmp_nan.rs | 6 ++--- tests/ui/cmp_null.rs | 4 +-- tests/ui/cmp_owned.rs | 6 ++--- tests/ui/collapsible_if.rs | 4 +-- tests/ui/complex_types.rs | 6 ++--- tests/ui/copies.rs | 14 +++++----- tests/ui/copy_iterator.rs | 4 ++- tests/ui/cstring.rs | 4 ++- tests/ui/cyclomatic_complexity.rs | 8 +++--- tests/ui/cyclomatic_complexity_attr_used.rs | 4 +-- tests/ui/decimal_literal_representation.rs | 4 +-- tests/ui/default_trait_access.rs | 4 ++- tests/ui/derive.rs | 4 +-- tests/ui/diverging_sub_expression.rs | 10 ++++--- tests/ui/dlist.rs | 6 +++-- tests/ui/doc.rs | 6 +++-- tests/ui/double_neg.rs | 4 +-- tests/ui/double_parens.rs | 4 +-- tests/ui/drop_forget_copy.rs | 6 ++--- tests/ui/drop_forget_ref.rs | 6 ++--- tests/ui/duplicate_underscore_argument.rs | 4 +-- tests/ui/duration_subsec.rs | 4 ++- tests/ui/else_if_without_else.rs | 6 +++-- tests/ui/empty_enum.rs | 4 +-- tests/ui/empty_line_after_outer_attribute.rs | 4 +-- tests/ui/entry.rs | 6 ++--- tests/ui/enum_glob_use.rs | 6 ++--- tests/ui/enum_variants.rs | 6 +++-- tests/ui/enums_clike.rs | 4 ++- tests/ui/eq_op.rs | 10 +++---- tests/ui/erasing_op.rs | 6 ++--- tests/ui/eta.rs | 6 ++--- tests/ui/eval_order_dependence.rs | 6 ++--- tests/ui/excessive_precision.rs | 6 ++--- tests/ui/explicit_write.rs | 4 ++- tests/ui/fallible_impl_from.rs | 4 ++- tests/ui/filter_methods.rs | 6 ++--- tests/ui/float_cmp.rs | 6 ++--- tests/ui/float_cmp_const.rs | 10 +++---- tests/ui/for_loop.rs | 24 ++++++++--------- tests/ui/format.rs | 6 ++--- tests/ui/formatting.rs | 8 +++--- tests/ui/functions.rs | 4 +-- tests/ui/fxhash.rs | 4 ++- tests/ui/identity_conversion.rs | 6 +++-- tests/ui/identity_op.rs | 6 ++--- tests/ui/if_let_redundant_pattern_matching.rs | 6 ++--- tests/ui/if_not_else.rs | 6 ++--- tests/ui/impl.rs | 4 ++- tests/ui/inconsistent_digit_grouping.rs | 4 +-- tests/ui/indexing_slicing.rs | 8 +++--- tests/ui/infallible_destructuring_match.rs | 4 ++- tests/ui/infinite_iter.rs | 10 +++---- tests/ui/infinite_loop.rs | 6 +++-- tests/ui/inline_fn_without_body.rs | 6 ++--- tests/ui/int_plus_one.rs | 6 ++--- tests/ui/invalid_upcast_comparisons.rs | 6 ++--- tests/ui/issue_2356.rs | 4 ++- tests/ui/item_after_statement.rs | 4 +-- tests/ui/large_digit_groups.rs | 4 +-- tests/ui/large_enum_variant.rs | 4 +-- tests/ui/len_zero.rs | 6 +++-- tests/ui/let_if_seq.rs | 6 ++--- tests/ui/let_return.rs | 6 ++--- tests/ui/let_unit.rs | 4 +-- tests/ui/lifetimes.rs | 6 ++--- tests/ui/literals.rs | 8 +++--- tests/ui/map_clone.rs | 6 ++--- tests/ui/matches.rs | 8 +++--- tests/ui/mem_forget.rs | 6 ++--- tests/ui/methods.rs | 14 +++++----- tests/ui/min_max.rs | 4 +-- tests/ui/missing-doc.rs | 22 +++++++++------- tests/ui/missing_inline.rs | 6 +++-- tests/ui/module_inception.rs | 6 ++--- tests/ui/modulo_one.rs | 6 ++--- tests/ui/mut_from_ref.rs | 6 ++--- tests/ui/mut_mut.rs | 6 ++--- tests/ui/mut_reference.rs | 6 ++--- tests/ui/mutex_atomic.rs | 6 ++--- tests/ui/needless_bool.rs | 18 ++++++------- tests/ui/needless_borrow.rs | 8 +++--- tests/ui/needless_borrowed_ref.rs | 4 +-- tests/ui/needless_continue.rs | 4 +-- tests/ui/needless_pass_by_value.rs | 6 +++-- tests/ui/needless_pass_by_value_proc_macro.rs | 4 +-- tests/ui/needless_return.rs | 4 +-- tests/ui/needless_update.rs | 6 ++--- tests/ui/neg_cmp_op_on_partial_ord.rs | 4 ++- tests/ui/neg_multiply.rs | 6 ++--- tests/ui/never_loop.rs | 6 ++--- tests/ui/new_without_default.rs | 4 ++- tests/ui/no_effect.rs | 8 +++--- tests/ui/non_copy_const.rs | 6 +++-- tests/ui/non_expressive_names.rs | 6 ++--- tests/ui/ok_if_let.rs | 4 +-- tests/ui/op_ref.rs | 4 +-- tests/ui/open_options.rs | 4 +-- tests/ui/option_map_unit_fn.rs | 4 ++- tests/ui/overflow_check_conditional.rs | 6 ++--- tests/ui/panic_unimplemented.rs | 4 +-- tests/ui/patterns.rs | 4 +-- tests/ui/precedence.rs | 8 +++--- tests/ui/print.rs | 6 ++--- tests/ui/print_literal.rs | 4 +-- tests/ui/print_with_newline.rs | 6 ++--- tests/ui/ptr_arg.rs | 6 +++-- tests/ui/range.rs | 4 +-- tests/ui/range_plus_minus_one.rs | 4 ++- tests/ui/redundant_closure_call.rs | 4 +-- tests/ui/redundant_field_names.rs | 4 ++- tests/ui/reference.rs | 10 +++---- tests/ui/regex.rs | 4 +-- tests/ui/replace_consts.rs | 6 +++-- tests/ui/result_map_unit_fn.rs | 4 ++- tests/ui/serde.rs | 4 +-- tests/ui/shadow.rs | 6 ++--- tests/ui/short_circuit_statement.rs | 4 +-- tests/ui/single_char_pattern.rs | 4 ++- tests/ui/single_match.rs | 4 ++- tests/ui/starts_ends_with.rs | 6 +++-- tests/ui/strings.rs | 12 ++++----- tests/ui/stutter.rs | 4 +-- tests/ui/suspicious_arithmetic_impl.rs | 4 +-- tests/ui/swap.rs | 6 ++--- tests/ui/temporary_assignment.rs | 4 +-- tests/ui/toplevel_ref_arg.rs | 4 +-- tests/ui/transmute.rs | 26 +++++++++---------- tests/ui/transmute_64bit.rs | 4 ++- tests/ui/trivially_copy_pass_by_ref.rs | 8 +++--- tests/ui/unicode.rs | 8 +++--- tests/ui/unit_arg.rs | 6 +++-- tests/ui/unit_cmp.rs | 6 ++--- tests/ui/unnecessary_clone.rs | 6 +++-- tests/ui/unnecessary_ref.rs | 4 ++- tests/ui/unneeded_field_pattern.rs | 4 +-- tests/ui/unreadable_literal.rs | 4 +-- tests/ui/unsafe_removed_from_name.rs | 4 +-- tests/ui/unused_io_amount.rs | 4 +-- tests/ui/unused_labels.rs | 6 ++--- tests/ui/unused_lt.rs | 6 ++--- tests/ui/unwrap_or.rs | 3 ++- tests/ui/use_self.rs | 8 +++--- tests/ui/used_underscore_binding.rs | 8 +++--- tests/ui/useless_asref.rs | 8 +++--- tests/ui/useless_attribute.rs | 4 +-- tests/ui/vec.rs | 6 ++--- tests/ui/while_loop.rs | 8 +++--- tests/ui/write_literal.rs | 4 ++- tests/ui/write_with_newline.rs | 6 +++-- tests/ui/writeln_empty_string.rs | 4 ++- tests/ui/wrong_self_convention.rs | 10 +++---- tests/ui/zero_div_zero.rs | 4 +-- 176 files changed, 597 insertions(+), 486 deletions(-) diff --git a/tests/ui/absurd-extreme-comparisons.rs b/tests/ui/absurd-extreme-comparisons.rs index 8c036e6c072..d08c8008ec9 100644 --- a/tests/ui/absurd-extreme-comparisons.rs +++ b/tests/ui/absurd-extreme-comparisons.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(absurd_extreme_comparisons)] -#![allow(unused, eq_op, no_effect, unnecessary_operation, needless_pass_by_value)] +#![warn(clippy::absurd_extreme_comparisons)] +#![allow(unused, clippy::eq_op, clippy::no_effect, clippy::unnecessary_operation, clippy::needless_pass_by_value)] fn main() { const Z: u32 = 0; @@ -27,7 +27,7 @@ fn main() { b >= true; false > b; u > 0; // ok - // this is handled by unit_cmp + // this is handled by clippy::unit_cmp () < {}; } diff --git a/tests/ui/approx_const.rs b/tests/ui/approx_const.rs index d353d9075d4..46ca2fbfb57 100644 --- a/tests/ui/approx_const.rs +++ b/tests/ui/approx_const.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#[warn(approx_constant)] -#[allow(unused, shadow_unrelated, similar_names, unreadable_literal)] +#[warn(clippy::approx_constant)] +#[allow(unused, clippy::shadow_unrelated, clippy::similar_names, clippy::unreadable_literal)] fn main() { let my_e = 2.7182; let almost_e = 2.718; diff --git a/tests/ui/arithmetic.rs b/tests/ui/arithmetic.rs index 7ed71b59707..e7aa9a18b8a 100644 --- a/tests/ui/arithmetic.rs +++ b/tests/ui/arithmetic.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(integer_arithmetic, float_arithmetic)] -#![allow(unused, shadow_reuse, shadow_unrelated, no_effect, unnecessary_operation)] +#![warn(clippy::integer_arithmetic, clippy::float_arithmetic)] +#![allow(unused, clippy::shadow_reuse, clippy::shadow_unrelated, clippy::no_effect, clippy::unnecessary_operation)] fn main() { let i = 1i32; 1 + i; diff --git a/tests/ui/assign_ops.rs b/tests/ui/assign_ops.rs index 7332b41fa0b..765dbb67990 100644 --- a/tests/ui/assign_ops.rs +++ b/tests/ui/assign_ops.rs @@ -1,5 +1,7 @@ +#![feature(tool_lints)] + #[allow(dead_code, unused_assignments)] -#[warn(assign_op_pattern)] +#[warn(clippy::assign_op_pattern)] fn main() { let mut a = 5; a = a + 1; diff --git a/tests/ui/assign_ops2.rs b/tests/ui/assign_ops2.rs index 2d3adc2a661..c3f5083bb1f 100644 --- a/tests/ui/assign_ops2.rs +++ b/tests/ui/assign_ops2.rs @@ -1,8 +1,8 @@ - +#![feature(tool_lints)] #[allow(unused_assignments)] -#[warn(misrefactored_assign_op, assign_op_pattern)] +#[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)] fn main() { let mut a = 5; a += a + 1; diff --git a/tests/ui/attrs.rs b/tests/ui/attrs.rs index eb27b833ade..b1f0ca640aa 100644 --- a/tests/ui/attrs.rs +++ b/tests/ui/attrs.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(inline_always, deprecated_semver)] +#![warn(clippy::inline_always, clippy::deprecated_semver)] #[inline(always)] fn test_attr_lint() { diff --git a/tests/ui/bit_masks.rs b/tests/ui/bit_masks.rs index 4843b4eba0d..4111f344b66 100644 --- a/tests/ui/bit_masks.rs +++ b/tests/ui/bit_masks.rs @@ -1,11 +1,11 @@ - +#![feature(tool_lints)] const THREE_BITS : i64 = 7; const EVEN_MORE_REDIRECTION : i64 = THREE_BITS; -#[warn(bad_bit_mask)] -#[allow(ineffective_bit_mask, identity_op, no_effect, unnecessary_operation)] +#[warn(clippy::bad_bit_mask)] +#[allow(clippy::ineffective_bit_mask, clippy::identity_op, clippy::no_effect, clippy::unnecessary_operation)] fn main() { let x = 5; @@ -44,8 +44,8 @@ fn main() { ineffective(); } -#[warn(ineffective_bit_mask)] -#[allow(bad_bit_mask, no_effect, unnecessary_operation)] +#[warn(clippy::ineffective_bit_mask)] +#[allow(clippy::bad_bit_mask, clippy::no_effect, clippy::unnecessary_operation)] fn ineffective() { let x = 5; diff --git a/tests/ui/blacklisted_name.rs b/tests/ui/blacklisted_name.rs index 7baeb7bb75c..4e2e5388c98 100644 --- a/tests/ui/blacklisted_name.rs +++ b/tests/ui/blacklisted_name.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![allow(dead_code, similar_names, single_match, toplevel_ref_arg, unused_mut, unused_variables)] -#![warn(blacklisted_name)] +#![allow(dead_code, clippy::similar_names, clippy::single_match, clippy::toplevel_ref_arg, unused_mut, unused_variables)] +#![warn(clippy::blacklisted_name)] fn test(foo: ()) {} diff --git a/tests/ui/block_in_if_condition.rs b/tests/ui/block_in_if_condition.rs index 9e65a127af2..dd0e5503437 100644 --- a/tests/ui/block_in_if_condition.rs +++ b/tests/ui/block_in_if_condition.rs @@ -1,10 +1,10 @@ +#![feature(tool_lints)] - -#![warn(block_in_if_condition_expr)] -#![warn(block_in_if_condition_stmt)] -#![allow(unused, let_and_return)] -#![warn(nonminimal_bool)] +#![warn(clippy::block_in_if_condition_expr)] +#![warn(clippy::block_in_if_condition_stmt)] +#![allow(unused, clippy::let_and_return)] +#![warn(clippy::nonminimal_bool)] macro_rules! blocky { diff --git a/tests/ui/bool_comparison.rs b/tests/ui/bool_comparison.rs index f05b9894fea..144f9f4c631 100644 --- a/tests/ui/bool_comparison.rs +++ b/tests/ui/bool_comparison.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#[warn(bool_comparison)] +#[warn(clippy::bool_comparison)] fn main() { let x = true; if x == true { "yes" } else { "no" }; diff --git a/tests/ui/booleans.rs b/tests/ui/booleans.rs index fc16c12af28..eaa686c9a90 100644 --- a/tests/ui/booleans.rs +++ b/tests/ui/booleans.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] +#![warn(clippy::nonminimal_bool, clippy::logic_bug)] -#![warn(nonminimal_bool, logic_bug)] - -#[allow(unused, many_single_char_names)] +#[allow(unused, clippy::many_single_char_names)] fn main() { let a: bool = unimplemented!(); let b: bool = unimplemented!(); @@ -23,7 +23,7 @@ fn main() { let _ = !(!a && b); } -#[allow(unused, many_single_char_names)] +#[allow(unused, clippy::many_single_char_names)] fn equality_stuff() { let a: i32 = unimplemented!(); let b: i32 = unimplemented!(); @@ -39,7 +39,7 @@ fn equality_stuff() { let _ = a != b || !(a != b || c == d); } -#[allow(unused, many_single_char_names)] +#[allow(unused, clippy::many_single_char_names)] fn methods_with_negation() { let a: Option = unimplemented!(); let b: Result = unimplemented!(); @@ -59,7 +59,7 @@ fn methods_with_negation() { } // Simplified versions of https://github.com/rust-lang-nursery/rust-clippy/issues/2638 -// nonminimal_bool should only check the built-in Result and Some type, not +// clippy::nonminimal_bool should only check the built-in Result and Some type, not // any other types like the following. enum CustomResultOk { Ok, Err(E) } enum CustomResultErr { Ok, Err(E) } @@ -115,7 +115,7 @@ fn warn_for_built_in_methods_with_negation() { if !res.is_none() { } } -#[allow(neg_cmp_op_on_partial_ord)] +#[allow(clippy::neg_cmp_op_on_partial_ord)] fn dont_warn_for_negated_partial_ord_comparison() { let a: f64 = unimplemented!(); let b: f64 = unimplemented!(); diff --git a/tests/ui/borrow_box.rs b/tests/ui/borrow_box.rs index 394b810ed86..216dbebda67 100644 --- a/tests/ui/borrow_box.rs +++ b/tests/ui/borrow_box.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![deny(borrowed_box)] -#![allow(blacklisted_name)] +#![deny(clippy::borrowed_box)] +#![allow(clippy::blacklisted_name)] #![allow(unused_variables)] #![allow(dead_code)] diff --git a/tests/ui/box_vec.rs b/tests/ui/box_vec.rs index 75b3b62643e..bc5e8361d8b 100644 --- a/tests/ui/box_vec.rs +++ b/tests/ui/box_vec.rs @@ -1,9 +1,9 @@ +#![feature(tool_lints)] - -#![warn(clippy)] -#![allow(boxed_local, needless_pass_by_value)] -#![allow(blacklisted_name)] +#![warn(clippy::all)] +#![allow(clippy::boxed_local, clippy::needless_pass_by_value)] +#![allow(clippy::blacklisted_name)] macro_rules! boxit { ($init:expr, $x:ty) => { diff --git a/tests/ui/builtin-type-shadow.rs b/tests/ui/builtin-type-shadow.rs index 4c4f5cbd3fe..56892fc9483 100644 --- a/tests/ui/builtin-type-shadow.rs +++ b/tests/ui/builtin-type-shadow.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![warn(builtin_type_shadow)] +#![warn(clippy::builtin_type_shadow)] fn foo(a: u32) -> u32 { 42 diff --git a/tests/ui/bytecount.rs b/tests/ui/bytecount.rs index fc94667d968..7211284e4a0 100644 --- a/tests/ui/bytecount.rs +++ b/tests/ui/bytecount.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#[deny(naive_bytecount)] +#[deny(clippy::naive_bytecount)] fn main() { let x = vec![0_u8; 16]; diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index 833e5a55780..0668b16ff32 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -1,17 +1,17 @@ +#![feature(tool_lints)] - -#[warn(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap, cast_lossless)] -#[allow(no_effect, unnecessary_operation)] +#[warn(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless)] +#[allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { - // Test cast_precision_loss + // Test clippy::cast_precision_loss 1i32 as f32; 1i64 as f32; 1i64 as f64; 1u32 as f32; 1u64 as f32; 1u64 as f64; - // Test cast_possible_truncation + // Test clippy::cast_possible_truncation 1f32 as i32; 1f32 as u32; 1f64 as f32; @@ -19,17 +19,17 @@ fn main() { 1i32 as u8; 1f64 as isize; 1f64 as usize; - // Test cast_possible_wrap + // Test clippy::cast_possible_wrap 1u8 as i8; 1u16 as i16; 1u32 as i32; 1u64 as i64; 1usize as isize; - // Test cast_lossless with casts from floating-point types + // Test clippy::cast_lossless with casts from floating-point types 1.0f32 as f64; - // Test cast_lossless with an expression wrapped in parens + // Test clippy::cast_lossless with an expression wrapped in parens (1u8 + 1u8) as u16; - // Test cast_sign_loss + // Test clippy::cast_sign_loss 1i32 as u32; 1isize as usize; // Extra checks for *size diff --git a/tests/ui/cast_alignment.rs b/tests/ui/cast_alignment.rs index 32e2f93169e..1f7606de649 100644 --- a/tests/ui/cast_alignment.rs +++ b/tests/ui/cast_alignment.rs @@ -1,11 +1,13 @@ +#![feature(tool_lints)] + //! Test casts for alignment issues #![feature(libc)] extern crate libc; -#[warn(cast_ptr_alignment)] -#[allow(no_effect, unnecessary_operation, cast_lossless)] +#[warn(clippy::cast_ptr_alignment)] +#[allow(clippy::no_effect, clippy::unnecessary_operation, clippy::cast_lossless)] fn main() { /* These should be warned against */ diff --git a/tests/ui/cast_lossless_float.rs b/tests/ui/cast_lossless_float.rs index 9e61059b630..437c4b67120 100644 --- a/tests/ui/cast_lossless_float.rs +++ b/tests/ui/cast_lossless_float.rs @@ -1,7 +1,9 @@ -#[warn(cast_lossless)] -#[allow(no_effect, unnecessary_operation)] +#![feature(tool_lints)] + +#[warn(clippy::cast_lossless)] +#[allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { - // Test cast_lossless with casts to floating-point types + // Test clippy::cast_lossless with casts to floating-point types 1i8 as f32; 1i8 as f64; 1u8 as f32; diff --git a/tests/ui/cast_lossless_integer.rs b/tests/ui/cast_lossless_integer.rs index 5f89d057c33..e06e653c6f5 100644 --- a/tests/ui/cast_lossless_integer.rs +++ b/tests/ui/cast_lossless_integer.rs @@ -1,8 +1,8 @@ - -#[warn(cast_lossless)] -#[allow(no_effect, unnecessary_operation)] +#![feature(tool_lints)] +#[warn(clippy::cast_lossless)] +#[allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { - // Test cast_lossless with casts to integer types + // Test clippy::cast_lossless with casts to integer types 1i8 as i16; 1i8 as i32; 1i8 as i64; diff --git a/tests/ui/cast_size.rs b/tests/ui/cast_size.rs index d0bef860c70..4c72f57165c 100644 --- a/tests/ui/cast_size.rs +++ b/tests/ui/cast_size.rs @@ -1,5 +1,7 @@ -#[warn(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap, cast_lossless)] -#[allow(no_effect, unnecessary_operation)] +#![feature(tool_lints)] + +#[warn(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless)] +#[allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { // Casting from *size 1isize as i8; diff --git a/tests/ui/char_lit_as_u8.rs b/tests/ui/char_lit_as_u8.rs index c69181c7649..f9937ede351 100644 --- a/tests/ui/char_lit_as_u8.rs +++ b/tests/ui/char_lit_as_u8.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(char_lit_as_u8)] +#![warn(clippy::char_lit_as_u8)] #![allow(unused_variables)] fn main() { let c = 'a' as u8; diff --git a/tests/ui/checked_unwrap.rs b/tests/ui/checked_unwrap.rs index 2b5118fa814..b3979245d36 100644 --- a/tests/ui/checked_unwrap.rs +++ b/tests/ui/checked_unwrap.rs @@ -1,5 +1,7 @@ -#![deny(panicking_unwrap, unnecessary_unwrap)] -#![allow(if_same_then_else)] +#![feature(tool_lints)] + +#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +#![allow(clippy::if_same_then_else)] fn main() { let x = Some(()); diff --git a/tests/ui/clone_on_copy_mut.rs b/tests/ui/clone_on_copy_mut.rs index 5b491573c3f..77dffc67670 100644 --- a/tests/ui/clone_on_copy_mut.rs +++ b/tests/ui/clone_on_copy_mut.rs @@ -1,3 +1,5 @@ +#![feature(tool_lints)] + pub fn dec_read_dec(i: &mut i32) -> i32 { *i -= 1; let ret = *i; @@ -5,7 +7,7 @@ pub fn dec_read_dec(i: &mut i32) -> i32 { ret } -#[allow(trivially_copy_pass_by_ref)] +#[allow(clippy::trivially_copy_pass_by_ref)] pub fn minus_1(i: &i32) -> i32 { dec_read_dec(&mut i.clone()) } diff --git a/tests/ui/cmp_nan.rs b/tests/ui/cmp_nan.rs index 71dfdd43da7..fdebb7da18a 100644 --- a/tests/ui/cmp_nan.rs +++ b/tests/ui/cmp_nan.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#[warn(cmp_nan)] -#[allow(float_cmp, no_effect, unnecessary_operation)] +#[warn(clippy::cmp_nan)] +#[allow(clippy::float_cmp, clippy::no_effect, clippy::unnecessary_operation)] fn main() { let x = 5f32; x == std::f32::NAN; diff --git a/tests/ui/cmp_null.rs b/tests/ui/cmp_null.rs index 0f463bcfc30..e10b3e104ec 100644 --- a/tests/ui/cmp_null.rs +++ b/tests/ui/cmp_null.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![warn(cmp_null)] +#![warn(clippy::cmp_null)] #![allow(unused_mut)] use std::ptr; diff --git a/tests/ui/cmp_owned.rs b/tests/ui/cmp_owned.rs index 36d3140d246..713975c4404 100644 --- a/tests/ui/cmp_owned.rs +++ b/tests/ui/cmp_owned.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#[warn(cmp_owned)] -#[allow(unnecessary_operation)] +#[warn(clippy::cmp_owned)] +#[allow(clippy::unnecessary_operation)] fn main() { fn with_to_string(x : &str) { x != "foo".to_string(); diff --git a/tests/ui/collapsible_if.rs b/tests/ui/collapsible_if.rs index de22352e311..d40be631933 100644 --- a/tests/ui/collapsible_if.rs +++ b/tests/ui/collapsible_if.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#[warn(collapsible_if)] +#[warn(clippy::collapsible_if)] fn main() { let x = "hello"; let y = "world"; diff --git a/tests/ui/complex_types.rs b/tests/ui/complex_types.rs index 7719a7a8632..a6875793c83 100644 --- a/tests/ui/complex_types.rs +++ b/tests/ui/complex_types.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(clippy)] -#![allow(unused, needless_pass_by_value)] +#![warn(clippy::all)] +#![allow(unused, clippy::needless_pass_by_value)] #![feature(associated_type_defaults)] type Alias = Vec>>; // no warning here diff --git a/tests/ui/copies.rs b/tests/ui/copies.rs index 65a565c68ec..064c7fc1c59 100644 --- a/tests/ui/copies.rs +++ b/tests/ui/copies.rs @@ -1,5 +1,7 @@ -#![allow(blacklisted_name, collapsible_if, cyclomatic_complexity, eq_op, needless_continue, - needless_return, never_loop, no_effect, zero_divided_by_zero)] +#![feature(tool_lints)] + +#![allow(clippy::blacklisted_name, clippy::collapsible_if, clippy::cyclomatic_complexity, clippy::eq_op, clippy::needless_continue, + clippy::needless_return, clippy::never_loop, clippy::no_effect, clippy::zero_divided_by_zero)] fn bar(_: T) {} fn foo() -> bool { unimplemented!() } @@ -14,8 +16,8 @@ pub enum Abc { C, } -#[warn(if_same_then_else)] -#[warn(match_same_arms)] +#[warn(clippy::if_same_then_else)] +#[warn(clippy::match_same_arms)] fn if_same_then_else() -> Result<&'static str, ()> { if true { Foo { bar: 42 }; @@ -340,8 +342,8 @@ fn if_same_then_else() -> Result<&'static str, ()> { } } -#[warn(ifs_same_cond)] -#[allow(if_same_then_else)] // all empty blocks +#[warn(clippy::ifs_same_cond)] +#[allow(clippy::if_same_then_else)] // all empty blocks fn ifs_same_cond() { let a = 0; let b = false; diff --git a/tests/ui/copy_iterator.rs b/tests/ui/copy_iterator.rs index 1b65cc4f8cc..5ccb9910c1e 100644 --- a/tests/ui/copy_iterator.rs +++ b/tests/ui/copy_iterator.rs @@ -1,4 +1,6 @@ -#![warn(copy_iterator)] +#![feature(tool_lints)] + +#![warn(clippy::copy_iterator)] #[derive(Copy, Clone)] struct Countdown(u8); diff --git a/tests/ui/cstring.rs b/tests/ui/cstring.rs index 8b7b0b66bc6..e68874d5409 100644 --- a/tests/ui/cstring.rs +++ b/tests/ui/cstring.rs @@ -1,6 +1,8 @@ +#![feature(tool_lints)] + fn main() {} -#[allow(result_unwrap_used)] +#[allow(clippy::result_unwrap_used)] fn temporary_cstring() { use std::ffi::CString; diff --git a/tests/ui/cyclomatic_complexity.rs b/tests/ui/cyclomatic_complexity.rs index 7166ed25948..84e2a1b6583 100644 --- a/tests/ui/cyclomatic_complexity.rs +++ b/tests/ui/cyclomatic_complexity.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![allow(clippy)] -#![warn(cyclomatic_complexity)] +#![allow(clippy::all)] +#![warn(clippy::cyclomatic_complexity)] #![allow(unused)] fn main() { @@ -172,7 +172,7 @@ fn bar() { #[test] #[clippy::cyclomatic_complexity = "0"] -/// Tests are usually complex but simple at the same time. `cyclomatic_complexity` used to give +/// Tests are usually complex but simple at the same time. `clippy::cyclomatic_complexity` used to give /// lots of false-positives in tests. fn dont_warn_on_tests() { match 99 { diff --git a/tests/ui/cyclomatic_complexity_attr_used.rs b/tests/ui/cyclomatic_complexity_attr_used.rs index dbd4e438a12..fd8be25e670 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.rs +++ b/tests/ui/cyclomatic_complexity_attr_used.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![warn(cyclomatic_complexity)] +#![warn(clippy::cyclomatic_complexity)] #![warn(unused)] fn main() { diff --git a/tests/ui/decimal_literal_representation.rs b/tests/ui/decimal_literal_representation.rs index 5463b8957f3..472ea618571 100644 --- a/tests/ui/decimal_literal_representation.rs +++ b/tests/ui/decimal_literal_representation.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#[warn(decimal_literal_representation)] +#[warn(clippy::decimal_literal_representation)] #[allow(unused_variables)] fn main() { let good = ( // Hex: diff --git a/tests/ui/default_trait_access.rs b/tests/ui/default_trait_access.rs index 675e64246fa..ba8886cd6a4 100644 --- a/tests/ui/default_trait_access.rs +++ b/tests/ui/default_trait_access.rs @@ -1,4 +1,6 @@ -#![warn(default_trait_access)] +#![feature(tool_lints)] + +#![warn(clippy::default_trait_access)] use std::default::Default as D2; use std::string; diff --git a/tests/ui/derive.rs b/tests/ui/derive.rs index f43b8c382a4..ae54c0290bc 100644 --- a/tests/ui/derive.rs +++ b/tests/ui/derive.rs @@ -1,9 +1,9 @@ - +#![feature(tool_lints)] #![feature(untagged_unions)] #![allow(dead_code)] -#![warn(expl_impl_clone_on_copy)] +#![warn(clippy::expl_impl_clone_on_copy)] use std::hash::{Hash, Hasher}; diff --git a/tests/ui/diverging_sub_expression.rs b/tests/ui/diverging_sub_expression.rs index b89a2f1bcaf..a8284dca326 100644 --- a/tests/ui/diverging_sub_expression.rs +++ b/tests/ui/diverging_sub_expression.rs @@ -1,9 +1,11 @@ +#![feature(tool_lints)] + #![feature(never_type)] -#![warn(diverging_sub_expression)] -#![allow(match_same_arms, logic_bug)] +#![warn(clippy::diverging_sub_expression)] +#![allow(clippy::match_same_arms, clippy::logic_bug)] -#[allow(empty_loop)] +#[allow(clippy::empty_loop)] fn diverge() -> ! { loop {} } struct A; @@ -12,7 +14,7 @@ impl A { fn foo(&self) -> ! { diverge() } } -#[allow(unused_variables, unnecessary_operation, short_circuit_statement)] +#[allow(unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)] fn main() { let b = true; b || diverge(); diff --git a/tests/ui/dlist.rs b/tests/ui/dlist.rs index 1318ed78717..395ff217497 100644 --- a/tests/ui/dlist.rs +++ b/tests/ui/dlist.rs @@ -1,9 +1,11 @@ +#![feature(tool_lints)] + #![feature(alloc)] #![feature(associated_type_defaults)] -#![warn(linkedlist)] -#![allow(dead_code, needless_pass_by_value)] +#![warn(clippy::linkedlist)] +#![allow(dead_code, clippy::needless_pass_by_value)] extern crate alloc; use alloc::collections::linked_list::LinkedList; diff --git a/tests/ui/doc.rs b/tests/ui/doc.rs index 45e25409b12..d48007a9347 100644 --- a/tests/ui/doc.rs +++ b/tests/ui/doc.rs @@ -1,9 +1,11 @@ +#![feature(tool_lints)] + //! This file tests for the DOC_MARKDOWN lint #![allow(dead_code)] -#![warn(doc_markdown)] +#![warn(clippy::doc_markdown)] /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun @@ -50,7 +52,7 @@ fn test_units() { } /// This test has [a link_with_underscores][chunked-example] inside it. See #823. -/// See also [the issue tracker](https://github.com/rust-lang-nursery/rust-clippy/search?q=doc_markdown&type=Issues) +/// See also [the issue tracker](https://github.com/rust-lang-nursery/rust-clippy/search?q=clippy::doc_markdown&type=Issues) /// on GitHub (which is a camel-cased word, but is OK). And here is another [inline link][inline_link]. /// It can also be [inline_link2]. /// diff --git a/tests/ui/double_neg.rs b/tests/ui/double_neg.rs index 641e334fd16..0ec13900f99 100644 --- a/tests/ui/double_neg.rs +++ b/tests/ui/double_neg.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#[warn(double_neg)] +#[warn(clippy::double_neg)] fn main() { let x = 1; -x; diff --git a/tests/ui/double_parens.rs b/tests/ui/double_parens.rs index 19d17732867..8d81ee16fe9 100644 --- a/tests/ui/double_parens.rs +++ b/tests/ui/double_parens.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(double_parens)] +#![warn(clippy::double_parens)] #![allow(dead_code)] fn dummy_fn(_: T) {} diff --git a/tests/ui/drop_forget_copy.rs b/tests/ui/drop_forget_copy.rs index 9fef06b0ede..aa70490f8ab 100644 --- a/tests/ui/drop_forget_copy.rs +++ b/tests/ui/drop_forget_copy.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(drop_copy, forget_copy)] -#![allow(toplevel_ref_arg, drop_ref, forget_ref, unused_mut)] +#![warn(clippy::drop_copy, clippy::forget_copy)] +#![allow(clippy::toplevel_ref_arg, clippy::drop_ref, clippy::forget_ref, unused_mut)] use std::mem::{drop, forget}; use std::vec::Vec; diff --git a/tests/ui/drop_forget_ref.rs b/tests/ui/drop_forget_ref.rs index e8ab6a0d5d1..bb4781db71b 100644 --- a/tests/ui/drop_forget_ref.rs +++ b/tests/ui/drop_forget_ref.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(drop_ref, forget_ref)] -#![allow(toplevel_ref_arg, similar_names, needless_pass_by_value)] +#![warn(clippy::drop_ref, clippy::forget_ref)] +#![allow(clippy::toplevel_ref_arg, clippy::similar_names, clippy::needless_pass_by_value)] use std::mem::{drop, forget}; diff --git a/tests/ui/duplicate_underscore_argument.rs b/tests/ui/duplicate_underscore_argument.rs index df00f56aa62..e54920c1b56 100644 --- a/tests/ui/duplicate_underscore_argument.rs +++ b/tests/ui/duplicate_underscore_argument.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(duplicate_underscore_argument)] +#![warn(clippy::duplicate_underscore_argument)] #[allow(dead_code, unused)] fn join_the_dark_side(darth: i32, _darth: i32) {} diff --git a/tests/ui/duration_subsec.rs b/tests/ui/duration_subsec.rs index 8c75c5f2fcd..d732a0228d5 100644 --- a/tests/ui/duration_subsec.rs +++ b/tests/ui/duration_subsec.rs @@ -1,4 +1,6 @@ -#![warn(duration_subsec)] +#![feature(tool_lints)] + +#![warn(clippy::duration_subsec)] use std::time::Duration; diff --git a/tests/ui/else_if_without_else.rs b/tests/ui/else_if_without_else.rs index 4f019819eff..3776aecf54f 100644 --- a/tests/ui/else_if_without_else.rs +++ b/tests/ui/else_if_without_else.rs @@ -1,5 +1,7 @@ -#![warn(clippy)] -#![warn(else_if_without_else)] +#![feature(tool_lints)] + +#![warn(clippy::all)] +#![warn(clippy::else_if_without_else)] fn bla1() -> bool { unimplemented!() } fn bla2() -> bool { unimplemented!() } diff --git a/tests/ui/empty_enum.rs b/tests/ui/empty_enum.rs index c6e6946de86..3398b71eead 100644 --- a/tests/ui/empty_enum.rs +++ b/tests/ui/empty_enum.rs @@ -1,8 +1,8 @@ - +#![feature(tool_lints)] #![allow(dead_code)] -#![warn(empty_enum)] +#![warn(clippy::empty_enum)] enum Empty {} diff --git a/tests/ui/empty_line_after_outer_attribute.rs b/tests/ui/empty_line_after_outer_attribute.rs index 30063dac0a4..c46a0496a73 100644 --- a/tests/ui/empty_line_after_outer_attribute.rs +++ b/tests/ui/empty_line_after_outer_attribute.rs @@ -1,5 +1,5 @@ - -#![warn(empty_line_after_outer_attr)] +#![feature(tool_lints)] +#![warn(clippy::empty_line_after_outer_attr)] // This should produce a warning #[crate_type = "lib"] diff --git a/tests/ui/entry.rs b/tests/ui/entry.rs index ccbc7038f13..955b0a6e917 100644 --- a/tests/ui/entry.rs +++ b/tests/ui/entry.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] +#![allow(unused, clippy::needless_pass_by_value)] -#![allow(unused, needless_pass_by_value)] - -#![warn(map_entry)] +#![warn(clippy::map_entry)] use std::collections::{BTreeMap, HashMap}; use std::hash::Hash; diff --git a/tests/ui/enum_glob_use.rs b/tests/ui/enum_glob_use.rs index efb37fbe49d..47082f8f3e6 100644 --- a/tests/ui/enum_glob_use.rs +++ b/tests/ui/enum_glob_use.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(clippy, clippy_pedantic)] -#![allow(unused_imports, dead_code, missing_docs_in_private_items)] +#![warn(clippy::all, clippy::pedantic)] +#![allow(unused_imports, dead_code, clippy::missing_docs_in_private_items)] use std::cmp::Ordering::*; diff --git a/tests/ui/enum_variants.rs b/tests/ui/enum_variants.rs index 222c76c25b7..4ddb7207a30 100644 --- a/tests/ui/enum_variants.rs +++ b/tests/ui/enum_variants.rs @@ -1,6 +1,8 @@ +#![feature(tool_lints)] + #![feature(non_ascii_idents)] -#![warn(clippy, pub_enum_variant_names)] +#![warn(clippy::all, clippy::pub_enum_variant_names)] enum FakeCallType { CALL, CREATE @@ -93,7 +95,7 @@ pub enum PubSeall { WithOut, } -#[allow(pub_enum_variant_names)] +#[allow(clippy::pub_enum_variant_names)] mod allowed { pub enum PubAllowed { SomeThis, diff --git a/tests/ui/enums_clike.rs b/tests/ui/enums_clike.rs index 618603683e8..8212f12b3db 100644 --- a/tests/ui/enums_clike.rs +++ b/tests/ui/enums_clike.rs @@ -1,7 +1,9 @@ +#![feature(tool_lints)] + // ignore-x86 -#![warn(clippy)] +#![warn(clippy::all)] #![allow(unused)] diff --git a/tests/ui/eq_op.rs b/tests/ui/eq_op.rs index ef573b2b91a..a88866436dd 100644 --- a/tests/ui/eq_op.rs +++ b/tests/ui/eq_op.rs @@ -1,10 +1,10 @@ +#![feature(tool_lints)] - -#[warn(eq_op)] -#[allow(identity_op, double_parens, many_single_char_names)] -#[allow(no_effect, unused_variables, unnecessary_operation, short_circuit_statement)] -#[warn(nonminimal_bool)] +#[warn(clippy::eq_op)] +#[allow(clippy::identity_op, clippy::double_parens, clippy::many_single_char_names)] +#[allow(clippy::no_effect, unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)] +#[warn(clippy::nonminimal_bool)] fn main() { // simple values and comparisons 1 == 1; diff --git a/tests/ui/erasing_op.rs b/tests/ui/erasing_op.rs index e5143146f26..02745ac5d91 100644 --- a/tests/ui/erasing_op.rs +++ b/tests/ui/erasing_op.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#[allow(no_effect)] -#[warn(erasing_op)] +#[allow(clippy::no_effect)] +#[warn(clippy::erasing_op)] fn main() { let x: u8 = 0; diff --git a/tests/ui/eta.rs b/tests/ui/eta.rs index 6e0b6f8cacd..4dd46f20e76 100644 --- a/tests/ui/eta.rs +++ b/tests/ui/eta.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![allow(unknown_lints, unused, no_effect, redundant_closure_call, many_single_char_names, needless_pass_by_value, option_map_unit_fn, trivially_copy_pass_by_ref)] -#![warn(redundant_closure, needless_borrow)] +#![allow(unknown_lints, unused, clippy::no_effect, clippy::redundant_closure_call, clippy::many_single_char_names, clippy::needless_pass_by_value, clippy::option_map_unit_fn, clippy::trivially_copy_pass_by_ref)] +#![warn(clippy::redundant_closure, clippy::needless_borrow)] fn main() { let a = Some(1u8).map(|a| foo(a)); diff --git a/tests/ui/eval_order_dependence.rs b/tests/ui/eval_order_dependence.rs index e7ccb190d2c..b240dde06f8 100644 --- a/tests/ui/eval_order_dependence.rs +++ b/tests/ui/eval_order_dependence.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#[warn(eval_order_dependence)] -#[allow(unused_assignments, unused_variables, many_single_char_names, no_effect, dead_code, blacklisted_name)] +#[warn(clippy::eval_order_dependence)] +#[allow(unused_assignments, unused_variables, clippy::many_single_char_names, clippy::no_effect, dead_code, clippy::blacklisted_name)] fn main() { let mut x = 0; let a = { x = 1; 1 } + x; diff --git a/tests/ui/excessive_precision.rs b/tests/ui/excessive_precision.rs index 88f24d27dbc..b44364d6beb 100644 --- a/tests/ui/excessive_precision.rs +++ b/tests/ui/excessive_precision.rs @@ -1,6 +1,6 @@ - -#![warn(excessive_precision)] -#![allow(print_literal)] +#![feature(tool_lints)] +#![warn(clippy::excessive_precision)] +#![allow(clippy::print_literal)] fn main() { // Consts diff --git a/tests/ui/explicit_write.rs b/tests/ui/explicit_write.rs index 71992123ceb..9d6d13c84c5 100644 --- a/tests/ui/explicit_write.rs +++ b/tests/ui/explicit_write.rs @@ -1,4 +1,6 @@ -#![warn(explicit_write)] +#![feature(tool_lints)] + +#![warn(clippy::explicit_write)] fn stdout() -> String { diff --git a/tests/ui/fallible_impl_from.rs b/tests/ui/fallible_impl_from.rs index db118919071..5e33cca59fa 100644 --- a/tests/ui/fallible_impl_from.rs +++ b/tests/ui/fallible_impl_from.rs @@ -1,4 +1,6 @@ -#![deny(fallible_impl_from)] +#![feature(tool_lints)] + +#![deny(clippy::fallible_impl_from)] // docs example struct Foo(i32); diff --git a/tests/ui/filter_methods.rs b/tests/ui/filter_methods.rs index 29230c48ea3..d7a50a58838 100644 --- a/tests/ui/filter_methods.rs +++ b/tests/ui/filter_methods.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(clippy, clippy_pedantic)] -#![allow(missing_docs_in_private_items)] +#![warn(clippy::all, clippy::pedantic)] +#![allow(clippy::missing_docs_in_private_items)] fn main() { let _: Vec<_> = vec![5; 6].into_iter() diff --git a/tests/ui/float_cmp.rs b/tests/ui/float_cmp.rs index 9dd9ea9b04d..d5b02fb706f 100644 --- a/tests/ui/float_cmp.rs +++ b/tests/ui/float_cmp.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(float_cmp)] -#![allow(unused, no_effect, unnecessary_operation, cast_lossless)] +#![warn(clippy::float_cmp)] +#![allow(unused, clippy::no_effect, clippy::unnecessary_operation, clippy::cast_lossless)] use std::ops::Add; diff --git a/tests/ui/float_cmp_const.rs b/tests/ui/float_cmp_const.rs index adf2ab70368..279400604a2 100644 --- a/tests/ui/float_cmp_const.rs +++ b/tests/ui/float_cmp_const.rs @@ -1,9 +1,9 @@ +#![feature(tool_lints)] - -#![warn(float_cmp_const)] -#![allow(float_cmp)] -#![allow(unused, no_effect, unnecessary_operation)] +#![warn(clippy::float_cmp_const)] +#![allow(clippy::float_cmp)] +#![allow(unused, clippy::no_effect, clippy::unnecessary_operation)] const ONE: f32 = 1.0; const TWO: f32 = 2.0; @@ -36,7 +36,7 @@ fn main() { ONE != ::std::f32::INFINITY; ONE == ::std::f32::NEG_INFINITY; - // no errors, but will warn float_cmp if '#![allow(float_cmp)]' above is removed + // no errors, but will warn clippy::float_cmp if '#![allow(float_cmp)]' above is removed let w = 1.1; v == w; v != w; diff --git a/tests/ui/for_loop.rs b/tests/ui/for_loop.rs index bc0c3172bf0..39eee64883c 100644 --- a/tests/ui/for_loop.rs +++ b/tests/ui/for_loop.rs @@ -1,4 +1,4 @@ - +#![feature(tool_lints)] use std::collections::*; @@ -7,7 +7,7 @@ use std::rc::Rc; static STATIC: [usize; 4] = [0, 1, 8, 16]; const CONST: [usize; 4] = [0, 1, 8, 16]; -#[warn(clippy)] +#[warn(clippy::all)] fn for_loop_over_option_and_result() { let option = Some(1); let result = option.ok_or("x not found"); @@ -27,7 +27,7 @@ fn for_loop_over_option_and_result() { println!("{}", x); } - // make sure LOOP_OVER_NEXT lint takes precedence when next() is the last call + // make sure LOOP_OVER_NEXT lint takes clippy::precedence when next() is the last call // in the chain for x in v.iter().next() { println!("{}", x); @@ -73,11 +73,11 @@ impl Unrelated { } } -#[warn(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, - explicit_counter_loop, for_kv_map)] -#[warn(unused_collect)] -#[allow(linkedlist, shadow_unrelated, unnecessary_mut_passed, cyclomatic_complexity, similar_names)] -#[allow(many_single_char_names, unused_variables)] +#[warn(clippy::needless_range_loop, clippy::explicit_iter_loop, clippy::explicit_into_iter_loop, clippy::iter_next_loop, clippy::reverse_range_loop, + clippy::explicit_counter_loop, clippy::for_kv_map)] +#[warn(clippy::unused_collect)] +#[allow(clippy::linkedlist, clippy::shadow_unrelated, clippy::unnecessary_mut_passed, clippy::cyclomatic_complexity, clippy::similar_names)] +#[allow(clippy::many_single_char_names, unused_variables)] fn main() { const MAX_LEN: usize = 42; @@ -429,7 +429,7 @@ fn main() { } } -#[allow(used_underscore_binding)] +#[allow(clippy::used_underscore_binding)] fn test_for_kv_map() { let m: HashMap = HashMap::new(); @@ -456,7 +456,7 @@ fn partition(v: &mut [T]) -> usize { const LOOP_OFFSET: usize = 5000; -#[warn(needless_range_loop)] +#[warn(clippy::needless_range_loop)] pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { // plain manual memcpy for i in 0..src.len() { @@ -542,14 +542,14 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { } } -#[warn(needless_range_loop)] +#[warn(clippy::needless_range_loop)] pub fn manual_clone(src: &[String], dst: &mut [String]) { for i in 0..src.len() { dst[i] = src[i].clone(); } } -#[warn(needless_range_loop)] +#[warn(clippy::needless_range_loop)] pub fn manual_copy_same_destination(dst: &mut [i32], d: usize, s: usize) { // Same source and destination - don't trigger lint for i in 0..dst.len() { diff --git a/tests/ui/format.rs b/tests/ui/format.rs index 783c6ea095d..8f31d92ac3c 100644 --- a/tests/ui/format.rs +++ b/tests/ui/format.rs @@ -1,6 +1,6 @@ - -#![allow(print_literal)] -#![warn(useless_format)] +#![feature(tool_lints)] +#![allow(clippy::print_literal)] +#![warn(clippy::useless_format)] struct Foo(pub String); diff --git a/tests/ui/formatting.rs b/tests/ui/formatting.rs index 20b1c1655a7..74d42f08f5a 100644 --- a/tests/ui/formatting.rs +++ b/tests/ui/formatting.rs @@ -1,11 +1,11 @@ +#![feature(tool_lints)] - -#![warn(clippy)] +#![warn(clippy::all)] #![allow(unused_variables)] #![allow(unused_assignments)] -#![allow(if_same_then_else)] -#![allow(deref_addrof)] +#![allow(clippy::if_same_then_else)] +#![allow(clippy::deref_addrof)] fn foo() -> bool { true } diff --git a/tests/ui/functions.rs b/tests/ui/functions.rs index 5688c471d86..ab5ce5b06d8 100644 --- a/tests/ui/functions.rs +++ b/tests/ui/functions.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(clippy)] +#![warn(clippy::all)] #![allow(dead_code)] #![allow(unused_unsafe)] diff --git a/tests/ui/fxhash.rs b/tests/ui/fxhash.rs index c6ed9436a51..1376b9442b6 100644 --- a/tests/ui/fxhash.rs +++ b/tests/ui/fxhash.rs @@ -1,4 +1,6 @@ -#![warn(default_hash_types)] +#![feature(tool_lints)] + +#![warn(clippy::default_hash_types)] #![feature(rustc_private)] extern crate rustc_data_structures; diff --git a/tests/ui/identity_conversion.rs b/tests/ui/identity_conversion.rs index 8f5bd12bc9f..b9ad8d06ad5 100644 --- a/tests/ui/identity_conversion.rs +++ b/tests/ui/identity_conversion.rs @@ -1,4 +1,6 @@ -#![deny(identity_conversion)] +#![feature(tool_lints)] + +#![deny(clippy::identity_conversion)] fn test_generic(val: T) -> T { let _ = T::from(val); @@ -28,7 +30,7 @@ fn main() { let _: String = "foo".into(); let _: String = From::from("foo"); let _ = String::from("foo"); - #[allow(identity_conversion)] + #[allow(clippy::identity_conversion)] { let _: String = "foo".into(); let _ = String::from("foo"); diff --git a/tests/ui/identity_op.rs b/tests/ui/identity_op.rs index 1ed9f974d43..ae8c66faa41 100644 --- a/tests/ui/identity_op.rs +++ b/tests/ui/identity_op.rs @@ -1,12 +1,12 @@ - +#![feature(tool_lints)] const ONE : i64 = 1; const NEG_ONE : i64 = -1; const ZERO : i64 = 0; -#[allow(eq_op, no_effect, unnecessary_operation, double_parens)] -#[warn(identity_op)] +#[allow(clippy::eq_op, clippy::no_effect, clippy::unnecessary_operation, clippy::double_parens)] +#[warn(clippy::identity_op)] fn main() { let x = 0; diff --git a/tests/ui/if_let_redundant_pattern_matching.rs b/tests/ui/if_let_redundant_pattern_matching.rs index 0963caa62e2..90265853f00 100644 --- a/tests/ui/if_let_redundant_pattern_matching.rs +++ b/tests/ui/if_let_redundant_pattern_matching.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(clippy)] -#![warn(if_let_redundant_pattern_matching)] +#![warn(clippy::all)] +#![warn(clippy::if_let_redundant_pattern_matching)] fn main() { diff --git a/tests/ui/if_not_else.rs b/tests/ui/if_not_else.rs index 9436af70cb8..bb16e16700b 100644 --- a/tests/ui/if_not_else.rs +++ b/tests/ui/if_not_else.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(clippy)] -#![warn(if_not_else)] +#![warn(clippy::all)] +#![warn(clippy::if_not_else)] fn bla() -> bool { unimplemented!() } diff --git a/tests/ui/impl.rs b/tests/ui/impl.rs index 9e10dbade4e..7da0e04e59e 100644 --- a/tests/ui/impl.rs +++ b/tests/ui/impl.rs @@ -1,5 +1,7 @@ +#![feature(tool_lints)] + #![allow(dead_code)] -#![warn(multiple_inherent_impl)] +#![warn(clippy::multiple_inherent_impl)] struct MyStruct; diff --git a/tests/ui/inconsistent_digit_grouping.rs b/tests/ui/inconsistent_digit_grouping.rs index ed6dc06edb1..056d8761109 100644 --- a/tests/ui/inconsistent_digit_grouping.rs +++ b/tests/ui/inconsistent_digit_grouping.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#[warn(inconsistent_digit_grouping)] +#[warn(clippy::inconsistent_digit_grouping)] #[allow(unused_variables)] fn main() { let good = (123, 1_234, 1_2345_6789, 123_f32, 1_234.12_f32, 1_234.123_4_f32, 1.123_456_7_f32); diff --git a/tests/ui/indexing_slicing.rs b/tests/ui/indexing_slicing.rs index e39dc92367c..b9f1c4a4a5d 100644 --- a/tests/ui/indexing_slicing.rs +++ b/tests/ui/indexing_slicing.rs @@ -1,7 +1,9 @@ +#![feature(tool_lints)] + #![feature(plugin)] -#![warn(indexing_slicing)] -#![warn(out_of_bounds_indexing)] -#![allow(no_effect, unnecessary_operation)] +#![warn(clippy::indexing_slicing)] +#![warn(clippy::out_of_bounds_indexing)] +#![allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { let x = [1, 2, 3, 4]; diff --git a/tests/ui/infallible_destructuring_match.rs b/tests/ui/infallible_destructuring_match.rs index 6f3d7a3ff2b..b3e2835d72f 100644 --- a/tests/ui/infallible_destructuring_match.rs +++ b/tests/ui/infallible_destructuring_match.rs @@ -1,5 +1,7 @@ +#![feature(tool_lints)] + #![feature(exhaustive_patterns, never_type)] -#![allow(let_and_return)] +#![allow(clippy::let_and_return)] enum SingleVariantEnum { Variant(i32), diff --git a/tests/ui/infinite_iter.rs b/tests/ui/infinite_iter.rs index a7841416671..44fa934aa26 100644 --- a/tests/ui/infinite_iter.rs +++ b/tests/ui/infinite_iter.rs @@ -1,11 +1,11 @@ - +#![feature(tool_lints)] use std::iter::repeat; -#[allow(trivially_copy_pass_by_ref)] +#[allow(clippy::trivially_copy_pass_by_ref)] fn square_is_lower_64(x: &u32) -> bool { x * x < 64 } -#[allow(maybe_infinite_iter)] -#[deny(infinite_iter)] +#[allow(clippy::maybe_infinite_iter)] +#[deny(clippy::infinite_iter)] fn infinite_iters() { repeat(0_u8).collect::>(); // infinite iter (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter @@ -19,7 +19,7 @@ fn infinite_iters() { (0..).next(); // iterator is not exhausted } -#[deny(maybe_infinite_iter)] +#[deny(clippy::maybe_infinite_iter)] fn potential_infinite_iters() { (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter diff --git a/tests/ui/infinite_loop.rs b/tests/ui/infinite_loop.rs index 9e801911602..9449a295e3a 100644 --- a/tests/ui/infinite_loop.rs +++ b/tests/ui/infinite_loop.rs @@ -1,4 +1,6 @@ -#![allow(trivially_copy_pass_by_ref)] +#![feature(tool_lints)] + +#![allow(clippy::trivially_copy_pass_by_ref)] fn fn_val(i: i32) -> i32 { unimplemented!() } @@ -7,7 +9,7 @@ fn fn_mutref(i: &mut i32) { unimplemented!() } fn fooi() -> i32 { unimplemented!() } fn foob() -> bool { unimplemented!() } -#[allow(many_single_char_names)] +#[allow(clippy::many_single_char_names)] fn immutable_condition() { // Should warn when all vars mentioned are immutable let y = 0; diff --git a/tests/ui/inline_fn_without_body.rs b/tests/ui/inline_fn_without_body.rs index 76e50e56780..830da6d1124 100644 --- a/tests/ui/inline_fn_without_body.rs +++ b/tests/ui/inline_fn_without_body.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(inline_fn_without_body)] -#![allow(inline_always)] +#![warn(clippy::inline_fn_without_body)] +#![allow(clippy::inline_always)] trait Foo { #[inline] diff --git a/tests/ui/int_plus_one.rs b/tests/ui/int_plus_one.rs index a9e059f4a3e..1eb0e49290f 100644 --- a/tests/ui/int_plus_one.rs +++ b/tests/ui/int_plus_one.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#[allow(no_effect, unnecessary_operation)] -#[warn(int_plus_one)] +#[allow(clippy::no_effect, clippy::unnecessary_operation)] +#[warn(clippy::int_plus_one)] fn main() { let x = 1i32; let y = 0i32; diff --git a/tests/ui/invalid_upcast_comparisons.rs b/tests/ui/invalid_upcast_comparisons.rs index 5bf0bfdcb98..0a700518f8f 100644 --- a/tests/ui/invalid_upcast_comparisons.rs +++ b/tests/ui/invalid_upcast_comparisons.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(invalid_upcast_comparisons)] -#![allow(unused, eq_op, no_effect, unnecessary_operation, cast_lossless)] +#![warn(clippy::invalid_upcast_comparisons)] +#![allow(unused, clippy::eq_op, clippy::no_effect, clippy::unnecessary_operation, clippy::cast_lossless)] fn mk_value() -> T { unimplemented!() } diff --git a/tests/ui/issue_2356.rs b/tests/ui/issue_2356.rs index d4cefb0f1e3..398e0d1d1f0 100644 --- a/tests/ui/issue_2356.rs +++ b/tests/ui/issue_2356.rs @@ -1,4 +1,6 @@ -#![deny(while_let_on_iterator)] +#![feature(tool_lints)] + +#![deny(clippy::while_let_on_iterator)] use std::iter::Iterator; diff --git a/tests/ui/item_after_statement.rs b/tests/ui/item_after_statement.rs index 710a1adca56..9626a59ed02 100644 --- a/tests/ui/item_after_statement.rs +++ b/tests/ui/item_after_statement.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![warn(items_after_statements)] +#![warn(clippy::items_after_statements)] fn ok() { fn foo() { println!("foo"); } diff --git a/tests/ui/large_digit_groups.rs b/tests/ui/large_digit_groups.rs index 5d0fb11dbea..af569ea7566 100644 --- a/tests/ui/large_digit_groups.rs +++ b/tests/ui/large_digit_groups.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#[warn(large_digit_groups)] +#[warn(clippy::large_digit_groups)] #[allow(unused_variables)] fn main() { let good = (0b1011_i64, 0o1_234_u32, 0x1_234_567, 1_2345_6789, 1234_f32, 1_234.12_f32, 1_234.123_f32, 1.123_4_f32); diff --git a/tests/ui/large_enum_variant.rs b/tests/ui/large_enum_variant.rs index aaf3e2924b3..cd1772ad1d1 100644 --- a/tests/ui/large_enum_variant.rs +++ b/tests/ui/large_enum_variant.rs @@ -1,9 +1,9 @@ - +#![feature(tool_lints)] #![allow(dead_code)] #![allow(unused_variables)] -#![warn(large_enum_variant)] +#![warn(clippy::large_enum_variant)] enum LargeEnum { A(i32), diff --git a/tests/ui/len_zero.rs b/tests/ui/len_zero.rs index 2e71c2761fa..b188db5186e 100644 --- a/tests/ui/len_zero.rs +++ b/tests/ui/len_zero.rs @@ -1,4 +1,6 @@ -#![warn(len_without_is_empty, len_zero)] +#![feature(tool_lints)] + +#![warn(clippy::len_without_is_empty, clippy::len_zero)] #![allow(dead_code, unused)] pub struct PubOne; @@ -19,7 +21,7 @@ impl PubOne { // Identical to PubOne, but with an allow attribute on the impl complaining len pub struct PubAllowed; -#[allow(len_without_is_empty)] +#[allow(clippy::len_without_is_empty)] impl PubAllowed { pub fn len(self: &Self) -> isize { 1 diff --git a/tests/ui/let_if_seq.rs b/tests/ui/let_if_seq.rs index 564a67d2c8e..102b72f3e25 100644 --- a/tests/ui/let_if_seq.rs +++ b/tests/ui/let_if_seq.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![allow(unused_variables, unused_assignments, similar_names, blacklisted_name)] -#![warn(useless_let_if_seq)] +#![allow(unused_variables, unused_assignments, clippy::similar_names, clippy::blacklisted_name)] +#![warn(clippy::useless_let_if_seq)] fn f() -> bool { true } fn g(x: i32) -> i32 { x + 1 } diff --git a/tests/ui/let_return.rs b/tests/ui/let_return.rs index 1083603b2d6..9b584d6e293 100644 --- a/tests/ui/let_return.rs +++ b/tests/ui/let_return.rs @@ -1,8 +1,8 @@ - +#![feature(tool_lints)] #![allow(unused)] -#![warn(let_and_return)] +#![warn(clippy::let_and_return)] fn test() -> i32 { let _y = 0; // no warning @@ -37,7 +37,7 @@ fn test_nowarn_3() -> (i32, i32) { } fn test_nowarn_4() -> i32 { - // this should technically warn, but not b/c of let_and_return, but b/c of useless type + // this should technically warn, but not b/c of clippy::let_and_return, but b/c of useless type let x: i32 = 5; x } diff --git a/tests/ui/let_unit.rs b/tests/ui/let_unit.rs index 032dc85f2cd..187ff9d1358 100644 --- a/tests/ui/let_unit.rs +++ b/tests/ui/let_unit.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(let_unit_value)] +#![warn(clippy::let_unit_value)] #![allow(unused_variables)] macro_rules! let_and_return { diff --git a/tests/ui/lifetimes.rs b/tests/ui/lifetimes.rs index 0322d42e81f..aa5640f4e22 100644 --- a/tests/ui/lifetimes.rs +++ b/tests/ui/lifetimes.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(needless_lifetimes, extra_unused_lifetimes)] -#![allow(dead_code, needless_pass_by_value, trivially_copy_pass_by_ref)] +#![warn(clippy::needless_lifetimes, clippy::extra_unused_lifetimes)] +#![allow(dead_code, clippy::needless_pass_by_value, clippy::trivially_copy_pass_by_ref)] fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) { } diff --git a/tests/ui/literals.rs b/tests/ui/literals.rs index 581fbbb70c9..d45da257ad4 100644 --- a/tests/ui/literals.rs +++ b/tests/ui/literals.rs @@ -1,6 +1,8 @@ -#![warn(mixed_case_hex_literals)] -#![warn(unseparated_literal_suffix)] -#![warn(zero_prefixed_literal)] +#![feature(tool_lints)] + +#![warn(clippy::mixed_case_hex_literals)] +#![warn(clippy::unseparated_literal_suffix)] +#![warn(clippy::zero_prefixed_literal)] #![allow(dead_code)] fn main() { diff --git a/tests/ui/map_clone.rs b/tests/ui/map_clone.rs index f11d21d2dfa..90c95be2c1c 100644 --- a/tests/ui/map_clone.rs +++ b/tests/ui/map_clone.rs @@ -1,9 +1,9 @@ +#![feature(tool_lints)] +#![warn(clippy::map_clone)] -#![warn(map_clone)] - -#![allow(clone_on_copy, unused)] +#![allow(clippy::clone_on_copy, unused)] use std::ops::Deref; diff --git a/tests/ui/matches.rs b/tests/ui/matches.rs index e339aeb9c6a..92befb25a7e 100644 --- a/tests/ui/matches.rs +++ b/tests/ui/matches.rs @@ -1,10 +1,10 @@ - +#![feature(tool_lints)] #![feature(exclusive_range_pattern)] -#![warn(clippy)] -#![allow(unused, if_let_redundant_pattern_matching)] -#![warn(single_match_else, match_same_arms)] +#![warn(clippy::all)] +#![allow(unused, clippy::if_let_redundant_pattern_matching)] +#![warn(clippy::single_match_else, clippy::match_same_arms)] enum ExprNode { ExprAddrOf, diff --git a/tests/ui/mem_forget.rs b/tests/ui/mem_forget.rs index 991a402e207..96d333a7170 100644 --- a/tests/ui/mem_forget.rs +++ b/tests/ui/mem_forget.rs @@ -1,4 +1,4 @@ - +#![feature(tool_lints)] @@ -8,8 +8,8 @@ use std::rc::Rc; use std::mem::forget as forgetSomething; use std::mem as memstuff; -#[warn(mem_forget)] -#[allow(forget_copy)] +#[warn(clippy::mem_forget)] +#[allow(clippy::forget_copy)] fn main() { let five: i32 = 5; forgetSomething(five); diff --git a/tests/ui/methods.rs b/tests/ui/methods.rs index 220b08caaf7..37f4cb2f71e 100644 --- a/tests/ui/methods.rs +++ b/tests/ui/methods.rs @@ -1,10 +1,10 @@ - +#![feature(tool_lints)] #![feature(const_fn)] -#![warn(clippy, clippy_pedantic, option_unwrap_used)] -#![allow(blacklisted_name, unused, print_stdout, non_ascii_literal, new_without_default, - new_without_default_derive, missing_docs_in_private_items, needless_pass_by_value, - default_trait_access, use_self)] +#![warn(clippy::all, clippy::pedantic, clippy::option_unwrap_used)] +#![allow(clippy::blacklisted_name, unused, clippy::print_stdout, clippy::non_ascii_literal, clippy::new_without_default, + clippy::new_without_default_derive, clippy::missing_docs_in_private_items, clippy::needless_pass_by_value, + clippy::default_trait_access, clippy::use_self)] use std::collections::BTreeMap; use std::collections::HashMap; @@ -42,7 +42,7 @@ struct Lt<'a> { impl<'a> Lt<'a> { // The lifetime is different, but that’s irrelevant, see #734 - #[allow(needless_lifetimes)] + #[allow(clippy::needless_lifetimes)] pub fn new<'b>(s: &'b str) -> Lt<'b> { unimplemented!() } } @@ -438,7 +438,7 @@ fn iter_skip_next() { let _ = foo.filter().skip(42).next(); } -#[allow(similar_names)] +#[allow(clippy::similar_names)] fn main() { let opt = Some(0); let _ = opt.unwrap(); diff --git a/tests/ui/min_max.rs b/tests/ui/min_max.rs index 9b29f73b2ac..9866933f9fe 100644 --- a/tests/ui/min_max.rs +++ b/tests/ui/min_max.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(clippy)] +#![warn(clippy::all)] use std::cmp::{min, max}; use std::cmp::min as my_min; diff --git a/tests/ui/missing-doc.rs b/tests/ui/missing-doc.rs index cbd6439d47e..6968adb312b 100644 --- a/tests/ui/missing-doc.rs +++ b/tests/ui/missing-doc.rs @@ -1,3 +1,5 @@ +#![feature(tool_lints)] + /* This file incorporates work covered by the following copyright and * permission notice: * Copyright 2013 The Rust Project Developers. See the COPYRIGHT @@ -13,7 +15,7 @@ -#![warn(missing_docs_in_private_items)] +#![warn(clippy::missing_docs_in_private_items)] // When denying at the crate level, be sure to not get random warnings from the // injected intrinsics by the compiler. @@ -36,7 +38,7 @@ pub struct PubFoo { b: isize, } -#[allow(missing_docs_in_private_items)] +#[allow(clippy::missing_docs_in_private_items)] pub struct PubFoo2 { pub a: isize, pub c: isize, @@ -49,7 +51,7 @@ pub mod pub_module_no_dox {} pub fn foo() {} pub fn foo2() {} fn foo3() {} -#[allow(missing_docs_in_private_items)] pub fn foo4() {} +#[allow(clippy::missing_docs_in_private_items)] pub fn foo4() {} /// dox pub trait A { @@ -59,7 +61,7 @@ pub trait A { fn foo_with_impl(&self) {} } -#[allow(missing_docs_in_private_items)] +#[allow(clippy::missing_docs_in_private_items)] trait B { fn foo(&self); fn foo_with_impl(&self) {} @@ -70,7 +72,7 @@ pub trait C { fn foo_with_impl(&self) {} } -#[allow(missing_docs_in_private_items)] +#[allow(clippy::missing_docs_in_private_items)] pub trait D { fn dummy(&self) { } } @@ -98,10 +100,10 @@ impl PubFoo { /// dox pub fn foo1() {} fn foo2() {} - #[allow(missing_docs_in_private_items)] pub fn foo3() {} + #[allow(clippy::missing_docs_in_private_items)] pub fn foo3() {} } -#[allow(missing_docs_in_private_items)] +#[allow(clippy::missing_docs_in_private_items)] trait F { fn a(); fn b(&self); @@ -146,7 +148,7 @@ pub enum PubBaz2 { }, } -#[allow(missing_docs_in_private_items)] +#[allow(clippy::missing_docs_in_private_items)] pub enum PubBaz3 { PubBaz3A { b: isize @@ -160,7 +162,7 @@ pub fn baz() {} const FOO: u32 = 0; /// dox pub const FOO1: u32 = 0; -#[allow(missing_docs_in_private_items)] +#[allow(clippy::missing_docs_in_private_items)] pub const FOO2: u32 = 0; #[doc(hidden)] pub const FOO3: u32 = 0; @@ -170,7 +172,7 @@ pub const FOO4: u32 = 0; static BAR: u32 = 0; /// dox pub static BAR1: u32 = 0; -#[allow(missing_docs_in_private_items)] +#[allow(clippy::missing_docs_in_private_items)] pub static BAR2: u32 = 0; #[doc(hidden)] pub static BAR3: u32 = 0; diff --git a/tests/ui/missing_inline.rs b/tests/ui/missing_inline.rs index 38f59033071..7fbb01c6d2b 100644 --- a/tests/ui/missing_inline.rs +++ b/tests/ui/missing_inline.rs @@ -1,3 +1,5 @@ +#![feature(tool_lints)] + /* This file incorporates work covered by the following copyright and * permission notice: * Copyright 2013 The Rust Project Developers. See the COPYRIGHT @@ -10,7 +12,7 @@ * option. This file may not be copied, modified, or distributed * except according to those terms. */ -#![warn(missing_inline_in_public_items)] +#![warn(clippy::missing_inline_in_public_items)] #![crate_type = "dylib"] // When denying at the crate level, be sure to not get random warnings from the // injected intrinsics by the compiler. @@ -32,7 +34,7 @@ pub fn pub_foo() {} // missing #[inline] #[inline] pub fn pub_foo_inline() {} // ok #[inline(always)] pub fn pub_foo_inline_always() {} // ok -#[allow(missing_inline_in_public_items)] +#[allow(clippy::missing_inline_in_public_items)] pub fn pub_foo_no_inline() {} trait Bar { diff --git a/tests/ui/module_inception.rs b/tests/ui/module_inception.rs index 77bd446c569..b6917020ea2 100644 --- a/tests/ui/module_inception.rs +++ b/tests/ui/module_inception.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![warn(module_inception)] +#![warn(clippy::module_inception)] mod foo { mod bar { @@ -16,7 +16,7 @@ mod foo { // No warning. See . mod bar { - #[allow(module_inception)] + #[allow(clippy::module_inception)] mod bar { } } diff --git a/tests/ui/modulo_one.rs b/tests/ui/modulo_one.rs index 847ea1d9ab6..7dcec04baf9 100644 --- a/tests/ui/modulo_one.rs +++ b/tests/ui/modulo_one.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(modulo_one)] -#![allow(no_effect, unnecessary_operation)] +#![warn(clippy::modulo_one)] +#![allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { 10 % 1; diff --git a/tests/ui/mut_from_ref.rs b/tests/ui/mut_from_ref.rs index 3fc464083c4..b75fa92f098 100644 --- a/tests/ui/mut_from_ref.rs +++ b/tests/ui/mut_from_ref.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![allow(unused, trivially_copy_pass_by_ref)] -#![warn(mut_from_ref)] +#![allow(unused, clippy::trivially_copy_pass_by_ref)] +#![warn(clippy::mut_from_ref)] struct Foo; diff --git a/tests/ui/mut_mut.rs b/tests/ui/mut_mut.rs index 658ae18466f..4656d27648f 100644 --- a/tests/ui/mut_mut.rs +++ b/tests/ui/mut_mut.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![allow(unused, no_effect, unnecessary_operation)] -#![warn(mut_mut)] +#![allow(unused, clippy::no_effect, clippy::unnecessary_operation)] +#![warn(clippy::mut_mut)] diff --git a/tests/ui/mut_reference.rs b/tests/ui/mut_reference.rs index 34185f6a9c2..38b0e25e07c 100644 --- a/tests/ui/mut_reference.rs +++ b/tests/ui/mut_reference.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![allow(unused_variables, trivially_copy_pass_by_ref)] +#![allow(unused_variables, clippy::trivially_copy_pass_by_ref)] fn takes_an_immutable_reference(a: &i32) {} fn takes_a_mutable_reference(a: &mut i32) {} @@ -16,7 +16,7 @@ impl MyStruct { } } -#[warn(unnecessary_mut_passed)] +#[warn(clippy::unnecessary_mut_passed)] fn main() { // Functions takes_an_immutable_reference(&mut 42); diff --git a/tests/ui/mutex_atomic.rs b/tests/ui/mutex_atomic.rs index 96502738456..3eefbb97ab8 100644 --- a/tests/ui/mutex_atomic.rs +++ b/tests/ui/mutex_atomic.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(clippy)] -#![warn(mutex_integer)] +#![warn(clippy::all)] +#![warn(clippy::mutex_integer)] fn main() { use std::sync::Mutex; diff --git a/tests/ui/needless_bool.rs b/tests/ui/needless_bool.rs index 1213539c827..4e6f65ed0dd 100644 --- a/tests/ui/needless_bool.rs +++ b/tests/ui/needless_bool.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] +#![warn(clippy::needless_bool)] -#![warn(needless_bool)] - -#[allow(if_same_then_else)] +#[allow(clippy::if_same_then_else)] fn main() { let x = true; let y = false; @@ -20,32 +20,32 @@ fn main() { bool_ret6(x, x); } -#[allow(if_same_then_else, needless_return)] +#[allow(clippy::if_same_then_else, clippy::needless_return)] fn bool_ret(x: bool) -> bool { if x { return true } else { return true }; } -#[allow(if_same_then_else, needless_return)] +#[allow(clippy::if_same_then_else, clippy::needless_return)] fn bool_ret2(x: bool) -> bool { if x { return false } else { return false }; } -#[allow(needless_return)] +#[allow(clippy::needless_return)] fn bool_ret3(x: bool) -> bool { if x { return true } else { return false }; } -#[allow(needless_return)] +#[allow(clippy::needless_return)] fn bool_ret5(x: bool, y: bool) -> bool { if x && y { return true } else { return false }; } -#[allow(needless_return)] +#[allow(clippy::needless_return)] fn bool_ret4(x: bool) -> bool { if x { return false } else { return true }; } -#[allow(needless_return)] +#[allow(clippy::needless_return)] fn bool_ret6(x: bool, y: bool) -> bool { if x && y { return false } else { return true }; } diff --git a/tests/ui/needless_borrow.rs b/tests/ui/needless_borrow.rs index b086f0214a9..61384c43fa9 100644 --- a/tests/ui/needless_borrow.rs +++ b/tests/ui/needless_borrow.rs @@ -1,11 +1,13 @@ +#![feature(tool_lints)] + use std::borrow::Cow; -#[allow(trivially_copy_pass_by_ref)] +#[allow(clippy::trivially_copy_pass_by_ref)] fn x(y: &i32) -> i32 { *y } -#[warn(clippy, needless_borrow)] +#[warn(clippy::all, clippy::needless_borrow)] #[allow(unused_variables)] fn main() { let a = 5; @@ -42,7 +44,7 @@ trait Trait {} impl<'a> Trait for &'a str {} fn h(_: &Trait) {} -#[warn(needless_borrow)] +#[warn(clippy::needless_borrow)] #[allow(dead_code)] fn issue_1432() { let mut v = Vec::::new(); diff --git a/tests/ui/needless_borrowed_ref.rs b/tests/ui/needless_borrowed_ref.rs index 75ffa211180..000ecd32da4 100644 --- a/tests/ui/needless_borrowed_ref.rs +++ b/tests/ui/needless_borrowed_ref.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#[warn(needless_borrowed_reference)] +#[warn(clippy::needless_borrowed_reference)] #[allow(unused_variables)] fn main() { let mut v = Vec::::new(); diff --git a/tests/ui/needless_continue.rs b/tests/ui/needless_continue.rs index 3574b0fb3fd..4fe523e48de 100644 --- a/tests/ui/needless_continue.rs +++ b/tests/ui/needless_continue.rs @@ -1,4 +1,4 @@ - +#![feature(tool_lints)] macro_rules! zero { @@ -9,7 +9,7 @@ macro_rules! nonzero { ($x:expr) => (!zero!($x)); } -#[warn(needless_continue)] +#[warn(clippy::needless_continue)] fn main() { let mut i = 1; while i < 10 { diff --git a/tests/ui/needless_pass_by_value.rs b/tests/ui/needless_pass_by_value.rs index 322df0b8798..783386fab01 100644 --- a/tests/ui/needless_pass_by_value.rs +++ b/tests/ui/needless_pass_by_value.rs @@ -1,5 +1,7 @@ -#![warn(needless_pass_by_value)] -#![allow(dead_code, single_match, if_let_redundant_pattern_matching, many_single_char_names, option_option)] +#![feature(tool_lints)] + +#![warn(clippy::needless_pass_by_value)] +#![allow(dead_code, clippy::single_match, clippy::if_let_redundant_pattern_matching, clippy::many_single_char_names, clippy::option_option)] use std::borrow::Borrow; use std::convert::AsRef; diff --git a/tests/ui/needless_pass_by_value_proc_macro.rs b/tests/ui/needless_pass_by_value_proc_macro.rs index 652e11fee9d..6b1305fa2d8 100644 --- a/tests/ui/needless_pass_by_value_proc_macro.rs +++ b/tests/ui/needless_pass_by_value_proc_macro.rs @@ -1,7 +1,7 @@ - +#![feature(tool_lints)] #![crate_type = "proc-macro"] -#![warn(needless_pass_by_value)] +#![warn(clippy::needless_pass_by_value)] extern crate proc_macro; diff --git a/tests/ui/needless_return.rs b/tests/ui/needless_return.rs index 4739ded7b7e..a834563eca3 100644 --- a/tests/ui/needless_return.rs +++ b/tests/ui/needless_return.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(needless_return)] +#![warn(clippy::needless_return)] fn test_end_of_fn() -> bool { if true { diff --git a/tests/ui/needless_update.rs b/tests/ui/needless_update.rs index 35d5730dda1..675c60e2477 100644 --- a/tests/ui/needless_update.rs +++ b/tests/ui/needless_update.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(needless_update)] -#![allow(no_effect)] +#![warn(clippy::needless_update)] +#![allow(clippy::no_effect)] struct S { pub a: i32, diff --git a/tests/ui/neg_cmp_op_on_partial_ord.rs b/tests/ui/neg_cmp_op_on_partial_ord.rs index e739908bc28..3a472bf6995 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.rs +++ b/tests/ui/neg_cmp_op_on_partial_ord.rs @@ -1,10 +1,12 @@ +#![feature(tool_lints)] + //! This test case utilizes `f64` an easy example for `PartialOrd` only types //! but the lint itself actually validates any expression where the left //! operand implements `PartialOrd` but not `Ord`. use std::cmp::Ordering; -#[warn(neg_cmp_op_on_partial_ord)] +#[warn(clippy::neg_cmp_op_on_partial_ord)] fn main() { let a_value = 1.0; diff --git a/tests/ui/neg_multiply.rs b/tests/ui/neg_multiply.rs index 367d2d5edfb..b1a1879a3fc 100644 --- a/tests/ui/neg_multiply.rs +++ b/tests/ui/neg_multiply.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(neg_multiply)] -#![allow(no_effect, unnecessary_operation)] +#![warn(clippy::neg_multiply)] +#![allow(clippy::no_effect, clippy::unnecessary_operation)] use std::ops::Mul; diff --git a/tests/ui/never_loop.rs b/tests/ui/never_loop.rs index 20500126662..bb6d76b06cd 100644 --- a/tests/ui/never_loop.rs +++ b/tests/ui/never_loop.rs @@ -1,10 +1,10 @@ +#![feature(tool_lints)] - -#![allow(single_match, unused_assignments, unused_variables, while_immutable_condition)] +#![allow(clippy::single_match, unused_assignments, unused_variables, clippy::while_immutable_condition)] fn test1() { let mut x = 0; - loop { // never_loop + loop { // clippy::never_loop x += 1; if x == 1 { return diff --git a/tests/ui/new_without_default.rs b/tests/ui/new_without_default.rs index c06c9f9e962..bf63e9336e5 100644 --- a/tests/ui/new_without_default.rs +++ b/tests/ui/new_without_default.rs @@ -1,8 +1,10 @@ +#![feature(tool_lints)] + #![feature(const_fn)] #![allow(dead_code)] -#![warn(new_without_default, new_without_default_derive)] +#![warn(clippy::new_without_default, clippy::new_without_default_derive)] pub struct Foo; diff --git a/tests/ui/no_effect.rs b/tests/ui/no_effect.rs index 54028cd8b2b..2913ecdbf59 100644 --- a/tests/ui/no_effect.rs +++ b/tests/ui/no_effect.rs @@ -1,11 +1,13 @@ +#![feature(tool_lints)] + #![feature(box_syntax)] -#![warn(no_effect, unnecessary_operation)] +#![warn(clippy::no_effect, clippy::unnecessary_operation)] #![allow(dead_code)] #![allow(path_statements)] -#![allow(deref_addrof)] -#![allow(redundant_field_names)] +#![allow(clippy::deref_addrof)] +#![allow(clippy::redundant_field_names)] #![feature(untagged_unions)] struct Unit; diff --git a/tests/ui/non_copy_const.rs b/tests/ui/non_copy_const.rs index d7391577d23..4e086333b0c 100644 --- a/tests/ui/non_copy_const.rs +++ b/tests/ui/non_copy_const.rs @@ -1,5 +1,7 @@ +#![feature(tool_lints)] + #![feature(const_string_new, const_vec_new)] -#![allow(ref_in_deref, dead_code)] +#![allow(clippy::ref_in_deref, dead_code)] use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering}; use std::cell::Cell; @@ -30,7 +32,7 @@ const NO_ANN: &Display = &70; static STATIC_TUPLE: (AtomicUsize, String) = (ATOMIC, STRING); //^ there should be no lints on this line -#[allow(declare_interior_mutable_const)] +#[allow(clippy::declare_interior_mutable_const)] const ONCE_INIT: Once = Once::new(); trait Trait: Copy { diff --git a/tests/ui/non_expressive_names.rs b/tests/ui/non_expressive_names.rs index 7149bf8f3e7..7b5db015d77 100644 --- a/tests/ui/non_expressive_names.rs +++ b/tests/ui/non_expressive_names.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(clippy,similar_names)] -#![allow(unused, println_empty_string)] +#![warn(clippy::all,clippy::similar_names)] +#![allow(unused, clippy::println_empty_string)] struct Foo { diff --git a/tests/ui/ok_if_let.rs b/tests/ui/ok_if_let.rs index fdc01bcc7bc..46d85bb9cd0 100644 --- a/tests/ui/ok_if_let.rs +++ b/tests/ui/ok_if_let.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(if_let_some_result)] +#![warn(clippy::if_let_some_result)] fn str_to_int(x: &str) -> i32 { if let Some(y) = x.parse().ok() { diff --git a/tests/ui/op_ref.rs b/tests/ui/op_ref.rs index 9eb697571b6..a85a2c8bb51 100644 --- a/tests/ui/op_ref.rs +++ b/tests/ui/op_ref.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![allow(unused_variables, blacklisted_name)] +#![allow(unused_variables, clippy::blacklisted_name)] use std::collections::HashSet; diff --git a/tests/ui/open_options.rs b/tests/ui/open_options.rs index 514808d41f1..38b3dd7e49d 100644 --- a/tests/ui/open_options.rs +++ b/tests/ui/open_options.rs @@ -1,9 +1,9 @@ - +#![feature(tool_lints)] use std::fs::OpenOptions; #[allow(unused_must_use)] -#[warn(nonsensical_open_options)] +#[warn(clippy::nonsensical_open_options)] fn main() { OpenOptions::new().read(true).truncate(true).open("foo.txt"); OpenOptions::new().append(true).truncate(true).open("foo.txt"); diff --git a/tests/ui/option_map_unit_fn.rs b/tests/ui/option_map_unit_fn.rs index 06531e29032..e86cc99c522 100644 --- a/tests/ui/option_map_unit_fn.rs +++ b/tests/ui/option_map_unit_fn.rs @@ -1,4 +1,6 @@ -#![warn(option_map_unit_fn)] +#![feature(tool_lints)] + +#![warn(clippy::option_map_unit_fn)] #![allow(unused)] fn do_nothing(_: T) {} diff --git a/tests/ui/overflow_check_conditional.rs b/tests/ui/overflow_check_conditional.rs index 889c339c8fd..5c3cc5b08a9 100644 --- a/tests/ui/overflow_check_conditional.rs +++ b/tests/ui/overflow_check_conditional.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![allow(many_single_char_names)] -#![warn(overflow_check_conditional)] +#![allow(clippy::many_single_char_names)] +#![warn(clippy::overflow_check_conditional)] fn main() { let a: u32 = 1; diff --git a/tests/ui/panic_unimplemented.rs b/tests/ui/panic_unimplemented.rs index 33050633f7f..693dc921be3 100644 --- a/tests/ui/panic_unimplemented.rs +++ b/tests/ui/panic_unimplemented.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(panic_params, unimplemented)] +#![warn(clippy::panic_params, clippy::unimplemented)] fn missing() { if true { diff --git a/tests/ui/patterns.rs b/tests/ui/patterns.rs index 65e319e2f88..70f86afbacb 100644 --- a/tests/ui/patterns.rs +++ b/tests/ui/patterns.rs @@ -1,7 +1,7 @@ - +#![feature(tool_lints)] #![allow(unused)] -#![warn(clippy)] +#![warn(clippy::all)] fn main() { let v = Some(true); diff --git a/tests/ui/precedence.rs b/tests/ui/precedence.rs index aacd90cdf92..95476dd4f51 100644 --- a/tests/ui/precedence.rs +++ b/tests/ui/precedence.rs @@ -1,9 +1,9 @@ +#![feature(tool_lints)] - -#[warn(precedence)] -#[allow(identity_op)] -#[allow(eq_op)] +#[warn(clippy::precedence)] +#[allow(clippy::identity_op)] +#[allow(clippy::eq_op)] macro_rules! trip { ($a:expr) => { diff --git a/tests/ui/print.rs b/tests/ui/print.rs index 8719a691d43..cee3e700036 100644 --- a/tests/ui/print.rs +++ b/tests/ui/print.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![allow(print_literal, write_literal)] -#![warn(print_stdout, use_debug)] +#![allow(clippy::print_literal, clippy::write_literal)] +#![warn(clippy::print_stdout, clippy::use_debug)] use std::fmt::{Debug, Display, Formatter, Result}; diff --git a/tests/ui/print_literal.rs b/tests/ui/print_literal.rs index 620349bab33..46b91d40f8c 100644 --- a/tests/ui/print_literal.rs +++ b/tests/ui/print_literal.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![warn(print_literal)] +#![warn(clippy::print_literal)] fn main() { // these should be fine diff --git a/tests/ui/print_with_newline.rs b/tests/ui/print_with_newline.rs index 906fa987d17..5efee5abfc8 100644 --- a/tests/ui/print_with_newline.rs +++ b/tests/ui/print_with_newline.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![allow(print_literal)] -#![warn(print_with_newline)] +#![allow(clippy::print_literal)] +#![warn(clippy::print_with_newline)] fn main() { print!("Hello\n"); diff --git a/tests/ui/ptr_arg.rs b/tests/ui/ptr_arg.rs index ce572be7ad8..e76221355ae 100644 --- a/tests/ui/ptr_arg.rs +++ b/tests/ui/ptr_arg.rs @@ -1,5 +1,7 @@ -#![allow(unused, many_single_char_names)] -#![warn(ptr_arg)] +#![feature(tool_lints)] + +#![allow(unused, clippy::many_single_char_names)] +#![warn(clippy::ptr_arg)] use std::borrow::Cow; diff --git a/tests/ui/range.rs b/tests/ui/range.rs index 7291fd5d5d3..df3ce12689b 100644 --- a/tests/ui/range.rs +++ b/tests/ui/range.rs @@ -1,11 +1,11 @@ - +#![feature(tool_lints)] struct NotARange; impl NotARange { fn step_by(&self, _: u32) {} } -#[warn(iterator_step_by_zero, range_zip_with_len)] +#[warn(clippy::iterator_step_by_zero, clippy::range_zip_with_len)] fn main() { let _ = (0..1).step_by(0); // No warning for non-zero step diff --git a/tests/ui/range_plus_minus_one.rs b/tests/ui/range_plus_minus_one.rs index 31574a4aeed..12a1312de36 100644 --- a/tests/ui/range_plus_minus_one.rs +++ b/tests/ui/range_plus_minus_one.rs @@ -1,8 +1,10 @@ +#![feature(tool_lints)] + fn f() -> usize { 42 } -#[warn(range_plus_one)] +#[warn(clippy::range_plus_one)] fn main() { for _ in 0..2 { } for _ in 0..=2 { } diff --git a/tests/ui/redundant_closure_call.rs b/tests/ui/redundant_closure_call.rs index ab3897bc315..b09ed9a3574 100644 --- a/tests/ui/redundant_closure_call.rs +++ b/tests/ui/redundant_closure_call.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(redundant_closure_call)] +#![warn(clippy::redundant_closure_call)] fn main() { let a = (|| 42)(); diff --git a/tests/ui/redundant_field_names.rs b/tests/ui/redundant_field_names.rs index dc8548754d2..b379aa661cb 100644 --- a/tests/ui/redundant_field_names.rs +++ b/tests/ui/redundant_field_names.rs @@ -1,4 +1,6 @@ -#![warn(redundant_field_names)] +#![feature(tool_lints)] + +#![warn(clippy::redundant_field_names)] #![allow(unused_variables)] #![feature(inclusive_range, inclusive_range_fields, inclusive_range_methods)] diff --git a/tests/ui/reference.rs b/tests/ui/reference.rs index 0bd000082e8..97a0030a99a 100644 --- a/tests/ui/reference.rs +++ b/tests/ui/reference.rs @@ -1,4 +1,4 @@ - +#![feature(tool_lints)] fn get_number() -> usize { @@ -9,9 +9,9 @@ fn get_reference(n : &usize) -> &usize { n } -#[allow(many_single_char_names, double_parens)] +#[allow(clippy::many_single_char_names, clippy::double_parens)] #[allow(unused_variables)] -#[warn(deref_addrof)] +#[warn(clippy::deref_addrof)] fn main() { let a = 10; let aref = &a; @@ -38,7 +38,7 @@ fn main() { let b = **&aref; //This produces a suggestion of 'let b = *&a;' which - //will trigger the 'deref_addrof' lint again + //will trigger the 'clippy::deref_addrof' lint again let b = **&&a; { @@ -48,7 +48,7 @@ fn main() { { //This produces a suggestion of 'let y = *&mut x' which - //will trigger the 'deref_addrof' lint again + //will trigger the 'clippy::deref_addrof' lint again let mut x = 10; let y = **&mut &mut x; } diff --git a/tests/ui/regex.rs b/tests/ui/regex.rs index b80aaa2df32..e3837e104f4 100644 --- a/tests/ui/regex.rs +++ b/tests/ui/regex.rs @@ -1,8 +1,8 @@ - +#![feature(tool_lints)] #![allow(unused)] -#![warn(invalid_regex, trivial_regex, regex_macro)] +#![warn(clippy::invalid_regex, clippy::trivial_regex, clippy::regex_macro)] extern crate regex; diff --git a/tests/ui/replace_consts.rs b/tests/ui/replace_consts.rs index 71d4ea98e07..8420b368d3d 100644 --- a/tests/ui/replace_consts.rs +++ b/tests/ui/replace_consts.rs @@ -1,6 +1,8 @@ +#![feature(tool_lints)] + #![feature(integer_atomics)] -#![allow(blacklisted_name)] -#![deny(replace_consts)] +#![allow(clippy::blacklisted_name)] +#![deny(clippy::replace_consts)] use std::sync::atomic::*; use std::sync::{ONCE_INIT, Once}; diff --git a/tests/ui/result_map_unit_fn.rs b/tests/ui/result_map_unit_fn.rs index dd163439d78..8cac6a9c827 100644 --- a/tests/ui/result_map_unit_fn.rs +++ b/tests/ui/result_map_unit_fn.rs @@ -1,5 +1,7 @@ +#![feature(tool_lints)] + #![feature(never_type)] -#![warn(result_map_unit_fn)] +#![warn(clippy::result_map_unit_fn)] #![allow(unused)] fn do_nothing(_: T) {} diff --git a/tests/ui/serde.rs b/tests/ui/serde.rs index 792ebc9b0ea..65c2c344da7 100644 --- a/tests/ui/serde.rs +++ b/tests/ui/serde.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![warn(serde_api_misuse)] +#![warn(clippy::serde_api_misuse)] #![allow(dead_code)] extern crate serde; diff --git a/tests/ui/shadow.rs b/tests/ui/shadow.rs index 79c1030d48b..c73acf5c5dd 100644 --- a/tests/ui/shadow.rs +++ b/tests/ui/shadow.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(clippy, clippy_pedantic, shadow_same, shadow_reuse, shadow_unrelated)] -#![allow(unused_parens, unused_variables, missing_docs_in_private_items)] +#![warn(clippy::all, clippy::pedantic, clippy::shadow_same, clippy::shadow_reuse, clippy::shadow_unrelated)] +#![allow(unused_parens, unused_variables, clippy::missing_docs_in_private_items)] fn id(x: T) -> T { x } diff --git a/tests/ui/short_circuit_statement.rs b/tests/ui/short_circuit_statement.rs index 0f5773623be..e9cb8e4ad8c 100644 --- a/tests/ui/short_circuit_statement.rs +++ b/tests/ui/short_circuit_statement.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(short_circuit_statement)] +#![warn(clippy::short_circuit_statement)] fn main() { f() && g(); diff --git a/tests/ui/single_char_pattern.rs b/tests/ui/single_char_pattern.rs index 577a0e27090..147f974b999 100644 --- a/tests/ui/single_char_pattern.rs +++ b/tests/ui/single_char_pattern.rs @@ -1,3 +1,5 @@ +#![feature(tool_lints)] + use std::collections::HashSet; fn main() { @@ -9,7 +11,7 @@ fn main() { let y = "x"; x.split(y); // Not yet testing for multi-byte characters - // Changing `r.len() == 1` to `r.chars().count() == 1` in `lint_single_char_pattern` + // Changing `r.len() == 1` to `r.chars().count() == 1` in `lint_clippy::single_char_pattern` // should have done this but produced an ICE // // We may not want to suggest changing these anyway diff --git a/tests/ui/single_match.rs b/tests/ui/single_match.rs index b064eed5711..c0c82adafb5 100644 --- a/tests/ui/single_match.rs +++ b/tests/ui/single_match.rs @@ -1,4 +1,6 @@ -#![warn(single_match)] +#![feature(tool_lints)] + +#![warn(clippy::single_match)] fn dummy() { } diff --git a/tests/ui/starts_ends_with.rs b/tests/ui/starts_ends_with.rs index d47c8a5b076..adea56cf9a2 100644 --- a/tests/ui/starts_ends_with.rs +++ b/tests/ui/starts_ends_with.rs @@ -1,8 +1,10 @@ +#![feature(tool_lints)] + #![allow(dead_code)] fn main() {} -#[allow(unnecessary_operation)] +#[allow(clippy::unnecessary_operation)] fn starts_with() { "".chars().next() == Some(' '); Some(' ') != "".chars().next(); @@ -30,7 +32,7 @@ fn chars_cmp_with_unwrap() { } } -#[allow(unnecessary_operation)] +#[allow(clippy::unnecessary_operation)] fn ends_with() { "".chars().last() == Some(' '); Some(' ') != "".chars().last(); diff --git a/tests/ui/strings.rs b/tests/ui/strings.rs index 66d24a3c070..86819e3fd5c 100644 --- a/tests/ui/strings.rs +++ b/tests/ui/strings.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#[warn(string_add)] -#[allow(string_add_assign)] +#[warn(clippy::string_add)] +#[allow(clippy::string_add_assign)] fn add_only() { // ignores assignment distinction let mut x = "".to_owned(); @@ -16,7 +16,7 @@ fn add_only() { // ignores assignment distinction assert_eq!(&x, &z); } -#[warn(string_add_assign)] +#[warn(clippy::string_add_assign)] fn add_assign_only() { let mut x = "".to_owned(); @@ -30,7 +30,7 @@ fn add_assign_only() { assert_eq!(&x, &z); } -#[warn(string_add, string_add_assign)] +#[warn(clippy::string_add, clippy::string_add_assign)] fn both() { let mut x = "".to_owned(); @@ -45,7 +45,7 @@ fn both() { } #[allow(dead_code, unused_variables)] -#[warn(string_lit_as_bytes)] +#[warn(clippy::string_lit_as_bytes)] fn str_lit_as_bytes() { let bs = "hello there".as_bytes(); diff --git a/tests/ui/stutter.rs b/tests/ui/stutter.rs index 761339b0a8e..de67bb1aff5 100644 --- a/tests/ui/stutter.rs +++ b/tests/ui/stutter.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![warn(stutter)] +#![warn(clippy::stutter)] #![allow(dead_code)] mod foo { diff --git a/tests/ui/suspicious_arithmetic_impl.rs b/tests/ui/suspicious_arithmetic_impl.rs index 9f6fce2495a..04e235c690b 100644 --- a/tests/ui/suspicious_arithmetic_impl.rs +++ b/tests/ui/suspicious_arithmetic_impl.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(suspicious_arithmetic_impl)] +#![warn(clippy::suspicious_arithmetic_impl)] use std::ops::{Add, AddAssign, Mul, Sub, Div}; #[derive(Copy, Clone)] diff --git a/tests/ui/swap.rs b/tests/ui/swap.rs index d1d12641c46..377319e8faa 100644 --- a/tests/ui/swap.rs +++ b/tests/ui/swap.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(clippy)] -#![allow(blacklisted_name, unused_assignments)] +#![warn(clippy::all)] +#![allow(clippy::blacklisted_name, unused_assignments)] struct Foo(u32); diff --git a/tests/ui/temporary_assignment.rs b/tests/ui/temporary_assignment.rs index 8f25aad72bb..1d0cffcfc0a 100644 --- a/tests/ui/temporary_assignment.rs +++ b/tests/ui/temporary_assignment.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(temporary_assignment)] +#![warn(clippy::temporary_assignment)] use std::ops::{Deref, DerefMut}; diff --git a/tests/ui/toplevel_ref_arg.rs b/tests/ui/toplevel_ref_arg.rs index a0d6dd2dabd..86eb7fa5565 100644 --- a/tests/ui/toplevel_ref_arg.rs +++ b/tests/ui/toplevel_ref_arg.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(clippy)] +#![warn(clippy::all)] #![allow(unused)] fn the_answer(ref mut x: u8) { diff --git a/tests/ui/transmute.rs b/tests/ui/transmute.rs index 54e1734e141..34d50da11ca 100644 --- a/tests/ui/transmute.rs +++ b/tests/ui/transmute.rs @@ -1,4 +1,4 @@ - +#![feature(tool_lints)] #![allow(dead_code)] @@ -16,8 +16,8 @@ fn my_vec() -> MyVec { vec![] } -#[allow(needless_lifetimes, transmute_ptr_to_ptr)] -#[warn(useless_transmute)] +#[allow(clippy::needless_lifetimes, clippy::transmute_ptr_to_ptr)] +#[warn(clippy::useless_transmute)] unsafe fn _generic<'a, T, U: 'a>(t: &'a T) { let _: &'a T = core::intrinsics::transmute(t); @@ -30,7 +30,7 @@ unsafe fn _generic<'a, T, U: 'a>(t: &'a T) { let _: *const U = core::intrinsics::transmute(t); } -#[warn(transmute_ptr_to_ref)] +#[warn(clippy::transmute_ptr_to_ref)] unsafe fn _ptr_to_ref(p: *const T, m: *mut T, o: *const U, om: *mut U) { let _: &T = std::mem::transmute(p); let _: &T = &*p; @@ -54,7 +54,7 @@ unsafe fn _ptr_to_ref(p: *const T, m: *mut T, o: *const U, om: *mut U) { let _: &T = &*(om as *const T); } -#[warn(transmute_ptr_to_ref)] +#[warn(clippy::transmute_ptr_to_ref)] fn issue1231() { struct Foo<'a, T: 'a> { bar: &'a T, @@ -70,7 +70,7 @@ fn issue1231() { unsafe { std::mem::transmute::<_, Bar>(raw) }; } -#[warn(useless_transmute)] +#[warn(clippy::useless_transmute)] fn useless() { unsafe { let _: Vec = core::intrinsics::transmute(my_vec()); @@ -101,7 +101,7 @@ fn useless() { struct Usize(usize); -#[warn(crosspointer_transmute)] +#[warn(clippy::crosspointer_transmute)] fn crosspointer() { let mut int: Usize = Usize(0); let int_const_ptr: *const Usize = &int as *const Usize; @@ -118,18 +118,18 @@ fn crosspointer() { } } -#[warn(transmute_int_to_char)] +#[warn(clippy::transmute_int_to_char)] fn int_to_char() { let _: char = unsafe { std::mem::transmute(0_u32) }; let _: char = unsafe { std::mem::transmute(0_i32) }; } -#[warn(transmute_int_to_bool)] +#[warn(clippy::transmute_int_to_bool)] fn int_to_bool() { let _: bool = unsafe { std::mem::transmute(0_u8) }; } -#[warn(transmute_int_to_float)] +#[warn(clippy::transmute_int_to_float)] fn int_to_float() { let _: f32 = unsafe { std::mem::transmute(0_u32) }; let _: f32 = unsafe { std::mem::transmute(0_i32) }; @@ -144,13 +144,13 @@ fn bytes_to_str(b: &[u8], mb: &mut [u8]) { // of transmute // Make sure we can do static lifetime transmutes -#[warn(transmute_ptr_to_ptr)] +#[warn(clippy::transmute_ptr_to_ptr)] unsafe fn transmute_lifetime_to_static<'a, T>(t: &'a T) -> &'static T { std::mem::transmute::<&'a T, &'static T>(t) } // Make sure we can do non-static lifetime transmutes -#[warn(transmute_ptr_to_ptr)] +#[warn(clippy::transmute_ptr_to_ptr)] unsafe fn transmute_lifetime<'a, 'b, T>(t: &'a T, u: &'b T) -> &'b T { std::mem::transmute::<&'a T, &'b T>(t) } @@ -163,7 +163,7 @@ struct GenericParam { t: T, } -#[warn(transmute_ptr_to_ptr)] +#[warn(clippy::transmute_ptr_to_ptr)] fn transmute_ptr_to_ptr() { let ptr = &1u32 as *const u32; let mut_ptr = &mut 1u32 as *mut u32; diff --git a/tests/ui/transmute_64bit.rs b/tests/ui/transmute_64bit.rs index 65240c80a48..539b403cff9 100644 --- a/tests/ui/transmute_64bit.rs +++ b/tests/ui/transmute_64bit.rs @@ -1,9 +1,11 @@ +#![feature(tool_lints)] + //ignore-x86 //no-ignore-x86_64 -#[warn(wrong_transmute)] +#[warn(clippy::wrong_transmute)] fn main() { unsafe { let _: *const usize = std::mem::transmute(6.0f64); diff --git a/tests/ui/trivially_copy_pass_by_ref.rs b/tests/ui/trivially_copy_pass_by_ref.rs index a1a1de1e439..e3dbe510a47 100644 --- a/tests/ui/trivially_copy_pass_by_ref.rs +++ b/tests/ui/trivially_copy_pass_by_ref.rs @@ -1,4 +1,6 @@ -#![allow(many_single_char_names, blacklisted_name, redundant_field_names)] +#![feature(tool_lints)] + +#![allow(clippy::many_single_char_names, clippy::blacklisted_name, clippy::redundant_field_names)] #[derive(Copy, Clone)] struct Foo(u32); @@ -19,7 +21,7 @@ fn good_return_implicit_lt_ref(foo: &Foo) -> &u32 { &foo.0 } -#[allow(needless_lifetimes)] +#[allow(clippy::needless_lifetimes)] fn good_return_explicit_lt_ref<'a>(foo: &'a Foo) -> &'a u32 { &foo.0 } @@ -30,7 +32,7 @@ fn good_return_implicit_lt_struct(foo: &Foo) -> FooRef { } } -#[allow(needless_lifetimes)] +#[allow(clippy::needless_lifetimes)] fn good_return_explicit_lt_struct<'a>(foo: &'a Foo) -> FooRef<'a> { FooRef { foo, diff --git a/tests/ui/unicode.rs b/tests/ui/unicode.rs index 5bb0e7edfed..b997d6d3f14 100644 --- a/tests/ui/unicode.rs +++ b/tests/ui/unicode.rs @@ -1,19 +1,19 @@ +#![feature(tool_lints)] - -#[warn(zero_width_space)] +#[warn(clippy::zero_width_space)] fn zero() { print!("Here >​< is a ZWS, and ​another"); print!("This\u{200B}is\u{200B}fine"); } -#[warn(unicode_not_nfc)] +#[warn(clippy::unicode_not_nfc)] fn canon() { print!("̀àh?"); print!("a\u{0300}h?"); // also okay } -#[warn(non_ascii_literal)] +#[warn(clippy::non_ascii_literal)] fn uni() { print!("Üben!"); print!("\u{DC}ben!"); // this is okay diff --git a/tests/ui/unit_arg.rs b/tests/ui/unit_arg.rs index 8f290446b5e..2f743f227b8 100644 --- a/tests/ui/unit_arg.rs +++ b/tests/ui/unit_arg.rs @@ -1,5 +1,7 @@ -#![warn(unit_arg)] -#![allow(no_effect)] +#![feature(tool_lints)] + +#![warn(clippy::unit_arg)] +#![allow(clippy::no_effect)] use std::fmt::Debug; diff --git a/tests/ui/unit_cmp.rs b/tests/ui/unit_cmp.rs index 2b6d757845f..bd79d0f8189 100644 --- a/tests/ui/unit_cmp.rs +++ b/tests/ui/unit_cmp.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(unit_cmp)] -#![allow(no_effect, unnecessary_operation)] +#![warn(clippy::unit_cmp)] +#![allow(clippy::no_effect, clippy::unnecessary_operation)] #[derive(PartialEq)] pub struct ContainsUnit(()); // should be fine diff --git a/tests/ui/unnecessary_clone.rs b/tests/ui/unnecessary_clone.rs index 96166ed4f13..7a2fc4ac1f6 100644 --- a/tests/ui/unnecessary_clone.rs +++ b/tests/ui/unnecessary_clone.rs @@ -1,4 +1,6 @@ -#![warn(clone_on_ref_ptr)] +#![feature(tool_lints)] + +#![warn(clippy::clone_on_ref_ptr)] #![allow(unused)] use std::collections::HashSet; @@ -40,7 +42,7 @@ fn clone_on_ref_ptr() { sync::Weak::clone(&arc_weak); let x = Arc::new(SomeImpl); - let _: Arc = x.clone(); + let _: Arc = x.clone(); } fn clone_on_copy_generic(t: T) { diff --git a/tests/ui/unnecessary_ref.rs b/tests/ui/unnecessary_ref.rs index 53b970dfa72..afc920832ce 100644 --- a/tests/ui/unnecessary_ref.rs +++ b/tests/ui/unnecessary_ref.rs @@ -1,3 +1,5 @@ +#![feature(tool_lints)] + #![feature(tool_attributes)] #![feature(stmt_expr_attributes)] @@ -5,7 +7,7 @@ struct Outer { inner: u32, } -#[deny(ref_in_deref)] +#[deny(clippy::ref_in_deref)] fn main() { let outer = Outer { inner: 0 }; let inner = (&outer).inner; diff --git a/tests/ui/unneeded_field_pattern.rs b/tests/ui/unneeded_field_pattern.rs index 8c960602264..88b91235df6 100644 --- a/tests/ui/unneeded_field_pattern.rs +++ b/tests/ui/unneeded_field_pattern.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![warn(unneeded_field_pattern)] +#![warn(clippy::unneeded_field_pattern)] #[allow(dead_code, unused)] struct Foo { diff --git a/tests/ui/unreadable_literal.rs b/tests/ui/unreadable_literal.rs index 0ec757cfbcf..df3539e38e8 100644 --- a/tests/ui/unreadable_literal.rs +++ b/tests/ui/unreadable_literal.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#[warn(unreadable_literal)] +#[warn(clippy::unreadable_literal)] #[allow(unused_variables)] fn main() { let good = (0b1011_i64, 0o1_234_u32, 0x1_234_567, 65536, 1_2345_6789, 1234_f32, 1_234.12_f32, 1_234.123_f32, 1.123_4_f32); diff --git a/tests/ui/unsafe_removed_from_name.rs b/tests/ui/unsafe_removed_from_name.rs index 29f34d31a8e..41b98975d53 100644 --- a/tests/ui/unsafe_removed_from_name.rs +++ b/tests/ui/unsafe_removed_from_name.rs @@ -1,8 +1,8 @@ - +#![feature(tool_lints)] #![allow(unused_imports)] #![allow(dead_code)] -#![warn(unsafe_removed_from_name)] +#![warn(clippy::unsafe_removed_from_name)] use std::cell::{UnsafeCell as TotallySafeCell}; diff --git a/tests/ui/unused_io_amount.rs b/tests/ui/unused_io_amount.rs index ea72c1b1b70..53bcbce9dbf 100644 --- a/tests/ui/unused_io_amount.rs +++ b/tests/ui/unused_io_amount.rs @@ -1,8 +1,8 @@ - +#![feature(tool_lints)] #![allow(dead_code)] -#![warn(unused_io_amount)] +#![warn(clippy::unused_io_amount)] use std::io; diff --git a/tests/ui/unused_labels.rs b/tests/ui/unused_labels.rs index 115121dc275..b76fcad1699 100644 --- a/tests/ui/unused_labels.rs +++ b/tests/ui/unused_labels.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![allow(dead_code, items_after_statements, never_loop)] -#![warn(unused_label)] +#![allow(dead_code, clippy::items_after_statements, clippy::never_loop)] +#![warn(clippy::unused_label)] fn unused_label() { 'label: for i in 1..2 { diff --git a/tests/ui/unused_lt.rs b/tests/ui/unused_lt.rs index 8b166a34d29..e5c5e893504 100644 --- a/tests/ui/unused_lt.rs +++ b/tests/ui/unused_lt.rs @@ -1,7 +1,7 @@ +#![feature(tool_lints)] - -#![allow(unused, dead_code, needless_lifetimes, needless_pass_by_value, trivially_copy_pass_by_ref)] -#![warn(extra_unused_lifetimes)] +#![allow(unused, dead_code, clippy::needless_lifetimes, clippy::needless_pass_by_value, clippy::trivially_copy_pass_by_ref)] +#![warn(clippy::extra_unused_lifetimes)] fn empty() { diff --git a/tests/ui/unwrap_or.rs b/tests/ui/unwrap_or.rs index 79e3900fef0..682c42dc935 100644 --- a/tests/ui/unwrap_or.rs +++ b/tests/ui/unwrap_or.rs @@ -1,4 +1,5 @@ -#![warn(clippy)] +#![feature(tool_lints)] +#![warn(clippy::all)] fn main() { let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index 689c9d68d12..8d18d848ae0 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -1,6 +1,8 @@ -#![warn(use_self)] +#![feature(tool_lints)] + +#![warn(clippy::use_self)] #![allow(dead_code)] -#![allow(should_implement_trait)] +#![allow(clippy::should_implement_trait)] fn main() {} @@ -64,7 +66,7 @@ mod lifetimes { } } -#[allow(boxed_local)] +#[allow(clippy::boxed_local)] mod traits { use std::ops::Mul; diff --git a/tests/ui/used_underscore_binding.rs b/tests/ui/used_underscore_binding.rs index 60a2c4e8b4c..c1e1c9af5db 100644 --- a/tests/ui/used_underscore_binding.rs +++ b/tests/ui/used_underscore_binding.rs @@ -1,9 +1,9 @@ +#![feature(tool_lints)] +#![warn(clippy::all)] -#![warn(clippy)] - -#![allow(blacklisted_name)] -#![warn(used_underscore_binding)] +#![allow(clippy::blacklisted_name)] +#![warn(clippy::used_underscore_binding)] macro_rules! test_macro { () => {{ diff --git a/tests/ui/useless_asref.rs b/tests/ui/useless_asref.rs index 7508cdc7b43..52994566e09 100644 --- a/tests/ui/useless_asref.rs +++ b/tests/ui/useless_asref.rs @@ -1,10 +1,12 @@ -#![deny(useless_asref)] -#![allow(trivially_copy_pass_by_ref)] +#![feature(tool_lints)] + +#![deny(clippy::useless_asref)] +#![allow(clippy::trivially_copy_pass_by_ref)] use std::fmt::Debug; struct FakeAsRef; -#[allow(should_implement_trait)] +#[allow(clippy::should_implement_trait)] impl FakeAsRef { fn as_ref(&self) -> &Self { self } } diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index 68c7d2007a6..300fcfa2b70 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![warn(useless_attribute)] +#![warn(clippy::useless_attribute)] #[allow(dead_code, unused_extern_crates)] #[cfg_attr(feature = "cargo-clippy", allow(dead_code, unused_extern_crates))] diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs index 23e43872454..78a49f2580a 100644 --- a/tests/ui/vec.rs +++ b/tests/ui/vec.rs @@ -1,13 +1,13 @@ +#![feature(tool_lints)] - -#![warn(useless_vec)] +#![warn(clippy::useless_vec)] #[derive(Debug)] struct NonCopy; fn on_slice(_: &[u8]) {} -#[allow(ptr_arg)] +#[allow(clippy::ptr_arg)] fn on_vec(_: &Vec) {} struct Line { diff --git a/tests/ui/while_loop.rs b/tests/ui/while_loop.rs index 23a9ce80eb1..0b8691d57b4 100644 --- a/tests/ui/while_loop.rs +++ b/tests/ui/while_loop.rs @@ -1,8 +1,8 @@ +#![feature(tool_lints)] - -#![warn(while_let_loop, empty_loop, while_let_on_iterator)] -#![allow(dead_code, never_loop, unused, cyclomatic_complexity)] +#![warn(clippy::while_let_loop, clippy::empty_loop, clippy::while_let_on_iterator)] +#![allow(dead_code, clippy::never_loop, unused, clippy::cyclomatic_complexity)] fn main() { let y = Some(true); @@ -184,7 +184,7 @@ fn refutable() { } } - // should not trigger while_let_loop lint because break passes an expression + // should not trigger clippy::while_let_loop lint because break passes an expression let a = Some(10); let b = loop { if let Some(c) = a { diff --git a/tests/ui/write_literal.rs b/tests/ui/write_literal.rs index 48dfcd0ea3e..5ef4c15f409 100644 --- a/tests/ui/write_literal.rs +++ b/tests/ui/write_literal.rs @@ -1,5 +1,7 @@ +#![feature(tool_lints)] + #![allow(unused_must_use)] -#![warn(write_literal)] +#![warn(clippy::write_literal)] use std::io::Write; diff --git a/tests/ui/write_with_newline.rs b/tests/ui/write_with_newline.rs index 8badbd65726..e060459a411 100644 --- a/tests/ui/write_with_newline.rs +++ b/tests/ui/write_with_newline.rs @@ -1,5 +1,7 @@ -#![allow(write_literal)] -#![warn(write_with_newline)] +#![feature(tool_lints)] + +#![allow(clippy::write_literal)] +#![warn(clippy::write_with_newline)] use std::io::Write; diff --git a/tests/ui/writeln_empty_string.rs b/tests/ui/writeln_empty_string.rs index faccfd8291c..81dfdcdc0d0 100644 --- a/tests/ui/writeln_empty_string.rs +++ b/tests/ui/writeln_empty_string.rs @@ -1,5 +1,7 @@ +#![feature(tool_lints)] + #![allow(unused_must_use)] -#![warn(writeln_empty_string)] +#![warn(clippy::writeln_empty_string)] use std::io::Write; fn main() { diff --git a/tests/ui/wrong_self_convention.rs b/tests/ui/wrong_self_convention.rs index 07a93d6889b..1e718c1c648 100644 --- a/tests/ui/wrong_self_convention.rs +++ b/tests/ui/wrong_self_convention.rs @@ -1,9 +1,9 @@ +#![feature(tool_lints)] - -#![warn(wrong_self_convention)] -#![warn(wrong_pub_self_convention)] -#![allow(dead_code, trivially_copy_pass_by_ref)] +#![warn(clippy::wrong_self_convention)] +#![warn(clippy::wrong_pub_self_convention)] +#![allow(dead_code, clippy::trivially_copy_pass_by_ref)] fn main() {} @@ -26,7 +26,7 @@ impl Foo { pub fn to_i64(self) {} pub fn from_i64(self) {} // check whether the lint can be allowed at the function level - #[allow(wrong_self_convention)] + #[allow(clippy::wrong_self_convention)] pub fn from_cake(self) {} fn as_x>(_: F) { } diff --git a/tests/ui/zero_div_zero.rs b/tests/ui/zero_div_zero.rs index 65e1e239980..7927e8b8ac7 100644 --- a/tests/ui/zero_div_zero.rs +++ b/tests/ui/zero_div_zero.rs @@ -1,8 +1,8 @@ - +#![feature(tool_lints)] #[allow(unused_variables)] -#[warn(zero_divided_by_zero)] +#[warn(clippy::zero_divided_by_zero)] fn main() { let nan = 0.0 / 0.0; let f64_nan = 0.0 / 0.0f64; From e9af09c27490a9f5f264c4cf2a673272eb67b66d Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Wed, 1 Aug 2018 16:30:44 +0200 Subject: [PATCH 43/53] Adapt the *.stderr files of the ui-tests to the tool_lints --- tests/ui/absurd-extreme-comparisons.stderr | 4 +- tests/ui/approx_const.stderr | 2 +- tests/ui/arithmetic.stderr | 4 +- tests/ui/assign_ops.stderr | 54 +-- tests/ui/assign_ops2.stderr | 2 +- tests/ui/attrs.stderr | 4 +- tests/ui/author/matches.stderr | 2 +- tests/ui/bit_masks.stderr | 6 +- tests/ui/blacklisted_name.stderr | 2 +- tests/ui/block_in_if_condition.stderr | 6 +- tests/ui/bool_comparison.stderr | 2 +- tests/ui/booleans.stderr | 4 +- tests/ui/borrow_box.stderr | 4 +- tests/ui/box_vec.stderr | 2 +- tests/ui/builtin-type-shadow.stderr | 2 +- tests/ui/bytecount.stderr | 4 +- tests/ui/cast.stderr | 12 +- tests/ui/cast_alignment.stderr | 10 +- tests/ui/cast_lossless_float.stderr | 56 +-- tests/ui/cast_lossless_integer.stderr | 2 +- tests/ui/cast_size.stderr | 124 +++--- tests/ui/char_lit_as_u8.stderr | 2 +- tests/ui/checked_unwrap.stderr | 402 +++++++++--------- tests/ui/cmp_nan.stderr | 2 +- tests/ui/cmp_null.stderr | 2 +- tests/ui/cmp_owned.stderr | 2 +- tests/ui/collapsible_if.stderr | 2 +- tests/ui/complex_types.stderr | 2 +- tests/ui/const_static_lifetime.stderr | 2 +- tests/ui/copies.stderr | 356 ++++++++-------- tests/ui/copy_iterator.stderr | 16 +- tests/ui/cstring.stderr | 10 +- tests/ui/cyclomatic_complexity.stderr | 2 +- .../ui/cyclomatic_complexity_attr_used.stderr | 2 +- .../ui/decimal_literal_representation.stderr | 2 +- tests/ui/default_trait_access.stderr | 44 +- tests/ui/derive.stderr | 4 +- tests/ui/diverging_sub_expression.stderr | 26 +- tests/ui/dlist.stderr | 26 +- tests/ui/doc.stderr | 194 ++++----- tests/ui/double_comparison.stderr | 2 +- tests/ui/double_neg.stderr | 2 +- tests/ui/double_parens.stderr | 2 +- tests/ui/drop_forget_copy.stderr | 4 +- tests/ui/drop_forget_ref.stderr | 4 +- tests/ui/duplicate_underscore_argument.stderr | 2 +- tests/ui/duration_subsec.stderr | 32 +- tests/ui/else_if_without_else.stderr | 18 +- tests/ui/empty_enum.stderr | 2 +- .../empty_line_after_outer_attribute.stderr | 2 +- tests/ui/entry.stderr | 2 +- tests/ui/enum_glob_use.stderr | 2 +- tests/ui/enum_variants.stderr | 106 ++--- tests/ui/enums_clike.stderr | 40 +- tests/ui/eq_op.stderr | 6 +- tests/ui/erasing_op.stderr | 2 +- tests/ui/eta.stderr | 4 +- tests/ui/eval_order_dependence.stderr | 2 +- tests/ui/excessive_precision.stderr | 2 +- tests/ui/explicit_write.stderr | 26 +- tests/ui/fallible_impl_from.stderr | 100 ++--- tests/ui/filter_methods.stderr | 2 +- tests/ui/float_cmp.stderr | 2 +- tests/ui/float_cmp_const.stderr | 2 +- tests/ui/for_loop.stderr | 24 +- tests/ui/format.stderr | 2 +- tests/ui/formatting.stderr | 6 +- tests/ui/functions.stderr | 4 +- tests/ui/fxhash.stderr | 26 +- tests/ui/get_unwrap.stderr | 2 +- tests/ui/identity_conversion.stderr | 56 +-- tests/ui/identity_op.stderr | 2 +- .../if_let_redundant_pattern_matching.stderr | 2 +- tests/ui/if_not_else.stderr | 2 +- tests/ui/impl.stderr | 34 +- tests/ui/implicit_hasher.stderr | 2 +- tests/ui/inconsistent_digit_grouping.stderr | 2 +- tests/ui/indexing_slicing.stderr | 174 ++++---- .../ui/infallible_destructuring_match.stderr | 26 +- tests/ui/infinite_iter.stderr | 10 +- tests/ui/infinite_loop.stderr | 46 +- tests/ui/inline_fn_without_body.stderr | 2 +- tests/ui/int_plus_one.stderr | 2 +- tests/ui/invalid_ref.stderr | 2 +- tests/ui/invalid_upcast_comparisons.stderr | 2 +- tests/ui/issue_2356.stderr | 10 +- tests/ui/item_after_statement.stderr | 2 +- tests/ui/large_digit_groups.stderr | 2 +- tests/ui/large_enum_variant.stderr | 2 +- tests/ui/len_zero.stderr | 116 ++--- tests/ui/let_if_seq.stderr | 2 +- tests/ui/let_return.stderr | 2 +- tests/ui/let_unit.stderr | 2 +- tests/ui/lifetimes.stderr | 2 +- tests/ui/literals.stderr | 126 +++--- tests/ui/map_clone.stderr | 2 +- tests/ui/match_bool.stderr | 6 +- tests/ui/matches.stderr | 12 +- tests/ui/mem_forget.stderr | 2 +- tests/ui/methods.stderr | 30 +- tests/ui/min_max.stderr | 2 +- tests/ui/missing-doc.stderr | 230 +++++----- tests/ui/missing_inline.stderr | 40 +- tests/ui/module_inception.stderr | 2 +- tests/ui/modulo_one.stderr | 2 +- tests/ui/mut_from_ref.stderr | 2 +- tests/ui/mut_mut.stderr | 2 +- tests/ui/mut_range_bound.stderr | 2 +- tests/ui/mut_reference.stderr | 2 +- tests/ui/mutex_atomic.stderr | 4 +- tests/ui/needless_bool.stderr | 2 +- tests/ui/needless_borrow.stderr | 28 +- tests/ui/needless_borrowed_ref.stderr | 2 +- tests/ui/needless_continue.stderr | 2 +- tests/ui/needless_pass_by_value.stderr | 140 +++--- tests/ui/needless_range_loop.stderr | 2 +- tests/ui/needless_return.stderr | 2 +- tests/ui/needless_update.stderr | 2 +- tests/ui/neg_cmp_op_on_partial_ord.stderr | 18 +- tests/ui/neg_multiply.stderr | 2 +- tests/ui/never_loop.stderr | 4 +- tests/ui/new_without_default.stderr | 30 +- tests/ui/no_effect.stderr | 222 +++++----- tests/ui/non_copy_const.stderr | 180 ++++---- tests/ui/non_expressive_names.stderr | 6 +- tests/ui/ok_expect.stderr | 2 +- tests/ui/ok_if_let.stderr | 2 +- tests/ui/op_ref.stderr | 2 +- tests/ui/open_options.stderr | 2 +- tests/ui/option_map_unit_fn.stderr | 136 +++--- tests/ui/option_option.stderr | 2 +- tests/ui/overflow_check_conditional.stderr | 2 +- tests/ui/panic_unimplemented.stderr | 4 +- tests/ui/partialeq_ne_impl.stderr | 2 +- tests/ui/patterns.stderr | 2 +- tests/ui/precedence.stderr | 2 +- tests/ui/print.stderr | 4 +- tests/ui/print_literal.stderr | 2 +- tests/ui/print_with_newline.stderr | 2 +- tests/ui/println_empty_string.stderr | 2 +- tests/ui/ptr_arg.stderr | 50 +-- tests/ui/question_mark.stderr | 2 +- tests/ui/range.stderr | 4 +- tests/ui/range_plus_minus_one.stderr | 32 +- tests/ui/redundant_closure_call.stderr | 2 +- tests/ui/redundant_field_names.stderr | 30 +- tests/ui/reference.stderr | 2 +- tests/ui/regex.stderr | 4 +- tests/ui/replace_consts.stderr | 170 ++++---- tests/ui/result_map_unit_fn.stderr | 136 +++--- tests/ui/serde.stderr | 2 +- tests/ui/shadow.stderr | 6 +- tests/ui/short_circuit_statement.stderr | 2 +- tests/ui/single_char_pattern.stderr | 82 ++-- tests/ui/single_match.stderr | 52 +-- tests/ui/starts_ends_with.stderr | 74 ++-- tests/ui/string_extend.stderr | 2 +- tests/ui/strings.stderr | 8 +- tests/ui/stutter.stderr | 2 +- tests/ui/suspicious_arithmetic_impl.stderr | 4 +- tests/ui/swap.stderr | 4 +- tests/ui/temporary_assignment.stderr | 2 +- tests/ui/toplevel_ref_arg.stderr | 2 +- tests/ui/trailing_zeros.stderr | 2 +- tests/ui/transmute.stderr | 16 +- tests/ui/transmute_64bit.stderr | 16 +- tests/ui/trivially_copy_pass_by_ref.stderr | 54 +-- tests/ui/types.stderr | 2 +- tests/ui/types_fn_to_int.stderr | 4 +- tests/ui/unicode.stderr | 6 +- tests/ui/unit_arg.stderr | 72 ++-- tests/ui/unit_cmp.stderr | 2 +- tests/ui/unnecessary_clone.stderr | 62 +-- tests/ui/unnecessary_fold.stderr | 2 +- tests/ui/unnecessary_ref.stderr | 10 +- tests/ui/unneeded_field_pattern.stderr | 2 +- tests/ui/unreadable_literal.stderr | 2 +- tests/ui/unsafe_removed_from_name.stderr | 2 +- tests/ui/unused_io_amount.stderr | 2 +- tests/ui/unused_labels.stderr | 2 +- tests/ui/unused_lt.stderr | 2 +- tests/ui/unwrap_or.stderr | 14 +- tests/ui/use_self.stderr | 98 ++--- tests/ui/used_underscore_binding.stderr | 2 +- tests/ui/useless_asref.stderr | 50 +-- tests/ui/useless_attribute.stderr | 2 +- tests/ui/vec.stderr | 2 +- tests/ui/while_loop.stderr | 6 +- tests/ui/write_literal.stderr | 58 +-- tests/ui/write_with_newline.stderr | 34 +- tests/ui/writeln_empty_string.stderr | 16 +- tests/ui/wrong_self_convention.stderr | 2 +- tests/ui/zero_div_zero.stderr | 4 +- tests/ui/zero_ptr.stderr | 2 +- 194 files changed, 2421 insertions(+), 2421 deletions(-) diff --git a/tests/ui/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index 72b2f7a3942..2e5ebec7573 100644 --- a/tests/ui/absurd-extreme-comparisons.stderr +++ b/tests/ui/absurd-extreme-comparisons.stderr @@ -4,7 +4,7 @@ error: this comparison involving the minimum or maximum element for this type co 10 | u <= 0; | ^^^^^^ | - = note: `-D absurd-extreme-comparisons` implied by `-D warnings` + = note: `-D clippy::absurd-extreme-comparisons` implied by `-D warnings` = help: because 0 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 0 instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false @@ -141,7 +141,7 @@ error: <-comparison of unit values detected. This will always be false 31 | () < {}; | ^^^^^^^ | - = note: #[deny(unit_cmp)] on by default + = note: #[deny(clippy::unit_cmp)] on by default error: aborting due to 18 previous errors diff --git a/tests/ui/approx_const.stderr b/tests/ui/approx_const.stderr index e5d2ba29605..3ff016b9c40 100644 --- a/tests/ui/approx_const.stderr +++ b/tests/ui/approx_const.stderr @@ -4,7 +4,7 @@ error: approximate value of `f{32, 64}::consts::E` found. Consider using it dire 7 | let my_e = 2.7182; | ^^^^^^ | - = note: `-D approx-constant` implied by `-D warnings` + = note: `-D clippy::approx-constant` implied by `-D warnings` error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly --> $DIR/approx_const.rs:8:20 diff --git a/tests/ui/arithmetic.stderr b/tests/ui/arithmetic.stderr index ad4a02e2190..ee7a594fa15 100644 --- a/tests/ui/arithmetic.stderr +++ b/tests/ui/arithmetic.stderr @@ -4,7 +4,7 @@ error: integer arithmetic detected 8 | 1 + i; | ^^^^^ | - = note: `-D integer-arithmetic` implied by `-D warnings` + = note: `-D clippy::integer-arithmetic` implied by `-D warnings` error: integer arithmetic detected --> $DIR/arithmetic.rs:9:5 @@ -37,7 +37,7 @@ error: floating-point arithmetic detected 23 | f * 2.0; | ^^^^^^^ | - = note: `-D float-arithmetic` implied by `-D warnings` + = note: `-D clippy::float-arithmetic` implied by `-D warnings` error: floating-point arithmetic detected --> $DIR/arithmetic.rs:25:5 diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index 826dacc53a9..fe7ccff7805 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -1,57 +1,57 @@ -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:5:5 - | -5 | a = a + 1; - | ^^^^^^^^^ help: replace it with: `a += 1` - | - = note: `-D assign-op-pattern` implied by `-D warnings` - -error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:6:5 - | -6 | a = 1 + a; - | ^^^^^^^^^ help: replace it with: `a += 1` - error: manual implementation of an assign operation --> $DIR/assign_ops.rs:7:5 | -7 | a = a - 1; - | ^^^^^^^^^ help: replace it with: `a -= 1` +7 | a = a + 1; + | ^^^^^^^^^ help: replace it with: `a += 1` + | + = note: `-D clippy::assign-op-pattern` implied by `-D warnings` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:8:5 | -8 | a = a * 99; - | ^^^^^^^^^^ help: replace it with: `a *= 99` +8 | a = 1 + a; + | ^^^^^^^^^ help: replace it with: `a += 1` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:9:5 | -9 | a = 42 * a; - | ^^^^^^^^^^ help: replace it with: `a *= 42` +9 | a = a - 1; + | ^^^^^^^^^ help: replace it with: `a -= 1` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:10:5 | -10 | a = a / 2; - | ^^^^^^^^^ help: replace it with: `a /= 2` +10 | a = a * 99; + | ^^^^^^^^^^ help: replace it with: `a *= 99` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:11:5 | -11 | a = a % 5; - | ^^^^^^^^^ help: replace it with: `a %= 5` +11 | a = 42 * a; + | ^^^^^^^^^^ help: replace it with: `a *= 42` error: manual implementation of an assign operation --> $DIR/assign_ops.rs:12:5 | -12 | a = a & 1; +12 | a = a / 2; + | ^^^^^^^^^ help: replace it with: `a /= 2` + +error: manual implementation of an assign operation + --> $DIR/assign_ops.rs:13:5 + | +13 | a = a % 5; + | ^^^^^^^^^ help: replace it with: `a %= 5` + +error: manual implementation of an assign operation + --> $DIR/assign_ops.rs:14:5 + | +14 | a = a & 1; | ^^^^^^^^^ help: replace it with: `a &= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:18:5 + --> $DIR/assign_ops.rs:20:5 | -18 | s = s + "bla"; +20 | s = s + "bla"; | ^^^^^^^^^^^^^ help: replace it with: `s += "bla"` error: aborting due to 9 previous errors diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index 2858af1f8c0..93528e50577 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -4,7 +4,7 @@ error: variable appears on both sides of an assignment operation 8 | a += a + 1; | ^^^^^^^^^^ | - = note: `-D misrefactored-assign-op` implied by `-D warnings` + = note: `-D clippy::misrefactored-assign-op` implied by `-D warnings` help: Did you mean a = a + 1 or a = a + a + 1? Consider replacing it with | 8 | a += 1; diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index f743399a606..6b6ecd675b3 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -4,7 +4,7 @@ error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usuall 6 | #[inline(always)] | ^^^^^^^^^^^^^^^^^ | - = note: `-D inline-always` implied by `-D warnings` + = note: `-D clippy::inline-always` implied by `-D warnings` error: the since field must contain a semver-compliant version --> $DIR/attrs.rs:27:14 @@ -12,7 +12,7 @@ error: the since field must contain a semver-compliant version 27 | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ | - = note: `-D deprecated-semver` implied by `-D warnings` + = note: `-D clippy::deprecated-semver` implied by `-D warnings` error: the since field must contain a semver-compliant version --> $DIR/attrs.rs:30:14 diff --git a/tests/ui/author/matches.stderr b/tests/ui/author/matches.stderr index c4f69b10df7..46618fe4065 100644 --- a/tests/ui/author/matches.stderr +++ b/tests/ui/author/matches.stderr @@ -4,7 +4,7 @@ error: returning the result of a let binding from a block. Consider returning th 9 | x | ^ | - = note: `-D let-and-return` implied by `-D warnings` + = note: `-D clippy::let-and-return` implied by `-D warnings` note: this expression can be directly returned --> $DIR/matches.rs:8:21 | diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr index e1a4a42914c..dcf3f241b4b 100644 --- a/tests/ui/bit_masks.stderr +++ b/tests/ui/bit_masks.stderr @@ -4,7 +4,7 @@ error: &-masking with zero 12 | x & 0 == 0; | ^^^^^^^^^^ | - = note: `-D bad-bit-mask` implied by `-D warnings` + = note: `-D clippy::bad-bit-mask` implied by `-D warnings` error: this operation will always return zero. This is likely not the intended outcome --> $DIR/bit_masks.rs:12:5 @@ -12,7 +12,7 @@ error: this operation will always return zero. This is likely not the intended o 12 | x & 0 == 0; | ^^^^^ | - = note: #[deny(erasing_op)] on by default + = note: #[deny(clippy::erasing_op)] on by default error: incompatible bit mask: `_ & 2` can never be equal to `1` --> $DIR/bit_masks.rs:15:5 @@ -86,7 +86,7 @@ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared 52 | x | 1 > 3; | ^^^^^^^^^ | - = note: `-D ineffective-bit-mask` implied by `-D warnings` + = note: `-D clippy::ineffective-bit-mask` implied by `-D warnings` error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly --> $DIR/bit_masks.rs:53:5 diff --git a/tests/ui/blacklisted_name.stderr b/tests/ui/blacklisted_name.stderr index 68fbe27a01e..472401d5ed6 100644 --- a/tests/ui/blacklisted_name.stderr +++ b/tests/ui/blacklisted_name.stderr @@ -4,7 +4,7 @@ error: use of a blacklisted/placeholder name `foo` 7 | fn test(foo: ()) {} | ^^^ | - = note: `-D blacklisted-name` implied by `-D warnings` + = note: `-D clippy::blacklisted-name` implied by `-D warnings` error: use of a blacklisted/placeholder name `foo` --> $DIR/blacklisted_name.rs:10:9 diff --git a/tests/ui/block_in_if_condition.stderr b/tests/ui/block_in_if_condition.stderr index 4b7d12598ec..41f1e9c1681 100644 --- a/tests/ui/block_in_if_condition.stderr +++ b/tests/ui/block_in_if_condition.stderr @@ -8,7 +8,7 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; inste 33 | | } { | |_____^ | - = note: `-D block-in-if-condition-stmt` implied by `-D warnings` + = note: `-D clippy::block-in-if-condition-stmt` implied by `-D warnings` = help: try let res = { let x = 3; @@ -24,7 +24,7 @@ error: omit braces around single expression condition 41 | if { true } { | ^^^^^^^^ | - = note: `-D block-in-if-condition-expr` implied by `-D warnings` + = note: `-D clippy::block-in-if-condition-expr` implied by `-D warnings` = help: try if true { 6 @@ -48,7 +48,7 @@ error: this boolean expression can be simplified 67 | if true && x == 3 { | ^^^^^^^^^^^^^^ help: try: `x == 3` | - = note: `-D nonminimal-bool` implied by `-D warnings` + = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: aborting due to 5 previous errors diff --git a/tests/ui/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index 4436980bc11..2fcde94367a 100644 --- a/tests/ui/bool_comparison.stderr +++ b/tests/ui/bool_comparison.stderr @@ -4,7 +4,7 @@ error: equality checks against true are unnecessary 7 | if x == true { "yes" } else { "no" }; | ^^^^^^^^^ help: try simplifying it as shown: `x` | - = note: `-D bool-comparison` implied by `-D warnings` + = note: `-D clippy::bool-comparison` implied by `-D warnings` error: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:8:8 diff --git a/tests/ui/booleans.stderr b/tests/ui/booleans.stderr index f1996e8a26e..45e371025ef 100644 --- a/tests/ui/booleans.stderr +++ b/tests/ui/booleans.stderr @@ -4,7 +4,7 @@ error: this boolean expression contains a logic bug 12 | let _ = a && b || a; | ^^^^^^^^^^^ help: it would look like the following: `a` | - = note: `-D logic-bug` implied by `-D warnings` + = note: `-D clippy::logic-bug` implied by `-D warnings` help: this expression can be optimized out by applying boolean operations to the outer expression --> $DIR/booleans.rs:12:18 | @@ -17,7 +17,7 @@ error: this boolean expression can be simplified 14 | let _ = !true; | ^^^^^ help: try: `false` | - = note: `-D nonminimal-bool` implied by `-D warnings` + = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: this boolean expression can be simplified --> $DIR/booleans.rs:15:13 diff --git a/tests/ui/borrow_box.stderr b/tests/ui/borrow_box.stderr index 2cf0ea79626..1098c7785e2 100644 --- a/tests/ui/borrow_box.stderr +++ b/tests/ui/borrow_box.stderr @@ -7,8 +7,8 @@ error: you seem to be trying to use `&Box`. Consider using just `&T` note: lint level defined here --> $DIR/borrow_box.rs:4:9 | -4 | #![deny(borrowed_box)] - | ^^^^^^^^^^^^ +4 | #![deny(clippy::borrowed_box)] + | ^^^^^^^^^^^^^^^^^^^^ error: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:14:14 diff --git a/tests/ui/box_vec.stderr b/tests/ui/box_vec.stderr index 254d0771386..b90bb5e2a4e 100644 --- a/tests/ui/box_vec.stderr +++ b/tests/ui/box_vec.stderr @@ -4,7 +4,7 @@ error: you seem to be trying to use `Box>`. Consider using just `Vec` 17 | pub fn test(foo: Box>) { | ^^^^^^^^^^^^^^ | - = note: `-D box-vec` implied by `-D warnings` + = note: `-D clippy::box-vec` implied by `-D warnings` = help: `Vec` is already on the heap, `Box>` makes an extra allocation. error: aborting due to previous error diff --git a/tests/ui/builtin-type-shadow.stderr b/tests/ui/builtin-type-shadow.stderr index 5757a6ef390..78924ebf9cf 100644 --- a/tests/ui/builtin-type-shadow.stderr +++ b/tests/ui/builtin-type-shadow.stderr @@ -4,7 +4,7 @@ error: This generic shadows the built-in type `u32` 5 | fn foo(a: u32) -> u32 { | ^^^ | - = note: `-D builtin-type-shadow` implied by `-D warnings` + = note: `-D clippy::builtin-type-shadow` implied by `-D warnings` error[E0308]: mismatched types --> $DIR/builtin-type-shadow.rs:6:5 diff --git a/tests/ui/bytecount.stderr b/tests/ui/bytecount.stderr index 307edecfde1..0564d6a0b60 100644 --- a/tests/ui/bytecount.stderr +++ b/tests/ui/bytecount.stderr @@ -7,8 +7,8 @@ error: You appear to be counting bytes the naive way note: lint level defined here --> $DIR/bytecount.rs:4:8 | -4 | #[deny(naive_bytecount)] - | ^^^^^^^^^^^^^^^ +4 | #[deny(clippy::naive_bytecount)] + | ^^^^^^^^^^^^^^^^^^^^^^^ error: You appear to be counting bytes the naive way --> $DIR/bytecount.rs:10:13 diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 0a008cb68bb..2578c49893f 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -4,7 +4,7 @@ error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f 8 | 1i32 as f32; | ^^^^^^^^^^^ | - = note: `-D cast-precision-loss` implied by `-D warnings` + = note: `-D clippy::cast-precision-loss` implied by `-D warnings` error: casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide) --> $DIR/cast.rs:9:5 @@ -42,7 +42,7 @@ error: casting f32 to i32 may truncate the value 15 | 1f32 as i32; | ^^^^^^^^^^^ | - = note: `-D cast-possible-truncation` implied by `-D warnings` + = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` error: casting f32 to u32 may truncate the value --> $DIR/cast.rs:16:5 @@ -56,7 +56,7 @@ error: casting f32 to u32 may lose the sign of the value 16 | 1f32 as u32; | ^^^^^^^^^^^ | - = note: `-D cast-sign-loss` implied by `-D warnings` + = note: `-D clippy::cast-sign-loss` implied by `-D warnings` error: casting f64 to f32 may truncate the value --> $DIR/cast.rs:17:5 @@ -106,7 +106,7 @@ error: casting u8 to i8 may wrap around the value 23 | 1u8 as i8; | ^^^^^^^^^ | - = note: `-D cast-possible-wrap` implied by `-D warnings` + = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` error: casting u16 to i16 may wrap around the value --> $DIR/cast.rs:24:5 @@ -138,7 +138,7 @@ error: casting f32 to f64 may become silently lossy if types change 29 | 1.0f32 as f64; | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` | - = note: `-D cast-lossless` implied by `-D warnings` + = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting u8 to u16 may become silently lossy if types change --> $DIR/cast.rs:31:5 @@ -164,7 +164,7 @@ error: casting to the same type is unnecessary (`i32` -> `i32`) 37 | 1i32 as i32; | ^^^^^^^^^^^ | - = note: `-D unnecessary-cast` implied by `-D warnings` + = note: `-D clippy::unnecessary-cast` implied by `-D warnings` error: casting to the same type is unnecessary (`f32` -> `f32`) --> $DIR/cast.rs:38:5 diff --git a/tests/ui/cast_alignment.stderr b/tests/ui/cast_alignment.stderr index 42df78a37a6..d03d727a89c 100644 --- a/tests/ui/cast_alignment.stderr +++ b/tests/ui/cast_alignment.stderr @@ -1,15 +1,15 @@ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) - --> $DIR/cast_alignment.rs:13:5 + --> $DIR/cast_alignment.rs:15:5 | -13 | (&1u8 as *const u8) as *const u16; +15 | (&1u8 as *const u8) as *const u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D cast-ptr-alignment` implied by `-D warnings` + = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings` error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) - --> $DIR/cast_alignment.rs:14:5 + --> $DIR/cast_alignment.rs:16:5 | -14 | (&mut 1u8 as *mut u8) as *mut u16; +16 | (&mut 1u8 as *mut u8) as *mut u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr index a60f838fae8..9025633a141 100644 --- a/tests/ui/cast_lossless_float.stderr +++ b/tests/ui/cast_lossless_float.stderr @@ -1,63 +1,63 @@ error: casting i8 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:5:5 + --> $DIR/cast_lossless_float.rs:7:5 | -5 | 1i8 as f32; +7 | 1i8 as f32; | ^^^^^^^^^^ help: try: `f32::from(1i8)` | - = note: `-D cast-lossless` implied by `-D warnings` + = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting i8 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:6:5 + --> $DIR/cast_lossless_float.rs:8:5 | -6 | 1i8 as f64; +8 | 1i8 as f64; | ^^^^^^^^^^ help: try: `f64::from(1i8)` error: casting u8 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:7:5 + --> $DIR/cast_lossless_float.rs:9:5 | -7 | 1u8 as f32; +9 | 1u8 as f32; | ^^^^^^^^^^ help: try: `f32::from(1u8)` error: casting u8 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:8:5 - | -8 | 1u8 as f64; - | ^^^^^^^^^^ help: try: `f64::from(1u8)` - -error: casting i16 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:9:5 - | -9 | 1i16 as f32; - | ^^^^^^^^^^^ help: try: `f32::from(1i16)` - -error: casting i16 to f64 may become silently lossy if types change --> $DIR/cast_lossless_float.rs:10:5 | -10 | 1i16 as f64; +10 | 1u8 as f64; + | ^^^^^^^^^^ help: try: `f64::from(1u8)` + +error: casting i16 to f32 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:11:5 + | +11 | 1i16 as f32; + | ^^^^^^^^^^^ help: try: `f32::from(1i16)` + +error: casting i16 to f64 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:12:5 + | +12 | 1i16 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1i16)` error: casting u16 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:11:5 + --> $DIR/cast_lossless_float.rs:13:5 | -11 | 1u16 as f32; +13 | 1u16 as f32; | ^^^^^^^^^^^ help: try: `f32::from(1u16)` error: casting u16 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:12:5 + --> $DIR/cast_lossless_float.rs:14:5 | -12 | 1u16 as f64; +14 | 1u16 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1u16)` error: casting i32 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:13:5 + --> $DIR/cast_lossless_float.rs:15:5 | -13 | 1i32 as f64; +15 | 1i32 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1i32)` error: casting u32 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:14:5 + --> $DIR/cast_lossless_float.rs:16:5 | -14 | 1u32 as f64; +16 | 1u32 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1u32)` error: aborting due to 10 previous errors diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index 19d6176193c..9640e1e18fa 100644 --- a/tests/ui/cast_lossless_integer.stderr +++ b/tests/ui/cast_lossless_integer.stderr @@ -4,7 +4,7 @@ error: casting i8 to i16 may become silently lossy if types change 6 | 1i8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1i8)` | - = note: `-D cast-lossless` implied by `-D warnings` + = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting i8 to i32 may become silently lossy if types change --> $DIR/cast_lossless_integer.rs:7:5 diff --git a/tests/ui/cast_size.stderr b/tests/ui/cast_size.stderr index 1c4b12bcebf..1797e2e367f 100644 --- a/tests/ui/cast_size.stderr +++ b/tests/ui/cast_size.stderr @@ -1,123 +1,123 @@ error: casting isize to i8 may truncate the value - --> $DIR/cast_size.rs:5:5 - | -5 | 1isize as i8; - | ^^^^^^^^^^^^ - | - = note: `-D cast-possible-truncation` implied by `-D warnings` - -error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:6:5 - | -6 | 1isize as f64; - | ^^^^^^^^^^^^^ - | - = note: `-D cast-precision-loss` implied by `-D warnings` - -error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide) --> $DIR/cast_size.rs:7:5 | -7 | 1usize as f64; +7 | 1isize as i8; + | ^^^^^^^^^^^^ + | + = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` + +error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide) + --> $DIR/cast_size.rs:8:5 + | +8 | 1isize as f64; + | ^^^^^^^^^^^^^ + | + = note: `-D clippy::cast-precision-loss` implied by `-D warnings` + +error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide) + --> $DIR/cast_size.rs:9:5 + | +9 | 1usize as f64; | ^^^^^^^^^^^^^ error: casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:8:5 - | -8 | 1isize as f32; - | ^^^^^^^^^^^^^ - -error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:9:5 - | -9 | 1usize as f32; - | ^^^^^^^^^^^^^ - -error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers --> $DIR/cast_size.rs:10:5 | -10 | 1isize as i32; +10 | 1isize as f32; + | ^^^^^^^^^^^^^ + +error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) + --> $DIR/cast_size.rs:11:5 + | +11 | 1usize as f32; + | ^^^^^^^^^^^^^ + +error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers + --> $DIR/cast_size.rs:12:5 + | +12 | 1isize as i32; | ^^^^^^^^^^^^^ error: casting isize to u32 may lose the sign of the value - --> $DIR/cast_size.rs:11:5 + --> $DIR/cast_size.rs:13:5 | -11 | 1isize as u32; +13 | 1isize as u32; | ^^^^^^^^^^^^^ | - = note: `-D cast-sign-loss` implied by `-D warnings` + = note: `-D clippy::cast-sign-loss` implied by `-D warnings` error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:11:5 + --> $DIR/cast_size.rs:13:5 | -11 | 1isize as u32; +13 | 1isize as u32; | ^^^^^^^^^^^^^ error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:12:5 + --> $DIR/cast_size.rs:14:5 | -12 | 1usize as u32; +14 | 1usize as u32; | ^^^^^^^^^^^^^ error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:13:5 + --> $DIR/cast_size.rs:15:5 | -13 | 1usize as i32; +15 | 1usize as i32; | ^^^^^^^^^^^^^ error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:13:5 - | -13 | 1usize as i32; - | ^^^^^^^^^^^^^ - | - = note: `-D cast-possible-wrap` implied by `-D warnings` - -error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size.rs:15:5 | -15 | 1i64 as isize; +15 | 1usize as i32; + | ^^^^^^^^^^^^^ + | + = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` + +error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers + --> $DIR/cast_size.rs:17:5 + | +17 | 1i64 as isize; | ^^^^^^^^^^^^^ error: casting i64 to usize may lose the sign of the value - --> $DIR/cast_size.rs:16:5 + --> $DIR/cast_size.rs:18:5 | -16 | 1i64 as usize; +18 | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:16:5 + --> $DIR/cast_size.rs:18:5 | -16 | 1i64 as usize; +18 | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:17:5 + --> $DIR/cast_size.rs:19:5 | -17 | 1u64 as isize; +19 | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:17:5 + --> $DIR/cast_size.rs:19:5 | -17 | 1u64 as isize; +19 | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:18:5 + --> $DIR/cast_size.rs:20:5 | -18 | 1u64 as usize; +20 | 1u64 as usize; | ^^^^^^^^^^^^^ error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:19:5 + --> $DIR/cast_size.rs:21:5 | -19 | 1u32 as isize; +21 | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting i32 to usize may lose the sign of the value - --> $DIR/cast_size.rs:22:5 + --> $DIR/cast_size.rs:24:5 | -22 | 1i32 as usize; +24 | 1i32 as usize; | ^^^^^^^^^^^^^ error: aborting due to 19 previous errors diff --git a/tests/ui/char_lit_as_u8.stderr b/tests/ui/char_lit_as_u8.stderr index fcf038fe002..f6ea10d5731 100644 --- a/tests/ui/char_lit_as_u8.stderr +++ b/tests/ui/char_lit_as_u8.stderr @@ -4,7 +4,7 @@ error: casting character literal to u8. `char`s are 4 bytes wide in rust, so cas 7 | let c = 'a' as u8; | ^^^^^^^^^ | - = note: `-D char-lit-as-u8` implied by `-D warnings` + = note: `-D clippy::char-lit-as-u8` implied by `-D warnings` = help: Consider using a byte literal instead: b'a' diff --git a/tests/ui/checked_unwrap.stderr b/tests/ui/checked_unwrap.stderr index 1b46ceb5fa8..4508ce442fa 100644 --- a/tests/ui/checked_unwrap.stderr +++ b/tests/ui/checked_unwrap.stderr @@ -1,313 +1,313 @@ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:7:9 - | -6 | if x.is_some() { - | ----------- the check is happening here -7 | x.unwrap(); // unnecessary - | ^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/checked_unwrap.rs:1:27 - | -1 | #![deny(panicking_unwrap, unnecessary_unwrap)] - | ^^^^^^^^^^^^^^^^^^ - -error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:9:9 | -6 | if x.is_some() { - | ----------- because of this check -... -9 | x.unwrap(); // will panic +8 | if x.is_some() { + | ----------- the check is happening here +9 | x.unwrap(); // unnecessary | ^^^^^^^^^^ | note: lint level defined here - --> $DIR/checked_unwrap.rs:1:9 + --> $DIR/checked_unwrap.rs:3:35 | -1 | #![deny(panicking_unwrap, unnecessary_unwrap)] - | ^^^^^^^^^^^^^^^^ +3 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:12:9 + --> $DIR/checked_unwrap.rs:11:9 | -11 | if x.is_none() { +8 | if x.is_some() { | ----------- because of this check -12 | x.unwrap(); // will panic +... +11 | x.unwrap(); // will panic | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/checked_unwrap.rs:3:9 + | +3 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. +error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:14:9 | -11 | if x.is_none() { +13 | if x.is_none() { + | ----------- because of this check +14 | x.unwrap(); // will panic + | ^^^^^^^^^^ + +error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:16:9 + | +13 | if x.is_none() { | ----------- the check is happening here ... -14 | x.unwrap(); // unnecessary +16 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:18:9 + --> $DIR/checked_unwrap.rs:20:9 | -17 | if x.is_ok() { +19 | if x.is_ok() { | --------- the check is happening here -18 | x.unwrap(); // unnecessary +20 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:19:9 - | -17 | if x.is_ok() { - | --------- because of this check -18 | x.unwrap(); // unnecessary -19 | x.unwrap_err(); // will panic - | ^^^^^^^^^^^^^^ - -error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:21:9 | -17 | if x.is_ok() { +19 | if x.is_ok() { | --------- because of this check -... -21 | x.unwrap(); // will panic - | ^^^^^^^^^^ - -error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:22:9 - | -17 | if x.is_ok() { - | --------- the check is happening here -... -22 | x.unwrap_err(); // unnecessary +20 | x.unwrap(); // unnecessary +21 | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:25:9 + --> $DIR/checked_unwrap.rs:23:9 | -24 | if x.is_err() { - | ---------- because of this check -25 | x.unwrap(); // will panic +19 | if x.is_ok() { + | --------- because of this check +... +23 | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:26:9 + --> $DIR/checked_unwrap.rs:24:9 | -24 | if x.is_err() { - | ---------- the check is happening here -25 | x.unwrap(); // will panic -26 | x.unwrap_err(); // unnecessary +19 | if x.is_ok() { + | --------- the check is happening here +... +24 | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ -error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. +error: This call to `unwrap()` will always panic. + --> $DIR/checked_unwrap.rs:27:9 + | +26 | if x.is_err() { + | ---------- because of this check +27 | x.unwrap(); // will panic + | ^^^^^^^^^^ + +error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. --> $DIR/checked_unwrap.rs:28:9 | -24 | if x.is_err() { +26 | if x.is_err() { | ---------- the check is happening here -... -28 | x.unwrap(); // unnecessary - | ^^^^^^^^^^ - -error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:29:9 - | -24 | if x.is_err() { - | ---------- because of this check -... -29 | x.unwrap_err(); // will panic +27 | x.unwrap(); // will panic +28 | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:46:9 + --> $DIR/checked_unwrap.rs:30:9 | -45 | if x.is_ok() && y.is_err() { - | --------- the check is happening here -46 | x.unwrap(); // unnecessary +26 | if x.is_err() { + | ---------- the check is happening here +... +30 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:47:9 + --> $DIR/checked_unwrap.rs:31:9 | -45 | if x.is_ok() && y.is_err() { - | --------- because of this check -46 | x.unwrap(); // unnecessary -47 | x.unwrap_err(); // will panic +26 | if x.is_err() { + | ---------- because of this check +... +31 | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ -error: This call to `unwrap()` will always panic. +error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. --> $DIR/checked_unwrap.rs:48:9 | -45 | if x.is_ok() && y.is_err() { - | ---------- because of this check -... -48 | y.unwrap(); // will panic +47 | if x.is_ok() && y.is_err() { + | --------- the check is happening here +48 | x.unwrap(); // unnecessary | ^^^^^^^^^^ -error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. +error: This call to `unwrap_err()` will always panic. --> $DIR/checked_unwrap.rs:49:9 | -45 | if x.is_ok() && y.is_err() { - | ---------- the check is happening here -... -49 | y.unwrap_err(); // unnecessary +47 | if x.is_ok() && y.is_err() { + | --------- because of this check +48 | x.unwrap(); // unnecessary +49 | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:63:9 + --> $DIR/checked_unwrap.rs:50:9 | -58 | if x.is_ok() || y.is_ok() { - | --------- because of this check +47 | if x.is_ok() && y.is_err() { + | ---------- because of this check ... -63 | x.unwrap(); // will panic +50 | y.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:64:9 + --> $DIR/checked_unwrap.rs:51:9 | -58 | if x.is_ok() || y.is_ok() { - | --------- the check is happening here +47 | if x.is_ok() && y.is_err() { + | ---------- the check is happening here ... -64 | x.unwrap_err(); // unnecessary +51 | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:65:9 | -58 | if x.is_ok() || y.is_ok() { - | --------- because of this check +60 | if x.is_ok() || y.is_ok() { + | --------- because of this check ... -65 | y.unwrap(); // will panic +65 | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. --> $DIR/checked_unwrap.rs:66:9 | -58 | if x.is_ok() || y.is_ok() { +60 | if x.is_ok() || y.is_ok() { + | --------- the check is happening here +... +66 | x.unwrap_err(); // unnecessary + | ^^^^^^^^^^^^^^ + +error: This call to `unwrap()` will always panic. + --> $DIR/checked_unwrap.rs:67:9 + | +60 | if x.is_ok() || y.is_ok() { + | --------- because of this check +... +67 | y.unwrap(); // will panic + | ^^^^^^^^^^ + +error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:68:9 + | +60 | if x.is_ok() || y.is_ok() { | --------- the check is happening here ... -66 | y.unwrap_err(); // unnecessary +68 | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:70:9 - | -69 | if x.is_ok() && !(y.is_ok() || z.is_err()) { - | --------- the check is happening here -70 | x.unwrap(); // unnecessary - | ^^^^^^^^^^ - -error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:71:9 - | -69 | if x.is_ok() && !(y.is_ok() || z.is_err()) { - | --------- because of this check -70 | x.unwrap(); // unnecessary -71 | x.unwrap_err(); // will panic - | ^^^^^^^^^^^^^^ - -error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:72:9 | -69 | if x.is_ok() && !(y.is_ok() || z.is_err()) { - | --------- because of this check -... -72 | y.unwrap(); // will panic +71 | if x.is_ok() && !(y.is_ok() || z.is_err()) { + | --------- the check is happening here +72 | x.unwrap(); // unnecessary | ^^^^^^^^^^ -error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. +error: This call to `unwrap_err()` will always panic. --> $DIR/checked_unwrap.rs:73:9 | -69 | if x.is_ok() && !(y.is_ok() || z.is_err()) { - | --------- the check is happening here -... -73 | y.unwrap_err(); // unnecessary +71 | if x.is_ok() && !(y.is_ok() || z.is_err()) { + | --------- because of this check +72 | x.unwrap(); // unnecessary +73 | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ -error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. +error: This call to `unwrap()` will always panic. --> $DIR/checked_unwrap.rs:74:9 | -69 | if x.is_ok() && !(y.is_ok() || z.is_err()) { - | ---------- the check is happening here -... -74 | z.unwrap(); // unnecessary - | ^^^^^^^^^^ - -error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:75:9 - | -69 | if x.is_ok() && !(y.is_ok() || z.is_err()) { - | ---------- because of this check -... -75 | z.unwrap_err(); // will panic - | ^^^^^^^^^^^^^^ - -error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:83:9 - | -77 | if x.is_ok() || !(y.is_ok() && z.is_err()) { - | --------- because of this check -... -83 | x.unwrap(); // will panic - | ^^^^^^^^^^ - -error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:84:9 - | -77 | if x.is_ok() || !(y.is_ok() && z.is_err()) { - | --------- the check is happening here -... -84 | x.unwrap_err(); // unnecessary - | ^^^^^^^^^^^^^^ - -error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:85:9 - | -77 | if x.is_ok() || !(y.is_ok() && z.is_err()) { - | --------- the check is happening here -... -85 | y.unwrap(); // unnecessary - | ^^^^^^^^^^ - -error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:86:9 - | -77 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +71 | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check ... -86 | y.unwrap_err(); // will panic - | ^^^^^^^^^^^^^^ - -error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:87:9 - | -77 | if x.is_ok() || !(y.is_ok() && z.is_err()) { - | ---------- because of this check -... -87 | z.unwrap(); // will panic +74 | y.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:88:9 + --> $DIR/checked_unwrap.rs:75:9 | -77 | if x.is_ok() || !(y.is_ok() && z.is_err()) { - | ---------- the check is happening here +71 | if x.is_ok() && !(y.is_ok() || z.is_err()) { + | --------- the check is happening here ... -88 | z.unwrap_err(); // unnecessary +75 | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:96:13 + --> $DIR/checked_unwrap.rs:76:9 | -95 | if x.is_some() { +71 | if x.is_ok() && !(y.is_ok() || z.is_err()) { + | ---------- the check is happening here +... +76 | z.unwrap(); // unnecessary + | ^^^^^^^^^^ + +error: This call to `unwrap_err()` will always panic. + --> $DIR/checked_unwrap.rs:77:9 + | +71 | if x.is_ok() && !(y.is_ok() || z.is_err()) { + | ---------- because of this check +... +77 | z.unwrap_err(); // will panic + | ^^^^^^^^^^^^^^ + +error: This call to `unwrap()` will always panic. + --> $DIR/checked_unwrap.rs:85:9 + | +79 | if x.is_ok() || !(y.is_ok() && z.is_err()) { + | --------- because of this check +... +85 | x.unwrap(); // will panic + | ^^^^^^^^^^ + +error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:86:9 + | +79 | if x.is_ok() || !(y.is_ok() && z.is_err()) { + | --------- the check is happening here +... +86 | x.unwrap_err(); // unnecessary + | ^^^^^^^^^^^^^^ + +error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:87:9 + | +79 | if x.is_ok() || !(y.is_ok() && z.is_err()) { + | --------- the check is happening here +... +87 | y.unwrap(); // unnecessary + | ^^^^^^^^^^ + +error: This call to `unwrap_err()` will always panic. + --> $DIR/checked_unwrap.rs:88:9 + | +79 | if x.is_ok() || !(y.is_ok() && z.is_err()) { + | --------- because of this check +... +88 | y.unwrap_err(); // will panic + | ^^^^^^^^^^^^^^ + +error: This call to `unwrap()` will always panic. + --> $DIR/checked_unwrap.rs:89:9 + | +79 | if x.is_ok() || !(y.is_ok() && z.is_err()) { + | ---------- because of this check +... +89 | z.unwrap(); // will panic + | ^^^^^^^^^^ + +error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:90:9 + | +79 | if x.is_ok() || !(y.is_ok() && z.is_err()) { + | ---------- the check is happening here +... +90 | z.unwrap_err(); // unnecessary + | ^^^^^^^^^^^^^^ + +error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. + --> $DIR/checked_unwrap.rs:98:13 + | +97 | if x.is_some() { | ----------- the check is happening here -96 | x.unwrap(); // unnecessary +98 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:98:13 - | -95 | if x.is_some() { - | ----------- because of this check + --> $DIR/checked_unwrap.rs:100:13 + | +97 | if x.is_some() { + | ----------- because of this check ... -98 | x.unwrap(); // will panic - | ^^^^^^^^^^ +100 | x.unwrap(); // will panic + | ^^^^^^^^^^ error: aborting due to 34 previous errors diff --git a/tests/ui/cmp_nan.stderr b/tests/ui/cmp_nan.stderr index 46f3d3d57e0..7f636e6b534 100644 --- a/tests/ui/cmp_nan.stderr +++ b/tests/ui/cmp_nan.stderr @@ -4,7 +4,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead 8 | x == std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ | - = note: `-D cmp-nan` implied by `-D warnings` + = note: `-D clippy::cmp-nan` implied by `-D warnings` error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:9:5 diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index 481a4d0f942..55050d2a320 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -4,7 +4,7 @@ error: Comparing with null is better expressed by the .is_null() method 11 | if p == ptr::null() { | ^^^^^^^^^^^^^^^^ | - = note: `-D cmp-null` implied by `-D warnings` + = note: `-D clippy::cmp-null` implied by `-D warnings` error: Comparing with null is better expressed by the .is_null() method --> $DIR/cmp_null.rs:16:8 diff --git a/tests/ui/cmp_owned.stderr b/tests/ui/cmp_owned.stderr index d40fb4b8add..2691c12eab1 100644 --- a/tests/ui/cmp_owned.stderr +++ b/tests/ui/cmp_owned.stderr @@ -4,7 +4,7 @@ error: this creates an owned instance just for comparison 8 | x != "foo".to_string(); | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` | - = note: `-D cmp-owned` implied by `-D warnings` + = note: `-D clippy::cmp-owned` implied by `-D warnings` error: this creates an owned instance just for comparison --> $DIR/cmp_owned.rs:10:9 diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index 69f2013c1dc..a447fab7b6e 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -8,7 +8,7 @@ error: this if statement can be collapsed 12 | | } | |_____^ | - = note: `-D collapsible-if` implied by `-D warnings` + = note: `-D clippy::collapsible-if` implied by `-D warnings` help: try | 8 | if x == "hello" && y == "world" { diff --git a/tests/ui/complex_types.stderr b/tests/ui/complex_types.stderr index 829a22c233f..1c9106c0c21 100644 --- a/tests/ui/complex_types.stderr +++ b/tests/ui/complex_types.stderr @@ -4,7 +4,7 @@ error: very complex type used. Consider factoring parts into `type` definitions 9 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D type-complexity` implied by `-D warnings` + = note: `-D clippy::type-complexity` implied by `-D warnings` error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:10:12 diff --git a/tests/ui/const_static_lifetime.stderr b/tests/ui/const_static_lifetime.stderr index db33744c7a9..db6c4d9444f 100644 --- a/tests/ui/const_static_lifetime.stderr +++ b/tests/ui/const_static_lifetime.stderr @@ -4,7 +4,7 @@ error: Constants have by default a `'static` lifetime 4 | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` | - = note: `-D const-static-lifetime` implied by `-D warnings` + = note: `-D clippy::const-static-lifetime` implied by `-D warnings` error: Constants have by default a `'static` lifetime --> $DIR/const_static_lifetime.rs:8:21 diff --git a/tests/ui/copies.stderr b/tests/ui/copies.stderr index cce63280ce1..febd34603c9 100644 --- a/tests/ui/copies.stderr +++ b/tests/ui/copies.stderr @@ -1,384 +1,384 @@ error: this `if` has identical blocks - --> $DIR/copies.rs:29:10 + --> $DIR/copies.rs:31:10 | -29 | else { //~ ERROR same body as `if` block +31 | else { //~ ERROR same body as `if` block | __________^ -30 | | Foo { bar: 42 }; -31 | | 0..10; -32 | | ..; +32 | | Foo { bar: 42 }; +33 | | 0..10; +34 | | ..; ... | -36 | | foo(); -37 | | } +38 | | foo(); +39 | | } | |_____^ | - = note: `-D if-same-then-else` implied by `-D warnings` + = note: `-D clippy::if-same-then-else` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:20:13 + --> $DIR/copies.rs:22:13 | -20 | if true { +22 | if true { | _____________^ -21 | | Foo { bar: 42 }; -22 | | 0..10; -23 | | ..; +23 | | Foo { bar: 42 }; +24 | | 0..10; +25 | | ..; ... | -27 | | foo(); -28 | | } +29 | | foo(); +30 | | } | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:78:14 + --> $DIR/copies.rs:80:14 | -78 | _ => { //~ ERROR match arms have same body +80 | _ => { //~ ERROR match arms have same body | ______________^ -79 | | foo(); -80 | | let mut a = 42 + [23].len() as i32; -81 | | if true { +81 | | foo(); +82 | | let mut a = 42 + [23].len() as i32; +83 | | if true { ... | -85 | | a -86 | | } +87 | | a +88 | | } | |_________^ | - = note: `-D match-same-arms` implied by `-D warnings` + = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:69:15 + --> $DIR/copies.rs:71:15 | -69 | 42 => { +71 | 42 => { | _______________^ -70 | | foo(); -71 | | let mut a = 42 + [23].len() as i32; -72 | | if true { +72 | | foo(); +73 | | let mut a = 42 + [23].len() as i32; +74 | | if true { ... | -76 | | a -77 | | } +78 | | a +79 | | } | |_________^ note: `42` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:69:15 + --> $DIR/copies.rs:71:15 | -69 | 42 => { +71 | 42 => { | _______________^ -70 | | foo(); -71 | | let mut a = 42 + [23].len() as i32; -72 | | if true { +72 | | foo(); +73 | | let mut a = 42 + [23].len() as i32; +74 | | if true { ... | -76 | | a -77 | | } +78 | | a +79 | | } | |_________^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:92:14 + --> $DIR/copies.rs:94:14 | -92 | _ => 0, //~ ERROR match arms have same body +94 | _ => 0, //~ ERROR match arms have same body | ^ | note: same as this - --> $DIR/copies.rs:90:19 + --> $DIR/copies.rs:92:19 | -90 | Abc::A => 0, +92 | Abc::A => 0, | ^ note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:90:19 + --> $DIR/copies.rs:92:19 | -90 | Abc::A => 0, +92 | Abc::A => 0, | ^ error: this `if` has identical blocks - --> $DIR/copies.rs:102:10 + --> $DIR/copies.rs:104:10 | -102 | else { //~ ERROR same body as `if` block +104 | else { //~ ERROR same body as `if` block | __________^ -103 | | 42 -104 | | }; +105 | | 42 +106 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:99:21 + --> $DIR/copies.rs:101:21 | -99 | let _ = if true { +101 | let _ = if true { | _____________________^ -100 | | 42 -101 | | } +102 | | 42 +103 | | } | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:116:10 + --> $DIR/copies.rs:118:10 | -116 | else { //~ ERROR same body as `if` block +118 | else { //~ ERROR same body as `if` block | __________^ -117 | | for _ in &[42] { -118 | | let foo: &Option<_> = &Some::(42); -119 | | if true { +119 | | for _ in &[42] { +120 | | let foo: &Option<_> = &Some::(42); +121 | | if true { ... | -124 | | } -125 | | } +126 | | } +127 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:106:13 + --> $DIR/copies.rs:108:13 | -106 | if true { +108 | if true { | _____________^ -107 | | for _ in &[42] { -108 | | let foo: &Option<_> = &Some::(42); -109 | | if true { +109 | | for _ in &[42] { +110 | | let foo: &Option<_> = &Some::(42); +111 | | if true { ... | -114 | | } -115 | | } +116 | | } +117 | | } | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:138:10 + --> $DIR/copies.rs:140:10 | -138 | else { //~ ERROR same body as `if` block +140 | else { //~ ERROR same body as `if` block | __________^ -139 | | let bar = if true { -140 | | 42 -141 | | } +141 | | let bar = if true { +142 | | 42 +143 | | } ... | -147 | | bar + 1; -148 | | } +149 | | bar + 1; +150 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:127:13 + --> $DIR/copies.rs:129:13 | -127 | if true { +129 | if true { | _____________^ -128 | | let bar = if true { -129 | | 42 -130 | | } +130 | | let bar = if true { +131 | | 42 +132 | | } ... | -136 | | bar + 1; -137 | | } +138 | | bar + 1; +139 | | } | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:173:10 + --> $DIR/copies.rs:175:10 | -173 | else { //~ ERROR same body as `if` block +175 | else { //~ ERROR same body as `if` block | __________^ -174 | | if let Some(a) = Some(42) {} -175 | | } +176 | | if let Some(a) = Some(42) {} +177 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:170:13 + --> $DIR/copies.rs:172:13 | -170 | if true { +172 | if true { | _____________^ -171 | | if let Some(a) = Some(42) {} -172 | | } +173 | | if let Some(a) = Some(42) {} +174 | | } | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:180:10 + --> $DIR/copies.rs:182:10 | -180 | else { //~ ERROR same body as `if` block +182 | else { //~ ERROR same body as `if` block | __________^ -181 | | if let (1, .., 3) = (1, 2, 3) {} -182 | | } +183 | | if let (1, .., 3) = (1, 2, 3) {} +184 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:177:13 + --> $DIR/copies.rs:179:13 | -177 | if true { +179 | if true { | _____________^ -178 | | if let (1, .., 3) = (1, 2, 3) {} -179 | | } +180 | | if let (1, .., 3) = (1, 2, 3) {} +181 | | } | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:235:15 + --> $DIR/copies.rs:237:15 | -235 | 51 => foo(), //~ ERROR match arms have same body +237 | 51 => foo(), //~ ERROR match arms have same body | ^^^^^ | note: same as this - --> $DIR/copies.rs:234:15 + --> $DIR/copies.rs:236:15 | -234 | 42 => foo(), +236 | 42 => foo(), | ^^^^^ note: consider refactoring into `42 | 51` - --> $DIR/copies.rs:234:15 + --> $DIR/copies.rs:236:15 | -234 | 42 => foo(), +236 | 42 => foo(), | ^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:241:17 + --> $DIR/copies.rs:243:17 | -241 | None => 24, //~ ERROR match arms have same body +243 | None => 24, //~ ERROR match arms have same body | ^^ | note: same as this - --> $DIR/copies.rs:240:20 + --> $DIR/copies.rs:242:20 | -240 | Some(_) => 24, +242 | Some(_) => 24, | ^^ note: consider refactoring into `Some(_) | None` - --> $DIR/copies.rs:240:20 + --> $DIR/copies.rs:242:20 | -240 | Some(_) => 24, +242 | Some(_) => 24, | ^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:263:28 + --> $DIR/copies.rs:265:28 | -263 | (None, Some(a)) => bar(a), //~ ERROR match arms have same body +265 | (None, Some(a)) => bar(a), //~ ERROR match arms have same body | ^^^^^^ | note: same as this - --> $DIR/copies.rs:262:28 + --> $DIR/copies.rs:264:28 | -262 | (Some(a), None) => bar(a), +264 | (Some(a), None) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), None) | (None, Some(a))` - --> $DIR/copies.rs:262:28 + --> $DIR/copies.rs:264:28 | -262 | (Some(a), None) => bar(a), +264 | (Some(a), None) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:269:26 + --> $DIR/copies.rs:271:26 | -269 | (.., Some(a)) => bar(a), //~ ERROR match arms have same body +271 | (.., Some(a)) => bar(a), //~ ERROR match arms have same body | ^^^^^^ | note: same as this - --> $DIR/copies.rs:268:26 + --> $DIR/copies.rs:270:26 | -268 | (Some(a), ..) => bar(a), +270 | (Some(a), ..) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), ..) | (.., Some(a))` - --> $DIR/copies.rs:268:26 + --> $DIR/copies.rs:270:26 | -268 | (Some(a), ..) => bar(a), +270 | (Some(a), ..) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:275:20 + --> $DIR/copies.rs:277:20 | -275 | (.., 3) => 42, //~ ERROR match arms have same body +277 | (.., 3) => 42, //~ ERROR match arms have same body | ^^ | note: same as this - --> $DIR/copies.rs:274:23 + --> $DIR/copies.rs:276:23 | -274 | (1, .., 3) => 42, +276 | (1, .., 3) => 42, | ^^ note: consider refactoring into `(1, .., 3) | (.., 3)` - --> $DIR/copies.rs:274:23 + --> $DIR/copies.rs:276:23 | -274 | (1, .., 3) => 42, +276 | (1, .., 3) => 42, | ^^ error: this `if` has identical blocks - --> $DIR/copies.rs:281:12 + --> $DIR/copies.rs:283:12 | -281 | } else { //~ ERROR same body as `if` block +283 | } else { //~ ERROR same body as `if` block | ____________^ +284 | | 0.0 +285 | | }; + | |_____^ + | +note: same as this + --> $DIR/copies.rs:281:21 + | +281 | let _ = if true { + | _____________________^ 282 | | 0.0 -283 | | }; - | |_____^ - | -note: same as this - --> $DIR/copies.rs:279:21 - | -279 | let _ = if true { - | _____________________^ -280 | | 0.0 -281 | | } else { //~ ERROR same body as `if` block +283 | | } else { //~ ERROR same body as `if` block | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:287:12 + --> $DIR/copies.rs:289:12 | -287 | } else { //~ ERROR same body as `if` block +289 | } else { //~ ERROR same body as `if` block | ____________^ +290 | | -0.0 +291 | | }; + | |_____^ + | +note: same as this + --> $DIR/copies.rs:287:21 + | +287 | let _ = if true { + | _____________________^ 288 | | -0.0 -289 | | }; - | |_____^ - | -note: same as this - --> $DIR/copies.rs:285:21 - | -285 | let _ = if true { - | _____________________^ -286 | | -0.0 -287 | | } else { //~ ERROR same body as `if` block +289 | | } else { //~ ERROR same body as `if` block | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:307:12 + --> $DIR/copies.rs:309:12 | -307 | } else { //~ ERROR same body as `if` block +309 | } else { //~ ERROR same body as `if` block | ____________^ -308 | | std::f32::NAN -309 | | }; +310 | | std::f32::NAN +311 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:305:21 + --> $DIR/copies.rs:307:21 | -305 | let _ = if true { +307 | let _ = if true { | _____________________^ -306 | | std::f32::NAN -307 | | } else { //~ ERROR same body as `if` block +308 | | std::f32::NAN +309 | | } else { //~ ERROR same body as `if` block | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:325:10 + --> $DIR/copies.rs:327:10 | -325 | else { //~ ERROR same body as `if` block +327 | else { //~ ERROR same body as `if` block | __________^ -326 | | try!(Ok("foo")); -327 | | } +328 | | try!(Ok("foo")); +329 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:322:13 + --> $DIR/copies.rs:324:13 | -322 | if true { +324 | if true { | _____________^ -323 | | try!(Ok("foo")); -324 | | } +325 | | try!(Ok("foo")); +326 | | } | |_____^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:351:13 + --> $DIR/copies.rs:353:13 | -351 | else if b { //~ ERROR ifs same condition +353 | else if b { //~ ERROR ifs same condition | ^ | - = note: `-D ifs-same-cond` implied by `-D warnings` + = note: `-D clippy::ifs-same-cond` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:349:8 + --> $DIR/copies.rs:351:8 | -349 | if b { +351 | if b { | ^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:356:13 + --> $DIR/copies.rs:358:13 | -356 | else if a == 1 { //~ ERROR ifs same condition +358 | else if a == 1 { //~ ERROR ifs same condition | ^^^^^^ | note: same as this - --> $DIR/copies.rs:354:8 + --> $DIR/copies.rs:356:8 | -354 | if a == 1 { +356 | if a == 1 { | ^^^^^^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:363:13 + --> $DIR/copies.rs:365:13 | -363 | else if 2*a == 1 { //~ ERROR ifs same condition +365 | else if 2*a == 1 { //~ ERROR ifs same condition | ^^^^^^^^ | note: same as this - --> $DIR/copies.rs:359:8 + --> $DIR/copies.rs:361:8 | -359 | if 2*a == 1 { +361 | if 2*a == 1 { | ^^^^^^^^ error: aborting due to 20 previous errors diff --git a/tests/ui/copy_iterator.stderr b/tests/ui/copy_iterator.stderr index f520156b01e..9a06a52d4bb 100644 --- a/tests/ui/copy_iterator.stderr +++ b/tests/ui/copy_iterator.stderr @@ -1,16 +1,16 @@ error: you are implementing `Iterator` on a `Copy` type - --> $DIR/copy_iterator.rs:6:1 + --> $DIR/copy_iterator.rs:8:1 | -6 | / impl Iterator for Countdown { -7 | | type Item = u8; -8 | | -9 | | fn next(&mut self) -> Option { +8 | / impl Iterator for Countdown { +9 | | type Item = u8; +10 | | +11 | | fn next(&mut self) -> Option { ... | -14 | | } -15 | | } +16 | | } +17 | | } | |_^ | - = note: `-D copy-iterator` implied by `-D warnings` + = note: `-D clippy::copy-iterator` implied by `-D warnings` = note: consider implementing `IntoIterator` instead error: aborting due to previous error diff --git a/tests/ui/cstring.stderr b/tests/ui/cstring.stderr index 0e90f696357..2b2b51de6ae 100644 --- a/tests/ui/cstring.stderr +++ b/tests/ui/cstring.stderr @@ -1,15 +1,15 @@ error: you are getting the inner pointer of a temporary `CString` - --> $DIR/cstring.rs:7:5 + --> $DIR/cstring.rs:9:5 | -7 | CString::new("foo").unwrap().as_ptr(); +9 | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: #[deny(temporary_cstring_as_ptr)] on by default + = note: #[deny(clippy::temporary_cstring_as_ptr)] on by default = note: that pointer will be invalid outside this expression help: assign the `CString` to a variable to extend its lifetime - --> $DIR/cstring.rs:7:5 + --> $DIR/cstring.rs:9:5 | -7 | CString::new("foo").unwrap().as_ptr(); +9 | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/cyclomatic_complexity.stderr b/tests/ui/cyclomatic_complexity.stderr index 43676762d6c..ff93f21e3ae 100644 --- a/tests/ui/cyclomatic_complexity.stderr +++ b/tests/ui/cyclomatic_complexity.stderr @@ -10,7 +10,7 @@ error: the function has a cyclomatic complexity of 28 89 | | } | |_^ | - = note: `-D cyclomatic-complexity` implied by `-D warnings` + = note: `-D clippy::cyclomatic-complexity` implied by `-D warnings` = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 7 diff --git a/tests/ui/cyclomatic_complexity_attr_used.stderr b/tests/ui/cyclomatic_complexity_attr_used.stderr index e671b34393b..f8342f0d9e5 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.stderr +++ b/tests/ui/cyclomatic_complexity_attr_used.stderr @@ -10,7 +10,7 @@ error: the function has a cyclomatic complexity of 3 17 | | } | |_^ | - = note: `-D cyclomatic-complexity` implied by `-D warnings` + = note: `-D clippy::cyclomatic-complexity` implied by `-D warnings` = help: you could split it up into multiple smaller functions error: aborting due to previous error diff --git a/tests/ui/decimal_literal_representation.stderr b/tests/ui/decimal_literal_representation.stderr index baed3c41180..343936bb7a2 100644 --- a/tests/ui/decimal_literal_representation.stderr +++ b/tests/ui/decimal_literal_representation.stderr @@ -4,7 +4,7 @@ error: integer literal has a better hexadecimal representation 18 | 32_773, // 0x8005 | ^^^^^^ help: consider: `0x8005` | - = note: `-D decimal-literal-representation` implied by `-D warnings` + = note: `-D clippy::decimal-literal-representation` implied by `-D warnings` error: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:19:9 diff --git a/tests/ui/default_trait_access.stderr b/tests/ui/default_trait_access.stderr index 8bb4731035a..e3c263e7732 100644 --- a/tests/ui/default_trait_access.stderr +++ b/tests/ui/default_trait_access.stderr @@ -1,51 +1,51 @@ error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:8:22 - | -8 | let s1: String = Default::default(); - | ^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` - | - = note: `-D default-trait-access` implied by `-D warnings` - -error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:12:22 + --> $DIR/default_trait_access.rs:10:22 | -12 | let s3: String = D2::default(); - | ^^^^^^^^^^^^^ help: try: `std::string::String::default()` +10 | let s1: String = Default::default(); + | ^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` + | + = note: `-D clippy::default-trait-access` implied by `-D warnings` error: Calling std::string::String::default() is more clear than this expression --> $DIR/default_trait_access.rs:14:22 | -14 | let s4: String = std::default::Default::default(); +14 | let s3: String = D2::default(); + | ^^^^^^^^^^^^^ help: try: `std::string::String::default()` + +error: Calling std::string::String::default() is more clear than this expression + --> $DIR/default_trait_access.rs:16:22 + | +16 | let s4: String = std::default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:18:22 + --> $DIR/default_trait_access.rs:20:22 | -18 | let s6: String = default::Default::default(); +20 | let s6: String = default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling GenericDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:28:46 + --> $DIR/default_trait_access.rs:30:46 | -28 | let s11: GenericDerivedDefault = Default::default(); +30 | let s11: GenericDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault::default()` error: Calling TupleDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:34:36 + --> $DIR/default_trait_access.rs:36:36 | -34 | let s14: TupleDerivedDefault = Default::default(); +36 | let s14: TupleDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleDerivedDefault::default()` error: Calling ArrayDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:36:36 + --> $DIR/default_trait_access.rs:38:36 | -36 | let s15: ArrayDerivedDefault = Default::default(); +38 | let s15: ArrayDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `ArrayDerivedDefault::default()` error: Calling TupleStructDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:40:42 + --> $DIR/default_trait_access.rs:42:42 | -40 | let s17: TupleStructDerivedDefault = Default::default(); +42 | let s17: TupleStructDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleStructDerivedDefault::default()` error: aborting due to 8 previous errors diff --git a/tests/ui/derive.stderr b/tests/ui/derive.stderr index cbe3fe1029d..fa706f22b90 100644 --- a/tests/ui/derive.stderr +++ b/tests/ui/derive.stderr @@ -4,7 +4,7 @@ error: you are deriving `Hash` but have implemented `PartialEq` explicitly 17 | #[derive(Hash)] | ^^^^ | - = note: #[deny(derive_hash_xor_eq)] on by default + = note: #[deny(clippy::derive_hash_xor_eq)] on by default note: `PartialEq` implemented here --> $DIR/derive.rs:20:1 | @@ -49,7 +49,7 @@ error: you are implementing `Clone` explicitly on a `Copy` type 43 | | } | |_^ | - = note: `-D expl-impl-clone-on-copy` implied by `-D warnings` + = note: `-D clippy::expl-impl-clone-on-copy` implied by `-D warnings` note: consider deriving `Clone` or removing `Copy` --> $DIR/derive.rs:41:1 | diff --git a/tests/ui/diverging_sub_expression.stderr b/tests/ui/diverging_sub_expression.stderr index 0d7b1ca6fd6..8e86a7734dc 100644 --- a/tests/ui/diverging_sub_expression.stderr +++ b/tests/ui/diverging_sub_expression.stderr @@ -1,39 +1,39 @@ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:18:10 + --> $DIR/diverging_sub_expression.rs:20:10 | -18 | b || diverge(); +20 | b || diverge(); | ^^^^^^^^^ | - = note: `-D diverging-sub-expression` implied by `-D warnings` + = note: `-D clippy::diverging-sub-expression` implied by `-D warnings` error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:19:10 + --> $DIR/diverging_sub_expression.rs:21:10 | -19 | b || A.foo(); +21 | b || A.foo(); | ^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:28:26 + --> $DIR/diverging_sub_expression.rs:30:26 | -28 | 6 => true || return, +30 | 6 => true || return, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:29:26 + --> $DIR/diverging_sub_expression.rs:31:26 | -29 | 7 => true || continue, +31 | 7 => true || continue, | ^^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:32:26 + --> $DIR/diverging_sub_expression.rs:34:26 | -32 | 3 => true || diverge(), +34 | 3 => true || diverge(), | ^^^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:37:26 + --> $DIR/diverging_sub_expression.rs:39:26 | -37 | _ => true || break, +39 | _ => true || break, | ^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/dlist.stderr b/tests/ui/dlist.stderr index de0422e17ed..5322075208c 100644 --- a/tests/ui/dlist.stderr +++ b/tests/ui/dlist.stderr @@ -1,48 +1,48 @@ error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:12:16 + --> $DIR/dlist.rs:14:16 | -12 | type Baz = LinkedList; +14 | type Baz = LinkedList; | ^^^^^^^^^^^^^^ | - = note: `-D linkedlist` implied by `-D warnings` + = note: `-D clippy::linkedlist` implied by `-D warnings` = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:13:12 + --> $DIR/dlist.rs:15:12 | -13 | fn foo(LinkedList); +15 | fn foo(LinkedList); | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:14:24 + --> $DIR/dlist.rs:16:24 | -14 | const BAR : Option>; +16 | const BAR : Option>; | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:25:15 + --> $DIR/dlist.rs:27:15 | -25 | fn foo(_: LinkedList) {} +27 | fn foo(_: LinkedList) {} | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:28:39 + --> $DIR/dlist.rs:30:39 | -28 | pub fn test(my_favourite_linked_list: LinkedList) { +30 | pub fn test(my_favourite_linked_list: LinkedList) { | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:32:29 + --> $DIR/dlist.rs:34:29 | -32 | pub fn test_ret() -> Option> { +34 | pub fn test_ret() -> Option> { | ^^^^^^^^^^^^^^ | = help: a VecDeque might work diff --git a/tests/ui/doc.stderr b/tests/ui/doc.stderr index f38678e89aa..c781f36db7a 100644 --- a/tests/ui/doc.stderr +++ b/tests/ui/doc.stderr @@ -1,183 +1,183 @@ error: you should put `DOC_MARKDOWN` between ticks in the documentation - --> $DIR/doc.rs:1:29 + --> $DIR/doc.rs:3:29 | -1 | //! This file tests for the DOC_MARKDOWN lint +3 | //! This file tests for the DOC_MARKDOWN lint | ^^^^^^^^^^^^ | - = note: `-D doc-markdown` implied by `-D warnings` + = note: `-D clippy::doc-markdown` implied by `-D warnings` error: you should put `foo_bar` between ticks in the documentation - --> $DIR/doc.rs:8:9 - | -8 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) - | ^^^^^^^ + --> $DIR/doc.rs:10:9 + | +10 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) + | ^^^^^^^ error: you should put `foo::bar` between ticks in the documentation - --> $DIR/doc.rs:8:51 - | -8 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) - | ^^^^^^^^ + --> $DIR/doc.rs:10:51 + | +10 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) + | ^^^^^^^^ error: you should put `Foo::some_fun` between ticks in the documentation - --> $DIR/doc.rs:9:84 - | -9 | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun - | ^^^^^^^^^^^^^ + --> $DIR/doc.rs:11:84 + | +11 | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun + | ^^^^^^^^^^^^^ error: you should put `a::global:path` between ticks in the documentation - --> $DIR/doc.rs:11:15 + --> $DIR/doc.rs:13:15 | -11 | /// Here be ::a::global:path. +13 | /// Here be ::a::global:path. | ^^^^^^^^^^^^^^ error: you should put `NotInCodeBlock` between ticks in the documentation - --> $DIR/doc.rs:12:22 + --> $DIR/doc.rs:14:22 | -12 | /// That's not code ~NotInCodeBlock~. +14 | /// That's not code ~NotInCodeBlock~. | ^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:13:5 + --> $DIR/doc.rs:15:5 | -13 | /// be_sure_we_got_to_the_end_of_it +15 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:27:5 + --> $DIR/doc.rs:29:5 | -27 | /// be_sure_we_got_to_the_end_of_it +29 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:34:5 + --> $DIR/doc.rs:36:5 | -34 | /// be_sure_we_got_to_the_end_of_it +36 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:48:5 + --> $DIR/doc.rs:50:5 | -48 | /// be_sure_we_got_to_the_end_of_it +50 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `link_with_underscores` between ticks in the documentation - --> $DIR/doc.rs:52:22 + --> $DIR/doc.rs:54:22 | -52 | /// This test has [a link_with_underscores][chunked-example] inside it. See #823. +54 | /// This test has [a link_with_underscores][chunked-example] inside it. See #823. | ^^^^^^^^^^^^^^^^^^^^^ error: you should put `inline_link2` between ticks in the documentation - --> $DIR/doc.rs:55:21 + --> $DIR/doc.rs:57:21 | -55 | /// It can also be [inline_link2]. +57 | /// It can also be [inline_link2]. | ^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:65:5 + --> $DIR/doc.rs:67:5 | -65 | /// be_sure_we_got_to_the_end_of_it +67 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `CamelCaseThing` between ticks in the documentation - --> $DIR/doc.rs:73:8 + --> $DIR/doc.rs:75:8 | -73 | /// ## CamelCaseThing +75 | /// ## CamelCaseThing | ^^^^^^^^^^^^^^ error: you should put `CamelCaseThing` between ticks in the documentation - --> $DIR/doc.rs:76:7 + --> $DIR/doc.rs:78:7 | -76 | /// # CamelCaseThing +78 | /// # CamelCaseThing | ^^^^^^^^^^^^^^ error: you should put `CamelCaseThing` between ticks in the documentation - --> $DIR/doc.rs:78:22 + --> $DIR/doc.rs:80:22 | -78 | /// Not a title #897 CamelCaseThing +80 | /// Not a title #897 CamelCaseThing | ^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:79:5 + --> $DIR/doc.rs:81:5 | -79 | /// be_sure_we_got_to_the_end_of_it +81 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:86:5 + --> $DIR/doc.rs:88:5 | -86 | /// be_sure_we_got_to_the_end_of_it +88 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:99:5 - | -99 | /// be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: you should put `FooBar` between ticks in the documentation - --> $DIR/doc.rs:110:42 + --> $DIR/doc.rs:101:5 | -110 | /** E.g. serialization of an empty list: FooBar - | ^^^^^^ - -error: you should put `BarQuz` between ticks in the documentation - --> $DIR/doc.rs:115:5 - | -115 | And BarQuz too. - | ^^^^^^ - -error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:116:1 - | -116 | be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: you should put `FooBar` between ticks in the documentation - --> $DIR/doc.rs:121:42 - | -121 | /** E.g. serialization of an empty list: FooBar - | ^^^^^^ - -error: you should put `BarQuz` between ticks in the documentation - --> $DIR/doc.rs:126:5 - | -126 | And BarQuz too. - | ^^^^^^ - -error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:127:1 - | -127 | be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:138:5 - | -138 | /// be_sure_we_got_to_the_end_of_it +101 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: you should put bare URLs between `<`/`>` or make a proper Markdown link - --> $DIR/doc.rs:165:13 +error: you should put `FooBar` between ticks in the documentation + --> $DIR/doc.rs:112:42 | -165 | /// Not ok: http://www.unicode.org - | ^^^^^^^^^^^^^^^^^^^^^^ +112 | /** E.g. serialization of an empty list: FooBar + | ^^^^^^ -error: you should put bare URLs between `<`/`>` or make a proper Markdown link - --> $DIR/doc.rs:166:13 +error: you should put `BarQuz` between ticks in the documentation + --> $DIR/doc.rs:117:5 | -166 | /// Not ok: https://www.unicode.org - | ^^^^^^^^^^^^^^^^^^^^^^^ +117 | And BarQuz too. + | ^^^^^^ + +error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation + --> $DIR/doc.rs:118:1 + | +118 | be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: you should put `FooBar` between ticks in the documentation + --> $DIR/doc.rs:123:42 + | +123 | /** E.g. serialization of an empty list: FooBar + | ^^^^^^ + +error: you should put `BarQuz` between ticks in the documentation + --> $DIR/doc.rs:128:5 + | +128 | And BarQuz too. + | ^^^^^^ + +error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation + --> $DIR/doc.rs:129:1 + | +129 | be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation + --> $DIR/doc.rs:140:5 + | +140 | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put bare URLs between `<`/`>` or make a proper Markdown link --> $DIR/doc.rs:167:13 | -167 | /// Not ok: http://www.unicode.org/ +167 | /// Not ok: http://www.unicode.org | ^^^^^^^^^^^^^^^^^^^^^^ error: you should put bare URLs between `<`/`>` or make a proper Markdown link --> $DIR/doc.rs:168:13 | -168 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels +168 | /// Not ok: https://www.unicode.org + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: you should put bare URLs between `<`/`>` or make a proper Markdown link + --> $DIR/doc.rs:169:13 + | +169 | /// Not ok: http://www.unicode.org/ + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: you should put bare URLs between `<`/`>` or make a proper Markdown link + --> $DIR/doc.rs:170:13 + | +170 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 30 previous errors diff --git a/tests/ui/double_comparison.stderr b/tests/ui/double_comparison.stderr index 73dd8d02877..e6a0e976414 100644 --- a/tests/ui/double_comparison.stderr +++ b/tests/ui/double_comparison.stderr @@ -4,7 +4,7 @@ error: This binary expression can be simplified 4 | if x == y || x < y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` | - = note: `-D double-comparisons` implied by `-D warnings` + = note: `-D clippy::double-comparisons` implied by `-D warnings` error: This binary expression can be simplified --> $DIR/double_comparison.rs:7:8 diff --git a/tests/ui/double_neg.stderr b/tests/ui/double_neg.stderr index fd4da8820a2..02202dbd63c 100644 --- a/tests/ui/double_neg.stderr +++ b/tests/ui/double_neg.stderr @@ -4,7 +4,7 @@ error: `--x` could be misinterpreted as pre-decrement by C programmers, is usual 9 | --x; | ^^^ | - = note: `-D double-neg` implied by `-D warnings` + = note: `-D clippy::double-neg` implied by `-D warnings` error: aborting due to previous error diff --git a/tests/ui/double_parens.stderr b/tests/ui/double_parens.stderr index a77b08528c4..a6a29eeb063 100644 --- a/tests/ui/double_parens.stderr +++ b/tests/ui/double_parens.stderr @@ -4,7 +4,7 @@ error: Consider removing unnecessary double parentheses 16 | ((0)) | ^^^^^ | - = note: `-D double-parens` implied by `-D warnings` + = note: `-D clippy::double-parens` implied by `-D warnings` error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:20:14 diff --git a/tests/ui/drop_forget_copy.stderr b/tests/ui/drop_forget_copy.stderr index 3ea7bf9735a..043067fe8af 100644 --- a/tests/ui/drop_forget_copy.stderr +++ b/tests/ui/drop_forget_copy.stderr @@ -4,7 +4,7 @@ error: calls to `std::mem::drop` with a value that implements Copy. Dropping a c 33 | drop(s1); | ^^^^^^^^ | - = note: `-D drop-copy` implied by `-D warnings` + = note: `-D clippy::drop-copy` implied by `-D warnings` note: argument has type SomeStruct --> $DIR/drop_forget_copy.rs:33:10 | @@ -41,7 +41,7 @@ error: calls to `std::mem::forget` with a value that implements Copy. Forgetting 39 | forget(s1); | ^^^^^^^^^^ | - = note: `-D forget-copy` implied by `-D warnings` + = note: `-D clippy::forget-copy` implied by `-D warnings` note: argument has type SomeStruct --> $DIR/drop_forget_copy.rs:39:12 | diff --git a/tests/ui/drop_forget_ref.stderr b/tests/ui/drop_forget_ref.stderr index 1654fdd2861..227918f5917 100644 --- a/tests/ui/drop_forget_ref.stderr +++ b/tests/ui/drop_forget_ref.stderr @@ -4,7 +4,7 @@ error: calls to `std::mem::drop` with a reference instead of an owned value. Dro 12 | drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^ | - = note: `-D drop-ref` implied by `-D warnings` + = note: `-D clippy::drop-ref` implied by `-D warnings` note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:12:10 | @@ -17,7 +17,7 @@ error: calls to `std::mem::forget` with a reference instead of an owned value. F 13 | forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^ | - = note: `-D forget-ref` implied by `-D warnings` + = note: `-D clippy::forget-ref` implied by `-D warnings` note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:13:12 | diff --git a/tests/ui/duplicate_underscore_argument.stderr b/tests/ui/duplicate_underscore_argument.stderr index c926f57f154..70714534653 100644 --- a/tests/ui/duplicate_underscore_argument.stderr +++ b/tests/ui/duplicate_underscore_argument.stderr @@ -4,7 +4,7 @@ error: `darth` already exists, having another argument having almost the same na 7 | fn join_the_dark_side(darth: i32, _darth: i32) {} | ^^^^^ | - = note: `-D duplicate-underscore-argument` implied by `-D warnings` + = note: `-D clippy::duplicate-underscore-argument` implied by `-D warnings` error: aborting due to previous error diff --git a/tests/ui/duration_subsec.stderr b/tests/ui/duration_subsec.stderr index a1aacec3a75..c23b041a80a 100644 --- a/tests/ui/duration_subsec.stderr +++ b/tests/ui/duration_subsec.stderr @@ -1,33 +1,33 @@ error: Calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:8:24 - | -8 | let bad_millis_1 = dur.subsec_micros() / 1_000; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` - | - = note: `-D duration-subsec` implied by `-D warnings` + --> $DIR/duration_subsec.rs:10:24 + | +10 | let bad_millis_1 = dur.subsec_micros() / 1_000; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` + | + = note: `-D clippy::duration-subsec` implied by `-D warnings` error: Calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:9:24 - | -9 | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` + --> $DIR/duration_subsec.rs:11:24 + | +11 | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:14:22 + --> $DIR/duration_subsec.rs:16:22 | -14 | let bad_micros = dur.subsec_nanos() / 1_000; +16 | let bad_micros = dur.subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:19:13 + --> $DIR/duration_subsec.rs:21:13 | -19 | let _ = (&dur).subsec_nanos() / 1_000; +21 | let _ = (&dur).subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&dur).subsec_micros()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:23:13 + --> $DIR/duration_subsec.rs:25:13 | -23 | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; +25 | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` error: aborting due to 5 previous errors diff --git a/tests/ui/else_if_without_else.stderr b/tests/ui/else_if_without_else.stderr index b8a5031fbcf..a352546ce9f 100644 --- a/tests/ui/else_if_without_else.stderr +++ b/tests/ui/else_if_without_else.stderr @@ -1,21 +1,21 @@ error: if expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:39:12 + --> $DIR/else_if_without_else.rs:41:12 | -39 | } else if bla2() { //~ ERROR else if without else +41 | } else if bla2() { //~ ERROR else if without else | ____________^ -40 | | println!("else if"); -41 | | } +42 | | println!("else if"); +43 | | } | |_____^ help: add an `else` block here | - = note: `-D else-if-without-else` implied by `-D warnings` + = note: `-D clippy::else-if-without-else` implied by `-D warnings` error: if expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:47:12 + --> $DIR/else_if_without_else.rs:49:12 | -47 | } else if bla3() { //~ ERROR else if without else +49 | } else if bla3() { //~ ERROR else if without else | ____________^ -48 | | println!("else if 2"); -49 | | } +50 | | println!("else if 2"); +51 | | } | |_____^ help: add an `else` block here error: aborting due to 2 previous errors diff --git a/tests/ui/empty_enum.stderr b/tests/ui/empty_enum.stderr index ca377cee822..f198793fed4 100644 --- a/tests/ui/empty_enum.stderr +++ b/tests/ui/empty_enum.stderr @@ -4,7 +4,7 @@ error: enum with no variants 7 | enum Empty {} | ^^^^^^^^^^^^^ | - = note: `-D empty-enum` implied by `-D warnings` + = note: `-D clippy::empty-enum` implied by `-D warnings` help: consider using the uninhabited type `!` or a wrapper around it --> $DIR/empty_enum.rs:7:1 | diff --git a/tests/ui/empty_line_after_outer_attribute.stderr b/tests/ui/empty_line_after_outer_attribute.stderr index 7c9c7b8f349..7bcec54a600 100644 --- a/tests/ui/empty_line_after_outer_attribute.stderr +++ b/tests/ui/empty_line_after_outer_attribute.stderr @@ -7,7 +7,7 @@ error: Found an empty line after an outer attribute. Perhaps you forgot to add a 8 | | fn with_one_newline_and_comment() { assert!(true) } | |_ | - = note: `-D empty-line-after-outer-attr` implied by `-D warnings` + = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings` error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute? --> $DIR/empty_line_after_outer_attribute.rs:17:1 diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index 09c4a882280..cffe8b23235 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -4,7 +4,7 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` 13 | if !m.contains_key(&k) { m.insert(k, v); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k).or_insert(v)` | - = note: `-D map-entry` implied by `-D warnings` + = note: `-D clippy::map-entry` implied by `-D warnings` error: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:17:5 diff --git a/tests/ui/enum_glob_use.stderr b/tests/ui/enum_glob_use.stderr index 2d53618c1b1..bb1d19e41b2 100644 --- a/tests/ui/enum_glob_use.stderr +++ b/tests/ui/enum_glob_use.stderr @@ -4,7 +4,7 @@ error: don't use glob imports for enum variants 6 | use std::cmp::Ordering::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D enum-glob-use` implied by `-D warnings` + = note: `-D clippy::enum-glob-use` implied by `-D warnings` error: don't use glob imports for enum variants --> $DIR/enum_glob_use.rs:12:1 diff --git a/tests/ui/enum_variants.stderr b/tests/ui/enum_variants.stderr index e33e29ec78e..bd083e7e069 100644 --- a/tests/ui/enum_variants.stderr +++ b/tests/ui/enum_variants.stderr @@ -1,100 +1,100 @@ error: Variant name ends with the enum's name - --> $DIR/enum_variants.rs:14:5 + --> $DIR/enum_variants.rs:16:5 | -14 | cFoo, +16 | cFoo, | ^^^^ | - = note: `-D enum-variant-names` implied by `-D warnings` - -error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:25:5 - | -25 | FoodGood, - | ^^^^^^^^ - -error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:26:5 - | -26 | FoodMiddle, - | ^^^^^^^^^^ + = note: `-D clippy::enum-variant-names` implied by `-D warnings` error: Variant name starts with the enum's name --> $DIR/enum_variants.rs:27:5 | -27 | FoodBad, +27 | FoodGood, + | ^^^^^^^^ + +error: Variant name starts with the enum's name + --> $DIR/enum_variants.rs:28:5 + | +28 | FoodMiddle, + | ^^^^^^^^^^ + +error: Variant name starts with the enum's name + --> $DIR/enum_variants.rs:29:5 + | +29 | FoodBad, | ^^^^^^^ error: All variants have the same prefix: `Food` - --> $DIR/enum_variants.rs:24:1 + --> $DIR/enum_variants.rs:26:1 | -24 | / enum Food { -25 | | FoodGood, -26 | | FoodMiddle, -27 | | FoodBad, -28 | | } +26 | / enum Food { +27 | | FoodGood, +28 | | FoodMiddle, +29 | | FoodBad, +30 | | } | |_^ | = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `CallType` - --> $DIR/enum_variants.rs:34:1 + --> $DIR/enum_variants.rs:36:1 | -34 | / enum BadCallType { -35 | | CallTypeCall, -36 | | CallTypeCreate, -37 | | CallTypeDestroy, -38 | | } +36 | / enum BadCallType { +37 | | CallTypeCall, +38 | | CallTypeCreate, +39 | | CallTypeDestroy, +40 | | } | |_^ | = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `Constant` - --> $DIR/enum_variants.rs:45:1 + --> $DIR/enum_variants.rs:47:1 | -45 | / enum Consts { -46 | | ConstantInt, -47 | | ConstantCake, -48 | | ConstantLie, -49 | | } +47 | / enum Consts { +48 | | ConstantInt, +49 | | ConstantCake, +50 | | ConstantLie, +51 | | } | |_^ | = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `With` - --> $DIR/enum_variants.rs:78:1 + --> $DIR/enum_variants.rs:80:1 | -78 | / enum Seallll { -79 | | WithOutCake, -80 | | WithOutTea, -81 | | WithOut, -82 | | } +80 | / enum Seallll { +81 | | WithOutCake, +82 | | WithOutTea, +83 | | WithOut, +84 | | } | |_^ | = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `Prefix` - --> $DIR/enum_variants.rs:84:1 + --> $DIR/enum_variants.rs:86:1 | -84 | / enum NonCaps { -85 | | Prefix的, -86 | | PrefixTea, -87 | | PrefixCake, -88 | | } +86 | / enum NonCaps { +87 | | Prefix的, +88 | | PrefixTea, +89 | | PrefixCake, +90 | | } | |_^ | = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `With` - --> $DIR/enum_variants.rs:90:1 + --> $DIR/enum_variants.rs:92:1 | -90 | / pub enum PubSeall { -91 | | WithOutCake, -92 | | WithOutTea, -93 | | WithOut, -94 | | } +92 | / pub enum PubSeall { +93 | | WithOutCake, +94 | | WithOutTea, +95 | | WithOut, +96 | | } | |_^ | - = note: `-D pub-enum-variant-names` implied by `-D warnings` + = note: `-D clippy::pub-enum-variant-names` implied by `-D warnings` = help: remove the prefixes and use full paths to the variants instead of glob imports error: aborting due to 10 previous errors diff --git a/tests/ui/enums_clike.stderr b/tests/ui/enums_clike.stderr index d6a137c6fe4..cccf4ed030c 100644 --- a/tests/ui/enums_clike.stderr +++ b/tests/ui/enums_clike.stderr @@ -1,51 +1,51 @@ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:10:5 + --> $DIR/enums_clike.rs:12:5 | -10 | X = 0x1_0000_0000, +12 | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ | - = note: `-D enum-clike-unportable-variant` implied by `-D warnings` + = note: `-D clippy::enum-clike-unportable-variant` implied by `-D warnings` error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:17:5 + --> $DIR/enums_clike.rs:19:5 | -17 | X = 0x1_0000_0000, +19 | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:20:5 + --> $DIR/enums_clike.rs:22:5 | -20 | A = 0xFFFF_FFFF, +22 | A = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:27:5 + --> $DIR/enums_clike.rs:29:5 | -27 | Z = 0xFFFF_FFFF, +29 | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ -error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:28:5 - | -28 | A = 0x1_0000_0000, - | ^^^^^^^^^^^^^^^^^ - error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:30:5 | -30 | C = (std::i32::MIN as isize) - 1, +30 | A = 0x1_0000_0000, + | ^^^^^^^^^^^^^^^^^ + +error: Clike enum variant discriminant is not portable to 32-bit targets + --> $DIR/enums_clike.rs:32:5 + | +32 | C = (std::i32::MIN as isize) - 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:36:5 + --> $DIR/enums_clike.rs:38:5 | -36 | Z = 0xFFFF_FFFF, +38 | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:37:5 + --> $DIR/enums_clike.rs:39:5 | -37 | A = 0x1_0000_0000, +39 | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index ccf36606208..ad0c8d8ecd7 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -4,7 +4,7 @@ error: this boolean expression can be simplified 37 | true && true; | ^^^^^^^^^^^^ help: try: `true` | - = note: `-D nonminimal-bool` implied by `-D warnings` + = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: this boolean expression can be simplified --> $DIR/eq_op.rs:39:5 @@ -42,7 +42,7 @@ error: equal expressions as operands to `==` 10 | 1 == 1; | ^^^^^^ | - = note: `-D eq-op` implied by `-D warnings` + = note: `-D clippy::eq-op` implied by `-D warnings` error: equal expressions as operands to `==` --> $DIR/eq_op.rs:11:5 @@ -202,7 +202,7 @@ error: taken reference of right operand | | | help: use the right value directly: `y` | - = note: `-D op-ref` implied by `-D warnings` + = note: `-D clippy::op-ref` implied by `-D warnings` error: equal expressions as operands to `/` --> $DIR/eq_op.rs:97:20 diff --git a/tests/ui/erasing_op.stderr b/tests/ui/erasing_op.stderr index 310c41c541b..18486ab4781 100644 --- a/tests/ui/erasing_op.stderr +++ b/tests/ui/erasing_op.stderr @@ -4,7 +4,7 @@ error: this operation will always return zero. This is likely not the intended o 9 | x * 0; | ^^^^^ | - = note: `-D erasing-op` implied by `-D warnings` + = note: `-D clippy::erasing-op` implied by `-D warnings` error: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:10:5 diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index 5dca265c2a4..89543d6af0c 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -4,7 +4,7 @@ error: redundant closure found 7 | let a = Some(1u8).map(|a| foo(a)); | ^^^^^^^^^^ help: remove closure as shown: `foo` | - = note: `-D redundant-closure` implied by `-D warnings` + = note: `-D clippy::redundant-closure` implied by `-D warnings` error: redundant closure found --> $DIR/eta.rs:8:10 @@ -24,7 +24,7 @@ error: this expression borrows a reference that is immediately dereferenced by t 11 | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted | ^^^ help: change this to: `&2` | - = note: `-D needless-borrow` implied by `-D warnings` + = note: `-D clippy::needless-borrow` implied by `-D warnings` error: redundant closure found --> $DIR/eta.rs:18:27 diff --git a/tests/ui/eval_order_dependence.stderr b/tests/ui/eval_order_dependence.stderr index 2e01a167c01..3caba829be4 100644 --- a/tests/ui/eval_order_dependence.stderr +++ b/tests/ui/eval_order_dependence.stderr @@ -4,7 +4,7 @@ error: unsequenced read of a variable 8 | let a = { x = 1; 1 } + x; | ^ | - = note: `-D eval-order-dependence` implied by `-D warnings` + = note: `-D clippy::eval-order-dependence` implied by `-D warnings` note: whether read occurs before this write depends on evaluation order --> $DIR/eval_order_dependence.rs:8:15 | diff --git a/tests/ui/excessive_precision.stderr b/tests/ui/excessive_precision.stderr index 295846e9d7e..bb0546cdcc6 100644 --- a/tests/ui/excessive_precision.stderr +++ b/tests/ui/excessive_precision.stderr @@ -4,7 +4,7 @@ error: float has excessive precision 15 | const BAD32_1: f32 = 0.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` | - = note: `-D excessive-precision` implied by `-D warnings` + = note: `-D clippy::excessive-precision` implied by `-D warnings` error: float has excessive precision --> $DIR/excessive_precision.rs:16:26 diff --git a/tests/ui/explicit_write.stderr b/tests/ui/explicit_write.stderr index 7a2a0c66f23..fb14120b16d 100644 --- a/tests/ui/explicit_write.stderr +++ b/tests/ui/explicit_write.stderr @@ -1,39 +1,39 @@ error: use of `write!(stdout(), ...).unwrap()`. Consider using `print!` instead - --> $DIR/explicit_write.rs:16:9 + --> $DIR/explicit_write.rs:18:9 | -16 | write!(std::io::stdout(), "test").unwrap(); +18 | write!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D explicit-write` implied by `-D warnings` + = note: `-D clippy::explicit-write` implied by `-D warnings` error: use of `write!(stderr(), ...).unwrap()`. Consider using `eprint!` instead - --> $DIR/explicit_write.rs:17:9 + --> $DIR/explicit_write.rs:19:9 | -17 | write!(std::io::stderr(), "test").unwrap(); +19 | write!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `writeln!(stdout(), ...).unwrap()`. Consider using `println!` instead - --> $DIR/explicit_write.rs:18:9 + --> $DIR/explicit_write.rs:20:9 | -18 | writeln!(std::io::stdout(), "test").unwrap(); +20 | writeln!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `writeln!(stderr(), ...).unwrap()`. Consider using `eprintln!` instead - --> $DIR/explicit_write.rs:19:9 + --> $DIR/explicit_write.rs:21:9 | -19 | writeln!(std::io::stderr(), "test").unwrap(); +21 | writeln!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `stdout().write_fmt(...).unwrap()`. Consider using `print!` instead - --> $DIR/explicit_write.rs:20:9 + --> $DIR/explicit_write.rs:22:9 | -20 | std::io::stdout().write_fmt(format_args!("test")).unwrap(); +22 | std::io::stdout().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `stderr().write_fmt(...).unwrap()`. Consider using `eprint!` instead - --> $DIR/explicit_write.rs:21:9 + --> $DIR/explicit_write.rs:23:9 | -21 | std::io::stderr().write_fmt(format_args!("test")).unwrap(); +23 | std::io::stderr().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/fallible_impl_from.stderr b/tests/ui/fallible_impl_from.stderr index c8af77ecab3..4dbc7879d31 100644 --- a/tests/ui/fallible_impl_from.stderr +++ b/tests/ui/fallible_impl_from.stderr @@ -1,91 +1,91 @@ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:5:1 - | -5 | / impl From for Foo { -6 | | fn from(s: String) -> Self { -7 | | Foo(s.parse().unwrap()) -8 | | } -9 | | } - | |_^ - | + --> $DIR/fallible_impl_from.rs:7:1 + | +7 | / impl From for Foo { +8 | | fn from(s: String) -> Self { +9 | | Foo(s.parse().unwrap()) +10 | | } +11 | | } + | |_^ + | note: lint level defined here - --> $DIR/fallible_impl_from.rs:1:9 - | -1 | #![deny(fallible_impl_from)] - | ^^^^^^^^^^^^^^^^^^ - = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. + --> $DIR/fallible_impl_from.rs:3:9 + | +3 | #![deny(clippy::fallible_impl_from)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:7:13 - | -7 | Foo(s.parse().unwrap()) - | ^^^^^^^^^^^^^^^^^^ + --> $DIR/fallible_impl_from.rs:9:13 + | +9 | Foo(s.parse().unwrap()) + | ^^^^^^^^^^^^^^^^^^ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:28:1 + --> $DIR/fallible_impl_from.rs:30:1 | -28 | / impl From for Invalid { -29 | | fn from(i: usize) -> Invalid { -30 | | if i != 42 { -31 | | panic!(); +30 | / impl From for Invalid { +31 | | fn from(i: usize) -> Invalid { +32 | | if i != 42 { +33 | | panic!(); ... | -34 | | } -35 | | } +36 | | } +37 | | } | |_^ | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:31:13 + --> $DIR/fallible_impl_from.rs:33:13 | -31 | panic!(); +33 | panic!(); | ^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:37:1 + --> $DIR/fallible_impl_from.rs:39:1 | -37 | / impl From> for Invalid { -38 | | fn from(s: Option) -> Invalid { -39 | | let s = s.unwrap(); -40 | | if !s.is_empty() { +39 | / impl From> for Invalid { +40 | | fn from(s: Option) -> Invalid { +41 | | let s = s.unwrap(); +42 | | if !s.is_empty() { ... | -46 | | } -47 | | } +48 | | } +49 | | } | |_^ | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:39:17 + --> $DIR/fallible_impl_from.rs:41:17 | -39 | let s = s.unwrap(); +41 | let s = s.unwrap(); | ^^^^^^^^^^ -40 | if !s.is_empty() { -41 | panic!(42); +42 | if !s.is_empty() { +43 | panic!(42); | ^^^^^^^^^^^ -42 | } else if s.parse::().unwrap() != 42 { +44 | } else if s.parse::().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -43 | panic!("{:?}", s); +45 | panic!("{:?}", s); | ^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:55:1 + --> $DIR/fallible_impl_from.rs:57:1 | -55 | / impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { -56 | | fn from(s: &'a mut as ProjStrTrait>::ProjString) -> Invalid { -57 | | if s.parse::().ok().unwrap() != 42 { -58 | | panic!("{:?}", s); +57 | / impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { +58 | | fn from(s: &'a mut as ProjStrTrait>::ProjString) -> Invalid { +59 | | if s.parse::().ok().unwrap() != 42 { +60 | | panic!("{:?}", s); ... | -61 | | } -62 | | } +63 | | } +64 | | } | |_^ | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:57:12 + --> $DIR/fallible_impl_from.rs:59:12 | -57 | if s.parse::().ok().unwrap() != 42 { +59 | if s.parse::().ok().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -58 | panic!("{:?}", s); +60 | panic!("{:?}", s); | ^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) diff --git a/tests/ui/filter_methods.stderr b/tests/ui/filter_methods.stderr index cec03a47bfd..1fde70601aa 100644 --- a/tests/ui/filter_methods.stderr +++ b/tests/ui/filter_methods.stderr @@ -7,7 +7,7 @@ error: called `filter(p).map(q)` on an `Iterator`. This is more succinctly expre 10 | | .map(|x| x * 2) | |_____________________________________________^ | - = note: `-D filter-map` implied by `-D warnings` + = note: `-D clippy::filter-map` implied by `-D warnings` error: called `filter(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator. --> $DIR/filter_methods.rs:13:21 diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index df404a1eec3..598ebf33668 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -4,7 +4,7 @@ error: strict comparison of f32 or f64 49 | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(ONE as f64 - 2.0).abs() < error` | - = note: `-D float-cmp` implied by `-D warnings` + = note: `-D clippy::float-cmp` implied by `-D warnings` note: std::f32::EPSILON and std::f64::EPSILON are available. --> $DIR/float_cmp.rs:49:5 | diff --git a/tests/ui/float_cmp_const.stderr b/tests/ui/float_cmp_const.stderr index 6367ec73c96..14083979511 100644 --- a/tests/ui/float_cmp_const.stderr +++ b/tests/ui/float_cmp_const.stderr @@ -4,7 +4,7 @@ error: strict comparison of f32 or f64 constant 17 | 1f32 == ONE; | ^^^^^^^^^^^ help: consider comparing them within some error: `(1f32 - ONE).abs() < error` | - = note: `-D float-cmp-const` implied by `-D warnings` + = note: `-D clippy::float-cmp-const` implied by `-D warnings` note: std::f32::EPSILON and std::f64::EPSILON are available. --> $DIR/float_cmp_const.rs:17:5 | diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index 582ca84b133..732dc2ab448 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -4,7 +4,7 @@ error: for loop over `option`, which is an `Option`. This is more readably writt 17 | for x in option { | ^^^^^^ | - = note: `-D for-loop-over-option` implied by `-D warnings` + = note: `-D clippy::for-loop-over-option` implied by `-D warnings` = help: consider replacing `for x in option` with `if let Some(x) = option` error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement. @@ -13,7 +13,7 @@ error: for loop over `result`, which is a `Result`. This is more readably writte 22 | for x in result { | ^^^^^^ | - = note: `-D for-loop-over-result` implied by `-D warnings` + = note: `-D clippy::for-loop-over-result` implied by `-D warnings` = help: consider replacing `for x in result` with `if let Ok(x) = result` error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement. @@ -30,7 +30,7 @@ error: you are iterating over `Iterator::next()` which is an Option; this will c 32 | for x in v.iter().next() { | ^^^^^^^^^^^^^^^ | - = note: `-D iter-next-loop` implied by `-D warnings` + = note: `-D clippy::iter-next-loop` implied by `-D warnings` error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement. --> $DIR/for_loop.rs:37:14 @@ -57,7 +57,7 @@ error: this loop never actually loops 56 | | } | |_____^ | - = note: `-D never-loop` implied by `-D warnings` + = note: `-D clippy::never-loop` implied by `-D warnings` error: this loop never actually loops --> $DIR/for_loop.rs:59:5 @@ -74,7 +74,7 @@ error: the loop variable `i` is only used to index `vec`. 86 | for i in 0..vec.len() { | ^^^^^^^^^^^^ | - = note: `-D needless-range-loop` implied by `-D warnings` + = note: `-D clippy::needless-range-loop` implied by `-D warnings` help: consider using an iterator | 86 | for in &vec { @@ -206,7 +206,7 @@ error: this range is empty so this for loop will never run 148 | for i in 10..0 { | ^^^^^ | - = note: `-D reverse-range-loop` implied by `-D warnings` + = note: `-D clippy::reverse-range-loop` implied by `-D warnings` help: consider using the following if you are attempting to iterate over this range in reverse | 148 | for i in (0..10).rev() { @@ -270,7 +270,7 @@ error: it is more idiomatic to loop over references to containers instead of usi 215 | for _v in vec.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `&vec` | - = note: `-D explicit-iter-loop` implied by `-D warnings` + = note: `-D clippy::explicit-iter-loop` implied by `-D warnings` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:217:15 @@ -284,7 +284,7 @@ error: it is more idiomatic to loop over containers instead of using explicit it 220 | for _v in out_vec.into_iter() {} | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec` | - = note: `-D explicit-into-iter-loop` implied by `-D warnings` + = note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop.rs:223:15 @@ -358,7 +358,7 @@ error: you are collect()ing an iterator and throwing away the result. Consider u 264 | vec.iter().cloned().map(|x| out.push(x)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D unused-collect` implied by `-D warnings` + = note: `-D clippy::unused-collect` implied by `-D warnings` error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators --> $DIR/for_loop.rs:269:15 @@ -366,7 +366,7 @@ error: the variable `_index` is used as a loop counter. Consider using `for (_in 269 | for _v in &vec { | ^^^^ | - = note: `-D explicit-counter-loop` implied by `-D warnings` + = note: `-D clippy::explicit-counter-loop` implied by `-D warnings` error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators --> $DIR/for_loop.rs:275:15 @@ -380,7 +380,7 @@ error: you seem to want to iterate on a map's values 385 | for (_, v) in &m { | ^^ | - = note: `-D for-kv-map` implied by `-D warnings` + = note: `-D clippy::for-kv-map` implied by `-D warnings` help: use the corresponding method | 385 | for v in m.values() { @@ -432,7 +432,7 @@ error: it looks like you're manually copying between slices 462 | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` | - = note: `-D manual-memcpy` implied by `-D warnings` + = note: `-D clippy::manual-memcpy` implied by `-D warnings` error: it looks like you're manually copying between slices --> $DIR/for_loop.rs:467:14 diff --git a/tests/ui/format.stderr b/tests/ui/format.stderr index fa5c740c551..ca6ef905396 100644 --- a/tests/ui/format.stderr +++ b/tests/ui/format.stderr @@ -4,7 +4,7 @@ error: useless use of `format!` 12 | format!("foo"); | ^^^^^^^^^^^^^^^ help: consider using .to_string(): `"foo".to_string()` | - = note: `-D useless-format` implied by `-D warnings` + = note: `-D clippy::useless-format` implied by `-D warnings` error: useless use of `format!` --> $DIR/format.rs:14:5 diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index 266de262ea0..d9fee73660c 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -4,7 +4,7 @@ error: this looks like an `else if` but the `else` is missing 15 | } if foo() { | ^ | - = note: `-D suspicious-else-formatting` implied by `-D warnings` + = note: `-D clippy::suspicious-else-formatting` implied by `-D warnings` = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing @@ -50,7 +50,7 @@ error: this looks like you are trying to use `.. -= ..`, but you really are doin 71 | a =- 35; | ^^^^ | - = note: `-D suspicious-assignment-formatting` implied by `-D warnings` + = note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings` = note: to remove this lint, use either `-=` or `= -` error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` @@ -75,7 +75,7 @@ error: possibly missing a comma here 84 | -1, -2, -3 // <= no comma here | ^ | - = note: `-D possible-missing-comma` implied by `-D warnings` + = note: `-D clippy::possible-missing-comma` implied by `-D warnings` = note: to remove this lint, add a comma or write the expr in a single line error: possibly missing a comma here diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index 0a97748954f..c2f7b76aab4 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -5,7 +5,7 @@ error: this function has too many arguments (8/7) 12 | | } | |_^ | - = note: `-D too-many-arguments` implied by `-D warnings` + = note: `-D clippy::too-many-arguments` implied by `-D warnings` error: this function has too many arguments (8/7) --> $DIR/functions.rs:19:5 @@ -25,7 +25,7 @@ error: this public function dereferences a raw pointer but is not marked `unsafe 37 | println!("{}", unsafe { *p }); | ^ | - = note: `-D not-unsafe-ptr-arg-deref` implied by `-D warnings` + = note: `-D clippy::not-unsafe-ptr-arg-deref` implied by `-D warnings` error: this public function dereferences a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:38:35 diff --git a/tests/ui/fxhash.stderr b/tests/ui/fxhash.stderr index 5e90f84f1db..869a315c9eb 100644 --- a/tests/ui/fxhash.stderr +++ b/tests/ui/fxhash.stderr @@ -1,39 +1,39 @@ error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:6:24 + --> $DIR/fxhash.rs:8:24 | -6 | use std::collections::{HashMap, HashSet}; +8 | use std::collections::{HashMap, HashSet}; | ^^^^^^^ help: use: `FxHashMap` | - = note: `-D default-hash-types` implied by `-D warnings` + = note: `-D clippy::default-hash-types` implied by `-D warnings` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:6:33 + --> $DIR/fxhash.rs:8:33 | -6 | use std::collections::{HashMap, HashSet}; +8 | use std::collections::{HashMap, HashSet}; | ^^^^^^^ help: use: `FxHashSet` error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:10:15 + --> $DIR/fxhash.rs:12:15 | -10 | let _map: HashMap = HashMap::default(); +12 | let _map: HashMap = HashMap::default(); | ^^^^^^^ help: use: `FxHashMap` error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:10:41 + --> $DIR/fxhash.rs:12:41 | -10 | let _map: HashMap = HashMap::default(); +12 | let _map: HashMap = HashMap::default(); | ^^^^^^^ help: use: `FxHashMap` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:11:15 + --> $DIR/fxhash.rs:13:15 | -11 | let _set: HashSet = HashSet::default(); +13 | let _set: HashSet = HashSet::default(); | ^^^^^^^ help: use: `FxHashSet` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:11:33 + --> $DIR/fxhash.rs:13:33 | -11 | let _set: HashSet = HashSet::default(); +13 | let _set: HashSet = HashSet::default(); | ^^^^^^^ help: use: `FxHashSet` error: aborting due to 6 previous errors diff --git a/tests/ui/get_unwrap.stderr b/tests/ui/get_unwrap.stderr index b5ada862531..63f6603c821 100644 --- a/tests/ui/get_unwrap.stderr +++ b/tests/ui/get_unwrap.stderr @@ -4,7 +4,7 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more co 27 | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]` | - = note: `-D get-unwrap` implied by `-D warnings` + = note: `-D clippy::get-unwrap` implied by `-D warnings` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:28:17 diff --git a/tests/ui/identity_conversion.stderr b/tests/ui/identity_conversion.stderr index 7083b96e16f..ffcd3649ad6 100644 --- a/tests/ui/identity_conversion.stderr +++ b/tests/ui/identity_conversion.stderr @@ -1,61 +1,61 @@ error: identical conversion - --> $DIR/identity_conversion.rs:4:13 + --> $DIR/identity_conversion.rs:6:13 | -4 | let _ = T::from(val); +6 | let _ = T::from(val); | ^^^^^^^^^^^^ help: consider removing `T::from()`: `val` | note: lint level defined here - --> $DIR/identity_conversion.rs:1:9 + --> $DIR/identity_conversion.rs:3:9 | -1 | #![deny(identity_conversion)] - | ^^^^^^^^^^^^^^^^^^^ +3 | #![deny(clippy::identity_conversion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: identical conversion - --> $DIR/identity_conversion.rs:5:5 + --> $DIR/identity_conversion.rs:7:5 | -5 | val.into() +7 | val.into() | ^^^^^^^^^^ help: consider removing `.into()`: `val` error: identical conversion - --> $DIR/identity_conversion.rs:17:22 + --> $DIR/identity_conversion.rs:19:22 | -17 | let _: i32 = 0i32.into(); +19 | let _: i32 = 0i32.into(); | ^^^^^^^^^^^ help: consider removing `.into()`: `0i32` error: identical conversion - --> $DIR/identity_conversion.rs:38:21 + --> $DIR/identity_conversion.rs:40:21 | -38 | let _: String = "foo".to_string().into(); +40 | let _: String = "foo".to_string().into(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()` error: identical conversion - --> $DIR/identity_conversion.rs:39:21 + --> $DIR/identity_conversion.rs:41:21 | -39 | let _: String = From::from("foo".to_string()); +41 | let _: String = From::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()` -error: identical conversion - --> $DIR/identity_conversion.rs:40:13 - | -40 | let _ = String::from("foo".to_string()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` - -error: identical conversion - --> $DIR/identity_conversion.rs:41:13 - | -41 | let _ = String::from(format!("A: {:04}", 123)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)` - error: identical conversion --> $DIR/identity_conversion.rs:42:13 | -42 | let _ = "".lines().into_iter(); - | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()` +42 | let _ = String::from("foo".to_string()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` error: identical conversion --> $DIR/identity_conversion.rs:43:13 | -43 | let _ = vec![1, 2, 3].into_iter().into_iter(); +43 | let _ = String::from(format!("A: {:04}", 123)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)` + +error: identical conversion + --> $DIR/identity_conversion.rs:44:13 + | +44 | let _ = "".lines().into_iter(); + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()` + +error: identical conversion + --> $DIR/identity_conversion.rs:45:13 + | +45 | let _ = vec![1, 2, 3].into_iter().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()` error: aborting due to 9 previous errors diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index 45f579ce832..e494250c019 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -4,7 +4,7 @@ error: the operation is ineffective. Consider reducing it to `x` 13 | x + 0; | ^^^^^ | - = note: `-D identity-op` implied by `-D warnings` + = note: `-D clippy::identity-op` implied by `-D warnings` error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:14:5 diff --git a/tests/ui/if_let_redundant_pattern_matching.stderr b/tests/ui/if_let_redundant_pattern_matching.stderr index e7bfd0275d8..9046625855c 100644 --- a/tests/ui/if_let_redundant_pattern_matching.stderr +++ b/tests/ui/if_let_redundant_pattern_matching.stderr @@ -4,7 +4,7 @@ error: redundant pattern matching, consider using `is_ok()` 9 | if let Ok(_) = Ok::(42) {} | -------^^^^^--------------------- help: try this: `if Ok::(42).is_ok()` | - = note: `-D if-let-redundant-pattern-matching` implied by `-D warnings` + = note: `-D clippy::if-let-redundant-pattern-matching` implied by `-D warnings` error: redundant pattern matching, consider using `is_err()` --> $DIR/if_let_redundant_pattern_matching.rs:11:12 diff --git a/tests/ui/if_not_else.stderr b/tests/ui/if_not_else.stderr index b920ef3b625..9682f6dc18f 100644 --- a/tests/ui/if_not_else.stderr +++ b/tests/ui/if_not_else.stderr @@ -8,7 +8,7 @@ error: Unnecessary boolean `not` operation 13 | | } | |_____^ | - = note: `-D if-not-else` implied by `-D warnings` + = note: `-D clippy::if-not-else` implied by `-D warnings` = help: remove the `!` and swap the blocks of the if/else error: Unnecessary `!=` operation diff --git a/tests/ui/impl.stderr b/tests/ui/impl.stderr index 95e627cd509..13d4a76558d 100644 --- a/tests/ui/impl.stderr +++ b/tests/ui/impl.stderr @@ -1,34 +1,34 @@ error: Multiple implementations of this structure - --> $DIR/impl.rs:10:1 + --> $DIR/impl.rs:12:1 | -10 | / impl MyStruct { -11 | | fn second() {} -12 | | } +12 | / impl MyStruct { +13 | | fn second() {} +14 | | } | |_^ | - = note: `-D multiple-inherent-impl` implied by `-D warnings` + = note: `-D clippy::multiple-inherent-impl` implied by `-D warnings` note: First implementation here - --> $DIR/impl.rs:6:1 + --> $DIR/impl.rs:8:1 | -6 | / impl MyStruct { -7 | | fn first() {} -8 | | } +8 | / impl MyStruct { +9 | | fn first() {} +10 | | } | |_^ error: Multiple implementations of this structure - --> $DIR/impl.rs:24:5 + --> $DIR/impl.rs:26:5 | -24 | / impl super::MyStruct { -25 | | fn third() {} -26 | | } +26 | / impl super::MyStruct { +27 | | fn third() {} +28 | | } | |_____^ | note: First implementation here - --> $DIR/impl.rs:6:1 + --> $DIR/impl.rs:8:1 | -6 | / impl MyStruct { -7 | | fn first() {} -8 | | } +8 | / impl MyStruct { +9 | | fn first() {} +10 | | } | |_^ error: aborting due to 2 previous errors diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index f41ce40519f..5bb6f11b2a7 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -4,7 +4,7 @@ error: impl for `HashMap` should be generalized over different hashers 11 | impl Foo for HashMap { | ^^^^^^^^^^^^^ | - = note: `-D implicit-hasher` implied by `-D warnings` + = note: `-D clippy::implicit-hasher` implied by `-D warnings` help: consider adding a type parameter | 11 | impl Foo for HashMap { diff --git a/tests/ui/inconsistent_digit_grouping.stderr b/tests/ui/inconsistent_digit_grouping.stderr index 4d30529d820..51eeca2b864 100644 --- a/tests/ui/inconsistent_digit_grouping.stderr +++ b/tests/ui/inconsistent_digit_grouping.stderr @@ -4,7 +4,7 @@ error: digits grouped inconsistently by underscores 7 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `123_456` | - = note: `-D inconsistent-digit-grouping` implied by `-D warnings` + = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` error: digits grouped inconsistently by underscores --> $DIR/inconsistent_digit_grouping.rs:7:26 diff --git a/tests/ui/indexing_slicing.stderr b/tests/ui/indexing_slicing.stderr index ee11dce6d1c..3f09a6516e0 100644 --- a/tests/ui/indexing_slicing.stderr +++ b/tests/ui/indexing_slicing.stderr @@ -1,268 +1,268 @@ error: indexing may panic. - --> $DIR/indexing_slicing.rs:11:5 + --> $DIR/indexing_slicing.rs:13:5 | -11 | x[index]; +13 | x[index]; | ^^^^^^^^ | - = note: `-D indexing-slicing` implied by `-D warnings` + = note: `-D clippy::indexing-slicing` implied by `-D warnings` = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:12:6 + --> $DIR/indexing_slicing.rs:14:6 | -12 | &x[index..]; +14 | &x[index..]; | ^^^^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:13:6 + --> $DIR/indexing_slicing.rs:15:6 | -13 | &x[..index]; +15 | &x[..index]; | ^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:14:6 + --> $DIR/indexing_slicing.rs:16:6 | -14 | &x[index_from..index_to]; +16 | &x[index_from..index_to]; | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:15:6 + --> $DIR/indexing_slicing.rs:17:6 | -15 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. +17 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:15:6 + --> $DIR/indexing_slicing.rs:17:6 | -15 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. +17 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. | ^^^^^^^^^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:18:6 + --> $DIR/indexing_slicing.rs:20:6 | -18 | &x[..=4]; +20 | &x[..=4]; | ^^^^^^^ | - = note: `-D out-of-bounds-indexing` implied by `-D warnings` + = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` error: range is out of bounds - --> $DIR/indexing_slicing.rs:19:6 + --> $DIR/indexing_slicing.rs:21:6 | -19 | &x[1..5]; +21 | &x[1..5]; | ^^^^^^^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:20:6 + --> $DIR/indexing_slicing.rs:22:6 | -20 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. +22 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. | ^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead -error: range is out of bounds - --> $DIR/indexing_slicing.rs:20:6 - | -20 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. - | ^^^^^^ - -error: range is out of bounds - --> $DIR/indexing_slicing.rs:21:6 - | -21 | &x[5..]; - | ^^^^^^ - error: range is out of bounds --> $DIR/indexing_slicing.rs:22:6 | -22 | &x[..5]; +22 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. | ^^^^^^ error: range is out of bounds --> $DIR/indexing_slicing.rs:23:6 | -23 | &x[5..].iter().map(|x| 2 * x).collect::>(); +23 | &x[5..]; | ^^^^^^ error: range is out of bounds --> $DIR/indexing_slicing.rs:24:6 | -24 | &x[0..=4]; +24 | &x[..5]; + | ^^^^^^ + +error: range is out of bounds + --> $DIR/indexing_slicing.rs:25:6 + | +25 | &x[5..].iter().map(|x| 2 * x).collect::>(); + | ^^^^^^ + +error: range is out of bounds + --> $DIR/indexing_slicing.rs:26:6 + | +26 | &x[0..=4]; | ^^^^^^^^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:25:6 + --> $DIR/indexing_slicing.rs:27:6 | -25 | &x[0..][..3]; +27 | &x[0..][..3]; | ^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:26:6 + --> $DIR/indexing_slicing.rs:28:6 | -26 | &x[1..][..5]; +28 | &x[1..][..5]; | ^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:39:5 + --> $DIR/indexing_slicing.rs:41:5 | -39 | y[0]; +41 | y[0]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:40:6 + --> $DIR/indexing_slicing.rs:42:6 | -40 | &y[1..2]; +42 | &y[1..2]; | ^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:41:6 + --> $DIR/indexing_slicing.rs:43:6 | -41 | &y[0..=4]; +43 | &y[0..=4]; | ^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:42:6 + --> $DIR/indexing_slicing.rs:44:6 | -42 | &y[..=4]; +44 | &y[..=4]; | ^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead -error: range is out of bounds - --> $DIR/indexing_slicing.rs:48:6 - | -48 | &empty[1..5]; - | ^^^^^^^^^^^ - -error: range is out of bounds - --> $DIR/indexing_slicing.rs:49:6 - | -49 | &empty[0..=4]; - | ^^^^^^^^^^^^ - error: range is out of bounds --> $DIR/indexing_slicing.rs:50:6 | -50 | &empty[..=4]; +50 | &empty[1..5]; | ^^^^^^^^^^^ error: range is out of bounds --> $DIR/indexing_slicing.rs:51:6 | -51 | &empty[1..]; - | ^^^^^^^^^^ +51 | &empty[0..=4]; + | ^^^^^^^^^^^^ error: range is out of bounds --> $DIR/indexing_slicing.rs:52:6 | -52 | &empty[..4]; - | ^^^^^^^^^^ +52 | &empty[..=4]; + | ^^^^^^^^^^^ error: range is out of bounds --> $DIR/indexing_slicing.rs:53:6 | -53 | &empty[0..=0]; - | ^^^^^^^^^^^^ +53 | &empty[1..]; + | ^^^^^^^^^^ error: range is out of bounds --> $DIR/indexing_slicing.rs:54:6 | -54 | &empty[..=0]; +54 | &empty[..4]; + | ^^^^^^^^^^ + +error: range is out of bounds + --> $DIR/indexing_slicing.rs:55:6 + | +55 | &empty[0..=0]; + | ^^^^^^^^^^^^ + +error: range is out of bounds + --> $DIR/indexing_slicing.rs:56:6 + | +56 | &empty[..=0]; | ^^^^^^^^^^^ error: indexing may panic. - --> $DIR/indexing_slicing.rs:62:5 + --> $DIR/indexing_slicing.rs:64:5 | -62 | v[0]; +64 | v[0]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:63:5 + --> $DIR/indexing_slicing.rs:65:5 | -63 | v[10]; +65 | v[10]; | ^^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:64:5 + --> $DIR/indexing_slicing.rs:66:5 | -64 | v[1 << 3]; +66 | v[1 << 3]; | ^^^^^^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:65:6 + --> $DIR/indexing_slicing.rs:67:6 | -65 | &v[10..100]; +67 | &v[10..100]; | ^^^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:66:6 + --> $DIR/indexing_slicing.rs:68:6 | -66 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. +68 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:66:6 + --> $DIR/indexing_slicing.rs:68:6 | -66 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. +68 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^^^^^^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:67:6 + --> $DIR/indexing_slicing.rs:69:6 | -67 | &v[10..]; +69 | &v[10..]; | ^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:68:6 + --> $DIR/indexing_slicing.rs:70:6 | -68 | &v[..100]; +70 | &v[..100]; | ^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:80:5 + --> $DIR/indexing_slicing.rs:82:5 | -80 | v[N]; +82 | v[N]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:81:5 + --> $DIR/indexing_slicing.rs:83:5 | -81 | v[M]; +83 | v[M]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead diff --git a/tests/ui/infallible_destructuring_match.stderr b/tests/ui/infallible_destructuring_match.stderr index 8ee73bbfde8..6e26741fc87 100644 --- a/tests/ui/infallible_destructuring_match.stderr +++ b/tests/ui/infallible_destructuring_match.stderr @@ -1,27 +1,27 @@ error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:16:5 + --> $DIR/infallible_destructuring_match.rs:18:5 | -16 | / let data = match wrapper { -17 | | SingleVariantEnum::Variant(i) => i, -18 | | }; +18 | / let data = match wrapper { +19 | | SingleVariantEnum::Variant(i) => i, +20 | | }; | |______^ help: try this: `let SingleVariantEnum::Variant(data) = wrapper;` | - = note: `-D infallible-destructuring-match` implied by `-D warnings` + = note: `-D clippy::infallible-destructuring-match` implied by `-D warnings` error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:37:5 + --> $DIR/infallible_destructuring_match.rs:39:5 | -37 | / let data = match wrapper { -38 | | TupleStruct(i) => i, -39 | | }; +39 | / let data = match wrapper { +40 | | TupleStruct(i) => i, +41 | | }; | |______^ help: try this: `let TupleStruct(data) = wrapper;` error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:58:5 + --> $DIR/infallible_destructuring_match.rs:60:5 | -58 | / let data = match wrapper { -59 | | Ok(i) => i, -60 | | }; +60 | / let data = match wrapper { +61 | | Ok(i) => i, +62 | | }; | |______^ help: try this: `let Ok(data) = wrapper;` error: aborting due to 3 previous errors diff --git a/tests/ui/infinite_iter.stderr b/tests/ui/infinite_iter.stderr index f79db778488..c3d67bdfde3 100644 --- a/tests/ui/infinite_iter.stderr +++ b/tests/ui/infinite_iter.stderr @@ -4,7 +4,7 @@ error: you are collect()ing an iterator and throwing away the result. Consider u 10 | repeat(0_u8).collect::>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D unused-collect` implied by `-D warnings` + = note: `-D clippy::unused-collect` implied by `-D warnings` error: infinite iteration detected --> $DIR/infinite_iter.rs:10:5 @@ -15,8 +15,8 @@ error: infinite iteration detected note: lint level defined here --> $DIR/infinite_iter.rs:8:8 | -8 | #[deny(infinite_iter)] - | ^^^^^^^^^^^^^ +8 | #[deny(clippy::infinite_iter)] + | ^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected --> $DIR/infinite_iter.rs:11:5 @@ -57,8 +57,8 @@ error: possible infinite iteration detected note: lint level defined here --> $DIR/infinite_iter.rs:22:8 | -22 | #[deny(maybe_infinite_iter)] - | ^^^^^^^^^^^^^^^^^^^ +22 | #[deny(clippy::maybe_infinite_iter)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected --> $DIR/infinite_iter.rs:25:5 diff --git a/tests/ui/infinite_loop.stderr b/tests/ui/infinite_loop.stderr index 26ec9582fb4..edbe4937425 100644 --- a/tests/ui/infinite_loop.stderr +++ b/tests/ui/infinite_loop.stderr @@ -1,57 +1,57 @@ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:14:11 + --> $DIR/infinite_loop.rs:16:11 | -14 | while y < 10 { +16 | while y < 10 { | ^^^^^^ | - = note: #[deny(while_immutable_condition)] on by default + = note: #[deny(clippy::while_immutable_condition)] on by default error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:19:11 + --> $DIR/infinite_loop.rs:21:11 | -19 | while y < 10 && x < 3 { +21 | while y < 10 && x < 3 { | ^^^^^^^^^^^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:26:11 + --> $DIR/infinite_loop.rs:28:11 | -26 | while !cond { +28 | while !cond { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:70:11 + --> $DIR/infinite_loop.rs:72:11 | -70 | while i < 3 { +72 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:75:11 + --> $DIR/infinite_loop.rs:77:11 | -75 | while i < 3 && j > 0 { +77 | while i < 3 && j > 0 { | ^^^^^^^^^^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:79:11 + --> $DIR/infinite_loop.rs:81:11 | -79 | while i < 3 { +81 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:94:11 + --> $DIR/infinite_loop.rs:96:11 | -94 | while i < 3 { +96 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:99:11 - | -99 | while i < 3 { - | ^^^^^ - -error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:162:15 + --> $DIR/infinite_loop.rs:101:11 | -162 | while self.count < n { +101 | while i < 3 { + | ^^^^^ + +error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. + --> $DIR/infinite_loop.rs:164:15 + | +164 | while self.count < n { | ^^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/inline_fn_without_body.stderr b/tests/ui/inline_fn_without_body.stderr index 2b466b68610..a9a52b19053 100644 --- a/tests/ui/inline_fn_without_body.stderr +++ b/tests/ui/inline_fn_without_body.stderr @@ -6,7 +6,7 @@ error: use of `#[inline]` on trait method `default_inline` which has no body 9 | | fn default_inline(); | |____- help: remove | - = note: `-D inline-fn-without-body` implied by `-D warnings` + = note: `-D clippy::inline-fn-without-body` implied by `-D warnings` error: use of `#[inline]` on trait method `always_inline` which has no body --> $DIR/inline_fn_without_body.rs:11:5 diff --git a/tests/ui/int_plus_one.stderr b/tests/ui/int_plus_one.stderr index deecaffa1cf..12d7000dcfa 100644 --- a/tests/ui/int_plus_one.stderr +++ b/tests/ui/int_plus_one.stderr @@ -4,7 +4,7 @@ error: Unnecessary `>= y + 1` or `x - 1 >=` 10 | x >= y + 1; | ^^^^^^^^^^ | - = note: `-D int-plus-one` implied by `-D warnings` + = note: `-D clippy::int-plus-one` implied by `-D warnings` help: change `>= y + 1` to `> y` as shown | 10 | x > y; diff --git a/tests/ui/invalid_ref.stderr b/tests/ui/invalid_ref.stderr index f8420738526..1ca825dd94c 100644 --- a/tests/ui/invalid_ref.stderr +++ b/tests/ui/invalid_ref.stderr @@ -4,7 +4,7 @@ error: reference to zeroed memory 27 | let ref_zero: &T = std::mem::zeroed(); // warning | ^^^^^^^^^^^^^^^^^^ | - = note: #[deny(invalid_ref)] on by default + = note: #[deny(clippy::invalid_ref)] on by default = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to zeroed memory diff --git a/tests/ui/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index eb46802899e..ce6d1dfa1ae 100644 --- a/tests/ui/invalid_upcast_comparisons.stderr +++ b/tests/ui/invalid_upcast_comparisons.stderr @@ -4,7 +4,7 @@ error: because of the numeric bounds on `u8` prior to casting, this expression i 16 | (u8 as u32) > 300; | ^^^^^^^^^^^^^^^^^ | - = note: `-D invalid-upcast-comparisons` implied by `-D warnings` + = note: `-D clippy::invalid-upcast-comparisons` implied by `-D warnings` error: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:17:5 diff --git a/tests/ui/issue_2356.stderr b/tests/ui/issue_2356.stderr index 4b82a0a7565..fe2d9d45b77 100644 --- a/tests/ui/issue_2356.stderr +++ b/tests/ui/issue_2356.stderr @@ -1,14 +1,14 @@ error: this loop could be written as a `for` loop - --> $DIR/issue_2356.rs:15:29 + --> $DIR/issue_2356.rs:17:29 | -15 | while let Some(e) = it.next() { +17 | while let Some(e) = it.next() { | ^^^^^^^^^ help: try: `for e in it { .. }` | note: lint level defined here - --> $DIR/issue_2356.rs:1:9 + --> $DIR/issue_2356.rs:3:9 | -1 | #![deny(while_let_on_iterator)] - | ^^^^^^^^^^^^^^^^^^^^^ +3 | #![deny(clippy::while_let_on_iterator)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/item_after_statement.stderr b/tests/ui/item_after_statement.stderr index ec1296caf83..6d20899b5ec 100644 --- a/tests/ui/item_after_statement.stderr +++ b/tests/ui/item_after_statement.stderr @@ -4,7 +4,7 @@ error: adding items after statements is confusing, since items exist from the st 12 | fn foo() { println!("foo"); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D items-after-statements` implied by `-D warnings` + = note: `-D clippy::items-after-statements` implied by `-D warnings` error: adding items after statements is confusing, since items exist from the start of the scope --> $DIR/item_after_statement.rs:17:5 diff --git a/tests/ui/large_digit_groups.stderr b/tests/ui/large_digit_groups.stderr index f2e6a62d13c..b322ded9cfb 100644 --- a/tests/ui/large_digit_groups.stderr +++ b/tests/ui/large_digit_groups.stderr @@ -4,7 +4,7 @@ error: digit groups should be smaller 7 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); | ^^^^^^^^^^^^^ help: consider: `0b11_0110_i64` | - = note: `-D large-digit-groups` implied by `-D warnings` + = note: `-D clippy::large-digit-groups` implied by `-D warnings` error: digit groups should be smaller --> $DIR/large_digit_groups.rs:7:31 diff --git a/tests/ui/large_enum_variant.stderr b/tests/ui/large_enum_variant.stderr index 5e938337bc0..af42f905458 100644 --- a/tests/ui/large_enum_variant.stderr +++ b/tests/ui/large_enum_variant.stderr @@ -4,7 +4,7 @@ error: large size difference between variants 10 | B([i32; 8000]), | ^^^^^^^^^^^^^^ | - = note: `-D large-enum-variant` implied by `-D warnings` + = note: `-D clippy::large-enum-variant` implied by `-D warnings` help: consider boxing the large fields to reduce the total size of the enum | 10 | B(Box<[i32; 8000]>), diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index a04185bc63f..49e365e6c21 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -1,139 +1,139 @@ error: item `PubOne` has a public `len` method but no corresponding `is_empty` method - --> $DIR/len_zero.rs:6:1 + --> $DIR/len_zero.rs:8:1 | -6 | / impl PubOne { -7 | | pub fn len(self: &Self) -> isize { -8 | | 1 -9 | | } -10 | | } +8 | / impl PubOne { +9 | | pub fn len(self: &Self) -> isize { +10 | | 1 +11 | | } +12 | | } | |_^ | - = note: `-D len-without-is-empty` implied by `-D warnings` + = note: `-D clippy::len-without-is-empty` implied by `-D warnings` error: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_zero.rs:55:1 + --> $DIR/len_zero.rs:57:1 | -55 | / pub trait PubTraitsToo { -56 | | fn len(self: &Self) -> isize; -57 | | } +57 | / pub trait PubTraitsToo { +58 | | fn len(self: &Self) -> isize; +59 | | } | |_^ error: item `HasIsEmpty` has a public `len` method but a private `is_empty` method - --> $DIR/len_zero.rs:89:1 + --> $DIR/len_zero.rs:91:1 | -89 | / impl HasIsEmpty { -90 | | pub fn len(self: &Self) -> isize { -91 | | 1 -92 | | } +91 | / impl HasIsEmpty { +92 | | pub fn len(self: &Self) -> isize { +93 | | 1 +94 | | } ... | -96 | | } -97 | | } +98 | | } +99 | | } | |_^ error: item `HasWrongIsEmpty` has a public `len` method but no corresponding `is_empty` method - --> $DIR/len_zero.rs:118:1 + --> $DIR/len_zero.rs:120:1 | -118 | / impl HasWrongIsEmpty { -119 | | pub fn len(self: &Self) -> isize { -120 | | 1 -121 | | } +120 | / impl HasWrongIsEmpty { +121 | | pub fn len(self: &Self) -> isize { +122 | | 1 +123 | | } ... | -125 | | } -126 | | } +127 | | } +128 | | } | |_^ error: length comparison to zero - --> $DIR/len_zero.rs:139:8 + --> $DIR/len_zero.rs:141:8 | -139 | if x.len() == 0 { +141 | if x.len() == 0 { | ^^^^^^^^^^^^ help: using `is_empty` is more concise: `x.is_empty()` | - = note: `-D len-zero` implied by `-D warnings` + = note: `-D clippy::len-zero` implied by `-D warnings` error: length comparison to zero - --> $DIR/len_zero.rs:143:8 + --> $DIR/len_zero.rs:145:8 | -143 | if "".len() == 0 {} +145 | if "".len() == 0 {} | ^^^^^^^^^^^^^ help: using `is_empty` is more concise: `"".is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:158:8 + --> $DIR/len_zero.rs:160:8 | -158 | if has_is_empty.len() == 0 { +160 | if has_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:161:8 + --> $DIR/len_zero.rs:163:8 | -161 | if has_is_empty.len() != 0 { +163 | if has_is_empty.len() != 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:164:8 + --> $DIR/len_zero.rs:166:8 | -164 | if has_is_empty.len() > 0 { +166 | if has_is_empty.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:167:8 + --> $DIR/len_zero.rs:169:8 | -167 | if has_is_empty.len() < 1 { +169 | if has_is_empty.len() < 1 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:170:8 + --> $DIR/len_zero.rs:172:8 | -170 | if has_is_empty.len() >= 1 { +172 | if has_is_empty.len() >= 1 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:181:8 + --> $DIR/len_zero.rs:183:8 | -181 | if 0 == has_is_empty.len() { +183 | if 0 == has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:184:8 + --> $DIR/len_zero.rs:186:8 | -184 | if 0 != has_is_empty.len() { +186 | if 0 != has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:187:8 + --> $DIR/len_zero.rs:189:8 | -187 | if 0 < has_is_empty.len() { +189 | if 0 < has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:190:8 + --> $DIR/len_zero.rs:192:8 | -190 | if 1 <= has_is_empty.len() { +192 | if 1 <= has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:193:8 + --> $DIR/len_zero.rs:195:8 | -193 | if 1 > has_is_empty.len() { +195 | if 1 > has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:207:8 + --> $DIR/len_zero.rs:209:8 | -207 | if with_is_empty.len() == 0 { +209 | if with_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `with_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:220:8 + --> $DIR/len_zero.rs:222:8 | -220 | if b.len() != 0 {} +222 | if b.len() != 0 {} | ^^^^^^^^^^^^ help: using `is_empty` is more concise: `!b.is_empty()` error: trait `DependsOnFoo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_zero.rs:226:1 + --> $DIR/len_zero.rs:228:1 | -226 | / pub trait DependsOnFoo: Foo { -227 | | fn len(&mut self) -> usize; -228 | | } +228 | / pub trait DependsOnFoo: Foo { +229 | | fn len(&mut self) -> usize; +230 | | } | |_^ error: aborting due to 19 previous errors diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index b912373f95c..7b4c78003ab 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -7,7 +7,7 @@ error: `if _ { .. } else { .. }` is an expression 60 | | } | |_____^ help: it is more idiomatic to write: `let foo = if f() { 42 } else { 0 };` | - = note: `-D useless-let-if-seq` implied by `-D warnings` + = note: `-D clippy::useless-let-if-seq` implied by `-D warnings` = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression diff --git a/tests/ui/let_return.stderr b/tests/ui/let_return.stderr index 459b2eafa26..dad628bc912 100644 --- a/tests/ui/let_return.stderr +++ b/tests/ui/let_return.stderr @@ -4,7 +4,7 @@ error: returning the result of a let binding from a block. Consider returning th 10 | x | ^ | - = note: `-D let-and-return` implied by `-D warnings` + = note: `-D clippy::let-and-return` implied by `-D warnings` note: this expression can be directly returned --> $DIR/let_return.rs:9:13 | diff --git a/tests/ui/let_unit.stderr b/tests/ui/let_unit.stderr index da579ec80f3..f6f5d3f7dcc 100644 --- a/tests/ui/let_unit.stderr +++ b/tests/ui/let_unit.stderr @@ -4,7 +4,7 @@ error: this let-binding has unit value. Consider omitting `let _x =` 14 | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D let-unit-value` implied by `-D warnings` + = note: `-D clippy::let-unit-value` implied by `-D warnings` error: this let-binding has unit value. Consider omitting `let _a =` --> $DIR/let_unit.rs:18:9 diff --git a/tests/ui/lifetimes.stderr b/tests/ui/lifetimes.stderr index b69438af9f8..42fb01b7580 100644 --- a/tests/ui/lifetimes.stderr +++ b/tests/ui/lifetimes.stderr @@ -4,7 +4,7 @@ error: explicit lifetimes given in parameter types where they could be elided 7 | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D needless-lifetimes` implied by `-D warnings` + = note: `-D clippy::needless-lifetimes` implied by `-D warnings` error: explicit lifetimes given in parameter types where they could be elided --> $DIR/lifetimes.rs:9:1 diff --git a/tests/ui/literals.stderr b/tests/ui/literals.stderr index 6f6ea75df10..40399e498ab 100644 --- a/tests/ui/literals.stderr +++ b/tests/ui/literals.stderr @@ -1,124 +1,124 @@ -error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:12:17 - | -12 | let fail1 = 0xabCD; - | ^^^^^^ - | - = note: `-D mixed-case-hex-literals` implied by `-D warnings` - -error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:13:17 - | -13 | let fail2 = 0xabCD_u32; - | ^^^^^^^^^^ - error: inconsistent casing in hexadecimal literal --> $DIR/literals.rs:14:17 | -14 | let fail2 = 0xabCD_isize; +14 | let fail1 = 0xabCD; + | ^^^^^^ + | + = note: `-D clippy::mixed-case-hex-literals` implied by `-D warnings` + +error: inconsistent casing in hexadecimal literal + --> $DIR/literals.rs:15:17 + | +15 | let fail2 = 0xabCD_u32; + | ^^^^^^^^^^ + +error: inconsistent casing in hexadecimal literal + --> $DIR/literals.rs:16:17 + | +16 | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ error: integer type suffix should be separated by an underscore - --> $DIR/literals.rs:15:27 + --> $DIR/literals.rs:17:27 | -15 | let fail_multi_zero = 000_123usize; +17 | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ | - = note: `-D unseparated-literal-suffix` implied by `-D warnings` + = note: `-D clippy::unseparated-literal-suffix` implied by `-D warnings` error: this is a decimal constant - --> $DIR/literals.rs:15:27 + --> $DIR/literals.rs:17:27 | -15 | let fail_multi_zero = 000_123usize; +17 | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ | - = note: `-D zero-prefixed-literal` implied by `-D warnings` + = note: `-D clippy::zero-prefixed-literal` implied by `-D warnings` help: if you mean to use a decimal constant, remove the `0` to remove confusion | -15 | let fail_multi_zero = 123usize; +17 | let fail_multi_zero = 123usize; | ^^^^^^^^ help: if you mean to use an octal constant, use `0o` | -15 | let fail_multi_zero = 0o123usize; +17 | let fail_multi_zero = 0o123usize; | ^^^^^^^^^^ -error: integer type suffix should be separated by an underscore - --> $DIR/literals.rs:20:17 - | -20 | let fail3 = 1234i32; - | ^^^^^^^ - -error: integer type suffix should be separated by an underscore - --> $DIR/literals.rs:21:17 - | -21 | let fail4 = 1234u32; - | ^^^^^^^ - error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:22:17 | -22 | let fail5 = 1234isize; - | ^^^^^^^^^ +22 | let fail3 = 1234i32; + | ^^^^^^^ error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:23:17 | -23 | let fail6 = 1234usize; +23 | let fail4 = 1234u32; + | ^^^^^^^ + +error: integer type suffix should be separated by an underscore + --> $DIR/literals.rs:24:17 + | +24 | let fail5 = 1234isize; + | ^^^^^^^^^ + +error: integer type suffix should be separated by an underscore + --> $DIR/literals.rs:25:17 + | +25 | let fail6 = 1234usize; | ^^^^^^^^^ error: float type suffix should be separated by an underscore - --> $DIR/literals.rs:24:17 + --> $DIR/literals.rs:26:17 | -24 | let fail7 = 1.5f32; +26 | let fail7 = 1.5f32; | ^^^^^^ error: this is a decimal constant - --> $DIR/literals.rs:28:17 + --> $DIR/literals.rs:30:17 | -28 | let fail8 = 0123; +30 | let fail8 = 0123; | ^^^^ help: if you mean to use a decimal constant, remove the `0` to remove confusion | -28 | let fail8 = 123; +30 | let fail8 = 123; | ^^^ help: if you mean to use an octal constant, use `0o` | -28 | let fail8 = 0o123; +30 | let fail8 = 0o123; | ^^^^^ error: long literal lacking separators - --> $DIR/literals.rs:39:17 + --> $DIR/literals.rs:41:17 | -39 | let fail9 = 0xabcdef; +41 | let fail9 = 0xabcdef; | ^^^^^^^^ help: consider: `0x00ab_cdef` | - = note: `-D unreadable-literal` implied by `-D warnings` - -error: long literal lacking separators - --> $DIR/literals.rs:40:18 - | -40 | let fail10 = 0xBAFEBAFE; - | ^^^^^^^^^^ help: consider: `0xBAFE_BAFE` - -error: long literal lacking separators - --> $DIR/literals.rs:41:18 - | -41 | let fail11 = 0xabcdeff; - | ^^^^^^^^^ help: consider: `0x0abc_deff` + = note: `-D clippy::unreadable-literal` implied by `-D warnings` error: long literal lacking separators --> $DIR/literals.rs:42:18 | -42 | let fail12 = 0xabcabcabcabcabcabc; +42 | let fail10 = 0xBAFEBAFE; + | ^^^^^^^^^^ help: consider: `0xBAFE_BAFE` + +error: long literal lacking separators + --> $DIR/literals.rs:43:18 + | +43 | let fail11 = 0xabcdeff; + | ^^^^^^^^^ help: consider: `0x0abc_deff` + +error: long literal lacking separators + --> $DIR/literals.rs:44:18 + | +44 | let fail12 = 0xabcabcabcabcabcabc; | ^^^^^^^^^^^^^^^^^^^^ help: consider: `0x00ab_cabc_abca_bcab_cabc` error: digit groups should be smaller - --> $DIR/literals.rs:43:18 + --> $DIR/literals.rs:45:18 | -43 | let fail13 = 0x1_23456_78901_usize; +45 | let fail13 = 0x1_23456_78901_usize; | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` | - = note: `-D large-digit-groups` implied by `-D warnings` + = note: `-D clippy::large-digit-groups` implied by `-D warnings` error: aborting due to 16 previous errors diff --git a/tests/ui/map_clone.stderr b/tests/ui/map_clone.stderr index c29f3791851..afad65b0071 100644 --- a/tests/ui/map_clone.stderr +++ b/tests/ui/map_clone.stderr @@ -4,7 +4,7 @@ error: you seem to be using .map() to clone the contents of an iterator, conside 12 | x.iter().map(|y| y.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D map-clone` implied by `-D warnings` + = note: `-D clippy::map-clone` implied by `-D warnings` = help: try x.iter().cloned() diff --git a/tests/ui/match_bool.stderr b/tests/ui/match_bool.stderr index 89378f438b0..7ef6f714f3a 100644 --- a/tests/ui/match_bool.stderr +++ b/tests/ui/match_bool.stderr @@ -4,7 +4,7 @@ error: this boolean expression can be simplified 25 | match test && test { | ^^^^^^^^^^^^ help: try: `test` | - = note: `-D nonminimal-bool` implied by `-D warnings` + = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:4:5 @@ -15,7 +15,7 @@ error: you seem to be trying to match on a boolean expression 7 | | }; | |_____^ help: consider using an if/else expression: `if test { 0 } else { 42 }` | - = note: `-D match-bool` implied by `-D warnings` + = note: `-D clippy::match-bool` implied by `-D warnings` error: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:10:5 @@ -59,7 +59,7 @@ error: equal expressions as operands to `&&` 25 | match test && test { | ^^^^^^^^^^^^ | - = note: #[deny(eq_op)] on by default + = note: #[deny(clippy::eq_op)] on by default error: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:30:5 diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index 61c13056cca..6f1a067382a 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -7,7 +7,7 @@ error: you seem to be trying to use match for destructuring a single pattern. Co 24 | | } | |_____^ help: try this: `if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None }` | - = note: `-D single-match-else` implied by `-D warnings` + = note: `-D clippy::single-match-else` implied by `-D warnings` error: you don't need to add `&` to all patterns --> $DIR/matches.rs:30:9 @@ -18,7 +18,7 @@ error: you don't need to add `&` to all patterns 33 | | } | |_________^ | - = note: `-D match-ref-pats` implied by `-D warnings` + = note: `-D clippy::match-ref-pats` implied by `-D warnings` help: instead of prefixing all patterns with `&`, you can dereference the expression | 30 | match *v { @@ -94,7 +94,7 @@ error: some ranges overlap 71 | 0 ... 10 => println!("0 ... 10"), | ^^^^^^^^ | - = note: `-D match-overlapping-arm` implied by `-D warnings` + = note: `-D clippy::match-overlapping-arm` implied by `-D warnings` note: overlaps with this --> $DIR/matches.rs:72:9 | @@ -155,7 +155,7 @@ error: Err(_) will match all errors, maybe not a good idea 132 | Err(_) => panic!("err") | ^^^^^^ | - = note: `-D match-wild-err-arm` implied by `-D warnings` + = note: `-D clippy::match-wild-err-arm` implied by `-D warnings` = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies @@ -164,7 +164,7 @@ error: this `match` has identical arm bodies 131 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | - = note: `-D match-same-arms` implied by `-D warnings` + = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this --> $DIR/matches.rs:130:18 | @@ -347,7 +347,7 @@ error: use as_ref() instead 215 | | }; | |_____^ help: try this: `owned.as_ref()` | - = note: `-D match-as-ref` implied by `-D warnings` + = note: `-D clippy::match-as-ref` implied by `-D warnings` error: use as_mut() instead --> $DIR/matches.rs:218:39 diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index 6e7a44694e1..1f43d9f360a 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -4,7 +4,7 @@ error: usage of mem::forget on Drop type 18 | memstuff::forget(six); | ^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D mem-forget` implied by `-D warnings` + = note: `-D clippy::mem-forget` implied by `-D warnings` error: usage of mem::forget on Drop type --> $DIR/mem_forget.rs:21:5 diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index bf529ce9465..3189f375647 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -4,7 +4,7 @@ error: defining a method called `add` on this type; consider implementing the `s 21 | pub fn add(self, other: T) -> T { self } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D should-implement-trait` implied by `-D warnings` + = note: `-D clippy::should-implement-trait` implied by `-D warnings` error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name --> $DIR/methods.rs:32:17 @@ -12,7 +12,7 @@ error: methods called `into_*` usually take self by value; consider choosing a l 32 | fn into_u16(&self) -> u16 { 0 } | ^^^^^ | - = note: `-D wrong-self-convention` implied by `-D warnings` + = note: `-D clippy::wrong-self-convention` implied by `-D warnings` error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name --> $DIR/methods.rs:34:21 @@ -32,7 +32,7 @@ error: methods called `new` usually return `Self` 36 | fn new(self) {} | ^^^^^^^^^^^^^^^ | - = note: `-D new-ret-no-self` implied by `-D warnings` + = note: `-D clippy::new-ret-no-self` implied by `-D warnings` error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead --> $DIR/methods.rs:104:13 @@ -43,7 +43,7 @@ error: called `map(f).unwrap_or(a)` on an Option value. This can be done more di 106 | | .unwrap_or(0); // should lint even though this call is on a separate line | |____________________________^ | - = note: `-D option-map-unwrap-or` implied by `-D warnings` + = note: `-D clippy::option-map-unwrap-or` implied by `-D warnings` = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)` error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead @@ -104,7 +104,7 @@ error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done mo 133 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line | |____________________________________^ | - = note: `-D option-map-unwrap-or-else` implied by `-D warnings` + = note: `-D clippy::option-map-unwrap-or-else` implied by `-D warnings` = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)` error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead @@ -133,7 +133,7 @@ error: called `map_or(None, f)` on an Option value. This can be done more direct 148 | let _ = opt.map_or(None, |x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using and_then instead: `opt.and_then(|x| Some(x + 1))` | - = note: `-D option-map-or-none` implied by `-D warnings` + = note: `-D clippy::option-map-or-none` implied by `-D warnings` error: called `map_or(None, f)` on an Option value. This can be done more directly by calling `and_then(f)` instead --> $DIR/methods.rs:150:13 @@ -160,7 +160,7 @@ error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done mor 165 | | .unwrap_or_else(|e| 0); // should lint even though this call is on a separate line | |_____________________________________^ | - = note: `-D result-map-unwrap-or-else` implied by `-D warnings` + = note: `-D clippy::result-map-unwrap-or-else` implied by `-D warnings` = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `ok().map_or_else(|e| 0, |x| x + 1)` error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead @@ -189,7 +189,7 @@ error: called `filter(p).next()` on an `Iterator`. This is more succinctly expre 234 | let _ = v.iter().filter(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D filter-next` implied by `-D warnings` + = note: `-D clippy::filter-next` implied by `-D warnings` = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)` error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead. @@ -208,7 +208,7 @@ error: called `is_some()` after searching an `Iterator` with find. This is more 252 | let _ = v.iter().find(|&x| *x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D search-is-some` implied by `-D warnings` + = note: `-D clippy::search-is-some` implied by `-D warnings` = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)` error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`. @@ -263,7 +263,7 @@ error: use of `unwrap_or` followed by a function call 308 | with_constructor.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)` | - = note: `-D or-fun-call` implied by `-D warnings` + = note: `-D clippy::or-fun-call` implied by `-D warnings` error: use of `unwrap_or` followed by a call to `new` --> $DIR/methods.rs:311:5 @@ -337,7 +337,7 @@ error: `error_code` is shadowed by `123_i32` 377 | let error_code = 123_i32; | ^^^^^^^^^^ | - = note: `-D shadow-unrelated` implied by `-D warnings` + = note: `-D clippy::shadow-unrelated` implied by `-D warnings` note: initialization happens here --> $DIR/methods.rs:377:22 | @@ -355,7 +355,7 @@ error: use of `expect` followed by a function call 366 | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` | - = note: `-D expect-fun-call` implied by `-D warnings` + = note: `-D clippy::expect-fun-call` implied by `-D warnings` error: use of `expect` followed by a function call --> $DIR/methods.rs:369:26 @@ -381,7 +381,7 @@ error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more 406 | let bad_vec = some_vec.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D iter-nth` implied by `-D warnings` + = note: `-D clippy::iter-nth` implied by `-D warnings` error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable --> $DIR/methods.rs:407:26 @@ -425,7 +425,7 @@ error: called `skip(x).next()` on an iterator. This is more succinctly expressed 432 | let _ = some_vec.iter().skip(42).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D iter-skip-next` implied by `-D warnings` + = note: `-D clippy::iter-skip-next` implied by `-D warnings` error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` --> $DIR/methods.rs:433:13 @@ -451,7 +451,7 @@ error: used unwrap() on an Option value. If you don't want to handle the None ca 444 | let _ = opt.unwrap(); | ^^^^^^^^^^^^ | - = note: `-D option-unwrap-used` implied by `-D warnings` + = note: `-D clippy::option-unwrap-used` implied by `-D warnings` error: aborting due to 56 previous errors diff --git a/tests/ui/min_max.stderr b/tests/ui/min_max.stderr index b8ea183fcc9..e89542a2ddc 100644 --- a/tests/ui/min_max.stderr +++ b/tests/ui/min_max.stderr @@ -4,7 +4,7 @@ error: this min/max combination leads to constant result 15 | min(1, max(3, x)); | ^^^^^^^^^^^^^^^^^ | - = note: `-D min-max` implied by `-D warnings` + = note: `-D clippy::min-max` implied by `-D warnings` error: this min/max combination leads to constant result --> $DIR/min_max.rs:16:5 diff --git a/tests/ui/missing-doc.stderr b/tests/ui/missing-doc.stderr index 54834f9021c..ebc4c5aca43 100644 --- a/tests/ui/missing-doc.stderr +++ b/tests/ui/missing-doc.stderr @@ -1,267 +1,267 @@ error: missing documentation for a type alias - --> $DIR/missing-doc.rs:26:1 + --> $DIR/missing-doc.rs:28:1 | -26 | type Typedef = String; +28 | type Typedef = String; | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D missing-docs-in-private-items` implied by `-D warnings` + = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` error: missing documentation for a type alias - --> $DIR/missing-doc.rs:27:1 + --> $DIR/missing-doc.rs:29:1 | -27 | pub type PubTypedef = String; +29 | pub type PubTypedef = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct - --> $DIR/missing-doc.rs:29:1 + --> $DIR/missing-doc.rs:31:1 | -29 | / struct Foo { -30 | | a: isize, -31 | | b: isize, -32 | | } +31 | / struct Foo { +32 | | a: isize, +33 | | b: isize, +34 | | } | |_^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:30:5 + --> $DIR/missing-doc.rs:32:5 | -30 | a: isize, +32 | a: isize, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:31:5 + --> $DIR/missing-doc.rs:33:5 | -31 | b: isize, +33 | b: isize, | ^^^^^^^^ error: missing documentation for a struct - --> $DIR/missing-doc.rs:34:1 + --> $DIR/missing-doc.rs:36:1 | -34 | / pub struct PubFoo { -35 | | pub a: isize, -36 | | b: isize, -37 | | } +36 | / pub struct PubFoo { +37 | | pub a: isize, +38 | | b: isize, +39 | | } | |_^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:35:5 + --> $DIR/missing-doc.rs:37:5 | -35 | pub a: isize, +37 | pub a: isize, | ^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:36:5 + --> $DIR/missing-doc.rs:38:5 | -36 | b: isize, +38 | b: isize, | ^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:45:1 + --> $DIR/missing-doc.rs:47:1 | -45 | mod module_no_dox {} +47 | mod module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:46:1 + --> $DIR/missing-doc.rs:48:1 | -46 | pub mod pub_module_no_dox {} +48 | pub mod pub_module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:50:1 + --> $DIR/missing-doc.rs:52:1 | -50 | pub fn foo2() {} +52 | pub fn foo2() {} | ^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:51:1 + --> $DIR/missing-doc.rs:53:1 | -51 | fn foo3() {} +53 | fn foo3() {} | ^^^^^^^^^^^^ error: missing documentation for a trait - --> $DIR/missing-doc.rs:68:1 + --> $DIR/missing-doc.rs:70:1 | -68 | / pub trait C { -69 | | fn foo(&self); -70 | | fn foo_with_impl(&self) {} -71 | | } +70 | / pub trait C { +71 | | fn foo(&self); +72 | | fn foo_with_impl(&self) {} +73 | | } | |_^ error: missing documentation for a trait method - --> $DIR/missing-doc.rs:69:5 + --> $DIR/missing-doc.rs:71:5 | -69 | fn foo(&self); +71 | fn foo(&self); | ^^^^^^^^^^^^^^ error: missing documentation for a trait method - --> $DIR/missing-doc.rs:70:5 + --> $DIR/missing-doc.rs:72:5 | -70 | fn foo_with_impl(&self) {} +72 | fn foo_with_impl(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type - --> $DIR/missing-doc.rs:80:5 + --> $DIR/missing-doc.rs:82:5 | -80 | type AssociatedType; +82 | type AssociatedType; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type - --> $DIR/missing-doc.rs:81:5 + --> $DIR/missing-doc.rs:83:5 | -81 | type AssociatedTypeDef = Self; +83 | type AssociatedTypeDef = Self; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:92:5 + --> $DIR/missing-doc.rs:94:5 | -92 | pub fn foo() {} +94 | pub fn foo() {} | ^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:93:5 + --> $DIR/missing-doc.rs:95:5 | -93 | fn bar() {} +95 | fn bar() {} | ^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:97:5 + --> $DIR/missing-doc.rs:99:5 | -97 | pub fn foo() {} +99 | pub fn foo() {} | ^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:100:5 + --> $DIR/missing-doc.rs:102:5 | -100 | fn foo2() {} +102 | fn foo2() {} | ^^^^^^^^^^^^ error: missing documentation for an enum - --> $DIR/missing-doc.rs:126:1 + --> $DIR/missing-doc.rs:128:1 | -126 | / enum Baz { -127 | | BazA { -128 | | a: isize, -129 | | b: isize -130 | | }, -131 | | BarB -132 | | } +128 | / enum Baz { +129 | | BazA { +130 | | a: isize, +131 | | b: isize +132 | | }, +133 | | BarB +134 | | } | |_^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:127:5 + --> $DIR/missing-doc.rs:129:5 | -127 | / BazA { -128 | | a: isize, -129 | | b: isize -130 | | }, +129 | / BazA { +130 | | a: isize, +131 | | b: isize +132 | | }, | |_____^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:128:9 + --> $DIR/missing-doc.rs:130:9 | -128 | a: isize, +130 | a: isize, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:129:9 + --> $DIR/missing-doc.rs:131:9 | -129 | b: isize +131 | b: isize | ^^^^^^^^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:131:5 + --> $DIR/missing-doc.rs:133:5 | -131 | BarB +133 | BarB | ^^^^ error: missing documentation for an enum - --> $DIR/missing-doc.rs:134:1 + --> $DIR/missing-doc.rs:136:1 | -134 | / pub enum PubBaz { -135 | | PubBazA { -136 | | a: isize, -137 | | }, -138 | | } +136 | / pub enum PubBaz { +137 | | PubBazA { +138 | | a: isize, +139 | | }, +140 | | } | |_^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:135:5 + --> $DIR/missing-doc.rs:137:5 | -135 | / PubBazA { -136 | | a: isize, -137 | | }, +137 | / PubBazA { +138 | | a: isize, +139 | | }, | |_____^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:136:9 + --> $DIR/missing-doc.rs:138:9 | -136 | a: isize, +138 | a: isize, | ^^^^^^^^ error: missing documentation for a constant - --> $DIR/missing-doc.rs:160:1 + --> $DIR/missing-doc.rs:162:1 | -160 | const FOO: u32 = 0; +162 | const FOO: u32 = 0; | ^^^^^^^^^^^^^^^^^^^ error: missing documentation for a constant - --> $DIR/missing-doc.rs:167:1 + --> $DIR/missing-doc.rs:169:1 | -167 | pub const FOO4: u32 = 0; +169 | pub const FOO4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing-doc.rs:170:1 + --> $DIR/missing-doc.rs:172:1 | -170 | static BAR: u32 = 0; +172 | static BAR: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing-doc.rs:177:1 + --> $DIR/missing-doc.rs:179:1 | -177 | pub static BAR4: u32 = 0; +179 | pub static BAR4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:180:1 + --> $DIR/missing-doc.rs:182:1 | -180 | / mod internal_impl { -181 | | /// dox -182 | | pub fn documented() {} -183 | | pub fn undocumented1() {} +182 | / mod internal_impl { +183 | | /// dox +184 | | pub fn documented() {} +185 | | pub fn undocumented1() {} ... | -192 | | } -193 | | } +194 | | } +195 | | } | |_^ -error: missing documentation for a function - --> $DIR/missing-doc.rs:183:5 - | -183 | pub fn undocumented1() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: missing documentation for a function - --> $DIR/missing-doc.rs:184:5 - | -184 | pub fn undocumented2() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - error: missing documentation for a function --> $DIR/missing-doc.rs:185:5 | -185 | fn undocumented3() {} +185 | pub fn undocumented1() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for a function + --> $DIR/missing-doc.rs:186:5 + | +186 | pub fn undocumented2() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for a function + --> $DIR/missing-doc.rs:187:5 + | +187 | fn undocumented3() {} | ^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:190:9 + --> $DIR/missing-doc.rs:192:9 | -190 | pub fn also_undocumented1() {} +192 | pub fn also_undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:191:9 + --> $DIR/missing-doc.rs:193:9 | -191 | fn also_undocumented2() {} +193 | fn also_undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 39 previous errors diff --git a/tests/ui/missing_inline.stderr b/tests/ui/missing_inline.stderr index fe343742708..3609c9101b7 100644 --- a/tests/ui/missing_inline.stderr +++ b/tests/ui/missing_inline.stderr @@ -1,39 +1,39 @@ error: missing `#[inline]` for a function - --> $DIR/missing_inline.rs:31:1 + --> $DIR/missing_inline.rs:33:1 | -31 | pub fn pub_foo() {} // missing #[inline] +33 | pub fn pub_foo() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^ | - = note: `-D missing-inline-in-public-items` implied by `-D warnings` + = note: `-D clippy::missing-inline-in-public-items` implied by `-D warnings` error: missing `#[inline]` for a default trait method - --> $DIR/missing_inline.rs:46:5 + --> $DIR/missing_inline.rs:48:5 | -46 | fn PubBar_b() {} // missing #[inline] - | ^^^^^^^^^^^^^^^^ - -error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:59:5 - | -59 | fn PubBar_a() {} // missing #[inline] - | ^^^^^^^^^^^^^^^^ - -error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:60:5 - | -60 | fn PubBar_b() {} // missing #[inline] +48 | fn PubBar_b() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method --> $DIR/missing_inline.rs:61:5 | -61 | fn PubBar_c() {} // missing #[inline] +61 | fn PubBar_a() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:71:5 + --> $DIR/missing_inline.rs:62:5 | -71 | pub fn PubFooImpl() {} // missing #[inline] +62 | fn PubBar_b() {} // missing #[inline] + | ^^^^^^^^^^^^^^^^ + +error: missing `#[inline]` for a method + --> $DIR/missing_inline.rs:63:5 + | +63 | fn PubBar_c() {} // missing #[inline] + | ^^^^^^^^^^^^^^^^ + +error: missing `#[inline]` for a method + --> $DIR/missing_inline.rs:73:5 + | +73 | pub fn PubFooImpl() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/module_inception.stderr b/tests/ui/module_inception.stderr index c9d3319db1b..43f9666f78d 100644 --- a/tests/ui/module_inception.stderr +++ b/tests/ui/module_inception.stderr @@ -6,7 +6,7 @@ error: module has the same name as its containing module 9 | | } | |_________^ | - = note: `-D module-inception` implied by `-D warnings` + = note: `-D clippy::module-inception` implied by `-D warnings` error: module has the same name as its containing module --> $DIR/module_inception.rs:12:5 diff --git a/tests/ui/modulo_one.stderr b/tests/ui/modulo_one.stderr index ccfca7154e0..5d42c3e0a29 100644 --- a/tests/ui/modulo_one.stderr +++ b/tests/ui/modulo_one.stderr @@ -4,7 +4,7 @@ error: any number modulo 1 will be 0 7 | 10 % 1; | ^^^^^^ | - = note: `-D modulo-one` implied by `-D warnings` + = note: `-D clippy::modulo-one` implied by `-D warnings` error: aborting due to previous error diff --git a/tests/ui/mut_from_ref.stderr b/tests/ui/mut_from_ref.stderr index a7cbc0b7a09..0f5baa2d27e 100644 --- a/tests/ui/mut_from_ref.stderr +++ b/tests/ui/mut_from_ref.stderr @@ -4,7 +4,7 @@ error: mutable borrow from immutable input(s) 9 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^^^^ | - = note: `-D mut-from-ref` implied by `-D warnings` + = note: `-D clippy::mut-from-ref` implied by `-D warnings` note: immutable borrow here --> $DIR/mut_from_ref.rs:9:29 | diff --git a/tests/ui/mut_mut.stderr b/tests/ui/mut_mut.stderr index d1f05ea8091..88bd2f729af 100644 --- a/tests/ui/mut_mut.stderr +++ b/tests/ui/mut_mut.stderr @@ -4,7 +4,7 @@ error: generally you want to avoid `&mut &mut _` if possible 10 | fn fun(x : &mut &mut u32) -> bool { | ^^^^^^^^^^^^^ | - = note: `-D mut-mut` implied by `-D warnings` + = note: `-D clippy::mut-mut` implied by `-D warnings` error: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:24:17 diff --git a/tests/ui/mut_range_bound.stderr b/tests/ui/mut_range_bound.stderr index d7be7ae1e6f..fece9610697 100644 --- a/tests/ui/mut_range_bound.stderr +++ b/tests/ui/mut_range_bound.stderr @@ -4,7 +4,7 @@ error: attempt to mutate range bound within loop; note that the range of the loo 18 | for i in 0..m { m = 5; } // warning | ^^^^^ | - = note: `-D mut-range-bound` implied by `-D warnings` + = note: `-D clippy::mut-range-bound` implied by `-D warnings` error: attempt to mutate range bound within loop; note that the range of the loop is unchanged --> $DIR/mut_range_bound.rs:23:22 diff --git a/tests/ui/mut_reference.stderr b/tests/ui/mut_reference.stderr index 73df19bf158..ee62e264767 100644 --- a/tests/ui/mut_reference.stderr +++ b/tests/ui/mut_reference.stderr @@ -4,7 +4,7 @@ error: The function/method `takes_an_immutable_reference` doesn't need a mutable 22 | takes_an_immutable_reference(&mut 42); | ^^^^^^^ | - = note: `-D unnecessary-mut-passed` implied by `-D warnings` + = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings` error: The function/method `as_ptr` doesn't need a mutable reference --> $DIR/mut_reference.rs:24:12 diff --git a/tests/ui/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index 354f9891c17..2df58889a47 100644 --- a/tests/ui/mutex_atomic.stderr +++ b/tests/ui/mutex_atomic.stderr @@ -4,7 +4,7 @@ error: Consider using an AtomicBool instead of a Mutex here. If you just want th 9 | Mutex::new(true); | ^^^^^^^^^^^^^^^^ | - = note: `-D mutex-atomic` implied by `-D warnings` + = note: `-D clippy::mutex-atomic` implied by `-D warnings` error: Consider using an AtomicUsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. --> $DIR/mutex_atomic.rs:10:5 @@ -36,7 +36,7 @@ error: Consider using an AtomicUsize instead of a Mutex here. If you just want t 15 | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ | - = note: `-D mutex-integer` implied by `-D warnings` + = note: `-D clippy::mutex-integer` implied by `-D warnings` error: Consider using an AtomicIsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. --> $DIR/mutex_atomic.rs:16:5 diff --git a/tests/ui/needless_bool.stderr b/tests/ui/needless_bool.stderr index 63e0632445f..dd132bc671e 100644 --- a/tests/ui/needless_bool.stderr +++ b/tests/ui/needless_bool.stderr @@ -4,7 +4,7 @@ error: this if-then-else expression will always return true 9 | if x { true } else { true }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D needless-bool` implied by `-D warnings` + = note: `-D clippy::needless-bool` implied by `-D warnings` error: this if-then-else expression will always return false --> $DIR/needless_bool.rs:10:5 diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index fde38508b32..c720dff5d29 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -1,41 +1,41 @@ error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:13:15 + --> $DIR/needless_borrow.rs:15:15 | -13 | let c = x(&&a); +15 | let c = x(&&a); | ^^^ help: change this to: `&a` | - = note: `-D needless-borrow` implied by `-D warnings` + = note: `-D clippy::needless-borrow` implied by `-D warnings` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow.rs:20:17 + --> $DIR/needless_borrow.rs:22:17 | -20 | if let Some(ref cake) = Some(&5) {} +22 | if let Some(ref cake) = Some(&5) {} | ^^^^^^^^ help: change this to: `cake` error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:27:15 + --> $DIR/needless_borrow.rs:29:15 | -27 | 46 => &&a, +29 | 46 => &&a, | ^^^ help: change this to: `&a` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrow.rs:49:34 + --> $DIR/needless_borrow.rs:51:34 | -49 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); +51 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` | - = note: `-D needless-borrowed-reference` implied by `-D warnings` + = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrow.rs:50:30 + --> $DIR/needless_borrow.rs:52:30 | -50 | let _ = v.iter().filter(|&ref a| a.is_empty()); +52 | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow.rs:50:31 + --> $DIR/needless_borrow.rs:52:31 | -50 | let _ = v.iter().filter(|&ref a| a.is_empty()); +52 | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^ help: change this to: `a` error: aborting due to 6 previous errors diff --git a/tests/ui/needless_borrowed_ref.stderr b/tests/ui/needless_borrowed_ref.stderr index 2a8cf4348d3..3113b887b05 100644 --- a/tests/ui/needless_borrowed_ref.stderr +++ b/tests/ui/needless_borrowed_ref.stderr @@ -4,7 +4,7 @@ error: this pattern takes a reference on something that is being de-referenced 8 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` | - = note: `-D needless-borrowed-reference` implied by `-D warnings` + = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` error: this pattern takes a reference on something that is being de-referenced --> $DIR/needless_borrowed_ref.rs:13:17 diff --git a/tests/ui/needless_continue.stderr b/tests/ui/needless_continue.stderr index 3e0368892a4..7cfaf89d6e0 100644 --- a/tests/ui/needless_continue.stderr +++ b/tests/ui/needless_continue.stderr @@ -8,7 +8,7 @@ error: This else block is redundant. 28 | | } | |_________^ | - = note: `-D needless-continue` implied by `-D warnings` + = note: `-D clippy::needless-continue` implied by `-D warnings` = help: Consider dropping the else clause and merging the code that follows (in the loop) with the if block, like so: if i % 2 == 0 && i % 3 == 0 { println!("{}", i); diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index 2fef0595cb3..9cb5e6e48cd 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -1,187 +1,187 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:9:23 - | -9 | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { - | ^^^^^^ help: consider changing the type to: `&[T]` - | - = note: `-D needless-pass-by-value` implied by `-D warnings` + --> $DIR/needless_pass_by_value.rs:11:23 + | +11 | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { + | ^^^^^^ help: consider changing the type to: `&[T]` + | + = note: `-D clippy::needless-pass-by-value` implied by `-D warnings` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:23:11 + --> $DIR/needless_pass_by_value.rs:25:11 | -23 | fn bar(x: String, y: Wrapper) { +25 | fn bar(x: String, y: Wrapper) { | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:23:22 + --> $DIR/needless_pass_by_value.rs:25:22 | -23 | fn bar(x: String, y: Wrapper) { +25 | fn bar(x: String, y: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:29:71 + --> $DIR/needless_pass_by_value.rs:31:71 | -29 | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { +31 | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { | ^ help: consider taking a reference instead: `&V` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:41:18 + --> $DIR/needless_pass_by_value.rs:43:18 | -41 | fn test_match(x: Option>, y: Option>) { +43 | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead | -41 | fn test_match(x: &Option>, y: Option>) { -42 | match *x { +43 | fn test_match(x: &Option>, y: Option>) { +44 | match *x { | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:54:24 + --> $DIR/needless_pass_by_value.rs:56:24 | -54 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +56 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:54:36 + --> $DIR/needless_pass_by_value.rs:56:36 | -54 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +56 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead | -54 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { -55 | let Wrapper(s) = z; // moved -56 | let Wrapper(ref t) = *y; // not moved -57 | let Wrapper(_) = *y; // still not moved +56 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { +57 | let Wrapper(s) = z; // moved +58 | let Wrapper(ref t) = *y; // not moved +59 | let Wrapper(_) = *y; // still not moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:70:49 + --> $DIR/needless_pass_by_value.rs:72:49 | -70 | fn test_blanket_ref(_foo: T, _serializable: S) {} +72 | fn test_blanket_ref(_foo: T, _serializable: S) {} | ^ help: consider taking a reference instead: `&T` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:72:18 + --> $DIR/needless_pass_by_value.rs:74:18 | -72 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +74 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:72:29 + --> $DIR/needless_pass_by_value.rs:74:29 | -72 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +74 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider changing the type to | -72 | fn issue_2114(s: String, t: &str, u: Vec, v: Vec) { +74 | fn issue_2114(s: String, t: &str, u: Vec, v: Vec) { | ^^^^ help: change `t.clone()` to | -74 | let _ = t.to_string(); +76 | let _ = t.to_string(); | ^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:72:40 + --> $DIR/needless_pass_by_value.rs:74:40 | -72 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +74 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider taking a reference instead: `&Vec` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:72:53 + --> $DIR/needless_pass_by_value.rs:74:53 | -72 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +74 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider changing the type to | -72 | fn issue_2114(s: String, t: String, u: Vec, v: &[i32]) { +74 | fn issue_2114(s: String, t: String, u: Vec, v: &[i32]) { | ^^^^^^ help: change `v.clone()` to | -76 | let _ = v.to_owned(); +78 | let _ = v.to_owned(); | ^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:84:12 + --> $DIR/needless_pass_by_value.rs:86:12 | -84 | s: String, +86 | s: String, | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:85:12 + --> $DIR/needless_pass_by_value.rs:87:12 | -85 | t: String, +87 | t: String, | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:97:13 + --> $DIR/needless_pass_by_value.rs:99:13 | -97 | _u: U, +99 | _u: U, | ^ help: consider taking a reference instead: `&U` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:98:13 - | -98 | _s: Self, - | ^^^^ help: consider taking a reference instead: `&Self` + --> $DIR/needless_pass_by_value.rs:100:13 + | +100 | _s: Self, + | ^^^^ help: consider taking a reference instead: `&Self` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:120:24 + --> $DIR/needless_pass_by_value.rs:122:24 | -120 | fn bar_copy(x: u32, y: CopyWrapper) { +122 | fn bar_copy(x: u32, y: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:118:1 + --> $DIR/needless_pass_by_value.rs:120:1 | -118 | struct CopyWrapper(u32); +120 | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:126:29 + --> $DIR/needless_pass_by_value.rs:128:29 | -126 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { +128 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:118:1 + --> $DIR/needless_pass_by_value.rs:120:1 | -118 | struct CopyWrapper(u32); +120 | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:126:45 + --> $DIR/needless_pass_by_value.rs:128:45 | -126 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { +128 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:118:1 + --> $DIR/needless_pass_by_value.rs:120:1 | -118 | struct CopyWrapper(u32); +120 | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead | -126 | fn test_destructure_copy(x: CopyWrapper, y: &CopyWrapper, z: CopyWrapper) { -127 | let CopyWrapper(s) = z; // moved -128 | let CopyWrapper(ref t) = *y; // not moved -129 | let CopyWrapper(_) = *y; // still not moved +128 | fn test_destructure_copy(x: CopyWrapper, y: &CopyWrapper, z: CopyWrapper) { +129 | let CopyWrapper(s) = z; // moved +130 | let CopyWrapper(ref t) = *y; // not moved +131 | let CopyWrapper(_) = *y; // still not moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:126:61 + --> $DIR/needless_pass_by_value.rs:128:61 | -126 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { +128 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:118:1 + --> $DIR/needless_pass_by_value.rs:120:1 | -118 | struct CopyWrapper(u32); +120 | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead | -126 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: &CopyWrapper) { -127 | let CopyWrapper(s) = *z; // moved +128 | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: &CopyWrapper) { +129 | let CopyWrapper(s) = *z; // moved | error: aborting due to 20 previous errors diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index c394469c17b..1954a8240b2 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -4,7 +4,7 @@ error: the loop variable `i` is only used to index `ns`. 8 | for i in 3..10 { | ^^^^^ | - = note: `-D needless-range-loop` implied by `-D warnings` + = note: `-D clippy::needless-range-loop` implied by `-D warnings` help: consider using an iterator | 8 | for in ns.iter().take(10).skip(3) { diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 42dc6e6594c..094fe3642a2 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -4,7 +4,7 @@ error: unneeded return statement 11 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` | - = note: `-D needless-return` implied by `-D warnings` + = note: `-D clippy::needless-return` implied by `-D warnings` error: unneeded return statement --> $DIR/needless_return.rs:15:5 diff --git a/tests/ui/needless_update.stderr b/tests/ui/needless_update.stderr index 3e509870d00..acc51198497 100644 --- a/tests/ui/needless_update.stderr +++ b/tests/ui/needless_update.stderr @@ -4,7 +4,7 @@ error: struct update has no effect, all the fields in the struct have already be 16 | S { a: 1, b: 1, ..base }; | ^^^^ | - = note: `-D needless-update` implied by `-D warnings` + = note: `-D clippy::needless-update` implied by `-D warnings` error: aborting due to previous error diff --git a/tests/ui/neg_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index ccd30561100..5fd4ab9ba48 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -1,27 +1,27 @@ error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:17:21 + --> $DIR/neg_cmp_op_on_partial_ord.rs:19:21 | -17 | let _not_less = !(a_value < another_value); +19 | let _not_less = !(a_value < another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D neg-cmp-op-on-partial-ord` implied by `-D warnings` + = note: `-D clippy::neg-cmp-op-on-partial-ord` implied by `-D warnings` error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:20:30 + --> $DIR/neg_cmp_op_on_partial_ord.rs:22:30 | -20 | let _not_less_or_equal = !(a_value <= another_value); +22 | let _not_less_or_equal = !(a_value <= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:23:24 + --> $DIR/neg_cmp_op_on_partial_ord.rs:25:24 | -23 | let _not_greater = !(a_value > another_value); +25 | let _not_greater = !(a_value > another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: The use of negated comparison operators on partially ordered types produces code that is hard to read and refactor. Please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable. - --> $DIR/neg_cmp_op_on_partial_ord.rs:26:33 + --> $DIR/neg_cmp_op_on_partial_ord.rs:28:33 | -26 | let _not_greater_or_equal = !(a_value >= another_value); +28 | let _not_greater_or_equal = !(a_value >= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/neg_multiply.stderr b/tests/ui/neg_multiply.stderr index 1d52ba16eae..ba59fdb8940 100644 --- a/tests/ui/neg_multiply.stderr +++ b/tests/ui/neg_multiply.stderr @@ -4,7 +4,7 @@ error: Negation by multiplying with -1 30 | x * -1; | ^^^^^^ | - = note: `-D neg-multiply` implied by `-D warnings` + = note: `-D clippy::neg-multiply` implied by `-D warnings` error: Negation by multiplying with -1 --> $DIR/neg_multiply.rs:32:5 diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index 664be379e35..3d1235964d1 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -1,7 +1,7 @@ error: this loop never actually loops --> $DIR/never_loop.rs:7:5 | -7 | / loop { // never_loop +7 | / loop { // clippy::never_loop 8 | | x += 1; 9 | | if x == 1 { 10 | | return @@ -10,7 +10,7 @@ error: this loop never actually loops 13 | | } | |_____^ | - = note: #[deny(never_loop)] on by default + = note: #[deny(clippy::never_loop)] on by default error: this loop never actually loops --> $DIR/never_loop.rs:28:5 diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index 335e60404fa..11ece5e8708 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -1,39 +1,39 @@ error: you should consider deriving a `Default` implementation for `Foo` - --> $DIR/new_without_default.rs:10:5 + --> $DIR/new_without_default.rs:12:5 | -10 | pub fn new() -> Foo { Foo } +12 | pub fn new() -> Foo { Foo } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D new-without-default-derive` implied by `-D warnings` + = note: `-D clippy::new-without-default-derive` implied by `-D warnings` help: try this | -7 | #[derive(Default)] +9 | #[derive(Default)] | error: you should consider deriving a `Default` implementation for `Bar` - --> $DIR/new_without_default.rs:16:5 + --> $DIR/new_without_default.rs:18:5 | -16 | pub fn new() -> Self { Bar } +18 | pub fn new() -> Self { Bar } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this | -13 | #[derive(Default)] +15 | #[derive(Default)] | error: you should consider adding a `Default` implementation for `LtKo<'c>` - --> $DIR/new_without_default.rs:64:5 + --> $DIR/new_without_default.rs:66:5 | -64 | pub fn new() -> LtKo<'c> { unimplemented!() } +66 | pub fn new() -> LtKo<'c> { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D new-without-default` implied by `-D warnings` + = note: `-D clippy::new-without-default` implied by `-D warnings` help: try this | -63 | impl Default for LtKo<'c> { -64 | fn default() -> Self { -65 | Self::new() -66 | } -67 | } +65 | impl Default for LtKo<'c> { +66 | fn default() -> Self { +67 | Self::new() +68 | } +69 | } | error: aborting due to 3 previous errors diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index 7ff0425ebb9..2429d934ca1 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -1,275 +1,275 @@ -error: statement with no effect - --> $DIR/no_effect.rs:59:5 - | -59 | 0; - | ^^ - | - = note: `-D no-effect` implied by `-D warnings` - -error: statement with no effect - --> $DIR/no_effect.rs:60:5 - | -60 | s2; - | ^^^ - error: statement with no effect --> $DIR/no_effect.rs:61:5 | -61 | Unit; - | ^^^^^ +61 | 0; + | ^^ + | + = note: `-D clippy::no-effect` implied by `-D warnings` error: statement with no effect --> $DIR/no_effect.rs:62:5 | -62 | Tuple(0); - | ^^^^^^^^^ +62 | s2; + | ^^^ error: statement with no effect --> $DIR/no_effect.rs:63:5 | -63 | Struct { field: 0 }; - | ^^^^^^^^^^^^^^^^^^^^ +63 | Unit; + | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:64:5 | -64 | Struct { ..s }; - | ^^^^^^^^^^^^^^^ +64 | Tuple(0); + | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:65:5 | -65 | Union { a: 0 }; - | ^^^^^^^^^^^^^^^ +65 | Struct { field: 0 }; + | ^^^^^^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:66:5 | -66 | Enum::Tuple(0); +66 | Struct { ..s }; | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:67:5 | -67 | Enum::Struct { field: 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +67 | Union { a: 0 }; + | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:68:5 | -68 | 5 + 6; - | ^^^^^^ +68 | Enum::Tuple(0); + | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:69:5 | -69 | *&42; - | ^^^^^ +69 | Enum::Struct { field: 0 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:70:5 | -70 | &6; - | ^^^ +70 | 5 + 6; + | ^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:71:5 | -71 | (5, 6, 7); - | ^^^^^^^^^^ +71 | *&42; + | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:72:5 | -72 | box 42; - | ^^^^^^^ +72 | &6; + | ^^^ error: statement with no effect --> $DIR/no_effect.rs:73:5 | -73 | ..; - | ^^^ +73 | (5, 6, 7); + | ^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:74:5 | -74 | 5..; - | ^^^^ +74 | box 42; + | ^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:75:5 | -75 | ..5; - | ^^^^ +75 | ..; + | ^^^ error: statement with no effect --> $DIR/no_effect.rs:76:5 | -76 | 5..6; - | ^^^^^ +76 | 5..; + | ^^^^ + +error: statement with no effect + --> $DIR/no_effect.rs:77:5 + | +77 | ..5; + | ^^^^ error: statement with no effect --> $DIR/no_effect.rs:78:5 | -78 | [42, 55]; - | ^^^^^^^^^ - -error: statement with no effect - --> $DIR/no_effect.rs:79:5 - | -79 | [42, 55][1]; - | ^^^^^^^^^^^^ +78 | 5..6; + | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:80:5 | -80 | (42, 55).1; - | ^^^^^^^^^^^ +80 | [42, 55]; + | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:81:5 | -81 | [42; 55]; - | ^^^^^^^^^ +81 | [42, 55][1]; + | ^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:82:5 | -82 | [42; 55][13]; - | ^^^^^^^^^^^^^ +82 | (42, 55).1; + | ^^^^^^^^^^^ + +error: statement with no effect + --> $DIR/no_effect.rs:83:5 + | +83 | [42; 55]; + | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:84:5 | -84 | || x += 5; - | ^^^^^^^^^^ +84 | [42; 55][13]; + | ^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:86:5 | -86 | FooString { s: s }; +86 | || x += 5; + | ^^^^^^^^^^ + +error: statement with no effect + --> $DIR/no_effect.rs:88:5 + | +88 | FooString { s: s }; | ^^^^^^^^^^^^^^^^^^^ -error: statement can be reduced - --> $DIR/no_effect.rs:97:5 - | -97 | Tuple(get_number()); - | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` - | - = note: `-D unnecessary-operation` implied by `-D warnings` - -error: statement can be reduced - --> $DIR/no_effect.rs:98:5 - | -98 | Struct { field: get_number() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` - error: statement can be reduced --> $DIR/no_effect.rs:99:5 | -99 | Struct { ..get_struct() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_struct();` +99 | Tuple(get_number()); + | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` + | + = note: `-D clippy::unnecessary-operation` implied by `-D warnings` error: statement can be reduced --> $DIR/no_effect.rs:100:5 | -100 | Enum::Tuple(get_number()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +100 | Struct { field: get_number() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:101:5 | -101 | Enum::Struct { field: get_number() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +101 | Struct { ..get_struct() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_struct();` error: statement can be reduced --> $DIR/no_effect.rs:102:5 | -102 | 5 + get_number(); - | ^^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` +102 | Enum::Tuple(get_number()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:103:5 | -103 | *&get_number(); - | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +103 | Enum::Struct { field: get_number() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:104:5 | -104 | &get_number(); - | ^^^^^^^^^^^^^^ help: replace it with: `get_number();` +104 | 5 + get_number(); + | ^^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:105:5 | -105 | (5, 6, get_number()); - | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `5;6;get_number();` +105 | *&get_number(); + | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:106:5 | -106 | box get_number(); - | ^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +106 | &get_number(); + | ^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:107:5 | -107 | get_number()..; - | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +107 | (5, 6, get_number()); + | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `5;6;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:108:5 | -108 | ..get_number(); - | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +108 | box get_number(); + | ^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:109:5 | -109 | 5..get_number(); - | ^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` +109 | get_number()..; + | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:110:5 | -110 | [42, get_number()]; - | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` +110 | ..get_number(); + | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:111:5 | -111 | [42, 55][get_number() as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42, 55];get_number() as usize;` +111 | 5..get_number(); + | ^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:112:5 | -112 | (42, get_number()).1; - | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` +112 | [42, get_number()]; + | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:113:5 | -113 | [get_number(); 55]; - | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +113 | [42, 55][get_number() as usize]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42, 55];get_number() as usize;` error: statement can be reduced --> $DIR/no_effect.rs:114:5 | -114 | [42; 55][get_number() as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42; 55];get_number() as usize;` +114 | (42, get_number()).1; + | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:115:5 | -115 | {get_number()}; - | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +115 | [get_number(); 55]; + | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:116:5 | -116 | FooString { s: String::from("blah"), }; +116 | [42; 55][get_number() as usize]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42; 55];get_number() as usize;` + +error: statement can be reduced + --> $DIR/no_effect.rs:117:5 + | +117 | {get_number()}; + | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:118:5 + | +118 | FooString { s: String::from("blah"), }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `String::from("blah");` error: aborting due to 45 previous errors diff --git a/tests/ui/non_copy_const.stderr b/tests/ui/non_copy_const.stderr index 388c7fabab0..7f164595b59 100644 --- a/tests/ui/non_copy_const.stderr +++ b/tests/ui/non_copy_const.stderr @@ -1,272 +1,272 @@ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:10:1 + --> $DIR/non_copy_const.rs:12:1 | -10 | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable +12 | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` | - = note: #[deny(declare_interior_mutable_const)] on by default + = note: #[deny(clippy::declare_interior_mutable_const)] on by default error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:11:1 + --> $DIR/non_copy_const.rs:13:1 | -11 | const CELL: Cell = Cell::new(6); //~ ERROR interior mutable +13 | const CELL: Cell = Cell::new(6); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:12:1 + --> $DIR/non_copy_const.rs:14:1 | -12 | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); +14 | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:16:42 + --> $DIR/non_copy_const.rs:18:42 | -16 | ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; }; +18 | ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; }; | ^^^^^^^^^^^^^^^^^^^^^^ -17 | } -18 | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable +19 | } +20 | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable | ------------------------------------------ in this macro invocation error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:39:5 + --> $DIR/non_copy_const.rs:41:5 | -39 | const ATOMIC: AtomicUsize; //~ ERROR interior mutable +41 | const ATOMIC: AtomicUsize; //~ ERROR interior mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:43:5 + --> $DIR/non_copy_const.rs:45:5 | -43 | const INPUT: T; +45 | const INPUT: T; | ^^^^^^^^^^^^^^^ | help: consider requiring `T` to be `Copy` - --> $DIR/non_copy_const.rs:43:18 + --> $DIR/non_copy_const.rs:45:18 | -43 | const INPUT: T; +45 | const INPUT: T; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:46:5 + --> $DIR/non_copy_const.rs:48:5 | -46 | const ASSOC: Self::NonCopyType; +48 | const ASSOC: Self::NonCopyType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `>::NonCopyType` to be `Copy` - --> $DIR/non_copy_const.rs:46:18 + --> $DIR/non_copy_const.rs:48:18 | -46 | const ASSOC: Self::NonCopyType; +48 | const ASSOC: Self::NonCopyType; | ^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:50:5 + --> $DIR/non_copy_const.rs:52:5 | -50 | const AN_INPUT: T = Self::INPUT; +52 | const AN_INPUT: T = Self::INPUT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `T` to be `Copy` - --> $DIR/non_copy_const.rs:50:21 + --> $DIR/non_copy_const.rs:52:21 | -50 | const AN_INPUT: T = Self::INPUT; +52 | const AN_INPUT: T = Self::INPUT; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:16:42 + --> $DIR/non_copy_const.rs:18:42 | -16 | ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; }; +18 | ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; }; | ^^^^^^^^^^^^^^^^^^^^^^ ... -53 | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable +55 | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable | ----------------------------------------------- in this macro invocation error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:59:5 + --> $DIR/non_copy_const.rs:61:5 | -59 | const SELF_2: Self; +61 | const SELF_2: Self; | ^^^^^^^^^^^^^^^^^^^ | help: consider requiring `Self` to be `Copy` - --> $DIR/non_copy_const.rs:59:19 + --> $DIR/non_copy_const.rs:61:19 | -59 | const SELF_2: Self; +61 | const SELF_2: Self; | ^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:80:5 + --> $DIR/non_copy_const.rs:82:5 | -80 | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable +82 | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:83:5 + --> $DIR/non_copy_const.rs:85:5 | -83 | const U_SELF: U = U::SELF_2; +85 | const U_SELF: U = U::SELF_2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `U` to be `Copy` - --> $DIR/non_copy_const.rs:83:19 + --> $DIR/non_copy_const.rs:85:19 | -83 | const U_SELF: U = U::SELF_2; +85 | const U_SELF: U = U::SELF_2; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:86:5 + --> $DIR/non_copy_const.rs:88:5 | -86 | const T_ASSOC: T::NonCopyType = T::ASSOC; +88 | const T_ASSOC: T::NonCopyType = T::ASSOC; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `>::NonCopyType` to be `Copy` - --> $DIR/non_copy_const.rs:86:20 + --> $DIR/non_copy_const.rs:88:20 | -86 | const T_ASSOC: T::NonCopyType = T::ASSOC; +88 | const T_ASSOC: T::NonCopyType = T::ASSOC; | ^^^^^^^^^^^^^^ error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:93:5 + --> $DIR/non_copy_const.rs:95:5 | -93 | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability +95 | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^ | - = note: #[deny(borrow_interior_mutable_const)] on by default + = note: #[deny(clippy::borrow_interior_mutable_const)] on by default = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:94:16 + --> $DIR/non_copy_const.rs:96:16 | -94 | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability +96 | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability | ^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:96:5 + --> $DIR/non_copy_const.rs:98:5 | -96 | ATOMIC_USIZE_INIT.store(2, Ordering::SeqCst); //~ ERROR interior mutability +98 | ATOMIC_USIZE_INIT.store(2, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:97:16 + --> $DIR/non_copy_const.rs:99:16 | -97 | assert_eq!(ATOMIC_USIZE_INIT.load(Ordering::SeqCst), 0); //~ ERROR interior mutability +99 | assert_eq!(ATOMIC_USIZE_INIT.load(Ordering::SeqCst), 0); //~ ERROR interior mutability | ^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:100:22 + --> $DIR/non_copy_const.rs:102:22 | -100 | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability +102 | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:101:25 + --> $DIR/non_copy_const.rs:103:25 | -101 | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability +103 | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:102:27 + --> $DIR/non_copy_const.rs:104:27 | -102 | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability +104 | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:103:26 + --> $DIR/non_copy_const.rs:105:26 | -103 | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability +105 | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:114:14 + --> $DIR/non_copy_const.rs:116:14 | -114 | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability +116 | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here -error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:115:14 - | -115 | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability - | ^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here - -error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:116:19 - | -116 | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability - | ^^^^^^^^^^^^ - | - = help: assign this const to a local or static variable, and use the variable here - error: a const item with interior mutability should not be borrowed --> $DIR/non_copy_const.rs:117:14 | -117 | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability +117 | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:118:13 + --> $DIR/non_copy_const.rs:118:19 | -118 | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability +118 | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability + | ^^^^^^^^^^^^ + | + = help: assign this const to a local or static variable, and use the variable here + +error: a const item with interior mutability should not be borrowed + --> $DIR/non_copy_const.rs:119:14 + | +119 | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability + | ^^^^^^^^^^^^ + | + = help: assign this const to a local or static variable, and use the variable here + +error: a const item with interior mutability should not be borrowed + --> $DIR/non_copy_const.rs:120:13 + | +120 | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:124:13 + --> $DIR/non_copy_const.rs:126:13 | -124 | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability +126 | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:129:5 + --> $DIR/non_copy_const.rs:131:5 | -129 | CELL.set(2); //~ ERROR interior mutability +131 | CELL.set(2); //~ ERROR interior mutability | ^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:130:16 + --> $DIR/non_copy_const.rs:132:16 | -130 | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability +132 | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability | ^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:143:5 + --> $DIR/non_copy_const.rs:145:5 | -143 | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability +145 | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:144:16 + --> $DIR/non_copy_const.rs:146:16 | -144 | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability +146 | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability | ^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index b4927e69e67..b1dd62ed87c 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -4,7 +4,7 @@ error: binding's name is too similar to existing binding 18 | let bpple: i32; | ^^^^^ | - = note: `-D similar-names` implied by `-D warnings` + = note: `-D clippy::similar-names` implied by `-D warnings` note: existing binding defined here --> $DIR/non_expressive_names.rs:16:9 | @@ -109,7 +109,7 @@ error: 5th binding whose name is just one char 120 | let e: i32; | ^ | - = note: `-D many-single-char-names` implied by `-D warnings` + = note: `-D clippy::many-single-char-names` implied by `-D warnings` error: 5th binding whose name is just one char --> $DIR/non_expressive_names.rs:123:17 @@ -135,7 +135,7 @@ error: consider choosing a more descriptive name 139 | let _1 = 1; //~ERROR Consider a more descriptive name | ^^ | - = note: `-D just-underscores-and-digits` implied by `-D warnings` + = note: `-D clippy::just-underscores-and-digits` implied by `-D warnings` error: consider choosing a more descriptive name --> $DIR/non_expressive_names.rs:140:9 diff --git a/tests/ui/ok_expect.stderr b/tests/ui/ok_expect.stderr index da2d3b9500f..7c158b5207b 100644 --- a/tests/ui/ok_expect.stderr +++ b/tests/ui/ok_expect.stderr @@ -4,7 +4,7 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly 14 | res.ok().expect("disaster!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D ok-expect` implied by `-D warnings` + = note: `-D clippy::ok-expect` implied by `-D warnings` error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` --> $DIR/ok_expect.rs:20:5 diff --git a/tests/ui/ok_if_let.stderr b/tests/ui/ok_if_let.stderr index e1371d924eb..eac49032ed8 100644 --- a/tests/ui/ok_if_let.stderr +++ b/tests/ui/ok_if_let.stderr @@ -8,7 +8,7 @@ error: Matching on `Some` with `ok()` is redundant 11 | | } | |_____^ | - = note: `-D if-let-some-result` implied by `-D warnings` + = note: `-D clippy::if-let-some-result` implied by `-D warnings` = help: Consider matching on `Ok(y)` and removing the call to `ok` instead error: aborting due to previous error diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index 4a6ff6fe6dc..398e3a6e9e6 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -4,7 +4,7 @@ error: needlessly taken reference of both operands 13 | let foo = &5 - &6; | ^^^^^^^ | - = note: `-D op-ref` implied by `-D warnings` + = note: `-D clippy::op-ref` implied by `-D warnings` help: use the values directly | 13 | let foo = 5 - 6; diff --git a/tests/ui/open_options.stderr b/tests/ui/open_options.stderr index f0d41904152..64ad667a4c7 100644 --- a/tests/ui/open_options.stderr +++ b/tests/ui/open_options.stderr @@ -4,7 +4,7 @@ error: file opened with "truncate" and "read" 8 | OpenOptions::new().read(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D nonsensical-open-options` implied by `-D warnings` + = note: `-D clippy::nonsensical-open-options` implied by `-D warnings` error: file opened with "append" and "truncate" --> $DIR/open_options.rs:9:5 diff --git a/tests/ui/option_map_unit_fn.stderr b/tests/ui/option_map_unit_fn.stderr index 3ca57a65b3f..77fe24d2696 100644 --- a/tests/ui/option_map_unit_fn.stderr +++ b/tests/ui/option_map_unit_fn.stderr @@ -1,13 +1,3 @@ -error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:32:5 - | -32 | x.field.map(do_nothing); - | ^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` - | - = note: `-D option-map-unit-fn` implied by `-D warnings` - error: called `map(f)` on an Option value where `f` is a unit function --> $DIR/option_map_unit_fn.rs:34:5 | @@ -15,193 +5,203 @@ error: called `map(f)` on an Option value where `f` is a unit function | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` + | + = note: `-D clippy::option-map-unit-fn` implied by `-D warnings` error: called `map(f)` on an Option value where `f` is a unit function --> $DIR/option_map_unit_fn.rs:36:5 | -36 | x.field.map(diverge); +36 | x.field.map(do_nothing); + | ^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` + +error: called `map(f)` on an Option value where `f` is a unit function + --> $DIR/option_map_unit_fn.rs:38:5 + | +38 | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:42:5 + --> $DIR/option_map_unit_fn.rs:44:5 | -42 | x.field.map(|value| x.do_option_nothing(value + captured)); +44 | x.field.map(|value| x.do_option_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:44:5 + --> $DIR/option_map_unit_fn.rs:46:5 | -44 | x.field.map(|value| { x.do_option_plus_one(value + captured); }); +46 | x.field.map(|value| { x.do_option_plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:47:5 - | -47 | x.field.map(|value| do_nothing(value + captured)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` - error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:49:5 | -49 | x.field.map(|value| { do_nothing(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +49 | x.field.map(|value| do_nothing(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:51:5 | -51 | x.field.map(|value| { do_nothing(value + captured); }); +51 | x.field.map(|value| { do_nothing(value + captured) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/option_map_unit_fn.rs:53:5 + | +53 | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:53:5 + --> $DIR/option_map_unit_fn.rs:55:5 | -53 | x.field.map(|value| { { do_nothing(value + captured); } }); +55 | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` -error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:56:5 - | -56 | x.field.map(|value| diverge(value + captured)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` - error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:58:5 | -58 | x.field.map(|value| { diverge(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +58 | x.field.map(|value| diverge(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:60:5 | -60 | x.field.map(|value| { diverge(value + captured); }); +60 | x.field.map(|value| { diverge(value + captured) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/option_map_unit_fn.rs:62:5 + | +62 | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:62:5 + --> $DIR/option_map_unit_fn.rs:64:5 | -62 | x.field.map(|value| { { diverge(value + captured); } }); +64 | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:67:5 + --> $DIR/option_map_unit_fn.rs:69:5 | -67 | x.field.map(|value| { let y = plus_one(value + captured); }); +69 | x.field.map(|value| { let y = plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:69:5 + --> $DIR/option_map_unit_fn.rs:71:5 | -69 | x.field.map(|value| { plus_one(value + captured); }); +71 | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:71:5 + --> $DIR/option_map_unit_fn.rs:73:5 | -71 | x.field.map(|value| { { plus_one(value + captured); } }); +73 | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:74:5 + --> $DIR/option_map_unit_fn.rs:76:5 | -74 | x.field.map(|ref value| { do_nothing(value + captured) }); +76 | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:77:5 + --> $DIR/option_map_unit_fn.rs:79:5 | -77 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); +79 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { ... }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:79:5 + --> $DIR/option_map_unit_fn.rs:81:5 | -79 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); +81 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { ... }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:83:5 + --> $DIR/option_map_unit_fn.rs:85:5 | -83 | x.field.map(|value| { +85 | x.field.map(|value| { | _____^ | |_____| | || -84 | || do_nothing(value); -85 | || do_nothing(value) -86 | || }); +86 | || do_nothing(value); +87 | || do_nothing(value) +88 | || }); | ||______^- help: try this: `if let Some(value) = x.field { ... }` | |_______| | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:87:5 + --> $DIR/option_map_unit_fn.rs:89:5 | -87 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); +89 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { ... }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:90:5 + --> $DIR/option_map_unit_fn.rs:92:5 | -90 | Some(42).map(diverge); +92 | Some(42).map(diverge); | ^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = Some(42) { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:91:5 + --> $DIR/option_map_unit_fn.rs:93:5 | -91 | "12".parse::().ok().map(diverge); +93 | "12".parse::().ok().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = "12".parse::().ok() { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:92:5 + --> $DIR/option_map_unit_fn.rs:94:5 | -92 | Some(plus_one(1)).map(do_nothing); +94 | Some(plus_one(1)).map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = Some(plus_one(1)) { do_nothing(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:96:5 + --> $DIR/option_map_unit_fn.rs:98:5 | -96 | y.map(do_nothing); +98 | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_y) = y { do_nothing(...) }` diff --git a/tests/ui/option_option.stderr b/tests/ui/option_option.stderr index 19e00efae71..4341857cce0 100644 --- a/tests/ui/option_option.stderr +++ b/tests/ui/option_option.stderr @@ -4,7 +4,7 @@ error: consider using `Option` instead of `Option>` or a custom enu 1 | fn input(_: Option>) { | ^^^^^^^^^^^^^^^^^^ | - = note: `-D option-option` implied by `-D warnings` + = note: `-D clippy::option-option` implied by `-D warnings` error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:4:16 diff --git a/tests/ui/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index adf353a1c4b..9659e352af1 100644 --- a/tests/ui/overflow_check_conditional.stderr +++ b/tests/ui/overflow_check_conditional.stderr @@ -4,7 +4,7 @@ error: You are trying to use classic C overflow conditions that will fail in Rus 11 | if a + b < a { | ^^^^^^^^^ | - = note: `-D overflow-check-conditional` implied by `-D warnings` + = note: `-D clippy::overflow-check-conditional` implied by `-D warnings` error: You are trying to use classic C overflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:14:5 diff --git a/tests/ui/panic_unimplemented.stderr b/tests/ui/panic_unimplemented.stderr index 3bf5589c468..c5ce42f4c54 100644 --- a/tests/ui/panic_unimplemented.stderr +++ b/tests/ui/panic_unimplemented.stderr @@ -4,7 +4,7 @@ error: you probably are missing some parameter in your format string 8 | panic!("{}"); | ^^^^ | - = note: `-D panic-params` implied by `-D warnings` + = note: `-D clippy::panic-params` implied by `-D warnings` error: you probably are missing some parameter in your format string --> $DIR/panic_unimplemented.rs:10:16 @@ -30,7 +30,7 @@ error: `unimplemented` should not be present in production code 58 | unimplemented!(); | ^^^^^^^^^^^^^^^^^ | - = note: `-D unimplemented` implied by `-D warnings` + = note: `-D clippy::unimplemented` implied by `-D warnings` error: aborting due to 5 previous errors diff --git a/tests/ui/partialeq_ne_impl.stderr b/tests/ui/partialeq_ne_impl.stderr index 5e536cc51d2..773bed8fd8e 100644 --- a/tests/ui/partialeq_ne_impl.stderr +++ b/tests/ui/partialeq_ne_impl.stderr @@ -4,7 +4,7 @@ error: re-implementing `PartialEq::ne` is unnecessary 10 | fn ne(&self, _: &Foo) -> bool { false } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D partialeq-ne-impl` implied by `-D warnings` + = note: `-D clippy::partialeq-ne-impl` implied by `-D warnings` error: aborting due to previous error diff --git a/tests/ui/patterns.stderr b/tests/ui/patterns.stderr index 59bce3a9a8f..ce8aab7e627 100644 --- a/tests/ui/patterns.stderr +++ b/tests/ui/patterns.stderr @@ -4,7 +4,7 @@ error: the `y @ _` pattern can be written as just `y` 10 | y @ _ => (), | ^^^^^ | - = note: `-D redundant-pattern` implied by `-D warnings` + = note: `-D clippy::redundant-pattern` implied by `-D warnings` error: aborting due to previous error diff --git a/tests/ui/precedence.stderr b/tests/ui/precedence.stderr index 92c1364746e..5ec1732ee56 100644 --- a/tests/ui/precedence.stderr +++ b/tests/ui/precedence.stderr @@ -4,7 +4,7 @@ error: operator precedence can trip the unwary 18 | 1 << 2 + 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` | - = note: `-D precedence` implied by `-D warnings` + = note: `-D clippy::precedence` implied by `-D warnings` error: operator precedence can trip the unwary --> $DIR/precedence.rs:19:5 diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index f2d2afd9bf7..92a2f2f9627 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -4,7 +4,7 @@ error: use of `Debug`-based formatting 13 | write!(f, "{:?}", 43.1415) | ^^^^^^ | - = note: `-D use-debug` implied by `-D warnings` + = note: `-D clippy::use-debug` implied by `-D warnings` error: use of `Debug`-based formatting --> $DIR/print.rs:20:19 @@ -18,7 +18,7 @@ error: use of `println!` 25 | println!("Hello"); | ^^^^^^^^^^^^^^^^^ | - = note: `-D print-stdout` implied by `-D warnings` + = note: `-D clippy::print-stdout` implied by `-D warnings` error: use of `print!` --> $DIR/print.rs:26:5 diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index cada26c6142..bd13f5d1730 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -4,7 +4,7 @@ error: literal with an empty format string 24 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ | - = note: `-D print-literal` implied by `-D warnings` + = note: `-D clippy::print-literal` implied by `-D warnings` error: literal with an empty format string --> $DIR/print_literal.rs:25:24 diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index 58413a9b4a9..12c4ecb2f3e 100644 --- a/tests/ui/print_with_newline.stderr +++ b/tests/ui/print_with_newline.stderr @@ -4,7 +4,7 @@ error: using `print!()` with a format string that ends in a single newline, cons 7 | print!("Hello/n"); | ^^^^^^^^^^^^^^^^^ | - = note: `-D print-with-newline` implied by `-D warnings` + = note: `-D clippy::print-with-newline` implied by `-D warnings` error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead --> $DIR/print_with_newline.rs:8:5 diff --git a/tests/ui/println_empty_string.stderr b/tests/ui/println_empty_string.stderr index cff3f988052..96d15838400 100644 --- a/tests/ui/println_empty_string.stderr +++ b/tests/ui/println_empty_string.stderr @@ -4,7 +4,7 @@ error: using `println!("")` 3 | println!(""); | ^^^^^^^^^^^^ help: replace it with: `println!()` | - = note: `-D println-empty-string` implied by `-D warnings` + = note: `-D clippy::println-empty-string` implied by `-D warnings` error: using `println!("")` --> $DIR/println_empty_string.rs:6:14 diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index a29e393baa1..6c16443f524 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -1,85 +1,85 @@ error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:6:14 + --> $DIR/ptr_arg.rs:8:14 | -6 | fn do_vec(x: &Vec) { +8 | fn do_vec(x: &Vec) { | ^^^^^^^^^ help: change this to: `&[i64]` | - = note: `-D ptr-arg` implied by `-D warnings` + = note: `-D clippy::ptr-arg` implied by `-D warnings` error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:14:14 + --> $DIR/ptr_arg.rs:16:14 | -14 | fn do_str(x: &String) { +16 | fn do_str(x: &String) { | ^^^^^^^ help: change this to: `&str` error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:27:18 + --> $DIR/ptr_arg.rs:29:18 | -27 | fn do_vec(x: &Vec); +29 | fn do_vec(x: &Vec); | ^^^^^^^^^ help: change this to: `&[i64]` error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:40:14 + --> $DIR/ptr_arg.rs:42:14 | -40 | fn cloned(x: &Vec) -> Vec { +42 | fn cloned(x: &Vec) -> Vec { | ^^^^^^^^ help: change this to | -40 | fn cloned(x: &[u8]) -> Vec { +42 | fn cloned(x: &[u8]) -> Vec { | ^^^^^ help: change `x.clone()` to | -41 | let e = x.to_owned(); +43 | let e = x.to_owned(); | ^^^^^^^^^^^^ help: change `x.clone()` to | -46 | x.to_owned() +48 | x.to_owned() | error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:49:18 + --> $DIR/ptr_arg.rs:51:18 | -49 | fn str_cloned(x: &String) -> String { +51 | fn str_cloned(x: &String) -> String { | ^^^^^^^ help: change this to | -49 | fn str_cloned(x: &str) -> String { +51 | fn str_cloned(x: &str) -> String { | ^^^^ help: change `x.clone()` to | -50 | let a = x.to_string(); +52 | let a = x.to_string(); | ^^^^^^^^^^^^^ help: change `x.clone()` to | -51 | let b = x.to_string(); +53 | let b = x.to_string(); | ^^^^^^^^^^^^^ help: change `x.clone()` to | -56 | x.to_string() +58 | x.to_string() | error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:59:44 + --> $DIR/ptr_arg.rs:61:44 | -59 | fn false_positive_capacity(x: &Vec, y: &String) { +61 | fn false_positive_capacity(x: &Vec, y: &String) { | ^^^^^^^ help: change this to | -59 | fn false_positive_capacity(x: &Vec, y: &str) { +61 | fn false_positive_capacity(x: &Vec, y: &str) { | ^^^^ help: change `y.clone()` to | -61 | let b = y.to_string(); +63 | let b = y.to_string(); | ^^^^^^^^^^^^^ help: change `y.as_str()` to | -62 | let c = y; +64 | let c = y; | ^ error: using a reference to `Cow` is not recommended. - --> $DIR/ptr_arg.rs:71:25 + --> $DIR/ptr_arg.rs:73:25 | -71 | fn test_cow_with_ref(c: &Cow<[i32]>) { +73 | fn test_cow_with_ref(c: &Cow<[i32]>) { | ^^^^^^^^^^^ help: change this to: `&[i32]` error: aborting due to 7 previous errors diff --git a/tests/ui/question_mark.stderr b/tests/ui/question_mark.stderr index e97b1869824..68c0e5e381a 100644 --- a/tests/ui/question_mark.stderr +++ b/tests/ui/question_mark.stderr @@ -7,7 +7,7 @@ error: this block may be rewritten with the `?` operator 4 | | } | |_____^ help: replace_it_with: `a?;` | - = note: `-D question-mark` implied by `-D warnings` + = note: `-D clippy::question-mark` implied by `-D warnings` error: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:37:3 diff --git a/tests/ui/range.stderr b/tests/ui/range.stderr index 064429c337c..651ff266c1a 100644 --- a/tests/ui/range.stderr +++ b/tests/ui/range.stderr @@ -4,7 +4,7 @@ error: Iterator::step_by(0) will panic at runtime 10 | let _ = (0..1).step_by(0); | ^^^^^^^^^^^^^^^^^ | - = note: `-D iterator-step-by-zero` implied by `-D warnings` + = note: `-D clippy::iterator-step-by-zero` implied by `-D warnings` error: Iterator::step_by(0) will panic at runtime --> $DIR/range.rs:14:13 @@ -30,7 +30,7 @@ error: It is more idiomatic to use v1.iter().enumerate() 26 | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D range-zip-with-len` implied by `-D warnings` + = note: `-D clippy::range-zip-with-len` implied by `-D warnings` error: Iterator::step_by(0) will panic at runtime --> $DIR/range.rs:30:13 diff --git a/tests/ui/range_plus_minus_one.stderr b/tests/ui/range_plus_minus_one.stderr index 1990300ef90..083c153addb 100644 --- a/tests/ui/range_plus_minus_one.stderr +++ b/tests/ui/range_plus_minus_one.stderr @@ -1,47 +1,47 @@ error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:10:14 + --> $DIR/range_plus_minus_one.rs:12:14 | -10 | for _ in 0..3+1 { } +12 | for _ in 0..3+1 { } | ^^^^^^ help: use: `0..=3` | - = note: `-D range-plus-one` implied by `-D warnings` + = note: `-D clippy::range-plus-one` implied by `-D warnings` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:13:14 + --> $DIR/range_plus_minus_one.rs:15:14 | -13 | for _ in 0..1+5 { } +15 | for _ in 0..1+5 { } | ^^^^^^ help: use: `0..=5` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:16:14 + --> $DIR/range_plus_minus_one.rs:18:14 | -16 | for _ in 1..1+1 { } +18 | for _ in 1..1+1 { } | ^^^^^^ help: use: `1..=1` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:22:14 + --> $DIR/range_plus_minus_one.rs:24:14 | -22 | for _ in 0..(1+f()) { } +24 | for _ in 0..(1+f()) { } | ^^^^^^^^^^ help: use: `0..=f()` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:26:13 + --> $DIR/range_plus_minus_one.rs:28:13 | -26 | let _ = ..=11-1; +28 | let _ = ..=11-1; | ^^^^^^^ help: use: `..11` | - = note: `-D range-minus-one` implied by `-D warnings` + = note: `-D clippy::range-minus-one` implied by `-D warnings` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:27:13 + --> $DIR/range_plus_minus_one.rs:29:13 | -27 | let _ = ..=(11-1); +29 | let _ = ..=(11-1); | ^^^^^^^^^ help: use: `..11` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:28:13 + --> $DIR/range_plus_minus_one.rs:30:13 | -28 | let _ = (f()+1)..(f()+1); +30 | let _ = (f()+1)..(f()+1); | ^^^^^^^^^^^^^^^^ help: use: `(f()+1)..=f()` error: aborting due to 7 previous errors diff --git a/tests/ui/redundant_closure_call.stderr b/tests/ui/redundant_closure_call.stderr index d2b5616a481..e4d490743ad 100644 --- a/tests/ui/redundant_closure_call.stderr +++ b/tests/ui/redundant_closure_call.stderr @@ -4,7 +4,7 @@ error: Closure called just once immediately after it was declared 15 | i = closure(); | ^^^^^^^^^^^^^ | - = note: `-D redundant-closure-call` implied by `-D warnings` + = note: `-D clippy::redundant-closure-call` implied by `-D warnings` error: Closure called just once immediately after it was declared --> $DIR/redundant_closure_call.rs:18:2 diff --git a/tests/ui/redundant_field_names.stderr b/tests/ui/redundant_field_names.stderr index 5821baf4c85..457fe7d3c6c 100644 --- a/tests/ui/redundant_field_names.stderr +++ b/tests/ui/redundant_field_names.stderr @@ -1,45 +1,45 @@ error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:34:9 + --> $DIR/redundant_field_names.rs:36:9 | -34 | gender: gender, +36 | gender: gender, | ^^^^^^^^^^^^^^ help: replace it with: `gender` | - = note: `-D redundant-field-names` implied by `-D warnings` + = note: `-D clippy::redundant-field-names` implied by `-D warnings` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:35:9 + --> $DIR/redundant_field_names.rs:37:9 | -35 | age: age, +37 | age: age, | ^^^^^^^^ help: replace it with: `age` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:56:25 + --> $DIR/redundant_field_names.rs:58:25 | -56 | let _ = RangeFrom { start: start }; +58 | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:57:23 + --> $DIR/redundant_field_names.rs:59:23 | -57 | let _ = RangeTo { end: end }; +59 | let _ = RangeTo { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:58:21 + --> $DIR/redundant_field_names.rs:60:21 | -58 | let _ = Range { start: start, end: end }; +60 | let _ = Range { start: start, end: end }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:58:35 + --> $DIR/redundant_field_names.rs:60:35 | -58 | let _ = Range { start: start, end: end }; +60 | let _ = Range { start: start, end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:60:32 + --> $DIR/redundant_field_names.rs:62:32 | -60 | let _ = RangeToInclusive { end: end }; +62 | let _ = RangeToInclusive { end: end }; | ^^^^^^^^ help: replace it with: `end` error: aborting due to 7 previous errors diff --git a/tests/ui/reference.stderr b/tests/ui/reference.stderr index 741c0cc1038..13e0da98795 100644 --- a/tests/ui/reference.stderr +++ b/tests/ui/reference.stderr @@ -4,7 +4,7 @@ error: immediately dereferencing a reference 19 | let b = *&a; | ^^^ help: try this: `a` | - = note: `-D deref-addrof` implied by `-D warnings` + = note: `-D clippy::deref-addrof` implied by `-D warnings` error: immediately dereferencing a reference --> $DIR/reference.rs:21:13 diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index 39c360583e7..fd8fecb1139 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -4,7 +4,7 @@ error: trivial regex 16 | let pipe_in_wrong_position = Regex::new("|"); | ^^^ | - = note: `-D trivial-regex` implied by `-D warnings` + = note: `-D clippy::trivial-regex` implied by `-D warnings` = help: the regex is unlikely to be useful as it is error: trivial regex @@ -21,7 +21,7 @@ error: regex syntax error: invalid character class range, the start must be <= t 18 | let wrong_char_ranice = Regex::new("[z-a]"); | ^^^ | - = note: `-D invalid-regex` implied by `-D warnings` + = note: `-D clippy::invalid-regex` implied by `-D warnings` error: regex syntax error: invalid character class range, the start must be <= the end --> $DIR/regex.rs:19:37 diff --git a/tests/ui/replace_consts.stderr b/tests/ui/replace_consts.stderr index 0a9d5f4ab75..fb9c9414c85 100644 --- a/tests/ui/replace_consts.stderr +++ b/tests/ui/replace_consts.stderr @@ -1,217 +1,217 @@ error: using `ATOMIC_BOOL_INIT` - --> $DIR/replace_consts.rs:12:17 + --> $DIR/replace_consts.rs:14:17 | -12 | { let foo = ATOMIC_BOOL_INIT; }; +14 | { let foo = ATOMIC_BOOL_INIT; }; | ^^^^^^^^^^^^^^^^ help: try this: `AtomicBool::new(false)` | note: lint level defined here - --> $DIR/replace_consts.rs:3:9 + --> $DIR/replace_consts.rs:5:9 | -3 | #![deny(replace_consts)] - | ^^^^^^^^^^^^^^ +5 | #![deny(clippy::replace_consts)] + | ^^^^^^^^^^^^^^^^^^^^^^ error: using `ATOMIC_ISIZE_INIT` - --> $DIR/replace_consts.rs:13:17 + --> $DIR/replace_consts.rs:15:17 | -13 | { let foo = ATOMIC_ISIZE_INIT; }; +15 | { let foo = ATOMIC_ISIZE_INIT; }; | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicIsize::new(0)` error: using `ATOMIC_I8_INIT` - --> $DIR/replace_consts.rs:14:17 + --> $DIR/replace_consts.rs:16:17 | -14 | { let foo = ATOMIC_I8_INIT; }; +16 | { let foo = ATOMIC_I8_INIT; }; | ^^^^^^^^^^^^^^ help: try this: `AtomicI8::new(0)` error: using `ATOMIC_I16_INIT` - --> $DIR/replace_consts.rs:15:17 + --> $DIR/replace_consts.rs:17:17 | -15 | { let foo = ATOMIC_I16_INIT; }; +17 | { let foo = ATOMIC_I16_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI16::new(0)` error: using `ATOMIC_I32_INIT` - --> $DIR/replace_consts.rs:16:17 + --> $DIR/replace_consts.rs:18:17 | -16 | { let foo = ATOMIC_I32_INIT; }; +18 | { let foo = ATOMIC_I32_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI32::new(0)` error: using `ATOMIC_I64_INIT` - --> $DIR/replace_consts.rs:17:17 + --> $DIR/replace_consts.rs:19:17 | -17 | { let foo = ATOMIC_I64_INIT; }; +19 | { let foo = ATOMIC_I64_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI64::new(0)` error: using `ATOMIC_USIZE_INIT` - --> $DIR/replace_consts.rs:18:17 + --> $DIR/replace_consts.rs:20:17 | -18 | { let foo = ATOMIC_USIZE_INIT; }; +20 | { let foo = ATOMIC_USIZE_INIT; }; | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicUsize::new(0)` error: using `ATOMIC_U8_INIT` - --> $DIR/replace_consts.rs:19:17 + --> $DIR/replace_consts.rs:21:17 | -19 | { let foo = ATOMIC_U8_INIT; }; +21 | { let foo = ATOMIC_U8_INIT; }; | ^^^^^^^^^^^^^^ help: try this: `AtomicU8::new(0)` error: using `ATOMIC_U16_INIT` - --> $DIR/replace_consts.rs:20:17 + --> $DIR/replace_consts.rs:22:17 | -20 | { let foo = ATOMIC_U16_INIT; }; +22 | { let foo = ATOMIC_U16_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU16::new(0)` error: using `ATOMIC_U32_INIT` - --> $DIR/replace_consts.rs:21:17 + --> $DIR/replace_consts.rs:23:17 | -21 | { let foo = ATOMIC_U32_INIT; }; +23 | { let foo = ATOMIC_U32_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU32::new(0)` error: using `ATOMIC_U64_INIT` - --> $DIR/replace_consts.rs:22:17 - | -22 | { let foo = ATOMIC_U64_INIT; }; - | ^^^^^^^^^^^^^^^ help: try this: `AtomicU64::new(0)` - -error: using `MIN` --> $DIR/replace_consts.rs:24:17 | -24 | { let foo = std::isize::MIN; }; - | ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()` - -error: using `MIN` - --> $DIR/replace_consts.rs:25:17 - | -25 | { let foo = std::i8::MIN; }; - | ^^^^^^^^^^^^ help: try this: `i8::min_value()` +24 | { let foo = ATOMIC_U64_INIT; }; + | ^^^^^^^^^^^^^^^ help: try this: `AtomicU64::new(0)` error: using `MIN` --> $DIR/replace_consts.rs:26:17 | -26 | { let foo = std::i16::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `i16::min_value()` +26 | { let foo = std::isize::MIN; }; + | ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:27:17 | -27 | { let foo = std::i32::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `i32::min_value()` +27 | { let foo = std::i8::MIN; }; + | ^^^^^^^^^^^^ help: try this: `i8::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:28:17 | -28 | { let foo = std::i64::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `i64::min_value()` +28 | { let foo = std::i16::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `i16::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:29:17 | -29 | { let foo = std::i128::MIN; }; - | ^^^^^^^^^^^^^^ help: try this: `i128::min_value()` +29 | { let foo = std::i32::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `i32::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:30:17 | -30 | { let foo = std::usize::MIN; }; - | ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()` +30 | { let foo = std::i64::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `i64::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:31:17 | -31 | { let foo = std::u8::MIN; }; - | ^^^^^^^^^^^^ help: try this: `u8::min_value()` +31 | { let foo = std::i128::MIN; }; + | ^^^^^^^^^^^^^^ help: try this: `i128::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:32:17 | -32 | { let foo = std::u16::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `u16::min_value()` +32 | { let foo = std::usize::MIN; }; + | ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:33:17 | -33 | { let foo = std::u32::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `u32::min_value()` +33 | { let foo = std::u8::MIN; }; + | ^^^^^^^^^^^^ help: try this: `u8::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:34:17 | -34 | { let foo = std::u64::MIN; }; - | ^^^^^^^^^^^^^ help: try this: `u64::min_value()` +34 | { let foo = std::u16::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `u16::min_value()` error: using `MIN` --> $DIR/replace_consts.rs:35:17 | -35 | { let foo = std::u128::MIN; }; - | ^^^^^^^^^^^^^^ help: try this: `u128::min_value()` +35 | { let foo = std::u32::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `u32::min_value()` -error: using `MAX` +error: using `MIN` + --> $DIR/replace_consts.rs:36:17 + | +36 | { let foo = std::u64::MIN; }; + | ^^^^^^^^^^^^^ help: try this: `u64::min_value()` + +error: using `MIN` --> $DIR/replace_consts.rs:37:17 | -37 | { let foo = std::isize::MAX; }; - | ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()` - -error: using `MAX` - --> $DIR/replace_consts.rs:38:17 - | -38 | { let foo = std::i8::MAX; }; - | ^^^^^^^^^^^^ help: try this: `i8::max_value()` +37 | { let foo = std::u128::MIN; }; + | ^^^^^^^^^^^^^^ help: try this: `u128::min_value()` error: using `MAX` --> $DIR/replace_consts.rs:39:17 | -39 | { let foo = std::i16::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `i16::max_value()` +39 | { let foo = std::isize::MAX; }; + | ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:40:17 | -40 | { let foo = std::i32::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `i32::max_value()` +40 | { let foo = std::i8::MAX; }; + | ^^^^^^^^^^^^ help: try this: `i8::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:41:17 | -41 | { let foo = std::i64::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `i64::max_value()` +41 | { let foo = std::i16::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `i16::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:42:17 | -42 | { let foo = std::i128::MAX; }; - | ^^^^^^^^^^^^^^ help: try this: `i128::max_value()` +42 | { let foo = std::i32::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `i32::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:43:17 | -43 | { let foo = std::usize::MAX; }; - | ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()` +43 | { let foo = std::i64::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `i64::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:44:17 | -44 | { let foo = std::u8::MAX; }; - | ^^^^^^^^^^^^ help: try this: `u8::max_value()` +44 | { let foo = std::i128::MAX; }; + | ^^^^^^^^^^^^^^ help: try this: `i128::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:45:17 | -45 | { let foo = std::u16::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `u16::max_value()` +45 | { let foo = std::usize::MAX; }; + | ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:46:17 | -46 | { let foo = std::u32::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `u32::max_value()` +46 | { let foo = std::u8::MAX; }; + | ^^^^^^^^^^^^ help: try this: `u8::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:47:17 | -47 | { let foo = std::u64::MAX; }; - | ^^^^^^^^^^^^^ help: try this: `u64::max_value()` +47 | { let foo = std::u16::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `u16::max_value()` error: using `MAX` --> $DIR/replace_consts.rs:48:17 | -48 | { let foo = std::u128::MAX; }; +48 | { let foo = std::u32::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `u32::max_value()` + +error: using `MAX` + --> $DIR/replace_consts.rs:49:17 + | +49 | { let foo = std::u64::MAX; }; + | ^^^^^^^^^^^^^ help: try this: `u64::max_value()` + +error: using `MAX` + --> $DIR/replace_consts.rs:50:17 + | +50 | { let foo = std::u128::MAX; }; | ^^^^^^^^^^^^^^ help: try this: `u128::max_value()` error: aborting due to 35 previous errors diff --git a/tests/ui/result_map_unit_fn.stderr b/tests/ui/result_map_unit_fn.stderr index 9ec24a7e97b..5fba1a0d7ad 100644 --- a/tests/ui/result_map_unit_fn.stderr +++ b/tests/ui/result_map_unit_fn.stderr @@ -1,13 +1,3 @@ -error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:33:5 - | -33 | x.field.map(do_nothing); - | ^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` - | - = note: `-D result-map-unit-fn` implied by `-D warnings` - error: called `map(f)` on an Result value where `f` is a unit function --> $DIR/result_map_unit_fn.rs:35:5 | @@ -15,180 +5,190 @@ error: called `map(f)` on an Result value where `f` is a unit function | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` + | + = note: `-D clippy::result-map-unit-fn` implied by `-D warnings` error: called `map(f)` on an Result value where `f` is a unit function --> $DIR/result_map_unit_fn.rs:37:5 | -37 | x.field.map(diverge); +37 | x.field.map(do_nothing); + | ^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` + +error: called `map(f)` on an Result value where `f` is a unit function + --> $DIR/result_map_unit_fn.rs:39:5 + | +39 | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:43:5 + --> $DIR/result_map_unit_fn.rs:45:5 | -43 | x.field.map(|value| x.do_result_nothing(value + captured)); +45 | x.field.map(|value| x.do_result_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:45:5 + --> $DIR/result_map_unit_fn.rs:47:5 | -45 | x.field.map(|value| { x.do_result_plus_one(value + captured); }); +47 | x.field.map(|value| { x.do_result_plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:48:5 - | -48 | x.field.map(|value| do_nothing(value + captured)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` - error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:50:5 | -50 | x.field.map(|value| { do_nothing(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +50 | x.field.map(|value| do_nothing(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:52:5 | -52 | x.field.map(|value| { do_nothing(value + captured); }); +52 | x.field.map(|value| { do_nothing(value + captured) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:54:5 + | +54 | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:54:5 + --> $DIR/result_map_unit_fn.rs:56:5 | -54 | x.field.map(|value| { { do_nothing(value + captured); } }); +56 | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:57:5 - | -57 | x.field.map(|value| diverge(value + captured)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` - error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:59:5 | -59 | x.field.map(|value| { diverge(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +59 | x.field.map(|value| diverge(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:61:5 | -61 | x.field.map(|value| { diverge(value + captured); }); +61 | x.field.map(|value| { diverge(value + captured) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:63:5 + | +63 | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:63:5 + --> $DIR/result_map_unit_fn.rs:65:5 | -63 | x.field.map(|value| { { diverge(value + captured); } }); +65 | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:68:5 + --> $DIR/result_map_unit_fn.rs:70:5 | -68 | x.field.map(|value| { let y = plus_one(value + captured); }); +70 | x.field.map(|value| { let y = plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:70:5 + --> $DIR/result_map_unit_fn.rs:72:5 | -70 | x.field.map(|value| { plus_one(value + captured); }); +72 | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:72:5 + --> $DIR/result_map_unit_fn.rs:74:5 | -72 | x.field.map(|value| { { plus_one(value + captured); } }); +74 | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:75:5 + --> $DIR/result_map_unit_fn.rs:77:5 | -75 | x.field.map(|ref value| { do_nothing(value + captured) }); +77 | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:78:5 + --> $DIR/result_map_unit_fn.rs:80:5 | -78 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); +80 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:80:5 + --> $DIR/result_map_unit_fn.rs:82:5 | -80 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); +82 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:84:5 + --> $DIR/result_map_unit_fn.rs:86:5 | -84 | x.field.map(|value| { +86 | x.field.map(|value| { | _____^ | |_____| | || -85 | || do_nothing(value); -86 | || do_nothing(value) -87 | || }); +87 | || do_nothing(value); +88 | || do_nothing(value) +89 | || }); | ||______^- help: try this: `if let Ok(value) = x.field { ... }` | |_______| | error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:88:5 + --> $DIR/result_map_unit_fn.rs:90:5 | -88 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); +90 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:92:5 + --> $DIR/result_map_unit_fn.rs:94:5 | -92 | "12".parse::().map(diverge); +94 | "12".parse::().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(_) = "12".parse::() { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:98:5 - | -98 | y.map(do_nothing); - | ^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(_y) = y { do_nothing(...) }` + --> $DIR/result_map_unit_fn.rs:100:5 + | +100 | y.map(do_nothing); + | ^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(_y) = y { do_nothing(...) }` error: aborting due to 23 previous errors diff --git a/tests/ui/serde.stderr b/tests/ui/serde.stderr index 58667e0f820..cce839a0d94 100644 --- a/tests/ui/serde.stderr +++ b/tests/ui/serde.stderr @@ -8,7 +8,7 @@ error: you should not implement `visit_string` without also implementing `visit_ 43 | | } | |_____^ | - = note: `-D serde-api-misuse` implied by `-D warnings` + = note: `-D clippy::serde-api-misuse` implied by `-D warnings` error: aborting due to previous error diff --git a/tests/ui/shadow.stderr b/tests/ui/shadow.stderr index 0eb5e5b2a2b..311177e25b4 100644 --- a/tests/ui/shadow.stderr +++ b/tests/ui/shadow.stderr @@ -4,7 +4,7 @@ error: `x` is shadowed by itself in `&mut x` 13 | let x = &mut x; | ^^^^^^^^^^^^^^^ | - = note: `-D shadow-same` implied by `-D warnings` + = note: `-D clippy::shadow-same` implied by `-D warnings` note: previous binding is here --> $DIR/shadow.rs:12:13 | @@ -41,7 +41,7 @@ error: `x` is shadowed by `{ *x + 1 }` which reuses the original value 16 | let x = { *x + 1 }; | ^ | - = note: `-D shadow-reuse` implied by `-D warnings` + = note: `-D clippy::shadow-reuse` implied by `-D warnings` note: initialization happens here --> $DIR/shadow.rs:16:13 | @@ -110,7 +110,7 @@ error: `x` is shadowed by `y` 21 | let x = y; | ^ | - = note: `-D shadow-unrelated` implied by `-D warnings` + = note: `-D clippy::shadow-unrelated` implied by `-D warnings` note: initialization happens here --> $DIR/shadow.rs:21:13 | diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index 7697cbd1c64..bef497c33a0 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -4,7 +4,7 @@ error: boolean short circuit operator in statement may be clearer using an expli 7 | f() && g(); | ^^^^^^^^^^^ help: replace it with: `if f() { g(); }` | - = note: `-D short-circuit-statement` implied by `-D warnings` + = note: `-D clippy::short-circuit-statement` implied by `-D warnings` error: boolean short circuit operator in statement may be clearer using an explicit test --> $DIR/short_circuit_statement.rs:8:5 diff --git a/tests/ui/single_char_pattern.stderr b/tests/ui/single_char_pattern.stderr index 044b4909a37..78355612717 100644 --- a/tests/ui/single_char_pattern.stderr +++ b/tests/ui/single_char_pattern.stderr @@ -1,123 +1,123 @@ error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:5:13 + --> $DIR/single_char_pattern.rs:7:13 | -5 | x.split("x"); +7 | x.split("x"); | ^^^ help: try using a char instead: `'x'` | - = note: `-D single-char-pattern` implied by `-D warnings` + = note: `-D clippy::single-char-pattern` implied by `-D warnings` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:22:16 + --> $DIR/single_char_pattern.rs:24:16 | -22 | x.contains("x"); +24 | x.contains("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:23:19 + --> $DIR/single_char_pattern.rs:25:19 | -23 | x.starts_with("x"); +25 | x.starts_with("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:24:17 + --> $DIR/single_char_pattern.rs:26:17 | -24 | x.ends_with("x"); +26 | x.ends_with("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:25:12 + --> $DIR/single_char_pattern.rs:27:12 | -25 | x.find("x"); +27 | x.find("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:26:13 + --> $DIR/single_char_pattern.rs:28:13 | -26 | x.rfind("x"); +28 | x.rfind("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:27:14 + --> $DIR/single_char_pattern.rs:29:14 | -27 | x.rsplit("x"); +29 | x.rsplit("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:28:24 + --> $DIR/single_char_pattern.rs:30:24 | -28 | x.split_terminator("x"); +30 | x.split_terminator("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:29:25 + --> $DIR/single_char_pattern.rs:31:25 | -29 | x.rsplit_terminator("x"); +31 | x.rsplit_terminator("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:30:17 + --> $DIR/single_char_pattern.rs:32:17 | -30 | x.splitn(0, "x"); +32 | x.splitn(0, "x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:31:18 + --> $DIR/single_char_pattern.rs:33:18 | -31 | x.rsplitn(0, "x"); +33 | x.rsplitn(0, "x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:32:15 + --> $DIR/single_char_pattern.rs:34:15 | -32 | x.matches("x"); +34 | x.matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:33:16 + --> $DIR/single_char_pattern.rs:35:16 | -33 | x.rmatches("x"); +35 | x.rmatches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:34:21 + --> $DIR/single_char_pattern.rs:36:21 | -34 | x.match_indices("x"); +36 | x.match_indices("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:35:22 + --> $DIR/single_char_pattern.rs:37:22 | -35 | x.rmatch_indices("x"); +37 | x.rmatch_indices("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:36:25 + --> $DIR/single_char_pattern.rs:38:25 | -36 | x.trim_left_matches("x"); +38 | x.trim_left_matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:37:26 + --> $DIR/single_char_pattern.rs:39:26 | -37 | x.trim_right_matches("x"); +39 | x.trim_right_matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:39:13 + --> $DIR/single_char_pattern.rs:41:13 | -39 | x.split("/n"); +41 | x.split("/n"); | ^^^^ help: try using a char instead: `'/n'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:44:31 + --> $DIR/single_char_pattern.rs:46:31 | -44 | x.replace(";", ",").split(","); // issue #2978 +46 | x.replace(";", ",").split(","); // issue #2978 | ^^^ help: try using a char instead: `','` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:45:19 + --> $DIR/single_char_pattern.rs:47:19 | -45 | x.starts_with("/x03"); // issue #2996 +47 | x.starts_with("/x03"); // issue #2996 | ^^^^^^ help: try using a char instead: `'/x03'` error: aborting due to 20 previous errors diff --git a/tests/ui/single_match.stderr b/tests/ui/single_match.stderr index d77211bc126..20d8fed25fd 100644 --- a/tests/ui/single_match.stderr +++ b/tests/ui/single_match.stderr @@ -1,48 +1,48 @@ error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:9:5 + --> $DIR/single_match.rs:11:5 | -9 | / match x { -10 | | Some(y) => { println!("{:?}", y); } -11 | | _ => () -12 | | }; +11 | / match x { +12 | | Some(y) => { println!("{:?}", y); } +13 | | _ => () +14 | | }; | |_____^ help: try this: `if let Some(y) = x { println!("{:?}", y); }` | - = note: `-D single-match` implied by `-D warnings` + = note: `-D clippy::single-match` implied by `-D warnings` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:15:5 + --> $DIR/single_match.rs:17:5 | -15 | / match z { -16 | | (2...3, 7...9) => dummy(), -17 | | _ => {} -18 | | }; +17 | / match z { +18 | | (2...3, 7...9) => dummy(), +19 | | _ => {} +20 | | }; | |_____^ help: try this: `if let (2...3, 7...9) = z { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:41:5 + --> $DIR/single_match.rs:43:5 | -41 | / match x { -42 | | Some(y) => dummy(), -43 | | None => () -44 | | }; +43 | / match x { +44 | | Some(y) => dummy(), +45 | | None => () +46 | | }; | |_____^ help: try this: `if let Some(y) = x { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:46:5 + --> $DIR/single_match.rs:48:5 | -46 | / match y { -47 | | Ok(y) => dummy(), -48 | | Err(..) => () -49 | | }; +48 | / match y { +49 | | Ok(y) => dummy(), +50 | | Err(..) => () +51 | | }; | |_____^ help: try this: `if let Ok(y) = y { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:53:5 + --> $DIR/single_match.rs:55:5 | -53 | / match c { -54 | | Cow::Borrowed(..) => dummy(), -55 | | Cow::Owned(..) => (), -56 | | }; +55 | / match c { +56 | | Cow::Borrowed(..) => dummy(), +57 | | Cow::Owned(..) => (), +58 | | }; | |_____^ help: try this: `if let Cow::Borrowed(..) = c { dummy() }` error: aborting due to 5 previous errors diff --git a/tests/ui/starts_ends_with.stderr b/tests/ui/starts_ends_with.stderr index 7d73f201b69..b3fb444b562 100644 --- a/tests/ui/starts_ends_with.stderr +++ b/tests/ui/starts_ends_with.stderr @@ -1,77 +1,77 @@ error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:7:5 + --> $DIR/starts_ends_with.rs:9:5 | -7 | "".chars().next() == Some(' '); +9 | "".chars().next() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with(' ')` | - = note: `-D chars-next-cmp` implied by `-D warnings` + = note: `-D clippy::chars-next-cmp` implied by `-D warnings` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:8:5 - | -8 | Some(' ') != "".chars().next(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with(' ')` - -error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:13:8 + --> $DIR/starts_ends_with.rs:10:5 | -13 | if s.chars().next().unwrap() == 'f' { // s.starts_with('f') +10 | Some(' ') != "".chars().next(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with(' ')` + +error: you should use the `starts_with` method + --> $DIR/starts_ends_with.rs:15:8 + | +15 | if s.chars().next().unwrap() == 'f' { // s.starts_with('f') | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:16:8 + --> $DIR/starts_ends_with.rs:18:8 | -16 | if s.chars().next_back().unwrap() == 'o' { // s.ends_with('o') +18 | if s.chars().next_back().unwrap() == 'o' { // s.ends_with('o') | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` | - = note: `-D chars-last-cmp` implied by `-D warnings` + = note: `-D clippy::chars-last-cmp` implied by `-D warnings` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:19:8 + --> $DIR/starts_ends_with.rs:21:8 | -19 | if s.chars().last().unwrap() == 'o' { // s.ends_with('o') +21 | if s.chars().last().unwrap() == 'o' { // s.ends_with('o') | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:22:8 + --> $DIR/starts_ends_with.rs:24:8 | -22 | if s.chars().next().unwrap() != 'f' { // !s.starts_with('f') +24 | if s.chars().next().unwrap() != 'f' { // !s.starts_with('f') | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:25:8 + --> $DIR/starts_ends_with.rs:27:8 | -25 | if s.chars().next_back().unwrap() != 'o' { // !s.ends_with('o') +27 | if s.chars().next_back().unwrap() != 'o' { // !s.ends_with('o') | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:28:8 + --> $DIR/starts_ends_with.rs:30:8 | -28 | if s.chars().last().unwrap() != 'o' { // !s.ends_with('o') +30 | if s.chars().last().unwrap() != 'o' { // !s.ends_with('o') | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` -error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:35:5 - | -35 | "".chars().last() == Some(' '); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` - -error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:36:5 - | -36 | Some(' ') != "".chars().last(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` - error: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:37:5 | -37 | "".chars().next_back() == Some(' '); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` +37 | "".chars().last() == Some(' '); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` error: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:38:5 | -38 | Some(' ') != "".chars().next_back(); +38 | Some(' ') != "".chars().last(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` + +error: you should use the `ends_with` method + --> $DIR/starts_ends_with.rs:39:5 + | +39 | "".chars().next_back() == Some(' '); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` + +error: you should use the `ends_with` method + --> $DIR/starts_ends_with.rs:40:5 + | +40 | Some(' ') != "".chars().next_back(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: aborting due to 12 previous errors diff --git a/tests/ui/string_extend.stderr b/tests/ui/string_extend.stderr index 4be2037ad31..32e3482699c 100644 --- a/tests/ui/string_extend.stderr +++ b/tests/ui/string_extend.stderr @@ -4,7 +4,7 @@ error: calling `.extend(_.chars())` 16 | s.extend(abc.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(abc)` | - = note: `-D string-extend-chars` implied by `-D warnings` + = note: `-D clippy::string-extend-chars` implied by `-D warnings` error: calling `.extend(_.chars())` --> $DIR/string_extend.rs:19:5 diff --git a/tests/ui/strings.stderr b/tests/ui/strings.stderr index d098ce9df5e..258920e2652 100644 --- a/tests/ui/strings.stderr +++ b/tests/ui/strings.stderr @@ -4,7 +4,7 @@ error: manual implementation of an assign operation 10 | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` | - = note: `-D assign-op-pattern` implied by `-D warnings` + = note: `-D clippy::assign-op-pattern` implied by `-D warnings` error: you added something to a string. Consider using `String::push_str()` instead --> $DIR/strings.rs:10:13 @@ -12,7 +12,7 @@ error: you added something to a string. Consider using `String::push_str()` inst 10 | x = x + "."; | ^^^^^^^ | - = note: `-D string-add` implied by `-D warnings` + = note: `-D clippy::string-add` implied by `-D warnings` error: you added something to a string. Consider using `String::push_str()` instead --> $DIR/strings.rs:14:13 @@ -26,7 +26,7 @@ error: you assigned the result of adding something to this string. Consider usin 24 | x = x + "."; | ^^^^^^^^^^^ | - = note: `-D string-add-assign` implied by `-D warnings` + = note: `-D clippy::string-add-assign` implied by `-D warnings` error: manual implementation of an assign operation --> $DIR/strings.rs:24:9 @@ -58,7 +58,7 @@ error: calling `as_bytes()` on a string literal 50 | let bs = "hello there".as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"hello there"` | - = note: `-D string-lit-as-bytes` implied by `-D warnings` + = note: `-D clippy::string-lit-as-bytes` implied by `-D warnings` error: calling `as_bytes()` on a string literal --> $DIR/strings.rs:55:18 diff --git a/tests/ui/stutter.stderr b/tests/ui/stutter.stderr index 25e857991b8..3cc0be39567 100644 --- a/tests/ui/stutter.stderr +++ b/tests/ui/stutter.stderr @@ -4,7 +4,7 @@ error: item name starts with its containing module's name 8 | pub fn foo_bar() {} | ^^^^^^^^^^^^^^^^^^^ | - = note: `-D stutter` implied by `-D warnings` + = note: `-D clippy::stutter` implied by `-D warnings` error: item name ends with its containing module's name --> $DIR/stutter.rs:9:5 diff --git a/tests/ui/suspicious_arithmetic_impl.stderr b/tests/ui/suspicious_arithmetic_impl.stderr index 8130b1cb31a..0f396c3a560 100644 --- a/tests/ui/suspicious_arithmetic_impl.stderr +++ b/tests/ui/suspicious_arithmetic_impl.stderr @@ -4,7 +4,7 @@ error: Suspicious use of binary operator in `Add` impl 14 | Foo(self.0 - other.0) | ^ | - = note: `-D suspicious-arithmetic-impl` implied by `-D warnings` + = note: `-D clippy::suspicious-arithmetic-impl` implied by `-D warnings` error: Suspicious use of binary operator in `AddAssign` impl --> $DIR/suspicious_arithmetic_impl.rs:20:23 @@ -12,7 +12,7 @@ error: Suspicious use of binary operator in `AddAssign` impl 20 | *self = *self - other; | ^ | - = note: #[deny(suspicious_op_assign_impl)] on by default + = note: #[deny(clippy::suspicious_op_assign_impl)] on by default error: aborting due to 2 previous errors diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index a01ec375e63..67d4fd8a14b 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -6,7 +6,7 @@ error: this looks like you are swapping elements of `foo` manually 13 | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` | - = note: `-D manual-swap` implied by `-D warnings` + = note: `-D clippy::manual-swap` implied by `-D warnings` error: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:20:5 @@ -53,7 +53,7 @@ error: this looks like you are trying to swap `a` and `b` 45 | | b = a; | |_________^ help: try: `std::mem::swap(&mut a, &mut b)` | - = note: `-D almost-swapped` implied by `-D warnings` + = note: `-D clippy::almost-swapped` implied by `-D warnings` = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `c.0` and `a` diff --git a/tests/ui/temporary_assignment.stderr b/tests/ui/temporary_assignment.stderr index 979720c914d..38379d8bd20 100644 --- a/tests/ui/temporary_assignment.stderr +++ b/tests/ui/temporary_assignment.stderr @@ -4,7 +4,7 @@ error: assignment to temporary 29 | Struct { field: 0 }.field = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D temporary-assignment` implied by `-D warnings` + = note: `-D clippy::temporary-assignment` implied by `-D warnings` error: assignment to temporary --> $DIR/temporary_assignment.rs:30:5 diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index f360e85329f..f3fe563f294 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -4,7 +4,7 @@ error: `ref` directly on a function argument is ignored. Consider using a refere 7 | fn the_answer(ref mut x: u8) { | ^^^^^^^^^ | - = note: `-D toplevel-ref-arg` implied by `-D warnings` + = note: `-D clippy::toplevel-ref-arg` implied by `-D warnings` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:18:7 diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr index 47b46be9ba8..477f42c28f4 100644 --- a/tests/ui/trailing_zeros.stderr +++ b/tests/ui/trailing_zeros.stderr @@ -4,7 +4,7 @@ error: bit mask could be simplified with a call to `trailing_zeros` 7 | let _ = #[clippy::author] (x & 0b1111 == 0); // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` | - = note: `-D verbose-bit-mask` implied by `-D warnings` + = note: `-D clippy::verbose-bit-mask` implied by `-D warnings` error: bit mask could be simplified with a call to `trailing_zeros` --> $DIR/trailing_zeros.rs:8:13 diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index abed5065c0a..4340c16b97c 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -4,7 +4,7 @@ error: transmute from a type (`&'a T`) to itself 22 | let _: &'a T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D useless-transmute` implied by `-D warnings` + = note: `-D clippy::useless-transmute` implied by `-D warnings` error: transmute from a reference to a pointer --> $DIR/transmute.rs:26:23 @@ -30,7 +30,7 @@ error: transmute from a pointer type (`*const T`) to a reference type (`&T`) 35 | let _: &T = std::mem::transmute(p); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p` | - = note: `-D transmute-ptr-to-ref` implied by `-D warnings` + = note: `-D clippy::transmute-ptr-to-ref` implied by `-D warnings` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) --> $DIR/transmute.rs:38:21 @@ -134,7 +134,7 @@ error: transmute from a type (`*const Usize`) to the type that it points to (`Us 111 | let _: Usize = core::intrinsics::transmute(int_const_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D crosspointer-transmute` implied by `-D warnings` + = note: `-D clippy::crosspointer-transmute` implied by `-D warnings` error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) --> $DIR/transmute.rs:113:24 @@ -160,7 +160,7 @@ error: transmute from a `u32` to a `char` 123 | let _: char = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_u32).unwrap()` | - = note: `-D transmute-int-to-char` implied by `-D warnings` + = note: `-D clippy::transmute-int-to-char` implied by `-D warnings` error: transmute from a `i32` to a `char` --> $DIR/transmute.rs:124:28 @@ -174,7 +174,7 @@ error: transmute from a `u8` to a `bool` 129 | let _: bool = unsafe { std::mem::transmute(0_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0` | - = note: `-D transmute-int-to-bool` implied by `-D warnings` + = note: `-D clippy::transmute-int-to-bool` implied by `-D warnings` error: transmute from a `u32` to a `f32` --> $DIR/transmute.rs:134:27 @@ -182,7 +182,7 @@ error: transmute from a `u32` to a `f32` 134 | let _: f32 = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)` | - = note: `-D transmute-int-to-float` implied by `-D warnings` + = note: `-D clippy::transmute-int-to-float` implied by `-D warnings` error: transmute from a `i32` to a `f32` --> $DIR/transmute.rs:135:27 @@ -196,7 +196,7 @@ error: transmute from a `&[u8]` to a `&str` 139 | let _: &str = unsafe { std::mem::transmute(b) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(b).unwrap()` | - = note: `-D transmute-bytes-to-str` implied by `-D warnings` + = note: `-D clippy::transmute-bytes-to-str` implied by `-D warnings` error: transmute from a `&mut [u8]` to a `&mut str` --> $DIR/transmute.rs:140:32 @@ -210,7 +210,7 @@ error: transmute from a pointer to a pointer 172 | let _: *const f32 = std::mem::transmute(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr as *const f32` | - = note: `-D transmute-ptr-to-ptr` implied by `-D warnings` + = note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings` error: transmute from a pointer to a pointer --> $DIR/transmute.rs:173:27 diff --git a/tests/ui/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index 3a6a6e73f57..e86908655a8 100644 --- a/tests/ui/transmute_64bit.stderr +++ b/tests/ui/transmute_64bit.stderr @@ -1,15 +1,15 @@ error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:9:31 - | -9 | let _: *const usize = std::mem::transmute(6.0f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D wrong-transmute` implied by `-D warnings` + --> $DIR/transmute_64bit.rs:11:31 + | +11 | let _: *const usize = std::mem::transmute(6.0f64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::wrong-transmute` implied by `-D warnings` error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:11:29 + --> $DIR/transmute_64bit.rs:13:29 | -11 | let _: *mut usize = std::mem::transmute(6.0f64); +13 | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/trivially_copy_pass_by_ref.stderr b/tests/ui/trivially_copy_pass_by_ref.stderr index 757b6b4c9a9..2db627dd9b1 100644 --- a/tests/ui/trivially_copy_pass_by_ref.stderr +++ b/tests/ui/trivially_copy_pass_by_ref.stderr @@ -1,81 +1,81 @@ error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:40:11 + --> $DIR/trivially_copy_pass_by_ref.rs:42:11 | -40 | fn bad(x: &u32, y: &Foo, z: &Baz) { +42 | fn bad(x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `u32` | - = note: `-D trivially-copy-pass-by-ref` implied by `-D warnings` + = note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:40:20 + --> $DIR/trivially_copy_pass_by_ref.rs:42:20 | -40 | fn bad(x: &u32, y: &Foo, z: &Baz) { +42 | fn bad(x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:40:29 + --> $DIR/trivially_copy_pass_by_ref.rs:42:29 | -40 | fn bad(x: &u32, y: &Foo, z: &Baz) { +42 | fn bad(x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:50:12 + --> $DIR/trivially_copy_pass_by_ref.rs:52:12 | -50 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +52 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { | ^^^^^ help: consider passing by value instead: `self` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:50:22 + --> $DIR/trivially_copy_pass_by_ref.rs:52:22 | -50 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +52 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:50:31 + --> $DIR/trivially_copy_pass_by_ref.rs:52:31 | -50 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +52 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:50:40 + --> $DIR/trivially_copy_pass_by_ref.rs:52:40 | -50 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +52 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:53:16 + --> $DIR/trivially_copy_pass_by_ref.rs:55:16 | -53 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +55 | fn bad2(x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:53:25 + --> $DIR/trivially_copy_pass_by_ref.rs:55:25 | -53 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +55 | fn bad2(x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:53:34 + --> $DIR/trivially_copy_pass_by_ref.rs:55:34 | -53 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +55 | fn bad2(x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:16 + --> $DIR/trivially_copy_pass_by_ref.rs:69:16 | -67 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +69 | fn bad2(x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:25 + --> $DIR/trivially_copy_pass_by_ref.rs:69:25 | -67 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +69 | fn bad2(x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:34 + --> $DIR/trivially_copy_pass_by_ref.rs:69:34 | -67 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +69 | fn bad2(x: &u32, y: &Foo, z: &Baz) { | ^^^^ help: consider passing by value instead: `Baz` error: aborting due to 13 previous errors diff --git a/tests/ui/types.stderr b/tests/ui/types.stderr index b41bff7a9b0..e2f75162867 100644 --- a/tests/ui/types.stderr +++ b/tests/ui/types.stderr @@ -4,7 +4,7 @@ error: casting i32 to i64 may become silently lossy if types change 9 | let c_i64 : i64 = c as i64; | ^^^^^^^^ help: try: `i64::from(c)` | - = note: `-D cast-lossless` implied by `-D warnings` + = note: `-D clippy::cast-lossless` implied by `-D warnings` error: aborting due to previous error diff --git a/tests/ui/types_fn_to_int.stderr b/tests/ui/types_fn_to_int.stderr index bbdf4ce2e70..a06809b9bfd 100644 --- a/tests/ui/types_fn_to_int.stderr +++ b/tests/ui/types_fn_to_int.stderr @@ -4,7 +4,7 @@ error: casting a `fn(usize) -> Foo {Foo::A}` to `i32` may truncate the function 12 | let _y = x as i32; | ^^^^^^^^ help: if you need the address of the function, consider: `x as usize` | - = note: #[deny(fn_to_numeric_cast_with_truncation)] on by default + = note: #[deny(clippy::fn_to_numeric_cast_with_truncation)] on by default error: casting a `fn(usize) -> Foo {Foo::A}` to `i32` may truncate the function address value. --> $DIR/types_fn_to_int.rs:13:15 @@ -36,7 +36,7 @@ error: casting a `fn() -> i32 {bar}` to `u64` is bad style. 17 | let _y = bar as u64; | ^^^^^^^^^^ help: if you need the address of the function, consider: `bar as usize` | - = note: `-D fn-to-numeric-cast` implied by `-D warnings` + = note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings` error: casting a `fn(usize) -> Foo {Foo::A}` to `i128` is bad style. --> $DIR/types_fn_to_int.rs:18:14 diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index 9e99a44bb60..b0e567fc212 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -4,7 +4,7 @@ error: zero-width space detected 6 | print!("Here >​< is a ZWS, and ​another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D zero-width-space` implied by `-D warnings` + = note: `-D clippy::zero-width-space` implied by `-D warnings` = help: Consider replacing the string with: ""Here >/u{200B}< is a ZWS, and /u{200B}another"" @@ -14,7 +14,7 @@ error: non-nfc unicode sequence detected 12 | print!("̀àh?"); | ^^^^^ | - = note: `-D unicode-not-nfc` implied by `-D warnings` + = note: `-D clippy::unicode-not-nfc` implied by `-D warnings` = help: Consider replacing the string with: ""̀àh?"" @@ -24,7 +24,7 @@ error: literal non-ASCII character detected 18 | print!("Üben!"); | ^^^^^^^ | - = note: `-D non-ascii-literal` implied by `-D warnings` + = note: `-D clippy::non-ascii-literal` implied by `-D warnings` = help: Consider replacing the string with: ""/u{dc}ben!"" diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr index ca48f39263b..e1845c0c0ea 100644 --- a/tests/ui/unit_arg.stderr +++ b/tests/ui/unit_arg.stderr @@ -1,30 +1,10 @@ -error: passing a unit value to a function - --> $DIR/unit_arg.rs:23:9 - | -23 | foo({}); - | ^^ - | - = note: `-D unit-arg` implied by `-D warnings` -help: if you intended to pass a unit value, use a unit literal instead - | -23 | foo(()); - | ^^ - -error: passing a unit value to a function - --> $DIR/unit_arg.rs:24:9 - | -24 | foo({ 1; }); - | ^^^^^^ -help: if you intended to pass a unit value, use a unit literal instead - | -24 | foo(()); - | ^^ - error: passing a unit value to a function --> $DIR/unit_arg.rs:25:9 | -25 | foo(foo(1)); - | ^^^^^^ +25 | foo({}); + | ^^ + | + = note: `-D clippy::unit-arg` implied by `-D warnings` help: if you intended to pass a unit value, use a unit literal instead | 25 | foo(()); @@ -33,35 +13,55 @@ help: if you intended to pass a unit value, use a unit literal instead error: passing a unit value to a function --> $DIR/unit_arg.rs:26:9 | -26 | foo({ - | _________^ -27 | | foo(1); -28 | | foo(2); -29 | | }); - | |_____^ +26 | foo({ 1; }); + | ^^^^^^ help: if you intended to pass a unit value, use a unit literal instead | 26 | foo(()); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:30:10 + --> $DIR/unit_arg.rs:27:9 | -30 | foo3({}, 2, 2); +27 | foo(foo(1)); + | ^^^^^^ +help: if you intended to pass a unit value, use a unit literal instead + | +27 | foo(()); + | ^^ + +error: passing a unit value to a function + --> $DIR/unit_arg.rs:28:9 + | +28 | foo({ + | _________^ +29 | | foo(1); +30 | | foo(2); +31 | | }); + | |_____^ +help: if you intended to pass a unit value, use a unit literal instead + | +28 | foo(()); + | ^^ + +error: passing a unit value to a function + --> $DIR/unit_arg.rs:32:10 + | +32 | foo3({}, 2, 2); | ^^ help: if you intended to pass a unit value, use a unit literal instead | -30 | foo3((), 2, 2); +32 | foo3((), 2, 2); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:32:11 + --> $DIR/unit_arg.rs:34:11 | -32 | b.bar({ 1; }); +34 | b.bar({ 1; }); | ^^^^^^ help: if you intended to pass a unit value, use a unit literal instead | -32 | b.bar(()); +34 | b.bar(()); | ^^ error: aborting due to 6 previous errors diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index 51ad3fca947..a85eb32841f 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -4,7 +4,7 @@ error: ==-comparison of unit values detected. This will always be true 16 | if { true; } == { false; } { | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D unit-cmp` implied by `-D warnings` + = note: `-D clippy::unit-cmp` implied by `-D warnings` error: >-comparison of unit values detected. This will always be false --> $DIR/unit_cmp.rs:19:8 diff --git a/tests/ui/unnecessary_clone.stderr b/tests/ui/unnecessary_clone.stderr index 3c1ce908022..b2985f84b04 100644 --- a/tests/ui/unnecessary_clone.stderr +++ b/tests/ui/unnecessary_clone.stderr @@ -1,84 +1,84 @@ error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:16:5 + --> $DIR/unnecessary_clone.rs:18:5 | -16 | 42.clone(); +18 | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call: `42` | - = note: `-D clone-on-copy` implied by `-D warnings` + = note: `-D clippy::clone-on-copy` implied by `-D warnings` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:20:5 + --> $DIR/unnecessary_clone.rs:22:5 | -20 | (&42).clone(); +22 | (&42).clone(); | ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:30:5 + --> $DIR/unnecessary_clone.rs:32:5 | -30 | rc.clone(); +32 | rc.clone(); | ^^^^^^^^^^ help: try this: `Rc::::clone(&rc)` | - = note: `-D clone-on-ref-ptr` implied by `-D warnings` + = note: `-D clippy::clone-on-ref-ptr` implied by `-D warnings` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:33:5 + --> $DIR/unnecessary_clone.rs:35:5 | -33 | arc.clone(); +35 | arc.clone(); | ^^^^^^^^^^^ help: try this: `Arc::::clone(&arc)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:36:5 + --> $DIR/unnecessary_clone.rs:38:5 | -36 | rcweak.clone(); +38 | rcweak.clone(); | ^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&rcweak)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:39:5 + --> $DIR/unnecessary_clone.rs:41:5 | -39 | arc_weak.clone(); +41 | arc_weak.clone(); | ^^^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&arc_weak)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:43:29 + --> $DIR/unnecessary_clone.rs:45:29 | -43 | let _: Arc = x.clone(); +45 | let _: Arc = x.clone(); | ^^^^^^^^^ help: try this: `Arc::::clone(&x)` -error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:47:5 - | -47 | t.clone(); - | ^^^^^^^^^ help: try removing the `clone` call: `t` - error: using `clone` on a `Copy` type --> $DIR/unnecessary_clone.rs:49:5 | -49 | Some(t).clone(); +49 | t.clone(); + | ^^^^^^^^^ help: try removing the `clone` call: `t` + +error: using `clone` on a `Copy` type + --> $DIR/unnecessary_clone.rs:51:5 + | +51 | Some(t).clone(); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `Some(t)` error: using `clone` on a double-reference; this will copy the reference instead of cloning the inner type - --> $DIR/unnecessary_clone.rs:55:22 + --> $DIR/unnecessary_clone.rs:57:22 | -55 | let z: &Vec<_> = y.clone(); +57 | let z: &Vec<_> = y.clone(); | ^^^^^^^^^ | - = note: #[deny(clone_double_ref)] on by default + = note: #[deny(clippy::clone_double_ref)] on by default help: try dereferencing it | -55 | let z: &Vec<_> = &(*y).clone(); +57 | let z: &Vec<_> = &(*y).clone(); | ^^^^^^^^^^^^^ help: or try being explicit about what type to clone | -55 | let z: &Vec<_> = &std::vec::Vec::clone(y); +57 | let z: &Vec<_> = &std::vec::Vec::clone(y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/unnecessary_clone.rs:62:27 + --> $DIR/unnecessary_clone.rs:64:27 | -62 | let v2 : Vec = v.iter().cloned().collect(); +64 | let v2 : Vec = v.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D iter-cloned-collect` implied by `-D warnings` + = note: `-D clippy::iter-cloned-collect` implied by `-D warnings` error: aborting due to 11 previous errors diff --git a/tests/ui/unnecessary_fold.stderr b/tests/ui/unnecessary_fold.stderr index 8bc4b8244bd..e72f671b67e 100644 --- a/tests/ui/unnecessary_fold.stderr +++ b/tests/ui/unnecessary_fold.stderr @@ -4,7 +4,7 @@ error: this `.fold` can be written more succinctly using another method 4 | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` | - = note: `-D unnecessary-fold` implied by `-D warnings` + = note: `-D clippy::unnecessary-fold` implied by `-D warnings` error: this `.fold` can be written more succinctly using another method --> $DIR/unnecessary_fold.rs:6:19 diff --git a/tests/ui/unnecessary_ref.stderr b/tests/ui/unnecessary_ref.stderr index ffc65084afa..d27ba26f349 100644 --- a/tests/ui/unnecessary_ref.stderr +++ b/tests/ui/unnecessary_ref.stderr @@ -1,14 +1,14 @@ error: Creating a reference that is immediately dereferenced. - --> $DIR/unnecessary_ref.rs:11:17 + --> $DIR/unnecessary_ref.rs:13:17 | -11 | let inner = (&outer).inner; +13 | let inner = (&outer).inner; | ^^^^^^^^ help: try this: `outer.inner` | note: lint level defined here - --> $DIR/unnecessary_ref.rs:8:8 + --> $DIR/unnecessary_ref.rs:10:8 | -8 | #[deny(ref_in_deref)] - | ^^^^^^^^^^^^ +10 | #[deny(clippy::ref_in_deref)] + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index 7e4c3a6cb9c..40aa4f524fe 100644 --- a/tests/ui/unneeded_field_pattern.stderr +++ b/tests/ui/unneeded_field_pattern.stderr @@ -4,7 +4,7 @@ error: You matched a field with a wildcard pattern. Consider using `..` instead 17 | Foo { a: _, b: 0, .. } => {} | ^^^^ | - = note: `-D unneeded-field-pattern` implied by `-D warnings` + = note: `-D clippy::unneeded-field-pattern` implied by `-D warnings` = help: Try with `Foo { b: 0, .. }` error: All the struct fields are matched to a wildcard pattern, consider using `..`. diff --git a/tests/ui/unreadable_literal.stderr b/tests/ui/unreadable_literal.stderr index cffcad1eef7..516b6ccc595 100644 --- a/tests/ui/unreadable_literal.stderr +++ b/tests/ui/unreadable_literal.stderr @@ -4,7 +4,7 @@ error: long literal lacking separators 7 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64` | - = note: `-D unreadable-literal` implied by `-D warnings` + = note: `-D clippy::unreadable-literal` implied by `-D warnings` error: long literal lacking separators --> $DIR/unreadable_literal.rs:7:30 diff --git a/tests/ui/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index 93f2ddd533f..2b014ca5863 100644 --- a/tests/ui/unsafe_removed_from_name.stderr +++ b/tests/ui/unsafe_removed_from_name.stderr @@ -4,7 +4,7 @@ error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCell 7 | use std::cell::{UnsafeCell as TotallySafeCell}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D unsafe-removed-from-name` implied by `-D warnings` + = note: `-D clippy::unsafe-removed-from-name` implied by `-D warnings` error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCellAgain` --> $DIR/unsafe_removed_from_name.rs:9:1 diff --git a/tests/ui/unused_io_amount.stderr b/tests/ui/unused_io_amount.stderr index 5114d375fff..48a5751579c 100644 --- a/tests/ui/unused_io_amount.stderr +++ b/tests/ui/unused_io_amount.stderr @@ -4,7 +4,7 @@ error: handle written amount returned or use `Write::write_all` instead 11 | try!(s.write(b"test")); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D unused-io-amount` implied by `-D warnings` + = note: `-D clippy::unused-io-amount` implied by `-D warnings` = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: handle read amount returned or use `Read::read_exact` instead diff --git a/tests/ui/unused_labels.stderr b/tests/ui/unused_labels.stderr index 19c91e2a6a3..d35ca41a1a1 100644 --- a/tests/ui/unused_labels.stderr +++ b/tests/ui/unused_labels.stderr @@ -6,7 +6,7 @@ error: unused label `'label` 10 | | } | |_____^ | - = note: `-D unused-label` implied by `-D warnings` + = note: `-D clippy::unused-label` implied by `-D warnings` error: unused label `'a` --> $DIR/unused_labels.rs:21:5 diff --git a/tests/ui/unused_lt.stderr b/tests/ui/unused_lt.stderr index f01dfda7013..4cad611c2a1 100644 --- a/tests/ui/unused_lt.stderr +++ b/tests/ui/unused_lt.stderr @@ -4,7 +4,7 @@ error: this lifetime isn't used in the function definition 16 | fn unused_lt<'a>(x: u8) { | ^^ | - = note: `-D extra-unused-lifetimes` implied by `-D warnings` + = note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings` error: this lifetime isn't used in the function definition --> $DIR/unused_lt.rs:20:25 diff --git a/tests/ui/unwrap_or.stderr b/tests/ui/unwrap_or.stderr index e4704dd0e43..42c72090ca5 100644 --- a/tests/ui/unwrap_or.stderr +++ b/tests/ui/unwrap_or.stderr @@ -1,16 +1,16 @@ error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:4:47 + --> $DIR/unwrap_or.rs:5:47 | -4 | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); +5 | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` | - = note: `-D or-fun-call` implied by `-D warnings` + = note: `-D clippy::or-fun-call` implied by `-D warnings` error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:9:10 - | -9 | .unwrap_or("Fail".to_string()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` + --> $DIR/unwrap_or.rs:10:10 + | +10 | .unwrap_or("Fail".to_string()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` error: aborting due to 2 previous errors diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index 89936101252..cf673e166d8 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -1,123 +1,123 @@ error: unnecessary structure name repetition - --> $DIR/use_self.rs:11:21 + --> $DIR/use_self.rs:13:21 | -11 | fn new() -> Foo { +13 | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` | - = note: `-D use-self` implied by `-D warnings` + = note: `-D clippy::use-self` implied by `-D warnings` error: unnecessary structure name repetition - --> $DIR/use_self.rs:12:13 + --> $DIR/use_self.rs:14:13 | -12 | Foo {} +14 | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:14:22 + --> $DIR/use_self.rs:16:22 | -14 | fn test() -> Foo { +16 | fn test() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:15:13 + --> $DIR/use_self.rs:17:13 | -15 | Foo::new() +17 | Foo::new() | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:20:25 + --> $DIR/use_self.rs:22:25 | -20 | fn default() -> Foo { +22 | fn default() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:21:13 + --> $DIR/use_self.rs:23:13 | -21 | Foo::new() +23 | Foo::new() | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:84:22 + --> $DIR/use_self.rs:86:22 | -84 | fn refs(p1: &Bad) -> &Bad { +86 | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:84:31 + --> $DIR/use_self.rs:86:31 | -84 | fn refs(p1: &Bad) -> &Bad { +86 | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:88:37 + --> $DIR/use_self.rs:90:37 | -88 | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { +90 | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:88:53 + --> $DIR/use_self.rs:90:53 | -88 | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { +90 | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:92:30 + --> $DIR/use_self.rs:94:30 | -92 | fn mut_refs(p1: &mut Bad) -> &mut Bad { +94 | fn mut_refs(p1: &mut Bad) -> &mut Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:92:43 + --> $DIR/use_self.rs:94:43 | -92 | fn mut_refs(p1: &mut Bad) -> &mut Bad { +94 | fn mut_refs(p1: &mut Bad) -> &mut Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:96:28 + --> $DIR/use_self.rs:98:28 | -96 | fn nested(_p1: Box, _p2: (&u8, &Bad)) { +98 | fn nested(_p1: Box, _p2: (&u8, &Bad)) { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:96:46 + --> $DIR/use_self.rs:98:46 | -96 | fn nested(_p1: Box, _p2: (&u8, &Bad)) { +98 | fn nested(_p1: Box, _p2: (&u8, &Bad)) { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:99:20 - | -99 | fn vals(_: Bad) -> Bad { - | ^^^ help: use the applicable keyword: `Self` - -error: unnecessary structure name repetition - --> $DIR/use_self.rs:99:28 - | -99 | fn vals(_: Bad) -> Bad { - | ^^^ help: use the applicable keyword: `Self` - -error: unnecessary structure name repetition - --> $DIR/use_self.rs:100:13 + --> $DIR/use_self.rs:101:20 | -100 | Bad::default() +101 | fn vals(_: Bad) -> Bad { + | ^^^ help: use the applicable keyword: `Self` + +error: unnecessary structure name repetition + --> $DIR/use_self.rs:101:28 + | +101 | fn vals(_: Bad) -> Bad { + | ^^^ help: use the applicable keyword: `Self` + +error: unnecessary structure name repetition + --> $DIR/use_self.rs:102:13 + | +102 | Bad::default() | ^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:105:23 + --> $DIR/use_self.rs:107:23 | -105 | type Output = Bad; +107 | type Output = Bad; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:107:27 + --> $DIR/use_self.rs:109:27 | -107 | fn mul(self, rhs: Bad) -> Bad { +109 | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:107:35 + --> $DIR/use_self.rs:109:35 | -107 | fn mul(self, rhs: Bad) -> Bad { +109 | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: aborting due to 20 previous errors diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 712f81c1b6f..a1bb57a50a5 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -4,7 +4,7 @@ error: used binding `_foo` which is prefixed with an underscore. A leading under 17 | _foo + 1 | ^^^^ | - = note: `-D used-underscore-binding` implied by `-D warnings` + = note: `-D clippy::used-underscore-binding` implied by `-D warnings` error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. --> $DIR/used_underscore_binding.rs:22:20 diff --git a/tests/ui/useless_asref.stderr b/tests/ui/useless_asref.stderr index 875d830a353..6247fb27a79 100644 --- a/tests/ui/useless_asref.stderr +++ b/tests/ui/useless_asref.stderr @@ -1,73 +1,73 @@ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:31:18 + --> $DIR/useless_asref.rs:33:18 | -31 | foo_rstr(rstr.as_ref()); +33 | foo_rstr(rstr.as_ref()); | ^^^^^^^^^^^^^ help: try this: `rstr` | note: lint level defined here - --> $DIR/useless_asref.rs:1:9 + --> $DIR/useless_asref.rs:3:9 | -1 | #![deny(useless_asref)] - | ^^^^^^^^^^^^^ +3 | #![deny(clippy::useless_asref)] + | ^^^^^^^^^^^^^^^^^^^^^ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:33:20 + --> $DIR/useless_asref.rs:35:20 | -33 | foo_rslice(rslice.as_ref()); +35 | foo_rslice(rslice.as_ref()); | ^^^^^^^^^^^^^^^ help: try this: `rslice` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:37:21 + --> $DIR/useless_asref.rs:39:21 | -37 | foo_mrslice(mrslice.as_mut()); +39 | foo_mrslice(mrslice.as_mut()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:39:20 + --> $DIR/useless_asref.rs:41:20 | -39 | foo_rslice(mrslice.as_ref()); +41 | foo_rslice(mrslice.as_ref()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:46:20 + --> $DIR/useless_asref.rs:48:20 | -46 | foo_rslice(rrrrrslice.as_ref()); +48 | foo_rslice(rrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^ help: try this: `rrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:48:18 + --> $DIR/useless_asref.rs:50:18 | -48 | foo_rstr(rrrrrstr.as_ref()); +50 | foo_rstr(rrrrrstr.as_ref()); | ^^^^^^^^^^^^^^^^^ help: try this: `rrrrrstr` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:53:21 + --> $DIR/useless_asref.rs:55:21 | -53 | foo_mrslice(mrrrrrslice.as_mut()); +55 | foo_mrslice(mrrrrrslice.as_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:55:20 + --> $DIR/useless_asref.rs:57:20 | -55 | foo_rslice(mrrrrrslice.as_ref()); +57 | foo_rslice(mrrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:58:16 + --> $DIR/useless_asref.rs:60:16 | -58 | foo_rrrrmr((&&&&MoreRef).as_ref()); +60 | foo_rrrrmr((&&&&MoreRef).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(&&&&MoreRef)` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:104:13 + --> $DIR/useless_asref.rs:106:13 | -104 | foo_mrt(mrt.as_mut()); +106 | foo_mrt(mrt.as_mut()); | ^^^^^^^^^^^^ help: try this: `mrt` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:106:12 + --> $DIR/useless_asref.rs:108:12 | -106 | foo_rt(mrt.as_ref()); +108 | foo_rt(mrt.as_ref()); | ^^^^^^^^^^^^ help: try this: `mrt` error: aborting due to 11 previous errors diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index 84b81e56107..59f1aaffb3f 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -4,7 +4,7 @@ error: useless lint attribute 5 | #[allow(dead_code, unused_extern_crates)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code, unused_extern_crates)]` | - = note: `-D useless-attribute` implied by `-D warnings` + = note: `-D clippy::useless-attribute` implied by `-D warnings` error: useless lint attribute --> $DIR/useless_attribute.rs:6:1 diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index 6a47eb5b064..b9541e58c77 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -4,7 +4,7 @@ error: useless use of `vec!` 24 | on_slice(&vec![]); | ^^^^^^^ help: you can use a slice directly: `&[]` | - = note: `-D useless-vec` implied by `-D warnings` + = note: `-D clippy::useless-vec` implied by `-D warnings` error: useless use of `vec!` --> $DIR/vec.rs:27:14 diff --git a/tests/ui/while_loop.stderr b/tests/ui/while_loop.stderr index d2b50b61e90..cc309e37946 100644 --- a/tests/ui/while_loop.stderr +++ b/tests/ui/while_loop.stderr @@ -10,7 +10,7 @@ error: this loop could be written as a `while let` loop 15 | | } | |_____^ help: try: `while let Some(_x) = y { .. }` | - = note: `-D while-let-loop` implied by `-D warnings` + = note: `-D clippy::while-let-loop` implied by `-D warnings` error: this loop could be written as a `while let` loop --> $DIR/while_loop.rs:22:5 @@ -65,7 +65,7 @@ error: this loop could be written as a `for` loop 68 | while let Option::Some(x) = iter.next() { | ^^^^^^^^^^^ help: try: `for x in iter { .. }` | - = note: `-D while-let-on-iterator` implied by `-D warnings` + = note: `-D clippy::while-let-on-iterator` implied by `-D warnings` error: this loop could be written as a `for` loop --> $DIR/while_loop.rs:73:25 @@ -97,7 +97,7 @@ error: empty `loop {}` detected. You may want to either use `panic!()` or add `s 123 | loop {} | ^^^^^^^ | - = note: `-D empty-loop` implied by `-D warnings` + = note: `-D clippy::empty-loop` implied by `-D warnings` error: this loop could be written as a `for` loop --> $DIR/while_loop.rs:183:29 diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index d2e8ca94ed8..644f6f15b42 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -1,87 +1,87 @@ error: literal with an empty format string - --> $DIR/write_literal.rs:27:79 + --> $DIR/write_literal.rs:29:79 | -27 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); +29 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ | - = note: `-D write-literal` implied by `-D warnings` + = note: `-D clippy::write-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/write_literal.rs:28:32 + --> $DIR/write_literal.rs:30:32 | -28 | write!(&mut v, "Hello {}", "world"); +30 | write!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:29:44 + --> $DIR/write_literal.rs:31:44 | -29 | writeln!(&mut v, "Hello {} {}", world, "world"); +31 | writeln!(&mut v, "Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:30:34 + --> $DIR/write_literal.rs:32:34 | -30 | writeln!(&mut v, "Hello {}", "world"); +32 | writeln!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:31:38 + --> $DIR/write_literal.rs:33:38 | -31 | writeln!(&mut v, "10 / 4 is {}", 2.5); +33 | writeln!(&mut v, "10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:32:36 + --> $DIR/write_literal.rs:34:36 | -32 | writeln!(&mut v, "2 + 1 = {}", 3); +34 | writeln!(&mut v, "2 + 1 = {}", 3); | ^ error: literal with an empty format string - --> $DIR/write_literal.rs:37:33 + --> $DIR/write_literal.rs:39:33 | -37 | writeln!(&mut v, "{0} {1}", "hello", "world"); +39 | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:37:42 + --> $DIR/write_literal.rs:39:42 | -37 | writeln!(&mut v, "{0} {1}", "hello", "world"); +39 | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:38:33 + --> $DIR/write_literal.rs:40:33 | -38 | writeln!(&mut v, "{1} {0}", "hello", "world"); +40 | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:38:42 + --> $DIR/write_literal.rs:40:42 | -38 | writeln!(&mut v, "{1} {0}", "hello", "world"); +40 | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:41:41 + --> $DIR/write_literal.rs:43:41 | -41 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); +43 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:41:54 + --> $DIR/write_literal.rs:43:54 | -41 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); +43 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:42:41 + --> $DIR/write_literal.rs:44:41 | -42 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); +44 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:42:54 + --> $DIR/write_literal.rs:44:54 | -42 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); +44 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); | ^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/write_with_newline.stderr b/tests/ui/write_with_newline.stderr index a8a6039f3e1..c8617b4939a 100644 --- a/tests/ui/write_with_newline.stderr +++ b/tests/ui/write_with_newline.stderr @@ -1,27 +1,27 @@ -error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:10:5 - | -10 | write!(&mut v, "Hello/n"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D write-with-newline` implied by `-D warnings` - -error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:11:5 - | -11 | write!(&mut v, "Hello {}/n", "world"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead --> $DIR/write_with_newline.rs:12:5 | -12 | write!(&mut v, "Hello {} {}/n", "world", "#2"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +12 | write!(&mut v, "Hello/n"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::write-with-newline` implied by `-D warnings` error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead --> $DIR/write_with_newline.rs:13:5 | -13 | write!(&mut v, "{}/n", 1265); +13 | write!(&mut v, "Hello {}/n", "world"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead + --> $DIR/write_with_newline.rs:14:5 + | +14 | write!(&mut v, "Hello {} {}/n", "world", "#2"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead + --> $DIR/write_with_newline.rs:15:5 + | +15 | write!(&mut v, "{}/n", 1265); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr index 7bb6350ecd2..ef1e9b3d36e 100644 --- a/tests/ui/writeln_empty_string.stderr +++ b/tests/ui/writeln_empty_string.stderr @@ -1,15 +1,15 @@ error: using `writeln!(&mut v, "")` - --> $DIR/writeln_empty_string.rs:9:5 - | -9 | writeln!(&mut v, ""); - | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut v)` - | - = note: `-D writeln-empty-string` implied by `-D warnings` + --> $DIR/writeln_empty_string.rs:11:5 + | +11 | writeln!(&mut v, ""); + | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut v)` + | + = note: `-D clippy::writeln-empty-string` implied by `-D warnings` error: using `writeln!(&mut suggestion, "")` - --> $DIR/writeln_empty_string.rs:12:5 + --> $DIR/writeln_empty_string.rs:14:5 | -12 | writeln!(&mut suggestion, ""); +14 | writeln!(&mut suggestion, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut suggestion)` error: aborting due to 2 previous errors diff --git a/tests/ui/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index 216fd0bb82b..4a6e5e0ab22 100644 --- a/tests/ui/wrong_self_convention.stderr +++ b/tests/ui/wrong_self_convention.stderr @@ -4,7 +4,7 @@ error: methods called `from_*` usually take no self; consider choosing a less am 21 | fn from_i32(self) {} | ^^^^ | - = note: `-D wrong-self-convention` implied by `-D warnings` + = note: `-D clippy::wrong-self-convention` implied by `-D warnings` error: methods called `from_*` usually take no self; consider choosing a less ambiguous name --> $DIR/wrong_self_convention.rs:27:21 diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index f1788fc9ec5..a5e86883d25 100644 --- a/tests/ui/zero_div_zero.stderr +++ b/tests/ui/zero_div_zero.stderr @@ -4,7 +4,7 @@ error: equal expressions as operands to `/` 7 | let nan = 0.0 / 0.0; | ^^^^^^^^^ | - = note: #[deny(eq_op)] on by default + = note: #[deny(clippy::eq_op)] on by default error: constant division of 0.0 with 0.0 will always result in NaN --> $DIR/zero_div_zero.rs:7:15 @@ -12,7 +12,7 @@ error: constant division of 0.0 with 0.0 will always result in NaN 7 | let nan = 0.0 / 0.0; | ^^^^^^^^^ | - = note: `-D zero-divided-by-zero` implied by `-D warnings` + = note: `-D clippy::zero-divided-by-zero` implied by `-D warnings` = help: Consider using `std::f64::NAN` if you would like a constant representing NaN error: equal expressions as operands to `/` diff --git a/tests/ui/zero_ptr.stderr b/tests/ui/zero_ptr.stderr index 5155dc401bd..b5e279eaa3a 100644 --- a/tests/ui/zero_ptr.stderr +++ b/tests/ui/zero_ptr.stderr @@ -4,7 +4,7 @@ error: `0 as *const _` detected. Consider using `ptr::null()` 6 | let x = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ | - = note: `-D zero-ptr` implied by `-D warnings` + = note: `-D clippy::zero-ptr` implied by `-D warnings` error: `0 as *mut _` detected. Consider using `ptr::null_mut()` --> $DIR/zero_ptr.rs:7:13 From ea43fedf9e111e904205ba5ebaa9ef8d9ff8f96c Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Mon, 30 Jul 2018 11:33:44 +0200 Subject: [PATCH 44/53] Adapt run-pass tests to the tool_lints --- tests/run-pass/associated-constant-ice.rs | 3 --- tests/run-pass/enum-glob-import-crate.rs | 4 ++-- tests/run-pass/ice-1588.rs | 4 ++-- tests/run-pass/ice-1969.rs | 4 ++-- tests/run-pass/ice-2499.rs | 4 +++- tests/run-pass/ice-2760.rs | 5 ++++- tests/run-pass/ice-2774.rs | 6 ++++-- tests/run-pass/ice-700.rs | 4 ++-- tests/run-pass/ice_exacte_size.rs | 4 +++- tests/run-pass/if_same_then_else.rs | 4 +++- tests/run-pass/match_same_arms_const.rs | 4 +++- tests/run-pass/mut_mut_macro.rs | 4 +++- tests/run-pass/needless_borrow_fp.rs | 4 +++- tests/run-pass/needless_lifetimes_impl_trait.rs | 3 ++- tests/run-pass/regressions.rs | 4 ++-- tests/run-pass/single-match-else.rs | 4 ++-- tests/run-pass/used_underscore_binding_macro.rs | 5 +++-- 17 files changed, 43 insertions(+), 27 deletions(-) diff --git a/tests/run-pass/associated-constant-ice.rs b/tests/run-pass/associated-constant-ice.rs index 744de9bcf38..2c5c90683cc 100644 --- a/tests/run-pass/associated-constant-ice.rs +++ b/tests/run-pass/associated-constant-ice.rs @@ -1,6 +1,3 @@ - - - pub trait Trait { const CONSTANT: u8; } diff --git a/tests/run-pass/enum-glob-import-crate.rs b/tests/run-pass/enum-glob-import-crate.rs index 21ed2dbf991..6014558a184 100644 --- a/tests/run-pass/enum-glob-import-crate.rs +++ b/tests/run-pass/enum-glob-import-crate.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![deny(clippy)] +#![deny(clippy::all)] #![allow(unused_imports)] use std::*; diff --git a/tests/run-pass/ice-1588.rs b/tests/run-pass/ice-1588.rs index 780df523511..fcda3814e4a 100644 --- a/tests/run-pass/ice-1588.rs +++ b/tests/run-pass/ice-1588.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![allow(clippy)] +#![allow(clippy::all)] fn main() { match 1 { diff --git a/tests/run-pass/ice-1969.rs b/tests/run-pass/ice-1969.rs index 29633982848..43d6bd8bfbc 100644 --- a/tests/run-pass/ice-1969.rs +++ b/tests/run-pass/ice-1969.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![allow(clippy)] +#![allow(clippy::all)] fn main() { } diff --git a/tests/run-pass/ice-2499.rs b/tests/run-pass/ice-2499.rs index 01deb7abfc1..c6793a78529 100644 --- a/tests/run-pass/ice-2499.rs +++ b/tests/run-pass/ice-2499.rs @@ -1,4 +1,6 @@ -#![allow(dead_code, char_lit_as_u8, needless_bool)] +#![feature(tool_lints)] + +#![allow(dead_code, clippy::char_lit_as_u8, clippy::needless_bool)] /// Should not trigger an ICE in `SpanlessHash` / `consts::constant` /// diff --git a/tests/run-pass/ice-2760.rs b/tests/run-pass/ice-2760.rs index 01ca6d42a94..2e9c6d527c4 100644 --- a/tests/run-pass/ice-2760.rs +++ b/tests/run-pass/ice-2760.rs @@ -1,4 +1,7 @@ -#![allow(unused_variables, blacklisted_name, needless_pass_by_value, dead_code)] +#![feature(tool_lints)] + +#![allow(unused_variables, clippy::blacklisted_name, + clippy::needless_pass_by_value, dead_code)] // This should not compile-fail with: // diff --git a/tests/run-pass/ice-2774.rs b/tests/run-pass/ice-2774.rs index c6d9bb4a276..6b14a2b5e03 100644 --- a/tests/run-pass/ice-2774.rs +++ b/tests/run-pass/ice-2774.rs @@ -1,3 +1,5 @@ +#![feature(tool_lints)] + use std::collections::HashSet; // See https://github.com/rust-lang-nursery/rust-clippy/issues/2774 @@ -10,7 +12,7 @@ pub struct Bar { #[derive(Eq, PartialEq, Debug, Hash)] pub struct Foo {} -#[allow(implicit_hasher)] +#[allow(clippy::implicit_hasher)] // This should not cause a 'cannot relate bound region' ICE pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) { let mut foos = HashSet::new(); @@ -19,7 +21,7 @@ pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) { ); } -#[allow(implicit_hasher)] +#[allow(clippy::implicit_hasher)] // Also this should not cause a 'cannot relate bound region' ICE pub fn add_barfoos_to_foos2(bars: &HashSet<&Bar>) { let mut foos = HashSet::new(); diff --git a/tests/run-pass/ice-700.rs b/tests/run-pass/ice-700.rs index a1e3a6756e9..3992af2c280 100644 --- a/tests/run-pass/ice-700.rs +++ b/tests/run-pass/ice-700.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![deny(clippy)] +#![deny(clippy::all)] fn core() {} diff --git a/tests/run-pass/ice_exacte_size.rs b/tests/run-pass/ice_exacte_size.rs index 914153c64ff..3d25aa50499 100644 --- a/tests/run-pass/ice_exacte_size.rs +++ b/tests/run-pass/ice_exacte_size.rs @@ -1,4 +1,6 @@ -#![deny(clippy)] +#![feature(tool_lints)] + +#![deny(clippy::all)] #[allow(dead_code)] struct Foo; diff --git a/tests/run-pass/if_same_then_else.rs b/tests/run-pass/if_same_then_else.rs index eb14ce80756..b7536e25028 100644 --- a/tests/run-pass/if_same_then_else.rs +++ b/tests/run-pass/if_same_then_else.rs @@ -1,4 +1,6 @@ -#![deny(if_same_then_else)] +#![feature(tool_lints)] + +#![deny(clippy::if_same_then_else)] fn main() {} diff --git a/tests/run-pass/match_same_arms_const.rs b/tests/run-pass/match_same_arms_const.rs index 08acc2bc4d8..59b939f3e01 100644 --- a/tests/run-pass/match_same_arms_const.rs +++ b/tests/run-pass/match_same_arms_const.rs @@ -1,4 +1,6 @@ -#![deny(match_same_arms)] +#![feature(tool_lints)] + +#![deny(clippy::match_same_arms)] const PRICE_OF_SWEETS: u32 = 5; const PRICE_OF_KINDNESS: u32 = 0; diff --git a/tests/run-pass/mut_mut_macro.rs b/tests/run-pass/mut_mut_macro.rs index 2b916c025d3..bfb9cfc7170 100644 --- a/tests/run-pass/mut_mut_macro.rs +++ b/tests/run-pass/mut_mut_macro.rs @@ -1,4 +1,6 @@ -#![deny(mut_mut, zero_ptr, cmp_nan)] +#![feature(tool_lints)] + +#![deny(clippy::mut_mut, clippy::zero_ptr, clippy::cmp_nan)] #![allow(dead_code)] // compiletest + extern crates doesn't work together diff --git a/tests/run-pass/needless_borrow_fp.rs b/tests/run-pass/needless_borrow_fp.rs index 9dc508006ed..204968e48d0 100644 --- a/tests/run-pass/needless_borrow_fp.rs +++ b/tests/run-pass/needless_borrow_fp.rs @@ -1,4 +1,6 @@ -#[deny(clippy)] +#![feature(tool_lints)] + +#[deny(clippy::all)] #[derive(Debug)] pub enum Error { diff --git a/tests/run-pass/needless_lifetimes_impl_trait.rs b/tests/run-pass/needless_lifetimes_impl_trait.rs index 700215baa64..f727b2547e3 100644 --- a/tests/run-pass/needless_lifetimes_impl_trait.rs +++ b/tests/run-pass/needless_lifetimes_impl_trait.rs @@ -1,5 +1,6 @@ +#![feature(tool_lints)] -#![deny(needless_lifetimes)] +#![deny(clippy::needless_lifetimes)] #![allow(dead_code)] trait Foo {} diff --git a/tests/run-pass/regressions.rs b/tests/run-pass/regressions.rs index d5e343c56c2..aa4e16d3949 100644 --- a/tests/run-pass/regressions.rs +++ b/tests/run-pass/regressions.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![allow(blacklisted_name)] +#![allow(clippy::blacklisted_name)] pub fn foo(bar: *const u8) { println!("{:#p}", bar); diff --git a/tests/run-pass/single-match-else.rs b/tests/run-pass/single-match-else.rs index b8fa7294dcd..379a98fc3ec 100644 --- a/tests/run-pass/single-match-else.rs +++ b/tests/run-pass/single-match-else.rs @@ -1,6 +1,6 @@ +#![feature(tool_lints)] - -#![warn(single_match_else)] +#![warn(clippy::single_match_else)] fn main() { let n = match (42, 43) { diff --git a/tests/run-pass/used_underscore_binding_macro.rs b/tests/run-pass/used_underscore_binding_macro.rs index c9c77257c0e..73f48a96e77 100644 --- a/tests/run-pass/used_underscore_binding_macro.rs +++ b/tests/run-pass/used_underscore_binding_macro.rs @@ -1,12 +1,13 @@ +#![feature(tool_lints)] - +#![allow(clippy::useless_attribute)] //issue #2910 #[macro_use] extern crate serde_derive; /// Test that we do not lint for unused underscores in a `MacroAttribute` /// expansion -#[deny(used_underscore_binding)] +#[deny(clippy::used_underscore_binding)] #[derive(Deserialize)] struct MacroAttributesTest { _foo: u32, From cfd4c538d462f640013a6bb6b7f1663e82447e1f Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Wed, 1 Aug 2018 22:38:04 +0200 Subject: [PATCH 45/53] Adapt ui-toml-tests to the tool_lints --- .../toml_blacklist/conf_french_blacklisted_name.rs | 6 +++--- .../toml_blacklist/conf_french_blacklisted_name.stderr | 2 +- tests/ui-toml/toml_trivially_copy/test.rs | 3 ++- tests/ui-toml/toml_trivially_copy/test.stderr | 10 +++++----- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs index 1f1a8ee91a1..fe533f521d0 100644 --- a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs +++ b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs @@ -1,10 +1,10 @@ - +#![feature(tool_lints)] #![allow(dead_code)] -#![allow(single_match)] +#![allow(clippy::single_match)] #![allow(unused_variables)] -#![warn(blacklisted_name)] +#![warn(clippy::blacklisted_name)] fn test(toto: ()) {} diff --git a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr index b2b0f26b140..4229b711b0d 100644 --- a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr +++ b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr @@ -4,7 +4,7 @@ error: use of a blacklisted/placeholder name `toto` 9 | fn test(toto: ()) {} | ^^^^ | - = note: `-D blacklisted-name` implied by `-D warnings` + = note: `-D clippy::blacklisted-name` implied by `-D warnings` error: use of a blacklisted/placeholder name `toto` --> $DIR/conf_french_blacklisted_name.rs:12:9 diff --git a/tests/ui-toml/toml_trivially_copy/test.rs b/tests/ui-toml/toml_trivially_copy/test.rs index bee092a5765..074ca064ab5 100644 --- a/tests/ui-toml/toml_trivially_copy/test.rs +++ b/tests/ui-toml/toml_trivially_copy/test.rs @@ -1,4 +1,5 @@ -#![allow(many_single_char_names)] +#![feature(tool_lints)] +#![allow(clippy::many_single_char_names)] #[derive(Copy, Clone)] struct Foo(u8); diff --git a/tests/ui-toml/toml_trivially_copy/test.stderr b/tests/ui-toml/toml_trivially_copy/test.stderr index 2d36c47c5da..cf2f15a68e6 100644 --- a/tests/ui-toml/toml_trivially_copy/test.stderr +++ b/tests/ui-toml/toml_trivially_copy/test.stderr @@ -1,15 +1,15 @@ error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/test.rs:12:11 + --> $DIR/test.rs:13:11 | -12 | fn bad(x: &u16, y: &Foo) { +13 | fn bad(x: &u16, y: &Foo) { | ^^^^ help: consider passing by value instead: `u16` | - = note: `-D trivially-copy-pass-by-ref` implied by `-D warnings` + = note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/test.rs:12:20 + --> $DIR/test.rs:13:20 | -12 | fn bad(x: &u16, y: &Foo) { +13 | fn bad(x: &u16, y: &Foo) { | ^^^^ help: consider passing by value instead: `Foo` error: aborting due to 2 previous errors From f3bb161f0e634f45ce1c189baaf0d3d6cc651cec Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Wed, 1 Aug 2018 22:48:41 +0200 Subject: [PATCH 46/53] Adapt codebase to the tool_lints --- clippy_lints/src/assign_ops.rs | 2 +- clippy_lints/src/booleans.rs | 6 +++--- clippy_lints/src/consts.rs | 3 +-- clippy_lints/src/cyclomatic_complexity.rs | 4 ++-- clippy_lints/src/doc.rs | 2 +- clippy_lints/src/enum_clike.rs | 2 +- clippy_lints/src/enum_variants.rs | 2 +- clippy_lints/src/eq_op.rs | 2 +- clippy_lints/src/identity_op.rs | 2 +- clippy_lints/src/int_plus_one.rs | 2 +- clippy_lints/src/lib.rs | 5 +++-- clippy_lints/src/methods.rs | 4 ++-- clippy_lints/src/neg_multiply.rs | 2 +- clippy_lints/src/types.rs | 4 ++-- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/comparisons.rs | 2 +- clippy_lints/src/utils/conf.rs | 2 +- clippy_lints/src/utils/constants.rs | 2 +- clippy_lints/src/utils/higher.rs | 2 +- clippy_lints/src/utils/hir_utils.rs | 2 +- clippy_lints/src/utils/inspector.rs | 2 +- clippy_lints/src/utils/sugg.rs | 6 ++---- src/driver.rs | 5 +++-- src/lib.rs | 3 ++- src/main.rs | 7 ++++--- 25 files changed, 39 insertions(+), 38 deletions(-) diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 5a27f6a2c36..9a1808345a5 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -108,7 +108,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { }, hir::ExprKind::Assign(ref assignee, ref e) => { if let hir::ExprKind::Binary(op, ref l, ref r) = e.node { - #[allow(cyclomatic_complexity)] + #[allow(clippy::cyclomatic_complexity)] let lint = |assignee: &hir::Expr, rhs: &hir::Expr| { let ty = cx.tables.expr_ty(assignee); let rty = cx.tables.expr_ty(rhs); diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index f867dc56c3c..3d3fa7b5e73 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -118,7 +118,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { } for (n, expr) in self.terminals.iter().enumerate() { if SpanlessEq::new(self.cx).ignore_fn().eq_expr(e, expr) { - #[allow(cast_possible_truncation)] + #[allow(clippy::cast_possible_truncation)] return Ok(Bool::Term(n as u8)); } let negated = match e.node { @@ -150,14 +150,14 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { _ => continue, }; if SpanlessEq::new(self.cx).ignore_fn().eq_expr(&negated, expr) { - #[allow(cast_possible_truncation)] + #[allow(clippy::cast_possible_truncation)] return Ok(Bool::Not(Box::new(Bool::Term(n as u8)))); } } let n = self.terminals.len(); self.terminals.push(e); if n < 32 { - #[allow(cast_possible_truncation)] + #[allow(clippy::cast_possible_truncation)] Ok(Bool::Term(n as u8)) } else { Err("too many literals".to_owned()) diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index ff189d6e893..b126215c049 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -1,5 +1,4 @@ -#![allow(cast_possible_truncation)] -#![allow(float_cmp)] +#![allow(clippy::float_cmp)] use rustc::lint::LateContext; use rustc::{span_bug, bug}; diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index 6195db7b482..c975e31cec9 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -186,7 +186,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CCHelper<'a, 'tcx> { } #[cfg(feature = "debugging")] -#[allow(too_many_arguments)] +#[allow(clippy::too_many_arguments)] fn report_cc_bug(_: &LateContext<'_, '_>, cc: u64, narms: u64, div: u64, shorts: u64, returns: u64, span: Span, _: NodeId) { span_bug!( span, @@ -200,7 +200,7 @@ fn report_cc_bug(_: &LateContext<'_, '_>, cc: u64, narms: u64, div: u64, shorts: ); } #[cfg(not(feature = "debugging"))] -#[allow(too_many_arguments)] +#[allow(clippy::too_many_arguments)] fn report_cc_bug(cx: &LateContext<'_, '_>, cc: u64, narms: u64, div: u64, shorts: u64, returns: u64, span: Span, id: NodeId) { if !is_allowed(cx, CYCLOMATIC_COMPLEXITY, id) { cx.sess().span_note_without_error( diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 2db950b3365..4d603570ebe 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -86,7 +86,7 @@ impl<'a> Iterator for Parser<'a> { /// `syntax::parse::lexer::comments::strip_doc_comment_decoration` because we /// need to keep track of /// the spans but this function is inspired from the later. -#[allow(cast_possible_truncation)] +#[allow(clippy::cast_possible_truncation)] pub fn strip_doc_comment_decoration(comment: &str, span: Span) -> (String, Vec<(usize, Span)>) { // one-line comments lose their prefix const ONELINERS: &[&str] = &["///!", "///", "//!", "//"]; diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index 3a7f884b784..0271fee8a3c 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -43,7 +43,7 @@ impl LintPass for UnportableVariant { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant { - #[allow(cast_possible_truncation, cast_sign_loss)] + #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { if cx.tcx.data_layout.pointer_size.bits() != 64 { return; diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index 85b133cbd03..56b99aa9449 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -147,7 +147,7 @@ fn partial_rmatch(post: &str, name: &str) -> usize { } // FIXME: #600 -#[allow(while_let_on_iterator)] +#[allow(clippy::while_let_on_iterator)] fn check_variant( cx: &EarlyContext<'_>, threshold: u64, diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index de1b5b77e6e..b6b34204480 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp { BinOpKind::Lt | BinOpKind::Le | BinOpKind::Ge | BinOpKind::Gt => (cx.tcx.lang_items().ord_trait(), true), }; if let Some(trait_id) = trait_id { - #[allow(match_same_arms)] + #[allow(clippy::match_same_arms)] match (&left.node, &right.node) { // do not suggest to dereference literals (&ExprKind::Lit(..), _) | (_, &ExprKind::Lit(..)) => {}, diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index bb3741088cf..052275d7a45 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityOp { } } -#[allow(cast_possible_wrap)] +#[allow(clippy::cast_possible_wrap)] fn check(cx: &LateContext<'_, '_>, e: &Expr, m: i8, span: Span, arg: Span) { if let Some(Constant::Int(v)) = constant_simple(cx, cx.tables, e) { let check = match cx.tables.expr_ty(e).sty { diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index b640eff2c5d..f94461b75a5 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -53,7 +53,7 @@ enum Side { } impl IntPlusOne { - #[allow(cast_sign_loss)] + #[allow(clippy::cast_sign_loss)] fn check_lit(&self, lit: &Lit, target_value: i128) -> bool { if let LitKind::Int(value, ..) = lit.node { return value == (target_value as u128); diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 32c3dca6357..f1a89c3d46b 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -5,9 +5,10 @@ #![feature(slice_patterns)] #![feature(stmt_expr_attributes)] #![feature(range_contains)] -#![allow(unknown_lints, shadow_reuse, missing_docs_in_private_items)] +#![allow(unknown_lints, clippy::shadow_reuse, clippy::missing_docs_in_private_items)] #![recursion_limit = "256"] #![feature(macro_at_most_once_rep)] +#![feature(tool_lints)] #![warn(rust_2018_idioms)] use toml; @@ -933,7 +934,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { // only exists to let the dogfood integration test works. // Don't run clippy as an executable directly -#[allow(dead_code, print_stdout)] +#[allow(dead_code, clippy::print_stdout)] fn main() { panic!("Please use the cargo-clippy executable"); } diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 4f6cb64dd4f..f428a498b4d 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -714,7 +714,7 @@ impl LintPass for Pass { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { - #[allow(cyclomatic_complexity)] + #[allow(clippy::cyclomatic_complexity)] fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) { if in_macro(expr.span) { return; @@ -922,7 +922,7 @@ fn lint_or_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span: Spa } /// Check for `*or(foo())`. - #[allow(too_many_arguments)] + #[allow(clippy::too_many_arguments)] fn check_general_case( cx: &LateContext<'_, '_>, name: &str, diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index 8df33b1e99a..93a83fe97ba 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -32,7 +32,7 @@ impl LintPass for NegMultiply { } } -#[allow(match_same_arms)] +#[allow(clippy::match_same_arms)] impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NegMultiply { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) { if let ExprKind::Binary(Spanned { node: BinOpKind::Mul, .. }, ref l, ref r) = e.node { diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 81842421fa3..400a06c061e 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -1525,7 +1525,7 @@ enum FullInt { } impl FullInt { - #[allow(cast_sign_loss)] + #[allow(clippy::cast_sign_loss)] fn cmp_s_u(s: i128, u: u128) -> Ordering { if s < 0 { Ordering::Less @@ -1744,7 +1744,7 @@ impl LintPass for ImplicitHasher { } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher { - #[allow(cast_possible_truncation)] + #[allow(clippy::cast_possible_truncation)] fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { use syntax_pos::BytePos; diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index fe8123d288d..fb131b9086a 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -1,7 +1,7 @@ //! A group of attributes that can be attached to Rust code in order //! to generate a clippy lint detecting said code automatically. -#![allow(print_stdout, use_debug)] +#![allow(clippy::print_stdout, clippy::use_debug)] use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::{declare_tool_lint, lint_array}; diff --git a/clippy_lints/src/utils/comparisons.rs b/clippy_lints/src/utils/comparisons.rs index 35f41d400ad..31e20f37e20 100644 --- a/clippy_lints/src/utils/comparisons.rs +++ b/clippy_lints/src/utils/comparisons.rs @@ -1,6 +1,6 @@ //! Utility functions about comparison operators. -#![deny(missing_docs_in_private_items)] +#![deny(clippy::missing_docs_in_private_items)] use rustc::hir::{BinOpKind, Expr}; diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index 1567bd9ffb6..47b71ae524f 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -1,6 +1,6 @@ //! Read configurations files. -#![deny(missing_docs_in_private_items)] +#![deny(clippy::missing_docs_in_private_items)] use lazy_static::lazy_static; use std::{env, fmt, fs, io, path}; diff --git a/clippy_lints/src/utils/constants.rs b/clippy_lints/src/utils/constants.rs index f59716268a0..b63be9b86c8 100644 --- a/clippy_lints/src/utils/constants.rs +++ b/clippy_lints/src/utils/constants.rs @@ -1,6 +1,6 @@ //! This module contains some useful constants. -#![deny(missing_docs_in_private_items)] +#![deny(clippy::missing_docs_in_private_items)] /// List of the built-in types names. /// diff --git a/clippy_lints/src/utils/higher.rs b/clippy_lints/src/utils/higher.rs index 65d58c4e55b..42b37568a99 100644 --- a/clippy_lints/src/utils/higher.rs +++ b/clippy_lints/src/utils/higher.rs @@ -1,7 +1,7 @@ //! This module contains functions for retrieve the original AST from lowered //! `hir`. -#![deny(missing_docs_in_private_items)] +#![deny(clippy::missing_docs_in_private_items)] use if_chain::if_chain; use rustc::{hir, ty}; diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 30c6db977f7..93d73ca707e 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -364,7 +364,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { }.hash(&mut self.s); } - #[allow(many_single_char_names)] + #[allow(clippy::many_single_char_names)] pub fn hash_expr(&mut self, e: &Expr) { if let Some(e) = constant_simple(self.cx, self.tables, e) { return e.hash(&mut self.s); diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 12b4f55e432..b9a0435eb35 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -1,4 +1,4 @@ -#![allow(print_stdout, use_debug)] +#![allow(clippy::print_stdout, clippy::use_debug)] //! checks for attributes diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index 3d587a72eec..4239b24d817 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -1,7 +1,5 @@ //! Contains utility functions to generate suggestions. -#![deny(missing_docs_in_private_items)] -// currently ignores lifetimes and generics -#![allow(use_self)] +#![deny(clippy::missing_docs_in_private_items)] use matches::matches; use rustc::hir; @@ -40,7 +38,7 @@ impl Display for Sugg<'_> { } } -#[allow(wrong_self_convention)] // ok, because of the function `as_ty` method +#[allow(clippy::wrong_self_convention)] // ok, because of the function `as_ty` method impl<'a> Sugg<'a> { /// Prepare a suggestion from an expression. pub fn hir_opt(cx: &LateContext<'_, '_>, expr: &hir::Expr) -> Option { diff --git a/src/driver.rs b/src/driver.rs index 6854ccbbddc..6885c2aed2b 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -1,13 +1,14 @@ // error-pattern:yummy #![feature(box_syntax)] #![feature(rustc_private)] -#![allow(unknown_lints, missing_docs_in_private_items)] +#![feature(tool_lints)] +#![allow(unknown_lints, clippy::missing_docs_in_private_items)] use rustc_driver::{self, driver::CompileController, Compilation}; use rustc_plugin; use std::process::{exit, Command}; -#[allow(print_stdout)] +#[allow(clippy::print_stdout)] fn show_version() { println!(env!("CARGO_PKG_VERSION")); } diff --git a/src/lib.rs b/src/lib.rs index 1525dbda4ee..a7167ac10de 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,9 @@ // error-pattern:cargo-clippy #![feature(plugin_registrar)] #![feature(rustc_private)] +#![feature(tool_lints)] #![allow(unknown_lints)] -#![allow(missing_docs_in_private_items)] +#![allow(clippy::missing_docs_in_private_items)] #![warn(rust_2018_idioms)] use rustc_plugin::Registry; diff --git a/src/main.rs b/src/main.rs index 057a585e3d7..12c07f60a11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,8 @@ // error-pattern:yummy #![feature(box_syntax)] #![feature(rustc_private)] -#![allow(unknown_lints, missing_docs_in_private_items)] +#![feature(tool_lints)] +#![allow(unknown_lints, clippy::missing_docs_in_private_items)] const CARGO_CLIPPY_HELP: &str = r#"Checks a package to catch common mistakes and improve your Rust code. @@ -28,12 +29,12 @@ it to allow or deny lints from the code, eg.: #[cfg_attr(feature = "cargo-clippy", allow(needless_lifetimes))] "#; -#[allow(print_stdout)] +#[allow(clippy::print_stdout)] fn show_help() { println!("{}", CARGO_CLIPPY_HELP); } -#[allow(print_stdout)] +#[allow(clippy::print_stdout)] fn show_version() { println!(env!("CARGO_PKG_VERSION")); } From d1f2f0c34cd6062bc43e88f11b06369e08af4af6 Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Tue, 28 Aug 2018 11:27:17 +0200 Subject: [PATCH 47/53] Fix some rebase fallout --- clippy_lints/src/copy_iterator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/copy_iterator.rs b/clippy_lints/src/copy_iterator.rs index 031b088bf9e..596e83bc539 100644 --- a/clippy_lints/src/copy_iterator.rs +++ b/clippy_lints/src/copy_iterator.rs @@ -1,7 +1,7 @@ use crate::utils::{is_copy, match_path, paths, span_note_and_lint}; use rustc::hir::{Item, ItemKind}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; -use rustc::{declare_lint, lint_array}; +use rustc::{declare_tool_lint, lint_array}; /// **What it does:** Checks for types that implement `Copy` as well as /// `Iterator`. From daa4f0ad34f79a91a6ae27fec6d56dd95e6feac2 Mon Sep 17 00:00:00 2001 From: flip1995 <9744647+flip1995@users.noreply.github.com> Date: Tue, 28 Aug 2018 14:16:31 +0200 Subject: [PATCH 48/53] Implement backwards compatibility changes introduced by rust-lang/rust#53762 --- clippy_lints/src/lib.rs | 20 ++++++++++---------- src/driver.rs | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index f1a89c3d46b..19d31d6fc0f 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -412,7 +412,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { reg.register_late_lint_pass(box non_copy_const::NonCopyConst); reg.register_late_lint_pass(box ptr_offset_with_cast::Pass); - reg.register_lint_group("clippy::restriction", vec![ + reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![ arithmetic::FLOAT_ARITHMETIC, arithmetic::INTEGER_ARITHMETIC, else_if_without_else::ELSE_IF_WITHOUT_ELSE, @@ -435,7 +435,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { write::USE_DEBUG, ]); - reg.register_lint_group("clippy::pedantic", vec![ + reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![ attrs::INLINE_ALWAYS, copies::MATCH_SAME_ARMS, copy_iterator::COPY_ITERATOR, @@ -473,13 +473,13 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { use_self::USE_SELF, ]); - reg.register_lint_group("clippy::internal", vec![ + reg.register_lint_group("clippy::internal", Some("clippy_internal"), vec![ utils::internal_lints::CLIPPY_LINTS_INTERNAL, utils::internal_lints::LINT_WITHOUT_LINT_PASS, utils::internal_lints::DEFAULT_HASH_TYPES, ]); - reg.register_lint_group("clippy::all", vec![ + reg.register_lint_group("clippy::all", Some("clippy"), vec![ approx_const::APPROX_CONSTANT, assign_ops::ASSIGN_OP_PATTERN, assign_ops::MISREFACTORED_ASSIGN_OP, @@ -694,7 +694,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { zero_div_zero::ZERO_DIVIDED_BY_ZERO, ]); - reg.register_lint_group("clippy::style", vec![ + reg.register_lint_group("clippy::style", Some("clippy_style"), vec![ assign_ops::ASSIGN_OP_PATTERN, bit_mask::VERBOSE_BIT_MASK, blacklisted_name::BLACKLISTED_NAME, @@ -778,7 +778,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { write::WRITELN_EMPTY_STRING, ]); - reg.register_lint_group("clippy::complexity", vec![ + reg.register_lint_group("clippy::complexity", Some("clippy_complexity"), vec![ assign_ops::MISREFACTORED_ASSIGN_OP, booleans::NONMINIMAL_BOOL, cyclomatic_complexity::CYCLOMATIC_COMPLEXITY, @@ -846,7 +846,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { zero_div_zero::ZERO_DIVIDED_BY_ZERO, ]); - reg.register_lint_group("clippy::correctness", vec![ + reg.register_lint_group("clippy::correctness", Some("clippy_correctness"), vec![ approx_const::APPROX_CONSTANT, attrs::DEPRECATED_SEMVER, attrs::USELESS_ATTRIBUTE, @@ -900,7 +900,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { unused_io_amount::UNUSED_IO_AMOUNT, ]); - reg.register_lint_group("clippy::perf", vec![ + reg.register_lint_group("clippy::perf", Some("clippy_perf"), vec![ bytecount::NAIVE_BYTECOUNT, entry::MAP_ENTRY, escape::BOXED_LOCAL, @@ -918,11 +918,11 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) { vec::USELESS_VEC, ]); - reg.register_lint_group("clippy::cargo", vec![ + reg.register_lint_group("clippy::cargo", Some("clippy_cargo"), vec![ multiple_crate_versions::MULTIPLE_CRATE_VERSIONS, ]); - reg.register_lint_group("clippy::nursery", vec![ + reg.register_lint_group("clippy::nursery", Some("clippy_nursery"), vec![ attrs::EMPTY_LINE_AFTER_OUTER_ATTR, fallible_impl_from::FALLIBLE_IMPL_FROM, mutex_atomic::MUTEX_INTEGER, diff --git a/src/driver.rs b/src/driver.rs index 6885c2aed2b..26ff846177b 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -119,8 +119,8 @@ pub fn main() { ls.register_late_pass(Some(sess), true, pass); } - for (name, to) in lint_groups { - ls.register_group(Some(sess), true, name, to); + for (name, (to, deprecated_name)) in lint_groups { + ls.register_group(Some(sess), true, name, deprecated_name, to); } clippy_lints::register_pre_expansion_lints(sess, &mut ls, &conf); From 559b2f871f9907eab4be3cc58e118ff37a5468d0 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Thu, 30 Aug 2018 07:33:53 +0200 Subject: [PATCH 49/53] Remove git diffing part Because we no bump versions --- pre_publish.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pre_publish.sh b/pre_publish.sh index d8a9105c67e..3602f671e3d 100755 --- a/pre_publish.sh +++ b/pre_publish.sh @@ -4,13 +4,6 @@ set -e ./util/update_lints.py -git status --short | sort | grep -v README.md | grep -v helper.txt | sort > helper.txt - -# abort if the files differ -diff "publish.files" "helper.txt" - -rm helper.txt - # add all changed files git add . git commit -m "Bump the version" From daacac6b9700bc581c0aced4c4f17b30aa01d15d Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Fri, 31 Aug 2018 06:10:30 +0200 Subject: [PATCH 50/53] Revert "fix-3078: verify test case" This reverts commit 6256ad05bac1f708298f827fdfa7b54042961294. --- clippy_lints/src/non_expressive_names.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index f92538cd097..daccc4bde03 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -114,11 +114,9 @@ impl<'a, 'tcx: 'a, 'b> Visitor<'tcx> for SimilarNamesNameVisitor<'a, 'tcx, 'b> { _ => walk_pat(self, pat), } } - /* fn visit_mac(&mut self, _mac: &Mac) { // do not check macs } - */ } fn get_whitelist(interned_name: &str) -> Option<&'static [&'static str]> { From 20dfaf7842f239b513e577542314ded27b5aacc3 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 31 Aug 2018 00:34:48 -0700 Subject: [PATCH 51/53] declare_lint -> declare_tool_lint --- clippy_lints/src/ptr_offset_with_cast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 9f475473c61..250a11dab88 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -1,4 +1,4 @@ -use rustc::{declare_lint, hir, lint, lint_array}; +use rustc::{declare_tool_lint, hir, lint, lint_array}; use crate::utils; use std::fmt; From 9abf6fca9c7288cb3bb99c0f7627f94b7930ee98 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 31 Aug 2018 00:38:27 -0700 Subject: [PATCH 52/53] Fix ptr offset tests --- tests/ui/ptr_offset_with_cast.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/ptr_offset_with_cast.stderr b/tests/ui/ptr_offset_with_cast.stderr index 16bbf328b33..214a39cdc11 100644 --- a/tests/ui/ptr_offset_with_cast.stderr +++ b/tests/ui/ptr_offset_with_cast.stderr @@ -4,7 +4,7 @@ error: use of `offset` with a `usize` casted to an `isize` 10 | ptr.offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)` | - = note: `-D ptr-offset-with-cast` implied by `-D warnings` + = note: `-D clippy::ptr-offset-with-cast` implied by `-D warnings` error: use of `wrapping_offset` with a `usize` casted to an `isize` --> $DIR/ptr_offset_with_cast.rs:14:9 From 19157c02cb25fa2e1e2995793f4b7da5ef107317 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Sun, 2 Sep 2018 09:38:25 +0200 Subject: [PATCH 53/53] Fix #3112 --- clippy_lints/src/eval_order_dependence.rs | 4 +++- clippy_lints/src/shadow.rs | 4 +++- clippy_lints/src/utils/author.rs | 12 +++++++++--- clippy_lints/src/utils/hir_utils.rs | 20 ++++++++++++++++++-- clippy_lints/src/utils/inspector.rs | 13 ++++++++++++- 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 72abbddf141..e3ae5607645 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -109,7 +109,9 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> { self.visit_expr(e); for arm in arms { if let Some(ref guard) = arm.guard { - self.visit_expr(guard); + match guard { + Guard::If(if_expr) => self.visit_expr(if_expr), + } } // make sure top level arm expressions aren't linted self.maybe_walk_expr(&*arm.body); diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index d552c01679a..1191723ba62 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -339,7 +339,9 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, bindings: check_pat(cx, pat, Some(&**init), pat.span, bindings); // This is ugly, but needed to get the right type if let Some(ref guard) = arm.guard { - check_expr(cx, guard, bindings); + match guard { + Guard::If(if_expr) => check_expr(cx, if_expr, bindings), + } } check_expr(cx, &arm.body, bindings); bindings.truncate(len); diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index fb131b9086a..e2c809c0c7c 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -345,9 +345,15 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { self.visit_expr(&arm.body); if let Some(ref guard) = arm.guard { let guard_pat = self.next("guard"); - println!(" if let Some(ref {}) = {}[{}].guard", guard_pat, arms_pat, i); - self.current = guard_pat; - self.visit_expr(guard); + println!(" if let Some(ref {}) = {}[{}].guard;", guard_pat, arms_pat, i); + match guard { + hir::Guard::If(ref if_expr) => { + let if_expr_pat = self.next("expr"); + println!(" if let Guard::If(ref {}) = {};", if_expr_pat, guard_pat); + self.current = if_expr_pat; + self.visit_expr(if_expr); + } + } } println!(" if {}[{}].pats.len() == {};", arms_pat, i, arm.pats.len()); for (j, pat) in arm.pats.iter().enumerate() { diff --git a/clippy_lints/src/utils/hir_utils.rs b/clippy_lints/src/utils/hir_utils.rs index 93d73ca707e..939b4f595e4 100644 --- a/clippy_lints/src/utils/hir_utils.rs +++ b/clippy_lints/src/utils/hir_utils.rs @@ -113,7 +113,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { }, (&ExprKind::Match(ref le, ref la, ref ls), &ExprKind::Match(ref re, ref ra, ref rs)) => { ls == rs && self.eq_expr(le, re) && over(la, ra, |l, r| { - self.eq_expr(&l.body, &r.body) && both(&l.guard, &r.guard, |l, r| self.eq_expr(l, r)) + self.eq_expr(&l.body, &r.body) && both(&l.guard, &r.guard, |l, r| self.eq_guard(l, r)) && over(&l.pats, &r.pats, |l, r| self.eq_pat(l, r)) }) }, @@ -152,6 +152,12 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> { left.ident.name == right.ident.name && self.eq_expr(&left.expr, &right.expr) } + fn eq_guard(&mut self, left: &Guard, right: &Guard) -> bool { + match (left, right) { + (Guard::If(l), Guard::If(r)) => self.eq_expr(l, r), + } + } + fn eq_generic_arg(&mut self, left: &GenericArg, right: &GenericArg) -> bool { match (left, right) { (GenericArg::Lifetime(l_lt), GenericArg::Lifetime(r_lt)) => self.eq_lifetime(l_lt, r_lt), @@ -497,7 +503,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { for arm in arms { // TODO: arm.pat? if let Some(ref e) = arm.guard { - self.hash_expr(e); + self.hash_guard(e); } self.hash_expr(&arm.body); } @@ -637,4 +643,14 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> { }, } } + + pub fn hash_guard(&mut self, g: &Guard) { + match g { + Guard::If(ref expr) => { + let c: fn(_) -> _ = Guard::If; + c.hash(&mut self.s); + self.hash_expr(expr); + } + } + } } diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index b9a0435eb35..56b76fdc7b0 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -113,7 +113,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { } if let Some(ref guard) = arm.guard { println!("guard:"); - print_expr(cx, guard, 1); + print_guard(cx, guard, 1); } println!("body:"); print_expr(cx, &arm.body, 1); @@ -515,3 +515,14 @@ fn print_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat, indent: usize) { }, } } + +fn print_guard(cx: &LateContext<'_, '_>, guard: &hir::Guard, indent: usize) { + let ind = " ".repeat(indent); + println!("{}+", ind); + match guard { + hir::Guard::If(expr) => { + println!("{}If", ind); + print_expr(cx, expr, indent + 1); + } + } +}