diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 232752c20..3d1385244 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, // ... @@ -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/README.md b/README.md index 41eacdba1..98f712c28 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 diff --git a/ci/base-tests.sh b/ci/base-tests.sh index 13b652c0f..f7c3342fe 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/approx_const.rs b/clippy_lints/src/approx_const.rs index cd2444ff3..99b9e7946 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 90f72d3d1..fa48b2b55 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 7d4f4e7cb..9a1808345 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -2,8 +2,8 @@ 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::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::ast; @@ -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); @@ -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 9804d3a0f..034c2cc24 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -6,8 +6,8 @@ use crate::utils::{ without_block_comments, }; use rustc::hir::*; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 12de4faa7..ecac7f825 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 cfec01d14..97749e6f9 100644 --- a/clippy_lints/src/blacklisted_name.rs +++ b/clippy_lints/src/blacklisted_name.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 f57a3571b..752d640fa 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 eda6a045c..3d3fa7b5e 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}; @@ -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/bytecount.rs b/clippy_lints/src/bytecount.rs index 6d086c13f..ddc017c27 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -1,6 +1,6 @@ use rustc::hir::*; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 2771006aa..55cc94f39 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -12,8 +12,8 @@ //! //! This lint is **warn** by default -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +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 1af0741d6..83dd4c050 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/consts.rs b/clippy_lints/src/consts.rs index ff189d6e8..6f646e340 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}; @@ -16,22 +15,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/copies.rs b/clippy_lints/src/copies.rs index 49518d1bb..8f1823be1 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty::Ty; use rustc::hir::*; use std::collections::HashMap; diff --git a/clippy_lints/src/copy_iterator.rs b/clippy_lints/src/copy_iterator.rs index ac0c2ed32..596e83bc5 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; /// **What it does:** Checks for types that implement `Copy` as well as /// `Iterator`. diff --git a/clippy_lints/src/cyclomatic_complexity.rs b/clippy_lints/src/cyclomatic_complexity.rs index 93074eadd..c975e31ce 100644 --- a/clippy_lints/src/cyclomatic_complexity.rs +++ b/clippy_lints/src/cyclomatic_complexity.rs @@ -1,8 +1,8 @@ //! calculate cyclomatic complexity and warn about overly complex functions use rustc::cfg::CFG; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, LintContext}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use rustc::ty; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; @@ -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/default_trait_access.rs b/clippy_lints/src/default_trait_access.rs index c8c4d6cb8..e7c90f041 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 e3abfe938..2a26cca21 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 12128eda2..4d603570e 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast; use syntax::source_map::{BytePos, Span}; use syntax_pos::Pos; @@ -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/double_comparison.rs b/clippy_lints/src/double_comparison.rs index 013a75e64..1f38be4d7 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -1,8 +1,8 @@ //! Lint on unnecessary double comparisons. Some examples: use rustc::hir::*; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 abd566638..42d6720d9 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 1e6189e38..be804780f 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 ef5d18f08..5853983dc 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 39404bbaf..1c026713a 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; +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 f95ae32d5..195a78a89 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 142a099f5..8a2fcbaea 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 2551f624c..0271fee8a 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -1,8 +1,8 @@ //! 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::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use rustc::ty; use rustc::ty::subst::Substs; @@ -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_glob_use.rs b/clippy_lints/src/enum_glob_use.rs index 90cc1716c..042a4765e 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 ca38d497d..56b99aa94 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, Lint}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use syntax::source_map::Span; use syntax::symbol::LocalInternedString; @@ -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 dfbc3b126..b6b342044 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 @@ -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/erasing_op.rs b/clippy_lints/src/erasing_op.rs index 297670042..5b61a9fd8 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 2cd2a46cb..282149f81 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -1,8 +1,7 @@ use rustc::hir::*; use rustc::hir::intravisit as visit; -use rustc::hir::map::Node::{NodeExpr, NodeStmt}; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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}; @@ -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 260cca76c..c4ffc70db 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 9ddc3ddbf..e3ae56076 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -1,8 +1,8 @@ use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc::hir::*; use rustc::ty; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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}; @@ -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); @@ -189,9 +191,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 52af7e129..e5809371e 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 22e6834ee..77c6c1a4a 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 22f6df655..88eb88031 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 4f83caa43..c10d55466 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -1,6 +1,6 @@ use rustc::hir::*; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 60001c792..8b20aeed1 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +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 b86e33321..c170b0a1e 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -1,8 +1,8 @@ use matches::matches; use rustc::hir::intravisit; use rustc::hir; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use rustc::ty; use rustc::hir::def::Def; use std::collections::HashSet; @@ -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 1909f2f8f..6adf2cd68 100644 --- a/clippy_lints/src/identity_conversion.rs +++ b/clippy_lints/src/identity_conversion.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 31e955dc5..052275d7a 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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; @@ -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/if_let_redundant_pattern_matching.rs b/clippy_lints/src/if_let_redundant_pattern_matching.rs index bc97584a2..253d29556 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 fea3069f3..3bfde1fd2 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -1,8 +1,8 @@ //! lint on if branches that could be swapped so no `!` operation is necessary //! on the condition -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; +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 9ec9c9f83..bca4844aa 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -5,8 +5,8 @@ use crate::utils; use crate::utils::higher; use crate::utils::higher::Range; use rustc::hir::*; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 8b8cb32de..208f2ec53 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 eaa93cb62..bb33c48fc 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 fc06af815..4ca812e56 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::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_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 70f88a76f..4dcc4ed47 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 9b6fc579a..f94461b75 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use syntax::ast::*; use crate::utils::{snippet_opt, span_lint_and_then}; @@ -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/invalid_ref.rs b/clippy_lints/src/invalid_ref.rs index 9c7d4626e..34a8939e1 100644 --- a/clippy_lints/src/invalid_ref.rs +++ b/clippy_lints/src/invalid_ref.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 07ef086d6..9fe70882c 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -1,8 +1,8 @@ //! lint when items are used after statements use matches::matches; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +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 2c03b6b5f..63201bb2e 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 2fb4c691c..4c9c21982 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 57ca5eff9..8b4e2b0de 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 84db58b89..adc4f76fe 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; @@ -17,40 +18,40 @@ 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_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 } + 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 } + 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 } + 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 } + 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 } + 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 } + 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 } + 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 } + 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 } + declare_tool_lint! { pub clippy::$name, Warn, $description, report_in_external_macro: true } }; } -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; @@ -142,6 +143,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,8 +410,9 @@ 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![ + reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![ arithmetic::FLOAT_ARITHMETIC, arithmetic::INTEGER_ARITHMETIC, else_if_without_else::ELSE_IF_WITHOUT_ELSE, @@ -432,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, @@ -470,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", vec![ + reg.register_lint_group("clippy::all", Some("clippy"), vec![ approx_const::APPROX_CONSTANT, assign_ops::ASSIGN_OP_PATTERN, assign_ops::MISREFACTORED_ASSIGN_OP, @@ -631,6 +634,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, @@ -690,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, @@ -774,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, @@ -815,6 +819,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, @@ -841,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, @@ -895,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, @@ -913,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, @@ -929,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/lifetimes.rs b/clippy_lints/src/lifetimes.rs index d8e6a43f8..beec9bac9 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; +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 45f9af49a..dcffba80b 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -1,8 +1,8 @@ //! Lints concerned with the grouping of digits with underscores in integral or //! floating-point literal expressions. -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; +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 973b70680..51e6327e7 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -4,9 +4,8 @@ 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::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::middle::region; // use rustc::middle::region::CodeExtent; @@ -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 c570f0b32..1a501b39e 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 eff00896c..90f149a1c 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 691d61f55..3ecf5d3b5 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -1,6 +1,6 @@ use rustc::hir::*; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; +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 80130de15..8a56dccad 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 1c31c414d..f428a498b 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, Lint, LintContext}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty}; use rustc::hir::def::Def; @@ -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, @@ -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 bc573841c..bbbc022f0 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -1,8 +1,8 @@ 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::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 a43c60f11..302af1363 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -2,8 +2,8 @@ use crate::reexport::*; use matches::matches; use rustc::hir::*; use rustc::hir::intravisit::FnKind; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty; use syntax::source_map::{ExpnFormat, Span}; @@ -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 6c82fa58e..c00b3d93c 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, LintContext, in_external_macro}; +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 9735799d1..f56a8fcd8 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::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, LintContext}; +use rustc::{declare_tool_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 8e2b08b51..bf88caa6a 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::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_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 d42460455..a2ed6a1de 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::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +use rustc::{declare_tool_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 d85612410..ea3d68dfc 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; +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 02a80a19e..97287aa83 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 8b56526f4..cb400ee4e 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 19d860dab..5b9a479c1 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -2,8 +2,8 @@ //! //! This lint is **warn** by default -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 ae931e583..a194cb2c6 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -2,8 +2,8 @@ //! //! This lint is **warn** by default -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 1679a9007..4905dbc8e 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -2,8 +2,8 @@ //! //! This lint is **warn** by default -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 0c9b35403..e14cd0fea 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -27,8 +27,8 @@ //! ``` //! //! This lint is **warn** by default. -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +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 c93cda557..340fa4d0e 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -1,9 +1,8 @@ use matches::matches; use rustc::hir::*; -use rustc::hir::map::*; use rustc::hir::intravisit::FnKind; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, RegionKind, TypeFoldable}; use rustc::traits; @@ -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/needless_update.rs b/clippy_lints/src/needless_update.rs index 90a1ee14a..dccb7f2e0 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 f53e2cb0c..db61ea375 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use crate::utils::{self, paths, span_lint}; @@ -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 2b0c021ea..93a83fe97 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use syntax::source_map::{Span, Spanned}; @@ -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/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 820e76f88..493e8d0f4 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; +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 cacb5d6a9..09a273307 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 119b4c2d8..deb088d3e 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}; @@ -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 acfa341ed..5e106cac9 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LintArray, LintPass, EarlyContext, EarlyLintPass}; +use rustc::{declare_tool_lint, lint_array}; use syntax::source_map::Span; use syntax::symbol::LocalInternedString; use syntax::ast::*; @@ -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/clippy_lints/src/ok_if_let.rs b/clippy_lints/src/ok_if_let.rs index 2a7f71c71..651ed4411 100644 --- a/clippy_lints/src/ok_if_let.rs +++ b/clippy_lints/src/ok_if_let.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 ac399e238..b5459059e 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 5714bdb52..d33ef5e05 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 e603773f7..7a7fa3c45 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 675d014c5..8b2e5f9c3 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 c4e802ada..0978a6b7d 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +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 b040bd91f..94bbfb0e5 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -2,10 +2,9 @@ use std::borrow::Cow; use rustc::hir::*; -use rustc::hir::map::NodeItem; use rustc::hir::QPath; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty; use syntax::ast::NodeId; @@ -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/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs new file mode 100644 index 000000000..250a11dab --- /dev/null +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -0,0 +1,151 @@ +use rustc::{declare_tool_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`. +/// +/// **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, + complexity, + "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 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 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 = 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); + } + + } +} + +// 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 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, &'tcx hir::Expr, Method)> { + if let hir::ExprKind::MethodCall(ref path_segment, _, ref args) = expr.node { + 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 +} + +// 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) == cx.tcx.types.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 { + cx.tables.expr_ty(expr).is_unsafe_ptr() +} + +fn build_suggestion<'a, 'tcx>( + cx: &lint::LateContext<'a, 'tcx>, + method: Method, + receiver_expr: &hir::Expr, + cast_lhs_expr: &hir::Expr, +) -> Option { + 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)) +} + +#[derive(Copy, Clone)] +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"), + } + } +} diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index 630dd1b57..3134f14b1 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 ba25e50d7..95fd14162 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 ba8b11e55..579d2ad14 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +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 f349f46d9..98de89895 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +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 4553b08e7..6ac40c5a1 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 b9a4c6ebb..aaea8b6dd 100644 --- a/clippy_lints/src/replace_consts.rs +++ b/clippy_lints/src/replace_consts.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 8125cc415..ddc0a9719 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass, in_external_macro, LintContext}; +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 ce326ea72..0f09988c2 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 cc4aa1298..1191723ba 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -1,6 +1,6 @@ use crate::reexport::*; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir::*; use rustc::hir::intravisit::FnKind; use rustc::ty; @@ -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/strings.rs b/clippy_lints/src/strings.rs index d66163984..70d90a8fb 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -1,6 +1,6 @@ use rustc::hir::*; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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}; @@ -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. /// diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index b0a8a2d00..9f9b279a6 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir; use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; @@ -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 14c8e94d3..9ae6ec483 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 56e705ad0..cb9223029 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 28c5971e8..6e82bee27 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 d88a970db..70a93e7f7 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -3,10 +3,9 @@ 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 rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::TyKind; use rustc::session::config::Config as SessionConfig; @@ -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 024aba7e8..400a06c06 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -2,8 +2,8 @@ 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::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, in_external_macro, LintContext}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::ty::{self, Ty, TyCtxt, TypeckTables}; use rustc::ty::layout::LayoutOf; @@ -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 { @@ -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/unicode.rs b/clippy_lints/src/unicode.rs index 2768efca8..01c4cd83c 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 37a5836f1..7ef235e92 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +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 a9a7e102a..c5507fcac 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 04b4fcabd..71d9520c0 100644 --- a/clippy_lints/src/unused_label.rs +++ b/clippy_lints/src/unused_label.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 2a557ed8e..a1d24f643 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 eb2b4e801..550f88c89 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 431032547..e2c809c0c 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -1,10 +1,10 @@ //! 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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}; @@ -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/camel_case.rs b/clippy_lints/src/utils/camel_case.rs new file mode 100644 index 000000000..e8a8d510f --- /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/comparisons.rs b/clippy_lints/src/utils/comparisons.rs index 35f41d400..31e20f37e 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 1567bd9ff..a7e73d85c 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}; @@ -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/constants.rs b/clippy_lints/src/utils/constants.rs index f59716268..b63be9b86 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 65d58c4e5..42b37568a 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 57486b30d..939b4f595 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}; @@ -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), @@ -364,7 +370,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); @@ -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 b6c241a68..56b76fdc7 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -1,9 +1,9 @@ -#![allow(print_stdout, use_debug)] +#![allow(clippy::print_stdout, clippy::use_debug)] //! checks for attributes -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use rustc::hir; use rustc::hir::print; use syntax::ast::Attribute; @@ -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); + } + } +} diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index 6df41f1cd..7b2d2f159 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass, EarlyContext, EarlyLintPass}; +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/utils/mod.rs b/clippy_lints/src/utils/mod.rs index b753f8072..650ea373d 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; @@ -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]; @@ -309,9 +298,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 +453,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 +467,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 { @@ -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 4d89f8ddf..3c03645cc 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 3d587a72e..8efee6cd9 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 { @@ -177,6 +175,7 @@ impl<'a> Sugg<'a> { /// 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), diff --git a/clippy_lints/src/utils/usage.rs b/clippy_lints/src/utils/usage.rs index 95199b9f2..2661bc945 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 f86ce5ab7..4cbefc29b 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -1,6 +1,6 @@ use rustc::hir::*; -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +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 97fe12f23..5d3215723 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -1,5 +1,5 @@ -use rustc::lint::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; +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 7c8af7880..73c9e64d2 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::*; -use rustc::{declare_lint, lint_array}; +use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; +use rustc::{declare_tool_lint, lint_array}; use if_chain::if_chain; use rustc::hir::*; use crate::utils::span_help_and_lint; diff --git a/pre_publish.sh b/pre_publish.sh index aca17b968..3602f671e 100755 --- a/pre_publish.sh +++ b/pre_publish.sh @@ -4,20 +4,19 @@ 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" 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." diff --git a/src/driver.rs b/src/driver.rs index 6854ccbbd..26ff84617 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")); } @@ -118,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); diff --git a/src/lib.rs b/src/lib.rs index 1525dbda4..a7167ac10 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 057a585e3..12c07f60a 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")); } diff --git a/tests/camel_case.rs b/tests/camel_case.rs deleted file mode 100644 index b7efbde65..000000000 --- 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/run-pass/associated-constant-ice.rs b/tests/run-pass/associated-constant-ice.rs index 744de9bcf..2c5c90683 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 21ed2dbf9..6014558a1 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 780df5235..fcda3814e 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 296339828..43d6bd8bf 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 01deb7abf..c6793a785 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 01ca6d42a..2e9c6d527 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 c6d9bb4a2..6b14a2b5e 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 a1e3a6756..3992af2c2 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 914153c64..3d25aa504 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 eb14ce807..b7536e250 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 08acc2bc4..59b939f3e 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 2b916c025..bfb9cfc71 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 9dc508006..204968e48 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 700215baa..f727b2547 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 d5e343c56..aa4e16d39 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 b8fa7294d..379a98fc3 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 c9c77257c..73f48a96e 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, diff --git a/tests/trim_multiline.rs b/tests/trim_multiline.rs deleted file mode 100644 index a0db2e59a..000000000 --- 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/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs index 1f1a8ee91..fe533f521 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 b2b0f26b1..4229b711b 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 bee092a57..074ca064a 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 2d36c47c5..cf2f15a68 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 diff --git a/tests/ui/absurd-extreme-comparisons.rs b/tests/ui/absurd-extreme-comparisons.rs index 8c036e6c0..d08c8008e 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/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index 72b2f7a39..2e5ebec75 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.rs b/tests/ui/approx_const.rs index d353d9075..46ca2fbfb 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/approx_const.stderr b/tests/ui/approx_const.stderr index e5d2ba296..3ff016b9c 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.rs b/tests/ui/arithmetic.rs index 7ed71b597..e7aa9a18b 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/arithmetic.stderr b/tests/ui/arithmetic.stderr index ad4a02e21..ee7a594fa 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.rs b/tests/ui/assign_ops.rs index 7332b41fa..765dbb679 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_ops.stderr b/tests/ui/assign_ops.stderr index 826dacc53..fe7ccff78 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.rs b/tests/ui/assign_ops2.rs index 2d3adc2a6..c3f5083bb 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/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index 2858af1f8..93528e505 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.rs b/tests/ui/attrs.rs index eb27b833a..b1f0ca640 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/attrs.stderr b/tests/ui/attrs.stderr index f743399a6..6b6ecd675 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 c4f69b10d..46618fe40 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.rs b/tests/ui/bit_masks.rs index 4843b4eba..4111f344b 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/bit_masks.stderr b/tests/ui/bit_masks.stderr index e1a4a4291..dcf3f241b 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.rs b/tests/ui/blacklisted_name.rs index 7baeb7bb7..4e2e5388c 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/blacklisted_name.stderr b/tests/ui/blacklisted_name.stderr index 68fbe27a0..472401d5e 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.rs b/tests/ui/block_in_if_condition.rs index 9e65a127a..dd0e55034 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/block_in_if_condition.stderr b/tests/ui/block_in_if_condition.stderr index 4b7d12598..41f1e9c16 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.rs b/tests/ui/bool_comparison.rs index f05b9894f..144f9f4c6 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/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index 4436980bc..2fcde9436 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.rs b/tests/ui/booleans.rs index fc16c12af..eaa686c9a 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/booleans.stderr b/tests/ui/booleans.stderr index f1996e8a2..45e371025 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.rs b/tests/ui/borrow_box.rs index 394b810ed..216dbebda 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/borrow_box.stderr b/tests/ui/borrow_box.stderr index 2cf0ea796..1098c7785 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.rs b/tests/ui/box_vec.rs index 75b3b6264..bc5e8361d 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/box_vec.stderr b/tests/ui/box_vec.stderr index 254d07713..b90bb5e2a 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.rs b/tests/ui/builtin-type-shadow.rs index 4c4f5cbd3..56892fc94 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/builtin-type-shadow.stderr b/tests/ui/builtin-type-shadow.stderr index 5757a6ef3..78924ebf9 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.rs b/tests/ui/bytecount.rs index fc94667d9..7211284e4 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/bytecount.stderr b/tests/ui/bytecount.stderr index 307edecfd..0564d6a0b 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.rs b/tests/ui/cast.rs index 833e5a557..0668b16ff 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.stderr b/tests/ui/cast.stderr index 0a008cb68..2578c4989 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.rs b/tests/ui/cast_alignment.rs index 32e2f9316..1f7606de6 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_alignment.stderr b/tests/ui/cast_alignment.stderr index 42df78a37..d03d727a8 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.rs b/tests/ui/cast_lossless_float.rs index 9e61059b6..437c4b671 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_float.stderr b/tests/ui/cast_lossless_float.stderr index a60f838fa..9025633a1 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.rs b/tests/ui/cast_lossless_integer.rs index 5f89d057c..e06e653c6 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_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index 19d617619..9640e1e18 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.rs b/tests/ui/cast_size.rs index d0bef860c..4c72f5716 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/cast_size.stderr b/tests/ui/cast_size.stderr index 1c4b12bce..1797e2e36 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.rs b/tests/ui/char_lit_as_u8.rs index c69181c76..f9937ede3 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/char_lit_as_u8.stderr b/tests/ui/char_lit_as_u8.stderr index fcf038fe0..f6ea10d57 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.rs b/tests/ui/checked_unwrap.rs index 2b5118fa8..b3979245d 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/checked_unwrap.stderr b/tests/ui/checked_unwrap.stderr index 1b46ceb5f..4508ce442 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/clone_on_copy_mut.rs b/tests/ui/clone_on_copy_mut.rs index 5b491573c..77dffc676 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 71dfdd43d..fdebb7da1 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_nan.stderr b/tests/ui/cmp_nan.stderr index 46f3d3d57..7f636e6b5 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.rs b/tests/ui/cmp_null.rs index 0f463bcfc..e10b3e104 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_null.stderr b/tests/ui/cmp_null.stderr index 481a4d0f9..55050d2a3 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.rs b/tests/ui/cmp_owned.rs index 36d3140d2..713975c44 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/cmp_owned.stderr b/tests/ui/cmp_owned.stderr index d40fb4b8a..2691c12ea 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.rs b/tests/ui/collapsible_if.rs index de22352e3..d40be6319 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/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index 69f2013c1..a447fab7b 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.rs b/tests/ui/complex_types.rs index 7719a7a86..a6875793c 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/complex_types.stderr b/tests/ui/complex_types.stderr index 829a22c23..1c9106c0c 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 db33744c7..db6c4d944 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.rs b/tests/ui/copies.rs index 65a565c68..064c7fc1c 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/copies.stderr b/tests/ui/copies.stderr index cce63280c..febd34603 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.rs b/tests/ui/copy_iterator.rs index 1b65cc4f8..5ccb9910c 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/copy_iterator.stderr b/tests/ui/copy_iterator.stderr index f520156b0..9a06a52d4 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.rs b/tests/ui/cstring.rs index 8b7b0b66b..e68874d54 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/cstring.stderr b/tests/ui/cstring.stderr index 0e90f6963..2b2b51de6 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.rs b/tests/ui/cyclomatic_complexity.rs index 7166ed259..84e2a1b65 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.stderr b/tests/ui/cyclomatic_complexity.stderr index 43676762d..ff93f21e3 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.rs b/tests/ui/cyclomatic_complexity_attr_used.rs index dbd4e438a..fd8be25e6 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/cyclomatic_complexity_attr_used.stderr b/tests/ui/cyclomatic_complexity_attr_used.stderr index e671b3439..f8342f0d9 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.rs b/tests/ui/decimal_literal_representation.rs index 5463b8957..472ea6185 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/decimal_literal_representation.stderr b/tests/ui/decimal_literal_representation.stderr index baed3c411..343936bb7 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.rs b/tests/ui/default_trait_access.rs index eba024353..248b4ec00 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/default_trait_access.stderr b/tests/ui/default_trait_access.stderr index 8bb473103..e3c263e77 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.rs b/tests/ui/derive.rs index f43b8c382..ae54c0290 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/derive.stderr b/tests/ui/derive.stderr index cbe3fe102..fa706f22b 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.rs b/tests/ui/diverging_sub_expression.rs index b89a2f1bc..a8284dca3 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/diverging_sub_expression.stderr b/tests/ui/diverging_sub_expression.stderr index 0d7b1ca6f..8e86a7734 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.rs b/tests/ui/dlist.rs index 1318ed787..395ff2174 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/dlist.stderr b/tests/ui/dlist.stderr index de0422e17..532207520 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.rs b/tests/ui/doc.rs index 45e25409b..d48007a93 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/doc.stderr b/tests/ui/doc.stderr index f38678e89..c781f36db 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 73dd8d028..e6a0e9764 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.rs b/tests/ui/double_neg.rs index 641e334fd..0ec13900f 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_neg.stderr b/tests/ui/double_neg.stderr index fd4da8820..02202dbd6 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.rs b/tests/ui/double_parens.rs index 19d177328..8d81ee16f 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/double_parens.stderr b/tests/ui/double_parens.stderr index a77b08528..a6a29eeb0 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.rs b/tests/ui/drop_forget_copy.rs index 9fef06b0e..aa70490f8 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_copy.stderr b/tests/ui/drop_forget_copy.stderr index 3ea7bf973..043067fe8 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.rs b/tests/ui/drop_forget_ref.rs index e8ab6a0d5..bb4781db7 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/drop_forget_ref.stderr b/tests/ui/drop_forget_ref.stderr index 1654fdd28..227918f59 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.rs b/tests/ui/duplicate_underscore_argument.rs index df00f56aa..e54920c1b 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/duplicate_underscore_argument.stderr b/tests/ui/duplicate_underscore_argument.stderr index c926f57f1..707145346 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.rs b/tests/ui/duration_subsec.rs index 8c75c5f2f..d732a0228 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/duration_subsec.stderr b/tests/ui/duration_subsec.stderr index a1aacec3a..c23b041a8 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.rs b/tests/ui/else_if_without_else.rs index 4f019819e..3776aecf5 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/else_if_without_else.stderr b/tests/ui/else_if_without_else.stderr index b8a5031fb..a352546ce 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.rs b/tests/ui/empty_enum.rs index c6e6946de..3398b71ee 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_enum.stderr b/tests/ui/empty_enum.stderr index ca377cee8..f198793fe 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.rs b/tests/ui/empty_line_after_outer_attribute.rs index 30063dac0..c46a0496a 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/empty_line_after_outer_attribute.stderr b/tests/ui/empty_line_after_outer_attribute.stderr index 7c9c7b8f3..7bcec54a6 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.rs b/tests/ui/entry.rs index ccbc7038f..955b0a6e9 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/entry.stderr b/tests/ui/entry.stderr index 09c4a8822..cffe8b232 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.rs b/tests/ui/enum_glob_use.rs index efb37fbe4..47082f8f3 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_glob_use.stderr b/tests/ui/enum_glob_use.stderr index 2d53618c1..bb1d19e41 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.rs b/tests/ui/enum_variants.rs index 222c76c25..4ddb7207a 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/enum_variants.stderr b/tests/ui/enum_variants.stderr index e33e29ec7..bd083e7e0 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.rs b/tests/ui/enums_clike.rs index 618603683..8212f12b3 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/enums_clike.stderr b/tests/ui/enums_clike.stderr index d6a137c6f..cccf4ed03 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.rs b/tests/ui/eq_op.rs index ef573b2b9..a88866436 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/eq_op.stderr b/tests/ui/eq_op.stderr index ccf366062..ad0c8d8ec 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.rs b/tests/ui/erasing_op.rs index e5143146f..02745ac5d 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/erasing_op.stderr b/tests/ui/erasing_op.stderr index 310c41c54..18486ab47 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.rs b/tests/ui/eta.rs index 6e0b6f8ca..4dd46f20e 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/eta.stderr b/tests/ui/eta.stderr index 5dca265c2..89543d6af 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.rs b/tests/ui/eval_order_dependence.rs index e7ccb190d..b240dde06 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/eval_order_dependence.stderr b/tests/ui/eval_order_dependence.stderr index 2e01a167c..3caba829b 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.rs b/tests/ui/excessive_precision.rs index 88f24d27d..b44364d6b 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/excessive_precision.stderr b/tests/ui/excessive_precision.stderr index 295846e9d..bb0546cdc 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.rs b/tests/ui/explicit_write.rs index 71992123c..9d6d13c84 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/explicit_write.stderr b/tests/ui/explicit_write.stderr index 7a2a0c66f..fb14120b1 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.rs b/tests/ui/fallible_impl_from.rs index db1189190..5e33cca59 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/fallible_impl_from.stderr b/tests/ui/fallible_impl_from.stderr index c8af77eca..4dbc7879d 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.rs b/tests/ui/filter_methods.rs index 29230c48e..d7a50a588 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/filter_methods.stderr b/tests/ui/filter_methods.stderr index cec03a47b..1fde70601 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.rs b/tests/ui/float_cmp.rs index 9dd9ea9b0..d5b02fb70 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.stderr b/tests/ui/float_cmp.stderr index df404a1ee..598ebf336 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.rs b/tests/ui/float_cmp_const.rs index adf2ab703..279400604 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/float_cmp_const.stderr b/tests/ui/float_cmp_const.stderr index 6367ec73c..140839795 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.rs b/tests/ui/for_loop.rs index bc0c3172b..39eee6488 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/for_loop.stderr b/tests/ui/for_loop.stderr index 582ca84b1..732dc2ab4 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.rs b/tests/ui/format.rs index 783c6ea09..8f31d92ac 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/format.stderr b/tests/ui/format.stderr index fa5c740c5..ca6ef9053 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.rs b/tests/ui/formatting.rs index 20b1c1655..74d42f08f 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/formatting.stderr b/tests/ui/formatting.stderr index 266de262e..d9fee7366 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.rs b/tests/ui/functions.rs index 5688c471d..ab5ce5b06 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/functions.stderr b/tests/ui/functions.stderr index 0a9774895..c2f7b76aa 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.rs b/tests/ui/fxhash.rs index c6ed9436a..1376b9442 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/fxhash.stderr b/tests/ui/fxhash.stderr index 5e90f84f1..869a315c9 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 b5ada8625..63f6603c8 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.rs b/tests/ui/identity_conversion.rs index 8f5bd12bc..b9ad8d06a 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_conversion.stderr b/tests/ui/identity_conversion.stderr index 7083b96e1..ffcd3649a 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.rs b/tests/ui/identity_op.rs index 1ed9f974d..ae8c66faa 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/identity_op.stderr b/tests/ui/identity_op.stderr index 45f579ce8..e494250c0 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.rs b/tests/ui/if_let_redundant_pattern_matching.rs index 0963caa62..90265853f 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_let_redundant_pattern_matching.stderr b/tests/ui/if_let_redundant_pattern_matching.stderr index e7bfd0275..904662585 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.rs b/tests/ui/if_not_else.rs index 9436af70c..bb16e1670 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/if_not_else.stderr b/tests/ui/if_not_else.stderr index b920ef3b6..9682f6dc1 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.rs b/tests/ui/impl.rs index 9e10dbade..7da0e04e5 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/impl.stderr b/tests/ui/impl.stderr index 95e627cd5..13d4a7655 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 f41ce4051..5bb6f11b2 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.rs b/tests/ui/inconsistent_digit_grouping.rs index ed6dc06ed..056d87611 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/inconsistent_digit_grouping.stderr b/tests/ui/inconsistent_digit_grouping.stderr index 4d30529d8..51eeca2b8 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.rs b/tests/ui/indexing_slicing.rs index e39dc9236..b9f1c4a4a 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/indexing_slicing.stderr b/tests/ui/indexing_slicing.stderr index ee11dce6d..3f09a6516 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.rs b/tests/ui/infallible_destructuring_match.rs index 6f3d7a3ff..b3e2835d7 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/infallible_destructuring_match.stderr b/tests/ui/infallible_destructuring_match.stderr index 8ee73bbfd..6e26741fc 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.rs b/tests/ui/infinite_iter.rs index a78414166..44fa934aa 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_iter.stderr b/tests/ui/infinite_iter.stderr index f79db7784..c3d67bdfd 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.rs b/tests/ui/infinite_loop.rs index 9e8019116..9449a295e 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/infinite_loop.stderr b/tests/ui/infinite_loop.stderr index 26ec9582f..edbe49374 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.rs b/tests/ui/inline_fn_without_body.rs index 76e50e567..830da6d11 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/inline_fn_without_body.stderr b/tests/ui/inline_fn_without_body.stderr index 2b466b686..a9a52b190 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.rs b/tests/ui/int_plus_one.rs index a9e059f4a..1eb0e4929 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/int_plus_one.stderr b/tests/ui/int_plus_one.stderr index deecaffa1..12d7000dc 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 f84207385..1ca825dd9 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.rs b/tests/ui/invalid_upcast_comparisons.rs index 5bf0bfdcb..0a700518f 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/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index eb4680289..ce6d1dfa1 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.rs b/tests/ui/issue_2356.rs index d4cefb0f1..398e0d1d1 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/issue_2356.stderr b/tests/ui/issue_2356.stderr index 4b82a0a75..fe2d9d45b 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.rs b/tests/ui/item_after_statement.rs index 710a1adca..9626a59ed 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/item_after_statement.stderr b/tests/ui/item_after_statement.stderr index ec1296caf..6d20899b5 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.rs b/tests/ui/large_digit_groups.rs index 5d0fb11db..af569ea75 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_digit_groups.stderr b/tests/ui/large_digit_groups.stderr index f2e6a62d1..b322ded9c 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.rs b/tests/ui/large_enum_variant.rs index aaf3e2924..cd1772ad1 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/large_enum_variant.stderr b/tests/ui/large_enum_variant.stderr index 5e938337b..af42f9054 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.rs b/tests/ui/len_zero.rs index 2e71c2761..b188db518 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/len_zero.stderr b/tests/ui/len_zero.stderr index a04185bc6..49e365e6c 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.rs b/tests/ui/let_if_seq.rs index 564a67d2c..102b72f3e 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_if_seq.stderr b/tests/ui/let_if_seq.stderr index b912373f9..7b4c78003 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.rs b/tests/ui/let_return.rs index 1083603b2..9b584d6e2 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_return.stderr b/tests/ui/let_return.stderr index 459b2eafa..dad628bc9 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.rs b/tests/ui/let_unit.rs index 032dc85f2..187ff9d13 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/let_unit.stderr b/tests/ui/let_unit.stderr index da579ec80..f6f5d3f7d 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.rs b/tests/ui/lifetimes.rs index 0322d42e8..aa5640f4e 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/lifetimes.stderr b/tests/ui/lifetimes.stderr index b69438af9..42fb01b75 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.rs b/tests/ui/literals.rs index 581fbbb70..d45da257a 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/literals.stderr b/tests/ui/literals.stderr index 6f6ea75df..40399e498 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.rs b/tests/ui/map_clone.rs index f11d21d2d..90c95be2c 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/map_clone.stderr b/tests/ui/map_clone.stderr index c29f37918..afad65b00 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 89378f438..7ef6f714f 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.rs b/tests/ui/matches.rs index e339aeb9c..92befb25a 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/matches.stderr b/tests/ui/matches.stderr index 61c13056c..6f1a06738 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.rs b/tests/ui/mem_forget.rs index 991a402e2..96d333a71 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/mem_forget.stderr b/tests/ui/mem_forget.stderr index 6e7a44694..1f43d9f36 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.rs b/tests/ui/methods.rs index 220b08caa..37f4cb2f7 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/methods.stderr b/tests/ui/methods.stderr index bf529ce94..3189f3756 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.rs b/tests/ui/min_max.rs index 9b29f73b2..9866933f9 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/min_max.stderr b/tests/ui/min_max.stderr index b8ea183fc..e89542a2d 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.rs b/tests/ui/missing-doc.rs index cbd6439d4..6968adb31 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-doc.stderr b/tests/ui/missing-doc.stderr index 54834f902..ebc4c5aca 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.rs b/tests/ui/missing_inline.rs index 38f590330..7fbb01c6d 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/missing_inline.stderr b/tests/ui/missing_inline.stderr index fe3437427..3609c9101 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.rs b/tests/ui/module_inception.rs index 77bd446c5..b6917020e 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/module_inception.stderr b/tests/ui/module_inception.stderr index c9d3319db..43f9666f7 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.rs b/tests/ui/modulo_one.rs index 847ea1d9a..7dcec04ba 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/modulo_one.stderr b/tests/ui/modulo_one.stderr index ccfca7154..5d42c3e0a 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.rs b/tests/ui/mut_from_ref.rs index 3fc464083..b75fa92f0 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_from_ref.stderr b/tests/ui/mut_from_ref.stderr index a7cbc0b7a..0f5baa2d2 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.rs b/tests/ui/mut_mut.rs index 658ae1846..4656d2764 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_mut.stderr b/tests/ui/mut_mut.stderr index d1f05ea80..88bd2f729 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 d7be7ae1e..fece96106 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.rs b/tests/ui/mut_reference.rs index 34185f6a9..38b0e25e0 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/mut_reference.stderr b/tests/ui/mut_reference.stderr index 73df19bf1..ee62e2647 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.rs b/tests/ui/mutex_atomic.rs index 965027384..3eefbb97a 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/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index 354f9891c..2df58889a 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.rs b/tests/ui/needless_bool.rs index 1213539c8..4e6f65ed0 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_bool.stderr b/tests/ui/needless_bool.stderr index 63e063244..dd132bc67 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.rs b/tests/ui/needless_borrow.rs index b086f0214..61384c43f 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_borrow.stderr b/tests/ui/needless_borrow.stderr index fde38508b..c720dff5d 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.rs b/tests/ui/needless_borrowed_ref.rs index 75ffa2111..000ecd32d 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_borrowed_ref.stderr b/tests/ui/needless_borrowed_ref.stderr index 2a8cf4348..3113b887b 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.rs b/tests/ui/needless_continue.rs index 3574b0fb3..4fe523e48 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_continue.stderr b/tests/ui/needless_continue.stderr index 3e0368892..7cfaf89d6 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.rs b/tests/ui/needless_pass_by_value.rs index 322df0b87..783386fab 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.stderr b/tests/ui/needless_pass_by_value.stderr index 2fef0595c..9cb5e6e48 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_pass_by_value_proc_macro.rs b/tests/ui/needless_pass_by_value_proc_macro.rs index 652e11fee..6b1305fa2 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_range_loop.stderr b/tests/ui/needless_range_loop.stderr index c394469c1..1954a8240 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.rs b/tests/ui/needless_return.rs index 4739ded7b..a834563ec 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_return.stderr b/tests/ui/needless_return.stderr index 42dc6e659..094fe3642 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.rs b/tests/ui/needless_update.rs index 35d5730dd..675c60e24 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/needless_update.stderr b/tests/ui/needless_update.stderr index 3e509870d..acc511984 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.rs b/tests/ui/neg_cmp_op_on_partial_ord.rs index e739908bc..3a472bf69 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_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index ccd305611..5fd4ab9ba 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.rs b/tests/ui/neg_multiply.rs index 367d2d5ed..b1a1879a3 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/neg_multiply.stderr b/tests/ui/neg_multiply.stderr index 1d52ba16e..ba59fdb89 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.rs b/tests/ui/never_loop.rs index 205001266..bb6d76b06 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/never_loop.stderr b/tests/ui/never_loop.stderr index 664be379e..3d1235964 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.rs b/tests/ui/new_without_default.rs index c06c9f9e9..bf63e9336 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/new_without_default.stderr b/tests/ui/new_without_default.stderr index 335e60404..11ece5e87 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.rs b/tests/ui/no_effect.rs index 54028cd8b..2913ecdbf 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/no_effect.stderr b/tests/ui/no_effect.stderr index 7ff0425eb..2429d934c 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.rs b/tests/ui/non_copy_const.rs index d7391577d..4e086333b 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_copy_const.stderr b/tests/ui/non_copy_const.stderr index 388c7faba..7f164595b 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.rs b/tests/ui/non_expressive_names.rs index 7149bf8f3..ce3dad391 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 { @@ -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 b4927e69e..53cb36eda 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 @@ -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 diff --git a/tests/ui/ok_expect.stderr b/tests/ui/ok_expect.stderr index da2d3b950..7c158b520 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.rs b/tests/ui/ok_if_let.rs index fdc01bcc7..46d85bb9c 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/ok_if_let.stderr b/tests/ui/ok_if_let.stderr index e1371d924..eac49032e 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.rs b/tests/ui/op_ref.rs index 9eb697571..a85a2c8bb 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/op_ref.stderr b/tests/ui/op_ref.stderr index 4a6ff6fe6..398e3a6e9 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.rs b/tests/ui/open_options.rs index 514808d41..38b3dd7e4 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/open_options.stderr b/tests/ui/open_options.stderr index f0d419041..64ad667a4 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.rs b/tests/ui/option_map_unit_fn.rs index 06531e290..e86cc99c5 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/option_map_unit_fn.stderr b/tests/ui/option_map_unit_fn.stderr index 3ca57a65b..77fe24d26 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 19e00efae..4341857cc 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.rs b/tests/ui/overflow_check_conditional.rs index 889c339c8..5c3cc5b08 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/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index adf353a1c..9659e352a 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.rs b/tests/ui/panic_unimplemented.rs index 33050633f..693dc921b 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/panic_unimplemented.stderr b/tests/ui/panic_unimplemented.stderr index 3bf5589c4..c5ce42f4c 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 5e536cc51..773bed8fd 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.rs b/tests/ui/patterns.rs index 65e319e2f..70f86afba 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/patterns.stderr b/tests/ui/patterns.stderr index 59bce3a9a..ce8aab7e6 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.rs b/tests/ui/precedence.rs index aacd90cdf..95476dd4f 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/precedence.stderr b/tests/ui/precedence.stderr index 92c136474..5ec1732ee 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.rs b/tests/ui/print.rs index 8719a691d..cee3e7000 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.stderr b/tests/ui/print.stderr index f2d2afd9b..92a2f2f96 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.rs b/tests/ui/print_literal.rs index 620349bab..46b91d40f 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_literal.stderr b/tests/ui/print_literal.stderr index cada26c61..bd13f5d17 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.rs b/tests/ui/print_with_newline.rs index 906fa987d..5efee5abf 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/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index 58413a9b4..12c4ecb2f 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 cff3f9880..96d158384 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.rs b/tests/ui/ptr_arg.rs index ce572be7a..e76221355 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/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index a29e393ba..6c16443f5 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/ptr_offset_with_cast.rs b/tests/ui/ptr_offset_with_cast.rs new file mode 100644 index 000000000..4549f960c --- /dev/null +++ b/tests/ui/ptr_offset_with_cast.rs @@ -0,0 +1,18 @@ +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); + + 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 new file mode 100644 index 000000000..214a39cdc --- /dev/null +++ b/tests/ui/ptr_offset_with_cast.stderr @@ -0,0 +1,16 @@ +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 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 + | +14 | ptr.wrapping_offset(offset_usize as isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/question_mark.stderr b/tests/ui/question_mark.stderr index e97b18698..68c0e5e38 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.rs b/tests/ui/range.rs index 7291fd5d5..df3ce1268 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.stderr b/tests/ui/range.stderr index 064429c33..651ff266c 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.rs b/tests/ui/range_plus_minus_one.rs index 31574a4ae..12a1312de 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/range_plus_minus_one.stderr b/tests/ui/range_plus_minus_one.stderr index 1990300ef..083c153ad 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.rs b/tests/ui/redundant_closure_call.rs index ab3897bc3..b09ed9a35 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_closure_call.stderr b/tests/ui/redundant_closure_call.stderr index d2b5616a4..e4d490743 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.rs b/tests/ui/redundant_field_names.rs index dc8548754..b379aa661 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/redundant_field_names.stderr b/tests/ui/redundant_field_names.stderr index 5821baf4c..457fe7d3c 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.rs b/tests/ui/reference.rs index 0bd000082..97a0030a9 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/reference.stderr b/tests/ui/reference.stderr index 741c0cc10..13e0da987 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.rs b/tests/ui/regex.rs index b80aaa2df..e3837e104 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/regex.stderr b/tests/ui/regex.stderr index 39c360583..fd8fecb11 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.rs b/tests/ui/replace_consts.rs index 71d4ea98e..8420b368d 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/replace_consts.stderr b/tests/ui/replace_consts.stderr index 0a9d5f4ab..fb9c9414c 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.rs b/tests/ui/result_map_unit_fn.rs index dd163439d..8cac6a9c8 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/result_map_unit_fn.stderr b/tests/ui/result_map_unit_fn.stderr index 9ec24a7e9..5fba1a0d7 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.rs b/tests/ui/serde.rs index 792ebc9b0..65c2c344d 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/serde.stderr b/tests/ui/serde.stderr index 58667e0f8..cce839a0d 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.rs b/tests/ui/shadow.rs index 79c1030d4..c73acf5c5 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/shadow.stderr b/tests/ui/shadow.stderr index 0eb5e5b2a..311177e25 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.rs b/tests/ui/short_circuit_statement.rs index 0f5773623..e9cb8e4ad 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/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index 7697cbd1c..bef497c33 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.rs b/tests/ui/single_char_pattern.rs index 577a0e270..147f974b9 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_char_pattern.stderr b/tests/ui/single_char_pattern.stderr index 044b4909a..783556127 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.rs b/tests/ui/single_match.rs index b064eed57..c0c82adaf 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/single_match.stderr b/tests/ui/single_match.stderr index d77211bc1..20d8fed25 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.rs b/tests/ui/starts_ends_with.rs index d47c8a5b0..adea56cf9 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/starts_ends_with.stderr b/tests/ui/starts_ends_with.stderr index 7d73f201b..b3fb444b5 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 4be2037ad..32e348269 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.rs b/tests/ui/strings.rs index 66d24a3c0..86819e3fd 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/strings.stderr b/tests/ui/strings.stderr index d098ce9df..258920e26 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.rs b/tests/ui/stutter.rs index 761339b0a..de67bb1af 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/stutter.stderr b/tests/ui/stutter.stderr index 25e857991..3cc0be395 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.rs b/tests/ui/suspicious_arithmetic_impl.rs index 9f6fce249..04e235c69 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/suspicious_arithmetic_impl.stderr b/tests/ui/suspicious_arithmetic_impl.stderr index 8130b1cb3..0f396c3a5 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.rs b/tests/ui/swap.rs index d1d12641c..377319e8f 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/swap.stderr b/tests/ui/swap.stderr index a01ec375e..67d4fd8a1 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.rs b/tests/ui/temporary_assignment.rs index 8f25aad72..1d0cffcfc 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/temporary_assignment.stderr b/tests/ui/temporary_assignment.stderr index 979720c91..38379d8bd 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.rs b/tests/ui/toplevel_ref_arg.rs index a0d6dd2da..86eb7fa55 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/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index f360e8532..f3fe563f2 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 47b46be9b..477f42c28 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.rs b/tests/ui/transmute.rs index 54e1734e1..34d50da11 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.stderr b/tests/ui/transmute.stderr index abed5065c..4340c16b9 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.rs b/tests/ui/transmute_64bit.rs index 65240c80a..539b403cf 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/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index 3a6a6e73f..e86908655 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.rs b/tests/ui/trivially_copy_pass_by_ref.rs index a1a1de1e4..e3dbe510a 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/trivially_copy_pass_by_ref.stderr b/tests/ui/trivially_copy_pass_by_ref.stderr index 757b6b4c9..2db627dd9 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 b41bff7a9..e2f751628 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 bbdf4ce2e..a06809b9b 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.rs b/tests/ui/unicode.rs index 5bb0e7edf..b997d6d3f 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/unicode.stderr b/tests/ui/unicode.stderr index 9e99a44bb..b0e567fc2 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.rs b/tests/ui/unit_arg.rs index 8f290446b..2f743f227 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_arg.stderr b/tests/ui/unit_arg.stderr index ca48f3926..e1845c0c0 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.rs b/tests/ui/unit_cmp.rs index 2b6d75784..bd79d0f81 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/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index 51ad3fca9..a85eb3284 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.rs b/tests/ui/unnecessary_clone.rs index 96166ed4f..7a2fc4ac1 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_clone.stderr b/tests/ui/unnecessary_clone.stderr index 3c1ce9080..b2985f84b 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 8bc4b8244..e72f671b6 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.rs b/tests/ui/unnecessary_ref.rs index 53b970dfa..afc920832 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/unnecessary_ref.stderr b/tests/ui/unnecessary_ref.stderr index ffc65084a..d27ba26f3 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.rs b/tests/ui/unneeded_field_pattern.rs index 8c9606022..88b91235d 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/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index 7e4c3a6cb..40aa4f524 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.rs b/tests/ui/unreadable_literal.rs index 0ec757cfb..df3539e38 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/unreadable_literal.stderr b/tests/ui/unreadable_literal.stderr index cffcad1ee..516b6ccc5 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.rs b/tests/ui/unsafe_removed_from_name.rs index 29f34d31a..41b98975d 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/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index 93f2ddd53..2b014ca58 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.rs b/tests/ui/unused_io_amount.rs index ea72c1b1b..53bcbce9d 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_io_amount.stderr b/tests/ui/unused_io_amount.stderr index 5114d375f..48a575157 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.rs b/tests/ui/unused_labels.rs index 115121dc2..b76fcad16 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_labels.stderr b/tests/ui/unused_labels.stderr index 19c91e2a6..d35ca41a1 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.rs b/tests/ui/unused_lt.rs index 8b166a34d..e5c5e8935 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/unused_lt.stderr b/tests/ui/unused_lt.stderr index f01dfda70..4cad611c2 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.rs b/tests/ui/unwrap_or.rs index 79e3900fe..682c42dc9 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/unwrap_or.stderr b/tests/ui/unwrap_or.stderr index e4704dd0e..42c72090c 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.rs b/tests/ui/use_self.rs index 689c9d68d..8d18d848a 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/use_self.stderr b/tests/ui/use_self.stderr index 899361012..cf673e166 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.rs b/tests/ui/used_underscore_binding.rs index 60a2c4e8b..c1e1c9af5 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/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 712f81c1b..a1bb57a50 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.rs b/tests/ui/useless_asref.rs index 7508cdc7b..52994566e 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_asref.stderr b/tests/ui/useless_asref.stderr index 875d830a3..6247fb27a 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.rs b/tests/ui/useless_attribute.rs index 68c7d2007..300fcfa2b 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/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index 84b81e561..59f1aaffb 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.rs b/tests/ui/vec.rs index 23e438724..78a49f258 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/vec.stderr b/tests/ui/vec.stderr index 6a47eb5b0..b9541e58c 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.rs b/tests/ui/while_loop.rs index 23a9ce80e..0b8691d57 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/while_loop.stderr b/tests/ui/while_loop.stderr index d2b50b61e..cc309e379 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.rs b/tests/ui/write_literal.rs index 48dfcd0ea..5ef4c15f4 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_literal.stderr b/tests/ui/write_literal.stderr index d2e8ca94e..644f6f15b 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.rs b/tests/ui/write_with_newline.rs index 8badbd657..e060459a4 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/write_with_newline.stderr b/tests/ui/write_with_newline.stderr index a8a6039f3..c8617b493 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.rs b/tests/ui/writeln_empty_string.rs index faccfd829..81dfdcdc0 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/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr index 7bb6350ec..ef1e9b3d3 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.rs b/tests/ui/wrong_self_convention.rs index 07a93d688..1e718c1c6 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/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index 216fd0bb8..4a6e5e0ab 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.rs b/tests/ui/zero_div_zero.rs index 65e1e2399..7927e8b8a 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; diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index f1788fc9e..a5e86883d 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 5155dc401..b5e279eaa 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 diff --git a/tests/without_block_comments.rs b/tests/without_block_comments.rs deleted file mode 100644 index 730c5cb12..000000000 --- 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"]); -} diff --git a/util/dogfood.sh b/util/dogfood.sh index 358fc46c8..bebe0e82a 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/gh-pages/index.html b/util/gh-pages/index.html index 0088ecc3d..656a73412 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; } diff --git a/util/update_lints.py b/util/update_lints.py index abc8e5dee..ea7b992ab 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)