From 5a13217ea9c07121e7d3cdcfb0ddd2aa52b90f12 Mon Sep 17 00:00:00 2001 From: ThibsG Date: Fri, 16 Oct 2020 17:58:26 +0200 Subject: Assert macro args extractor as a common function in higher --- clippy_lints/src/mutable_debug_assertion.rs | 66 +++++------------------------ 1 file changed, 11 insertions(+), 55 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index cc635c2a202..76417aa7ed0 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -1,7 +1,6 @@ -use crate::utils::{is_direct_expn_of, span_lint}; -use if_chain::if_chain; +use crate::utils::{higher, is_direct_expn_of, span_lint}; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; -use rustc_hir::{BorrowKind, Expr, ExprKind, MatchSource, Mutability, StmtKind, UnOp}; +use rustc_hir::{BorrowKind, Expr, ExprKind, MatchSource, Mutability}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::map::Map; use rustc_middle::ty; @@ -39,66 +38,23 @@ impl<'tcx> LateLintPass<'tcx> for DebugAssertWithMutCall { fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { for dmn in &DEBUG_MACRO_NAMES { if is_direct_expn_of(e.span, dmn).is_some() { - if let Some(span) = extract_call(cx, e) { - span_lint( - cx, - DEBUG_ASSERT_WITH_MUT_CALL, - span, - &format!("do not call a function with mutable arguments inside of `{}!`", dmn), - ); - } - } - } - } -} - -//HACK(hellow554): remove this when #4694 is implemented -fn extract_call<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> Option { - if_chain! { - if let ExprKind::Block(ref block, _) = e.kind; - if block.stmts.len() == 1; - if let StmtKind::Semi(ref matchexpr) = block.stmts[0].kind; - then { - // debug_assert - if_chain! { - if let ExprKind::Match(ref ifclause, _, _) = matchexpr.kind; - if let ExprKind::DropTemps(ref droptmp) = ifclause.kind; - if let ExprKind::Unary(UnOp::UnNot, ref condition) = droptmp.kind; - then { - let mut visitor = MutArgVisitor::new(cx); - visitor.visit_expr(condition); - return visitor.expr_span(); - } - } - - // debug_assert_{eq,ne} - if_chain! { - if let ExprKind::Block(ref matchblock, _) = matchexpr.kind; - if let Some(ref matchheader) = matchblock.expr; - if let ExprKind::Match(ref headerexpr, _, _) = matchheader.kind; - if let ExprKind::Tup(ref conditions) = headerexpr.kind; - if conditions.len() == 2; - then { - if let ExprKind::AddrOf(BorrowKind::Ref, _, ref lhs) = conditions[0].kind { + if let Some(macro_args) = higher::extract_assert_macro_args(e) { + for arg in macro_args { let mut visitor = MutArgVisitor::new(cx); - visitor.visit_expr(lhs); + visitor.visit_expr(arg); if let Some(span) = visitor.expr_span() { - return Some(span); - } - } - if let ExprKind::AddrOf(BorrowKind::Ref, _, ref rhs) = conditions[1].kind { - let mut visitor = MutArgVisitor::new(cx); - visitor.visit_expr(rhs); - if let Some(span) = visitor.expr_span() { - return Some(span); + span_lint( + cx, + DEBUG_ASSERT_WITH_MUT_CALL, + span, + &format!("do not call a function with mutable arguments inside of `{}!`", dmn), + ); } } } } } } - - None } struct MutArgVisitor<'a, 'tcx> { -- cgit 1.4.1-3-g733a5 From ada8c72f3f21013f789f774d4c0219c58264e663 Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Mon, 1 Mar 2021 11:53:33 -0600 Subject: Add version = "Two" to rustfmt.toml Ignore UI tests since this change makes rustfmt less friendly with UI test comments. --- clippy_lints/src/await_holding_invalid.rs | 14 ++--- clippy_lints/src/float_literal.rs | 6 +- clippy_lints/src/infinite_iter.rs | 6 +- clippy_lints/src/inherent_to_string.rs | 2 +- clippy_lints/src/loops.rs | 6 +- clippy_lints/src/mutable_debug_assertion.rs | 6 +- clippy_lints/src/needless_continue.rs | 6 +- clippy_lints/src/open_options.rs | 12 ++-- clippy_utils/src/camel_case.rs | 6 +- clippy_utils/src/lib.rs | 12 ++-- clippy_utils/src/ptr.rs | 6 +- rustfmt.toml | 1 + tests/lint_message_convention.rs | 4 +- .../upper_case_acronyms.rs | 5 +- .../upper_case_acronyms.stderr | 4 +- tests/ui/auxiliary/macro_rules.rs | 6 +- tests/ui/blocks_in_if_conditions.fixed | 33 ++++------ tests/ui/blocks_in_if_conditions.rs | 33 ++++------ tests/ui/blocks_in_if_conditions.stderr | 10 +-- tests/ui/checked_unwrap/simple_conditionals.rs | 14 +++-- tests/ui/crashes/ice-6256.rs | 1 + tests/ui/crashes/ice-6256.stderr | 6 +- tests/ui/dbg_macro.rs | 6 +- tests/ui/dbg_macro.stderr | 16 ++--- tests/ui/default_trait_access.fixed | 20 +----- tests/ui/default_trait_access.rs | 20 +----- tests/ui/doc_panics.rs | 12 +--- tests/ui/doc_panics.stderr | 12 ++-- tests/ui/float_cmp.rs | 12 +--- tests/ui/float_cmp.stderr | 12 ++-- tests/ui/float_cmp_const.rs | 6 +- tests/ui/float_cmp_const.stderr | 16 ++--- tests/ui/floating_point_abs.fixed | 30 ++------- tests/ui/floating_point_abs.rs | 72 ++++------------------ tests/ui/floating_point_abs.stderr | 70 +++++++-------------- tests/ui/if_let_some_result.fixed | 12 +--- tests/ui/if_let_some_result.rs | 12 +--- tests/ui/if_let_some_result.stderr | 6 +- tests/ui/implicit_return.fixed | 6 +- tests/ui/implicit_return.rs | 6 +- tests/ui/implicit_return.stderr | 28 ++++----- tests/ui/needless_lifetimes.rs | 6 +- tests/ui/needless_lifetimes.stderr | 36 +++++------ tests/ui/redundant_clone.fixed | 6 +- tests/ui/redundant_clone.rs | 6 +- tests/ui/redundant_clone.stderr | 28 ++++----- tests/ui/unnecessary_wraps.rs | 36 ++--------- tests/ui/unnecessary_wraps.stderr | 18 +++--- tests/ui/upper_case_acronyms.rs | 5 +- tests/ui/use_self.fixed | 6 +- tests/ui/use_self.rs | 6 +- tests/ui/use_self.stderr | 2 +- 52 files changed, 225 insertions(+), 503 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/await_holding_invalid.rs b/clippy_lints/src/await_holding_invalid.rs index fad3aff96cc..112c5bb14e3 100644 --- a/clippy_lints/src/await_holding_invalid.rs +++ b/clippy_lints/src/await_holding_invalid.rs @@ -123,13 +123,13 @@ fn check_interior_types(cx: &LateContext<'_>, ty_causes: &[GeneratorInteriorType } if is_refcell_ref(cx, adt.did) { span_lint_and_note( - cx, - AWAIT_HOLDING_REFCELL_REF, - ty_cause.span, - "this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await", - ty_cause.scope_span.or(Some(span)), - "these are all the await points this ref is held through", - ); + cx, + AWAIT_HOLDING_REFCELL_REF, + ty_cause.span, + "this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await", + ty_cause.scope_span.or(Some(span)), + "these are all the await points this ref is held through", + ); } } } diff --git a/clippy_lints/src/float_literal.rs b/clippy_lints/src/float_literal.rs index be646cbe4d0..8e256f34684 100644 --- a/clippy_lints/src/float_literal.rs +++ b/clippy_lints/src/float_literal.rs @@ -145,11 +145,7 @@ fn count_digits(s: &str) -> usize { .take_while(|c| *c != 'e' && *c != 'E') .fold(0, |count, c| { // leading zeros - if c == '0' && count == 0 { - count - } else { - count + 1 - } + if c == '0' && count == 0 { count } else { count + 1 } }) } diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index 129abd7d897..7040ac3191f 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -89,11 +89,7 @@ impl Finiteness { impl From for Finiteness { #[must_use] fn from(b: bool) -> Self { - if b { - Infinite - } else { - Finite - } + if b { Infinite } else { Finite } } } diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index a95321ea7e2..c1f3e1d9d68 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -139,7 +139,7 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) { self_type.to_string() ), None, - &format!("remove the inherent method from type `{}`", self_type.to_string()) + &format!("remove the inherent method from type `{}`", self_type.to_string()), ); } else { span_lint_and_help( diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 3ff9e182121..711cd5b3b15 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -3158,11 +3158,7 @@ fn detect_iter_and_into_iters<'tcx>(block: &'tcx Block<'tcx>, identifier: Ident) seen_other: false, }; visitor.visit_block(block); - if visitor.seen_other { - None - } else { - Some(visitor.uses) - } + if visitor.seen_other { None } else { Some(visitor.uses) } } fn shorten_needless_collect_span(expr: &Expr<'_>) -> Span { diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 76417aa7ed0..9ac127abe0a 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -73,11 +73,7 @@ impl<'a, 'tcx> MutArgVisitor<'a, 'tcx> { } fn expr_span(&self) -> Option { - if self.found { - self.expr_span - } else { - None - } + if self.found { self.expr_span } else { None } } } diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index 603071a5f4a..30fe2d6225c 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -416,11 +416,7 @@ fn erode_from_back(s: &str) -> String { break; } } - if ret.is_empty() { - s.to_string() - } else { - ret - } + if ret.is_empty() { s.to_string() } else { ret } } fn span_of_first_expr_in_block(block: &ast::Block) -> Option { diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index 73a99a3a2f8..07ca196990d 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -69,15 +69,11 @@ fn get_open_options(cx: &LateContext<'_>, argument: &Expr<'_>, options: &mut Vec .. } = *span { - if lit { - Argument::True - } else { - Argument::False - } + if lit { Argument::True } else { Argument::False } } else { - return; // The function is called with a literal - // which is not a boolean literal. This is theoretically - // possible, but not very likely. + // The function is called with a literal which is not a boolean literal. + // This is theoretically possible, but not very likely. + return; } }, _ => Argument::Unknown, diff --git a/clippy_utils/src/camel_case.rs b/clippy_utils/src/camel_case.rs index ba1c01ebc9f..a6636e39137 100644 --- a/clippy_utils/src/camel_case.rs +++ b/clippy_utils/src/camel_case.rs @@ -25,11 +25,7 @@ pub fn until(s: &str) -> usize { return i; } } - if up { - last_i - } else { - s.len() - } + if up { last_i } else { s.len() } } /// Returns index of the last camel-case component of `s`. diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 2380ea4c7bf..fbcc6d8dc4f 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -1563,12 +1563,12 @@ pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool { /// ``` pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_>, did: DefId) -> bool { use rustc_trait_selection::traits; - let predicates = - cx.tcx - .predicates_of(did) - .predicates - .iter() - .filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None }); + let predicates = cx + .tcx + .predicates_of(did) + .predicates + .iter() + .filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None }); traits::impossible_predicates( cx.tcx, traits::elaborate_predicates(cx.tcx, predicates) diff --git a/clippy_utils/src/ptr.rs b/clippy_utils/src/ptr.rs index baeff08e02c..df6143edbca 100644 --- a/clippy_utils/src/ptr.rs +++ b/clippy_utils/src/ptr.rs @@ -36,11 +36,7 @@ fn extract_clone_suggestions<'tcx>( abort: false, }; visitor.visit_body(body); - if visitor.abort { - None - } else { - Some(visitor.spans) - } + if visitor.abort { None } else { Some(visitor.spans) } } struct PtrCloneVisitor<'a, 'tcx> { diff --git a/rustfmt.toml b/rustfmt.toml index f1241e74b0a..4b415a31b27 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -4,3 +4,4 @@ match_block_trailing_comma = true wrap_comments = true edition = "2018" error_on_line_overflow = true +version = "Two" diff --git a/tests/lint_message_convention.rs b/tests/lint_message_convention.rs index 8c07c5b242f..3f754c255b7 100644 --- a/tests/lint_message_convention.rs +++ b/tests/lint_message_convention.rs @@ -98,7 +98,9 @@ fn lint_message_convention() { eprintln!("\n\n"); }); - eprintln!("\n\n\nLint message should not start with a capital letter and should not have punctuation at the end of the message unless multiple sentences are needed."); + eprintln!( + "\n\n\nLint message should not start with a capital letter and should not have punctuation at the end of the message unless multiple sentences are needed." + ); eprintln!("Check out the rustc-dev-guide for more information:"); eprintln!("https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-structure\n\n\n"); diff --git a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs index fdf8905f812..735909887ac 100644 --- a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs +++ b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs @@ -16,7 +16,8 @@ enum Flags { FIN, } -struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of - // `GccLlvmSomething` +// linted with cfg option, beware that lint suggests `GccllvmSomething` instead of +// `GccLlvmSomething` +struct GCCLLVMSomething; fn main() {} diff --git a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr index 1cc59dc45f2..38e30683d57 100644 --- a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr +++ b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr @@ -61,9 +61,9 @@ LL | FIN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin` error: name `GCCLLVMSomething` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:19:8 + --> $DIR/upper_case_acronyms.rs:21:8 | -LL | struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of +LL | struct GCCLLVMSomething; | ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething` error: aborting due to 11 previous errors diff --git a/tests/ui/auxiliary/macro_rules.rs b/tests/ui/auxiliary/macro_rules.rs index d6ecd8568ce..d4470d3f407 100644 --- a/tests/ui/auxiliary/macro_rules.rs +++ b/tests/ui/auxiliary/macro_rules.rs @@ -23,11 +23,7 @@ macro_rules! try_err { pub fn try_err_fn() -> Result { let err: i32 = 1; // To avoid warnings during rustfix - if true { - Err(err)? - } else { - Ok(2) - } + if true { Err(err)? } else { Ok(2) } } }; } diff --git a/tests/ui/blocks_in_if_conditions.fixed b/tests/ui/blocks_in_if_conditions.fixed index 14562c4d32c..e6e40a9948c 100644 --- a/tests/ui/blocks_in_if_conditions.fixed +++ b/tests/ui/blocks_in_if_conditions.fixed @@ -4,9 +4,7 @@ #![warn(clippy::nonminimal_bool)] macro_rules! blocky { - () => {{ - true - }}; + () => {{ true }}; } macro_rules! blocky_too { @@ -34,20 +32,12 @@ fn condition_has_block() -> i32 { } fn condition_has_block_with_single_expression() -> i32 { - if true { - 6 - } else { - 10 - } + if true { 6 } else { 10 } } fn condition_is_normal() -> i32 { let x = 3; - if x == 3 { - 6 - } else { - 10 - } + if x == 3 { 6 } else { 10 } } fn condition_is_unsafe_block() { @@ -61,14 +51,15 @@ fn condition_is_unsafe_block() { fn block_in_assert() { let opt = Some(42); - assert!(opt - .as_ref() - .map(|val| { - let mut v = val * 2; - v -= 1; - v * 3 - }) - .is_some()); + assert!( + opt.as_ref() + .map(|val| { + let mut v = val * 2; + v -= 1; + v * 3 + }) + .is_some() + ); } fn main() {} diff --git a/tests/ui/blocks_in_if_conditions.rs b/tests/ui/blocks_in_if_conditions.rs index bda87650f6d..69387ff5782 100644 --- a/tests/ui/blocks_in_if_conditions.rs +++ b/tests/ui/blocks_in_if_conditions.rs @@ -4,9 +4,7 @@ #![warn(clippy::nonminimal_bool)] macro_rules! blocky { - () => {{ - true - }}; + () => {{ true }}; } macro_rules! blocky_too { @@ -34,20 +32,12 @@ fn condition_has_block() -> i32 { } fn condition_has_block_with_single_expression() -> i32 { - if { true } { - 6 - } else { - 10 - } + if { true } { 6 } else { 10 } } fn condition_is_normal() -> i32 { let x = 3; - if true && x == 3 { - 6 - } else { - 10 - } + if true && x == 3 { 6 } else { 10 } } fn condition_is_unsafe_block() { @@ -61,14 +51,15 @@ fn condition_is_unsafe_block() { fn block_in_assert() { let opt = Some(42); - assert!(opt - .as_ref() - .map(|val| { - let mut v = val * 2; - v -= 1; - v * 3 - }) - .is_some()); + assert!( + opt.as_ref() + .map(|val| { + let mut v = val * 2; + v -= 1; + v * 3 + }) + .is_some() + ); } fn main() {} diff --git a/tests/ui/blocks_in_if_conditions.stderr b/tests/ui/blocks_in_if_conditions.stderr index 9bdddc8e152..9328492733f 100644 --- a/tests/ui/blocks_in_if_conditions.stderr +++ b/tests/ui/blocks_in_if_conditions.stderr @@ -1,5 +1,5 @@ error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` - --> $DIR/blocks_in_if_conditions.rs:26:5 + --> $DIR/blocks_in_if_conditions.rs:24:5 | LL | / if { LL | | let x = 3; @@ -17,15 +17,15 @@ LL | }; if res { | error: omit braces around single expression condition - --> $DIR/blocks_in_if_conditions.rs:37:8 + --> $DIR/blocks_in_if_conditions.rs:35:8 | -LL | if { true } { +LL | if { true } { 6 } else { 10 } | ^^^^^^^^ help: try: `true` error: this boolean expression can be simplified - --> $DIR/blocks_in_if_conditions.rs:46:8 + --> $DIR/blocks_in_if_conditions.rs:40:8 | -LL | if true && x == 3 { +LL | if true && x == 3 { 6 } else { 10 } | ^^^^^^^^^^^^^^ help: try: `x == 3` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` diff --git a/tests/ui/checked_unwrap/simple_conditionals.rs b/tests/ui/checked_unwrap/simple_conditionals.rs index 3e7b4b390ba..36967630834 100644 --- a/tests/ui/checked_unwrap/simple_conditionals.rs +++ b/tests/ui/checked_unwrap/simple_conditionals.rs @@ -66,14 +66,16 @@ fn main() { } if x.is_ok() { x = Err(()); - x.unwrap(); // not unnecessary because of mutation of x - // it will always panic but the lint is not smart enough to see this (it only - // checks if conditions). + // not unnecessary because of mutation of x + // it will always panic but the lint is not smart enough to see this (it only + // checks if conditions). + x.unwrap(); } else { x = Ok(()); - x.unwrap_err(); // not unnecessary because of mutation of x - // it will always panic but the lint is not smart enough to see this (it - // only checks if conditions). + // not unnecessary because of mutation of x + // it will always panic but the lint is not smart enough to see this (it + // only checks if conditions). + x.unwrap_err(); } assert!(x.is_ok(), "{:?}", x.unwrap_err()); // ok, it's a common test pattern diff --git a/tests/ui/crashes/ice-6256.rs b/tests/ui/crashes/ice-6256.rs index 5409f36b3f1..67308263dad 100644 --- a/tests/ui/crashes/ice-6256.rs +++ b/tests/ui/crashes/ice-6256.rs @@ -8,6 +8,7 @@ impl dyn TT { fn func(&self) {} } +#[rustfmt::skip] fn main() { let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types //[nll]~^ ERROR: borrowed data escapes outside of closure diff --git a/tests/ui/crashes/ice-6256.stderr b/tests/ui/crashes/ice-6256.stderr index d1a8bdc3c8d..d35d459168f 100644 --- a/tests/ui/crashes/ice-6256.stderr +++ b/tests/ui/crashes/ice-6256.stderr @@ -1,13 +1,13 @@ error[E0308]: mismatched types - --> $DIR/ice-6256.rs:12:28 + --> $DIR/ice-6256.rs:13:28 | LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types | ^^^^ lifetime mismatch | = note: expected reference `&(dyn TT + 'static)` found reference `&dyn TT` -note: the anonymous lifetime #1 defined on the body at 12:13... - --> $DIR/ice-6256.rs:12:13 +note: the anonymous lifetime #1 defined on the body at 13:13... + --> $DIR/ice-6256.rs:13:13 | LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/dbg_macro.rs b/tests/ui/dbg_macro.rs index d2df7fbd3e8..d74e2611ee1 100644 --- a/tests/ui/dbg_macro.rs +++ b/tests/ui/dbg_macro.rs @@ -1,11 +1,7 @@ #![warn(clippy::dbg_macro)] fn foo(n: u32) -> u32 { - if let Some(n) = dbg!(n.checked_sub(4)) { - n - } else { - n - } + if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } } fn factorial(n: u32) -> u32 { diff --git a/tests/ui/dbg_macro.stderr b/tests/ui/dbg_macro.stderr index b8aafe96678..bdf372af290 100644 --- a/tests/ui/dbg_macro.stderr +++ b/tests/ui/dbg_macro.stderr @@ -1,17 +1,17 @@ error: `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:4:22 | -LL | if let Some(n) = dbg!(n.checked_sub(4)) { +LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } | ^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::dbg-macro` implied by `-D warnings` help: ensure to avoid having uses of it in version control | -LL | if let Some(n) = n.checked_sub(4) { +LL | if let Some(n) = n.checked_sub(4) { n } else { n } | ^^^^^^^^^^^^^^^^ error: `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:12:8 + --> $DIR/dbg_macro.rs:8:8 | LL | if dbg!(n <= 1) { | ^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | if n <= 1 { | ^^^^^^ error: `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:13:9 + --> $DIR/dbg_macro.rs:9:9 | LL | dbg!(1) | ^^^^^^^ @@ -33,7 +33,7 @@ LL | 1 | error: `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:15:9 + --> $DIR/dbg_macro.rs:11:9 | LL | dbg!(n * factorial(n - 1)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | n * factorial(n - 1) | error: `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:20:5 + --> $DIR/dbg_macro.rs:16:5 | LL | dbg!(42); | ^^^^^^^^ @@ -55,7 +55,7 @@ LL | 42; | ^^ error: `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:21:5 + --> $DIR/dbg_macro.rs:17:5 | LL | dbg!(dbg!(dbg!(42))); | ^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL | dbg!(dbg!(42)); | ^^^^^^^^^^^^^^ error: `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:22:14 + --> $DIR/dbg_macro.rs:18:14 | LL | foo(3) + dbg!(factorial(4)); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/default_trait_access.fixed b/tests/ui/default_trait_access.fixed index d05567a3f82..4c80cabc723 100644 --- a/tests/ui/default_trait_access.fixed +++ b/tests/ui/default_trait_access.fixed @@ -48,25 +48,7 @@ fn main() { println!( "[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}], [{:?}]", - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - s14, - s15, - s16, - s17, - s18, - s19, + s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, ); } diff --git a/tests/ui/default_trait_access.rs b/tests/ui/default_trait_access.rs index 447e70c0bbb..a68b6455c04 100644 --- a/tests/ui/default_trait_access.rs +++ b/tests/ui/default_trait_access.rs @@ -48,25 +48,7 @@ fn main() { println!( "[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}], [{:?}]", - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - s14, - s15, - s16, - s17, - s18, - s19, + s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, ); } diff --git a/tests/ui/doc_panics.rs b/tests/ui/doc_panics.rs index 3008c2d5b85..17e72353f80 100644 --- a/tests/ui/doc_panics.rs +++ b/tests/ui/doc_panics.rs @@ -30,11 +30,7 @@ pub fn inner_body(opt: Option) { /// This needs to be documented pub fn unreachable_and_panic() { - if true { - unreachable!() - } else { - panic!() - } + if true { unreachable!() } else { panic!() } } /// This is documented @@ -84,11 +80,7 @@ pub fn todo_documented() { /// /// We still need to do this part pub fn unreachable_amd_panic_documented() { - if true { - unreachable!() - } else { - panic!() - } + if true { unreachable!() } else { panic!() } } /// This is okay because it is private diff --git a/tests/ui/doc_panics.stderr b/tests/ui/doc_panics.stderr index 287148690d2..2fa88a2f6ec 100644 --- a/tests/ui/doc_panics.stderr +++ b/tests/ui/doc_panics.stderr @@ -67,19 +67,15 @@ error: docs for function which may panic missing `# Panics` section --> $DIR/doc_panics.rs:32:1 | LL | / pub fn unreachable_and_panic() { -LL | | if true { -LL | | unreachable!() -LL | | } else { -LL | | panic!() -LL | | } +LL | | if true { unreachable!() } else { panic!() } LL | | } | |_^ | note: first possible panic found here - --> $DIR/doc_panics.rs:36:9 + --> $DIR/doc_panics.rs:33:39 | -LL | panic!() - | ^^^^^^^^ +LL | if true { unreachable!() } else { panic!() } + | ^^^^^^^^ = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 5 previous errors diff --git a/tests/ui/float_cmp.rs b/tests/ui/float_cmp.rs index 586784b73e6..ad5d1a09c03 100644 --- a/tests/ui/float_cmp.rs +++ b/tests/ui/float_cmp.rs @@ -21,19 +21,11 @@ where } fn eq_fl(x: f32, y: f32) -> bool { - if x.is_nan() { - y.is_nan() - } else { - x == y - } // no error, inside "eq" fn + if x.is_nan() { y.is_nan() } else { x == y } // no error, inside "eq" fn } fn fl_eq(x: f32, y: f32) -> bool { - if x.is_nan() { - y.is_nan() - } else { - x == y - } // no error, inside "eq" fn + if x.is_nan() { y.is_nan() } else { x == y } // no error, inside "eq" fn } struct X { diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index bb4051c4662..cb5b68b2e95 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -1,5 +1,5 @@ error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:66:5 + --> $DIR/float_cmp.rs:58:5 | LL | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE as f64 - 2.0).abs() > error_margin` @@ -8,7 +8,7 @@ LL | ONE as f64 != 2.0; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:71:5 + --> $DIR/float_cmp.rs:63:5 | LL | x == 1.0; | ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 1.0).abs() < error_margin` @@ -16,7 +16,7 @@ LL | x == 1.0; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:74:5 + --> $DIR/float_cmp.rs:66:5 | LL | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(twice(x) - twice(ONE as f64)).abs() > error_margin` @@ -24,7 +24,7 @@ LL | twice(x) != twice(ONE as f64); = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:94:5 + --> $DIR/float_cmp.rs:86:5 | LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(NON_ZERO_ARRAY[i] - NON_ZERO_ARRAY[j]).abs() < error_margin` @@ -32,7 +32,7 @@ LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` arrays - --> $DIR/float_cmp.rs:99:5 + --> $DIR/float_cmp.rs:91:5 | LL | a1 == a2; | ^^^^^^^^ @@ -40,7 +40,7 @@ LL | a1 == a2; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:100:5 + --> $DIR/float_cmp.rs:92:5 | LL | a1[0] == a2[0]; | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(a1[0] - a2[0]).abs() < error_margin` diff --git a/tests/ui/float_cmp_const.rs b/tests/ui/float_cmp_const.rs index 263d9a7b92d..86ce3bf3bd9 100644 --- a/tests/ui/float_cmp_const.rs +++ b/tests/ui/float_cmp_const.rs @@ -8,11 +8,7 @@ const ONE: f32 = 1.0; const TWO: f32 = 2.0; fn eq_one(x: f32) -> bool { - if x.is_nan() { - false - } else { - x == ONE - } // no error, inside "eq" fn + if x.is_nan() { false } else { x == ONE } // no error, inside "eq" fn } fn main() { diff --git a/tests/ui/float_cmp_const.stderr b/tests/ui/float_cmp_const.stderr index 5d0455363e8..d8182cf855b 100644 --- a/tests/ui/float_cmp_const.stderr +++ b/tests/ui/float_cmp_const.stderr @@ -1,5 +1,5 @@ error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:20:5 + --> $DIR/float_cmp_const.rs:16:5 | LL | 1f32 == ONE; | ^^^^^^^^^^^ help: consider comparing them within some margin of error: `(1f32 - ONE).abs() < error_margin` @@ -8,7 +8,7 @@ LL | 1f32 == ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:21:5 + --> $DIR/float_cmp_const.rs:17:5 | LL | TWO == ONE; | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(TWO - ONE).abs() < error_margin` @@ -16,7 +16,7 @@ LL | TWO == ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:22:5 + --> $DIR/float_cmp_const.rs:18:5 | LL | TWO != ONE; | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(TWO - ONE).abs() > error_margin` @@ -24,7 +24,7 @@ LL | TWO != ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:23:5 + --> $DIR/float_cmp_const.rs:19:5 | LL | ONE + ONE == TWO; | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE + ONE - TWO).abs() < error_margin` @@ -32,7 +32,7 @@ LL | ONE + ONE == TWO; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:25:5 + --> $DIR/float_cmp_const.rs:21:5 | LL | x as f32 == ONE; | ^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x as f32 - ONE).abs() < error_margin` @@ -40,7 +40,7 @@ LL | x as f32 == ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:28:5 + --> $DIR/float_cmp_const.rs:24:5 | LL | v == ONE; | ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() < error_margin` @@ -48,7 +48,7 @@ LL | v == ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:29:5 + --> $DIR/float_cmp_const.rs:25:5 | LL | v != ONE; | ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() > error_margin` @@ -56,7 +56,7 @@ LL | v != ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant arrays - --> $DIR/float_cmp_const.rs:61:5 + --> $DIR/float_cmp_const.rs:57:5 | LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/floating_point_abs.fixed b/tests/ui/floating_point_abs.fixed index b623e4988e7..cea727257c4 100644 --- a/tests/ui/floating_point_abs.fixed +++ b/tests/ui/floating_point_abs.fixed @@ -42,43 +42,23 @@ fn fake_nabs3(a: A) -> A { } fn not_fake_abs1(num: f64) -> f64 { - if num > 0.0 { - num - } else { - -num - 1f64 - } + if num > 0.0 { num } else { -num - 1f64 } } fn not_fake_abs2(num: f64) -> f64 { - if num > 0.0 { - num + 1.0 - } else { - -(num + 1.0) - } + if num > 0.0 { num + 1.0 } else { -(num + 1.0) } } fn not_fake_abs3(num1: f64, num2: f64) -> f64 { - if num1 > 0.0 { - num2 - } else { - -num2 - } + if num1 > 0.0 { num2 } else { -num2 } } fn not_fake_abs4(a: A) -> f64 { - if a.a > 0.0 { - a.b - } else { - -a.b - } + if a.a > 0.0 { a.b } else { -a.b } } fn not_fake_abs5(a: A) -> f64 { - if a.a > 0.0 { - a.a - } else { - -a.b - } + if a.a > 0.0 { a.a } else { -a.b } } fn main() { diff --git a/tests/ui/floating_point_abs.rs b/tests/ui/floating_point_abs.rs index cbf9c94e41e..ba8a8f18fa2 100644 --- a/tests/ui/floating_point_abs.rs +++ b/tests/ui/floating_point_abs.rs @@ -7,59 +7,31 @@ struct A { } fn fake_abs1(num: f64) -> f64 { - if num >= 0.0 { - num - } else { - -num - } + if num >= 0.0 { num } else { -num } } fn fake_abs2(num: f64) -> f64 { - if 0.0 < num { - num - } else { - -num - } + if 0.0 < num { num } else { -num } } fn fake_abs3(a: A) -> f64 { - if a.a > 0.0 { - a.a - } else { - -a.a - } + if a.a > 0.0 { a.a } else { -a.a } } fn fake_abs4(num: f64) -> f64 { - if 0.0 >= num { - -num - } else { - num - } + if 0.0 >= num { -num } else { num } } fn fake_abs5(a: A) -> f64 { - if a.a < 0.0 { - -a.a - } else { - a.a - } + if a.a < 0.0 { -a.a } else { a.a } } fn fake_nabs1(num: f64) -> f64 { - if num < 0.0 { - num - } else { - -num - } + if num < 0.0 { num } else { -num } } fn fake_nabs2(num: f64) -> f64 { - if 0.0 >= num { - num - } else { - -num - } + if 0.0 >= num { num } else { -num } } fn fake_nabs3(a: A) -> A { @@ -70,43 +42,23 @@ fn fake_nabs3(a: A) -> A { } fn not_fake_abs1(num: f64) -> f64 { - if num > 0.0 { - num - } else { - -num - 1f64 - } + if num > 0.0 { num } else { -num - 1f64 } } fn not_fake_abs2(num: f64) -> f64 { - if num > 0.0 { - num + 1.0 - } else { - -(num + 1.0) - } + if num > 0.0 { num + 1.0 } else { -(num + 1.0) } } fn not_fake_abs3(num1: f64, num2: f64) -> f64 { - if num1 > 0.0 { - num2 - } else { - -num2 - } + if num1 > 0.0 { num2 } else { -num2 } } fn not_fake_abs4(a: A) -> f64 { - if a.a > 0.0 { - a.b - } else { - -a.b - } + if a.a > 0.0 { a.b } else { -a.b } } fn not_fake_abs5(a: A) -> f64 { - if a.a > 0.0 { - a.a - } else { - -a.b - } + if a.a > 0.0 { a.a } else { -a.b } } fn main() { diff --git a/tests/ui/floating_point_abs.stderr b/tests/ui/floating_point_abs.stderr index 74a71f2ca7c..35af70201fa 100644 --- a/tests/ui/floating_point_abs.stderr +++ b/tests/ui/floating_point_abs.stderr @@ -1,77 +1,49 @@ error: manual implementation of `abs` method --> $DIR/floating_point_abs.rs:10:5 | -LL | / if num >= 0.0 { -LL | | num -LL | | } else { -LL | | -num -LL | | } - | |_____^ help: try: `num.abs()` +LL | if num >= 0.0 { num } else { -num } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` | = note: `-D clippy::suboptimal-flops` implied by `-D warnings` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:18:5 + --> $DIR/floating_point_abs.rs:14:5 | -LL | / if 0.0 < num { -LL | | num -LL | | } else { -LL | | -num -LL | | } - | |_____^ help: try: `num.abs()` +LL | if 0.0 < num { num } else { -num } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:26:5 + --> $DIR/floating_point_abs.rs:18:5 | -LL | / if a.a > 0.0 { -LL | | a.a -LL | | } else { -LL | | -a.a -LL | | } - | |_____^ help: try: `a.a.abs()` +LL | if a.a > 0.0 { a.a } else { -a.a } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:34:5 + --> $DIR/floating_point_abs.rs:22:5 | -LL | / if 0.0 >= num { -LL | | -num -LL | | } else { -LL | | num -LL | | } - | |_____^ help: try: `num.abs()` +LL | if 0.0 >= num { -num } else { num } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:42:5 + --> $DIR/floating_point_abs.rs:26:5 | -LL | / if a.a < 0.0 { -LL | | -a.a -LL | | } else { -LL | | a.a -LL | | } - | |_____^ help: try: `a.a.abs()` +LL | if a.a < 0.0 { -a.a } else { a.a } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()` error: manual implementation of negation of `abs` method - --> $DIR/floating_point_abs.rs:50:5 + --> $DIR/floating_point_abs.rs:30:5 | -LL | / if num < 0.0 { -LL | | num -LL | | } else { -LL | | -num -LL | | } - | |_____^ help: try: `-num.abs()` +LL | if num < 0.0 { num } else { -num } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()` error: manual implementation of negation of `abs` method - --> $DIR/floating_point_abs.rs:58:5 + --> $DIR/floating_point_abs.rs:34:5 | -LL | / if 0.0 >= num { -LL | | num -LL | | } else { -LL | | -num -LL | | } - | |_____^ help: try: `-num.abs()` +LL | if 0.0 >= num { num } else { -num } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()` error: manual implementation of negation of `abs` method - --> $DIR/floating_point_abs.rs:67:12 + --> $DIR/floating_point_abs.rs:39:12 | LL | a: if a.a >= 0.0 { -a.a } else { a.a }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-a.a.abs()` diff --git a/tests/ui/if_let_some_result.fixed b/tests/ui/if_let_some_result.fixed index 80505fd997f..62a25ce2d12 100644 --- a/tests/ui/if_let_some_result.fixed +++ b/tests/ui/if_let_some_result.fixed @@ -3,19 +3,11 @@ #![warn(clippy::if_let_some_result)] fn str_to_int(x: &str) -> i32 { - if let Ok(y) = x.parse() { - y - } else { - 0 - } + if let Ok(y) = x.parse() { y } else { 0 } } fn str_to_int_ok(x: &str) -> i32 { - if let Ok(y) = x.parse() { - y - } else { - 0 - } + if let Ok(y) = x.parse() { y } else { 0 } } #[rustfmt::skip] diff --git a/tests/ui/if_let_some_result.rs b/tests/ui/if_let_some_result.rs index ecac1357445..234ff5e9e80 100644 --- a/tests/ui/if_let_some_result.rs +++ b/tests/ui/if_let_some_result.rs @@ -3,19 +3,11 @@ #![warn(clippy::if_let_some_result)] fn str_to_int(x: &str) -> i32 { - if let Some(y) = x.parse().ok() { - y - } else { - 0 - } + if let Some(y) = x.parse().ok() { y } else { 0 } } fn str_to_int_ok(x: &str) -> i32 { - if let Ok(y) = x.parse() { - y - } else { - 0 - } + if let Ok(y) = x.parse() { y } else { 0 } } #[rustfmt::skip] diff --git a/tests/ui/if_let_some_result.stderr b/tests/ui/if_let_some_result.stderr index 6afee0f36b9..0646dd27f35 100644 --- a/tests/ui/if_let_some_result.stderr +++ b/tests/ui/if_let_some_result.stderr @@ -1,17 +1,17 @@ error: matching on `Some` with `ok()` is redundant --> $DIR/if_let_some_result.rs:6:5 | -LL | if let Some(y) = x.parse().ok() { +LL | if let Some(y) = x.parse().ok() { y } else { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::if-let-some-result` implied by `-D warnings` help: consider matching on `Ok(y)` and removing the call to `ok` instead | -LL | if let Ok(y) = x.parse() { +LL | if let Ok(y) = x.parse() { y } else { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^ error: matching on `Some` with `ok()` is redundant - --> $DIR/if_let_some_result.rs:24:9 + --> $DIR/if_let_some_result.rs:16:9 | LL | if let Some(y) = x . parse() . ok () { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/implicit_return.fixed b/tests/ui/implicit_return.fixed index 9066dc3fedf..59f7ad9c106 100644 --- a/tests/ui/implicit_return.fixed +++ b/tests/ui/implicit_return.fixed @@ -14,11 +14,7 @@ fn test_end_of_fn() -> bool { #[allow(clippy::needless_bool)] fn test_if_block() -> bool { - if true { - return true - } else { - return false - } + if true { return true } else { return false } } #[rustfmt::skip] diff --git a/tests/ui/implicit_return.rs b/tests/ui/implicit_return.rs index c0d70ecf502..2c1bc046515 100644 --- a/tests/ui/implicit_return.rs +++ b/tests/ui/implicit_return.rs @@ -14,11 +14,7 @@ fn test_end_of_fn() -> bool { #[allow(clippy::needless_bool)] fn test_if_block() -> bool { - if true { - true - } else { - false - } + if true { true } else { false } } #[rustfmt::skip] diff --git a/tests/ui/implicit_return.stderr b/tests/ui/implicit_return.stderr index fb2ec902764..3608319e5bd 100644 --- a/tests/ui/implicit_return.stderr +++ b/tests/ui/implicit_return.stderr @@ -7,61 +7,61 @@ LL | true = note: `-D clippy::implicit-return` implied by `-D warnings` error: missing `return` statement - --> $DIR/implicit_return.rs:18:9 + --> $DIR/implicit_return.rs:17:15 | -LL | true - | ^^^^ help: add `return` as shown: `return true` +LL | if true { true } else { false } + | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:20:9 + --> $DIR/implicit_return.rs:17:29 | -LL | false - | ^^^^^ help: add `return` as shown: `return false` +LL | if true { true } else { false } + | ^^^^^ help: add `return` as shown: `return false` error: missing `return` statement - --> $DIR/implicit_return.rs:27:17 + --> $DIR/implicit_return.rs:23:17 | LL | true => false, | ^^^^^ help: add `return` as shown: `return false` error: missing `return` statement - --> $DIR/implicit_return.rs:28:20 + --> $DIR/implicit_return.rs:24:20 | LL | false => { true }, | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:43:9 + --> $DIR/implicit_return.rs:39:9 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:51:13 + --> $DIR/implicit_return.rs:47:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:60:13 + --> $DIR/implicit_return.rs:56:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:78:18 + --> $DIR/implicit_return.rs:74:18 | LL | let _ = || { true }; | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:79:16 + --> $DIR/implicit_return.rs:75:16 | LL | let _ = || true; | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:87:5 + --> $DIR/implicit_return.rs:83:5 | LL | format!("test {}", "test") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add `return` as shown: `return format!("test {}", "test")` diff --git a/tests/ui/needless_lifetimes.rs b/tests/ui/needless_lifetimes.rs index 44972c8c639..bda0801e51c 100644 --- a/tests/ui/needless_lifetimes.rs +++ b/tests/ui/needless_lifetimes.rs @@ -105,11 +105,7 @@ fn fn_bound_3_cannot_elide() { // No error; multiple input refs. fn fn_bound_4<'a, F: FnOnce() -> &'a ()>(cond: bool, x: &'a (), f: F) -> &'a () { - if cond { - x - } else { - f() - } + if cond { x } else { f() } } struct X { diff --git a/tests/ui/needless_lifetimes.stderr b/tests/ui/needless_lifetimes.stderr index c8a2e8b81c0..33a6de1618d 100644 --- a/tests/ui/needless_lifetimes.stderr +++ b/tests/ui/needless_lifetimes.stderr @@ -43,109 +43,109 @@ LL | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:120:5 + --> $DIR/needless_lifetimes.rs:116:5 | LL | fn self_and_out<'s>(&'s self) -> &'s u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:129:5 + --> $DIR/needless_lifetimes.rs:125:5 | LL | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:148:1 + --> $DIR/needless_lifetimes.rs:144:1 | LL | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:178:1 + --> $DIR/needless_lifetimes.rs:174:1 | LL | fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:184:1 + --> $DIR/needless_lifetimes.rs:180:1 | LL | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:203:1 + --> $DIR/needless_lifetimes.rs:199:1 | LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:211:1 + --> $DIR/needless_lifetimes.rs:207:1 | LL | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:247:1 + --> $DIR/needless_lifetimes.rs:243:1 | LL | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:254:9 + --> $DIR/needless_lifetimes.rs:250:9 | LL | fn needless_lt<'a>(x: &'a u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:258:9 + --> $DIR/needless_lifetimes.rs:254:9 | LL | fn needless_lt<'a>(_x: &'a u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:271:9 + --> $DIR/needless_lifetimes.rs:267:9 | LL | fn baz<'a>(&'a self) -> impl Foo + 'a { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:300:5 + --> $DIR/needless_lifetimes.rs:296:5 | LL | fn impl_trait_elidable_nested_named_lifetimes<'a>(i: &'a i32, f: impl for<'b> Fn(&'b i32) -> &'b i32) -> &'a i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:303:5 + --> $DIR/needless_lifetimes.rs:299:5 | LL | fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:312:5 + --> $DIR/needless_lifetimes.rs:308:5 | LL | fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:324:5 + --> $DIR/needless_lifetimes.rs:320:5 | LL | fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:339:5 + --> $DIR/needless_lifetimes.rs:335:5 | LL | fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:352:5 + --> $DIR/needless_lifetimes.rs:348:5 | LL | fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/needless_lifetimes.rs:355:5 + --> $DIR/needless_lifetimes.rs:351:5 | LL | fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_clone.fixed b/tests/ui/redundant_clone.fixed index a5847e37c97..ec309109ed5 100644 --- a/tests/ui/redundant_clone.fixed +++ b/tests/ui/redundant_clone.fixed @@ -59,11 +59,7 @@ fn main() { #[derive(Clone)] struct Alpha; fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) { - if b { - (a.clone(), a) - } else { - (Alpha, a) - } + if b { (a.clone(), a) } else { (Alpha, a) } } fn cannot_double_move(a: Alpha) -> (Alpha, Alpha) { diff --git a/tests/ui/redundant_clone.rs b/tests/ui/redundant_clone.rs index dab8d7fb1c7..b57027456e0 100644 --- a/tests/ui/redundant_clone.rs +++ b/tests/ui/redundant_clone.rs @@ -59,11 +59,7 @@ fn main() { #[derive(Clone)] struct Alpha; fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) { - if b { - (a.clone(), a.clone()) - } else { - (Alpha, a) - } + if b { (a.clone(), a.clone()) } else { (Alpha, a) } } fn cannot_double_move(a: Alpha) -> (Alpha, Alpha) { diff --git a/tests/ui/redundant_clone.stderr b/tests/ui/redundant_clone.stderr index 87c219316ce..821e7934be8 100644 --- a/tests/ui/redundant_clone.stderr +++ b/tests/ui/redundant_clone.stderr @@ -108,61 +108,61 @@ LL | let _t = tup.0.clone(); | ^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:63:22 + --> $DIR/redundant_clone.rs:62:25 | -LL | (a.clone(), a.clone()) - | ^^^^^^^^ help: remove this +LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) } + | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:63:21 + --> $DIR/redundant_clone.rs:62:24 | -LL | (a.clone(), a.clone()) - | ^ +LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) } + | ^ error: redundant clone - --> $DIR/redundant_clone.rs:123:15 + --> $DIR/redundant_clone.rs:119:15 | LL | let _s = s.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:123:14 + --> $DIR/redundant_clone.rs:119:14 | LL | let _s = s.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:124:15 + --> $DIR/redundant_clone.rs:120:15 | LL | let _t = t.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:124:14 + --> $DIR/redundant_clone.rs:120:14 | LL | let _t = t.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:134:19 + --> $DIR/redundant_clone.rs:130:19 | LL | let _f = f.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:134:18 + --> $DIR/redundant_clone.rs:130:18 | LL | let _f = f.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:146:14 + --> $DIR/redundant_clone.rs:142:14 | LL | let y = x.clone().join("matthias"); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated - --> $DIR/redundant_clone.rs:146:13 + --> $DIR/redundant_clone.rs:142:13 | LL | let y = x.clone().join("matthias"); | ^^^^^^^^^ diff --git a/tests/ui/unnecessary_wraps.rs b/tests/ui/unnecessary_wraps.rs index a510263e67d..54f22e3ee6a 100644 --- a/tests/ui/unnecessary_wraps.rs +++ b/tests/ui/unnecessary_wraps.rs @@ -22,29 +22,17 @@ fn func2(a: bool, b: bool) -> Option { if a && b { return Some(10); } - if a { - Some(20) - } else { - Some(30) - } + if a { Some(20) } else { Some(30) } } // public fns should not be linted pub fn func3(a: bool) -> Option { - if a { - Some(1) - } else { - Some(1) - } + if a { Some(1) } else { Some(1) } } // should not be linted fn func4(a: bool) -> Option { - if a { - Some(1) - } else { - None - } + if a { Some(1) } else { None } } // should be linted @@ -64,11 +52,7 @@ fn func7() -> Result { // should not be linted fn func8(a: bool) -> Result { - if a { - Ok(1) - } else { - Err(()) - } + if a { Ok(1) } else { Err(()) } } // should not be linted @@ -143,20 +127,12 @@ fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> { // should not be linted fn issue_6640_3() -> Option<()> { - if true { - Some(()) - } else { - None - } + if true { Some(()) } else { None } } // should not be linted fn issue_6640_4() -> Result<(), ()> { - if true { - Ok(()) - } else { - Err(()) - } + if true { Ok(()) } else { Err(()) } } fn main() { diff --git a/tests/ui/unnecessary_wraps.stderr b/tests/ui/unnecessary_wraps.stderr index 9a861c61a46..0e570397e2a 100644 --- a/tests/ui/unnecessary_wraps.stderr +++ b/tests/ui/unnecessary_wraps.stderr @@ -32,8 +32,7 @@ LL | / fn func2(a: bool, b: bool) -> Option { LL | | if a && b { LL | | return Some(10); LL | | } -... | -LL | | } +LL | | if a { Some(20) } else { Some(30) } LL | | } | |_^ | @@ -45,14 +44,11 @@ help: ...and then change returning expressions | LL | return 10; LL | } -LL | if a { -LL | 20 -LL | } else { -LL | 30 +LL | if a { 20 } else { 30 } | error: this function's return value is unnecessarily wrapped by `Option` - --> $DIR/unnecessary_wraps.rs:51:1 + --> $DIR/unnecessary_wraps.rs:39:1 | LL | / fn func5() -> Option { LL | | Some(1) @@ -69,7 +65,7 @@ LL | 1 | error: this function's return value is unnecessarily wrapped by `Result` - --> $DIR/unnecessary_wraps.rs:61:1 + --> $DIR/unnecessary_wraps.rs:49:1 | LL | / fn func7() -> Result { LL | | Ok(1) @@ -86,7 +82,7 @@ LL | 1 | error: this function's return value is unnecessarily wrapped by `Option` - --> $DIR/unnecessary_wraps.rs:93:5 + --> $DIR/unnecessary_wraps.rs:77:5 | LL | / fn func12() -> Option { LL | | Some(1) @@ -103,7 +99,7 @@ LL | 1 | error: this function's return value is unnecessary - --> $DIR/unnecessary_wraps.rs:120:1 + --> $DIR/unnecessary_wraps.rs:104:1 | LL | / fn issue_6640_1(a: bool, b: bool) -> Option<()> { LL | | if a && b { @@ -129,7 +125,7 @@ LL | } else { ... error: this function's return value is unnecessary - --> $DIR/unnecessary_wraps.rs:133:1 + --> $DIR/unnecessary_wraps.rs:117:1 | LL | / fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> { LL | | if a && b { diff --git a/tests/ui/upper_case_acronyms.rs b/tests/ui/upper_case_acronyms.rs index fdf8905f812..735909887ac 100644 --- a/tests/ui/upper_case_acronyms.rs +++ b/tests/ui/upper_case_acronyms.rs @@ -16,7 +16,8 @@ enum Flags { FIN, } -struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of - // `GccLlvmSomething` +// linted with cfg option, beware that lint suggests `GccllvmSomething` instead of +// `GccLlvmSomething` +struct GCCLLVMSomething; fn main() {} diff --git a/tests/ui/use_self.fixed b/tests/ui/use_self.fixed index 95e7bc75431..2b22a2ed2d5 100644 --- a/tests/ui/use_self.fixed +++ b/tests/ui/use_self.fixed @@ -329,11 +329,7 @@ mod issue4140 { type To = Self; fn from(value: bool) -> Self { - if value { - 100 - } else { - 0 - } + if value { 100 } else { 0 } } } } diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index 75424f34159..609625abdec 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -329,11 +329,7 @@ mod issue4140 { type To = Self; fn from(value: bool) -> Self { - if value { - 100 - } else { - 0 - } + if value { 100 } else { 0 } } } } diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index 37dfef7cfe0..e1410d2e652 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -169,7 +169,7 @@ LL | type To = T::To; | ^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:457:13 + --> $DIR/use_self.rs:453:13 | LL | A::new::(submod::B {}) | ^ help: use the applicable keyword: `Self` -- cgit 1.4.1-3-g733a5 From 1c3a3e7dc62ae3b4b84cc00c067789dae1d722c9 Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Mon, 15 Mar 2021 19:55:45 -0500 Subject: Don't re-export clippy_utils::diagnostics::* --- clippy_lints/src/approx_const.rs | 2 +- clippy_lints/src/arithmetic.rs | 2 +- clippy_lints/src/as_conversions.rs | 3 +-- clippy_lints/src/asm_syntax.rs | 2 +- clippy_lints/src/assertions_on_constants.rs | 3 ++- clippy_lints/src/assign_ops.rs | 3 ++- clippy_lints/src/async_yields_async.rs | 2 +- clippy_lints/src/atomic_ordering.rs | 3 ++- clippy_lints/src/attrs.rs | 3 ++- clippy_lints/src/await_holding_invalid.rs | 3 ++- clippy_lints/src/bit_mask.rs | 2 +- clippy_lints/src/blacklisted_name.rs | 2 +- clippy_lints/src/blocks_in_if_conditions.rs | 3 ++- clippy_lints/src/booleans.rs | 3 ++- clippy_lints/src/bytecount.rs | 3 ++- clippy_lints/src/cargo_common_metadata.rs | 3 ++- clippy_lints/src/case_sensitive_file_extension_comparisons.rs | 2 +- clippy_lints/src/casts/cast_lossless.rs | 3 ++- clippy_lints/src/casts/cast_possible_truncation.rs | 2 +- clippy_lints/src/casts/cast_possible_wrap.rs | 3 +-- clippy_lints/src/casts/cast_precision_loss.rs | 3 +-- clippy_lints/src/casts/cast_ptr_alignment.rs | 3 ++- clippy_lints/src/casts/cast_ref_to_mut.rs | 6 ++---- clippy_lints/src/casts/cast_sign_loss.rs | 3 ++- clippy_lints/src/casts/char_lit_as_u8.rs | 3 +-- clippy_lints/src/casts/fn_to_numeric_cast.rs | 2 +- clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs | 2 +- clippy_lints/src/casts/ptr_as_ptr.rs | 3 ++- clippy_lints/src/casts/unnecessary_cast.rs | 3 ++- clippy_lints/src/checked_conversions.rs | 3 ++- clippy_lints/src/cognitive_complexity.rs | 3 ++- clippy_lints/src/collapsible_if.rs | 2 +- clippy_lints/src/collapsible_match.rs | 3 ++- clippy_lints/src/comparison_chain.rs | 3 ++- clippy_lints/src/copies.rs | 3 ++- clippy_lints/src/copy_iterator.rs | 2 +- clippy_lints/src/create_dir.rs | 3 ++- clippy_lints/src/dbg_macro.rs | 2 +- clippy_lints/src/default.rs | 2 +- clippy_lints/src/default_numeric_fallback.rs | 3 +-- clippy_lints/src/dereference.rs | 3 ++- clippy_lints/src/derive.rs | 6 ++---- clippy_lints/src/disallowed_method.rs | 3 ++- clippy_lints/src/doc.rs | 5 ++--- clippy_lints/src/double_comparison.rs | 3 ++- clippy_lints/src/double_parens.rs | 2 +- clippy_lints/src/drop_forget_ref.rs | 3 ++- clippy_lints/src/duration_subsec.rs | 2 +- clippy_lints/src/else_if_without_else.rs | 3 +-- clippy_lints/src/empty_enum.rs | 2 +- clippy_lints/src/entry.rs | 2 +- clippy_lints/src/enum_clike.rs | 2 +- clippy_lints/src/enum_variants.rs | 2 +- clippy_lints/src/eq_op.rs | 6 ++---- clippy_lints/src/erasing_op.rs | 2 +- clippy_lints/src/escape.rs | 3 +-- clippy_lints/src/eta_reduction.rs | 3 ++- clippy_lints/src/eval_order_dependence.rs | 3 ++- clippy_lints/src/excessive_bools.rs | 3 ++- clippy_lints/src/exhaustive_items.rs | 4 +--- clippy_lints/src/exit.rs | 3 ++- clippy_lints/src/explicit_write.rs | 3 ++- clippy_lints/src/fallible_impl_from.rs | 3 ++- clippy_lints/src/float_equality_without_abs.rs | 3 ++- clippy_lints/src/float_literal.rs | 3 ++- clippy_lints/src/floating_point_arithmetic.rs | 3 ++- clippy_lints/src/format.rs | 3 ++- clippy_lints/src/formatting.rs | 3 ++- clippy_lints/src/from_over_into.rs | 3 ++- clippy_lints/src/from_str_radix_10.rs | 2 +- clippy_lints/src/functions.rs | 3 ++- clippy_lints/src/future_not_send.rs | 3 ++- clippy_lints/src/get_last_with_len.rs | 3 ++- clippy_lints/src/identity_op.rs | 3 ++- clippy_lints/src/if_let_mutex.rs | 3 ++- clippy_lints/src/if_let_some_result.rs | 3 ++- clippy_lints/src/if_not_else.rs | 3 +-- clippy_lints/src/if_then_some_else_none.rs | 3 ++- clippy_lints/src/implicit_return.rs | 3 ++- clippy_lints/src/implicit_saturating_sub.rs | 3 ++- clippy_lints/src/inconsistent_struct_constructor.rs | 3 +-- clippy_lints/src/indexing_slicing.rs | 3 ++- clippy_lints/src/infinite_iter.rs | 3 ++- clippy_lints/src/inherent_impl.rs | 3 ++- clippy_lints/src/inherent_to_string.rs | 3 ++- clippy_lints/src/inline_fn_without_body.rs | 2 +- clippy_lints/src/int_plus_one.rs | 3 +-- clippy_lints/src/integer_division.rs | 2 +- clippy_lints/src/items_after_statements.rs | 2 +- clippy_lints/src/large_const_arrays.rs | 2 +- clippy_lints/src/large_enum_variant.rs | 2 +- clippy_lints/src/large_stack_arrays.rs | 2 +- clippy_lints/src/len_zero.rs | 3 ++- clippy_lints/src/let_if_seq.rs | 3 ++- clippy_lints/src/let_underscore.rs | 3 ++- clippy_lints/src/lifetimes.rs | 3 ++- clippy_lints/src/literal_representation.rs | 2 +- clippy_lints/src/loops/empty_loop.rs | 3 ++- clippy_lints/src/loops/explicit_counter_loop.rs | 3 ++- clippy_lints/src/loops/explicit_into_iter_loop.rs | 2 +- clippy_lints/src/loops/explicit_iter_loop.rs | 3 ++- clippy_lints/src/loops/for_kv_map.rs | 3 ++- clippy_lints/src/loops/for_loops_over_fallibles.rs | 5 ++--- clippy_lints/src/loops/iter_next_loop.rs | 3 ++- clippy_lints/src/loops/manual_flatten.rs | 3 ++- clippy_lints/src/loops/manual_memcpy.rs | 3 ++- clippy_lints/src/loops/mut_range_bound.rs | 3 ++- clippy_lints/src/loops/needless_collect.rs | 3 ++- clippy_lints/src/loops/needless_range_loop.rs | 4 ++-- clippy_lints/src/loops/never_loop.rs | 2 +- clippy_lints/src/loops/same_item_push.rs | 2 +- clippy_lints/src/loops/single_element_loop.rs | 3 ++- clippy_lints/src/loops/while_immutable_condition.rs | 2 +- clippy_lints/src/loops/while_let_loop.rs | 2 +- clippy_lints/src/loops/while_let_on_iterator.rs | 2 +- clippy_lints/src/macro_use.rs | 3 ++- clippy_lints/src/main_recursion.rs | 3 ++- clippy_lints/src/manual_async_fn.rs | 3 ++- clippy_lints/src/manual_map.rs | 3 ++- clippy_lints/src/manual_non_exhaustive.rs | 3 ++- clippy_lints/src/manual_ok_or.rs | 3 ++- clippy_lints/src/manual_strip.rs | 3 ++- clippy_lints/src/manual_unwrap_or.rs | 3 ++- clippy_lints/src/map_clone.rs | 3 ++- clippy_lints/src/map_err_ignore.rs | 3 +-- clippy_lints/src/map_identity.rs | 3 ++- clippy_lints/src/map_unit_fn.rs | 3 ++- clippy_lints/src/match_on_vec_items.rs | 2 +- clippy_lints/src/matches.rs | 11 +++++++---- clippy_lints/src/mem_discriminant.rs | 3 ++- clippy_lints/src/mem_forget.rs | 3 ++- clippy_lints/src/mem_replace.rs | 6 ++---- clippy_lints/src/methods/bind_instead_of_map.rs | 6 ++---- clippy_lints/src/methods/bytes_nth.rs | 2 +- clippy_lints/src/methods/clone_on_copy.rs | 3 ++- clippy_lints/src/methods/clone_on_ref_ptr.rs | 3 ++- clippy_lints/src/methods/expect_fun_call.rs | 3 ++- clippy_lints/src/methods/expect_used.rs | 2 +- clippy_lints/src/methods/filetype_is_file.rs | 3 ++- clippy_lints/src/methods/filter_flat_map.rs | 3 ++- clippy_lints/src/methods/filter_map.rs | 3 ++- clippy_lints/src/methods/filter_map_flat_map.rs | 3 ++- clippy_lints/src/methods/filter_map_identity.rs | 3 ++- clippy_lints/src/methods/filter_map_map.rs | 3 ++- clippy_lints/src/methods/filter_map_next.rs | 3 ++- clippy_lints/src/methods/filter_next.rs | 3 ++- clippy_lints/src/methods/flat_map_identity.rs | 3 ++- clippy_lints/src/methods/from_iter_instead_of_collect.rs | 3 ++- clippy_lints/src/methods/get_unwrap.rs | 3 ++- clippy_lints/src/methods/implicit_clone.rs | 2 +- clippy_lints/src/methods/inefficient_to_string.rs | 3 ++- clippy_lints/src/methods/inspect_for_each.rs | 3 ++- clippy_lints/src/methods/into_iter_on_ref.rs | 3 ++- clippy_lints/src/methods/iter_cloned_collect.rs | 2 +- clippy_lints/src/methods/iter_count.rs | 3 ++- clippy_lints/src/methods/iter_next_slice.rs | 3 ++- clippy_lints/src/methods/iter_nth.rs | 2 +- clippy_lints/src/methods/iter_nth_zero.rs | 3 ++- clippy_lints/src/methods/iter_skip_next.rs | 3 ++- clippy_lints/src/methods/iterator_step_by_zero.rs | 3 ++- clippy_lints/src/methods/manual_saturating_arithmetic.rs | 3 ++- clippy_lints/src/methods/map_collect_result_unit.rs | 3 ++- clippy_lints/src/methods/map_flatten.rs | 3 ++- clippy_lints/src/methods/map_unwrap_or.rs | 3 ++- clippy_lints/src/methods/mod.rs | 4 ++-- clippy_lints/src/methods/ok_expect.rs | 2 +- clippy_lints/src/methods/option_as_ref_deref.rs | 3 ++- clippy_lints/src/methods/option_map_or_none.rs | 3 ++- clippy_lints/src/methods/option_map_unwrap_or.rs | 3 ++- clippy_lints/src/methods/or_fun_call.rs | 3 ++- clippy_lints/src/methods/search_is_some.rs | 3 ++- clippy_lints/src/methods/single_char_insert_string.rs | 2 +- clippy_lints/src/methods/single_char_pattern.rs | 2 +- clippy_lints/src/methods/single_char_push_string.rs | 2 +- clippy_lints/src/methods/skip_while_next.rs | 3 ++- clippy_lints/src/methods/string_extend_chars.rs | 3 ++- clippy_lints/src/methods/suspicious_map.rs | 3 ++- clippy_lints/src/methods/uninit_assumed_init.rs | 3 ++- clippy_lints/src/methods/unnecessary_filter_map.rs | 3 ++- clippy_lints/src/methods/unnecessary_fold.rs | 3 ++- clippy_lints/src/methods/unnecessary_lazy_eval.rs | 2 +- clippy_lints/src/methods/unwrap_used.rs | 2 +- clippy_lints/src/methods/useless_asref.rs | 3 ++- clippy_lints/src/methods/wrong_self_convention.rs | 2 +- clippy_lints/src/methods/zst_offset.rs | 2 +- clippy_lints/src/minmax.rs | 3 ++- clippy_lints/src/misc.rs | 4 ++-- clippy_lints/src/misc_early.rs | 2 +- clippy_lints/src/missing_const_for_fn.rs | 3 ++- clippy_lints/src/missing_doc.rs | 2 +- clippy_lints/src/missing_inline.rs | 2 +- clippy_lints/src/modulo_arithmetic.rs | 3 ++- clippy_lints/src/multiple_crate_versions.rs | 3 ++- clippy_lints/src/mut_key.rs | 3 ++- clippy_lints/src/mut_mut.rs | 3 ++- clippy_lints/src/mut_mutex_lock.rs | 2 +- clippy_lints/src/mut_reference.rs | 2 +- clippy_lints/src/mutable_debug_assertion.rs | 3 ++- clippy_lints/src/mutex_atomic.rs | 2 +- clippy_lints/src/needless_arbitrary_self_type.rs | 3 ++- clippy_lints/src/needless_bool.rs | 3 ++- clippy_lints/src/needless_borrow.rs | 3 ++- clippy_lints/src/needless_borrowed_ref.rs | 2 +- clippy_lints/src/needless_continue.rs | 3 +-- clippy_lints/src/needless_pass_by_value.rs | 3 ++- clippy_lints/src/needless_question_mark.rs | 3 ++- clippy_lints/src/needless_update.rs | 2 +- clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 3 ++- clippy_lints/src/neg_multiply.rs | 2 +- clippy_lints/src/new_without_default.rs | 3 ++- clippy_lints/src/no_effect.rs | 2 +- clippy_lints/src/non_copy_const.rs | 3 ++- clippy_lints/src/non_expressive_names.rs | 2 +- clippy_lints/src/open_options.rs | 3 ++- clippy_lints/src/option_env_unwrap.rs | 3 ++- clippy_lints/src/option_if_let_else.rs | 3 ++- clippy_lints/src/overflow_check_conditional.rs | 3 ++- clippy_lints/src/panic_in_result_fn.rs | 3 ++- clippy_lints/src/panic_unimplemented.rs | 3 ++- clippy_lints/src/partialeq_ne_impl.rs | 3 ++- clippy_lints/src/pass_by_ref_or_value.rs | 3 ++- clippy_lints/src/path_buf_push_overwrite.rs | 2 +- clippy_lints/src/pattern_type_mismatch.rs | 3 ++- clippy_lints/src/precedence.rs | 2 +- clippy_lints/src/ptr.rs | 3 ++- clippy_lints/src/ptr_eq.rs | 3 ++- clippy_lints/src/ptr_offset_with_cast.rs | 2 +- clippy_lints/src/question_mark.rs | 3 ++- clippy_lints/src/ranges.rs | 6 ++---- clippy_lints/src/redundant_clone.rs | 3 ++- clippy_lints/src/redundant_closure_call.rs | 2 +- clippy_lints/src/redundant_else.rs | 2 +- clippy_lints/src/redundant_field_names.rs | 3 ++- clippy_lints/src/redundant_pub_crate.rs | 2 +- clippy_lints/src/redundant_slicing.rs | 3 +-- clippy_lints/src/redundant_static_lifetimes.rs | 3 ++- clippy_lints/src/ref_option_ref.rs | 3 ++- clippy_lints/src/reference.rs | 3 ++- clippy_lints/src/regex.rs | 3 ++- clippy_lints/src/repeat_once.rs | 3 ++- clippy_lints/src/returns.rs | 3 ++- clippy_lints/src/self_assignment.rs | 3 ++- clippy_lints/src/semicolon_if_nothing_returned.rs | 3 ++- clippy_lints/src/serde_api.rs | 3 ++- clippy_lints/src/shadow.rs | 3 ++- clippy_lints/src/single_component_path_imports.rs | 3 ++- clippy_lints/src/size_of_in_element_count.rs | 3 ++- clippy_lints/src/slow_vector_initialization.rs | 3 ++- clippy_lints/src/stable_sort_primitive.rs | 3 ++- clippy_lints/src/strings.rs | 6 ++---- clippy_lints/src/suspicious_operation_groupings.rs | 2 +- clippy_lints/src/suspicious_trait_impl.rs | 3 ++- clippy_lints/src/swap.rs | 3 ++- clippy_lints/src/tabs_in_doc_comments.rs | 2 +- clippy_lints/src/temporary_assignment.rs | 3 ++- clippy_lints/src/to_digit_is_some.rs | 3 ++- clippy_lints/src/to_string_in_display.rs | 3 ++- clippy_lints/src/trait_bounds.rs | 3 ++- clippy_lints/src/transmute/crosspointer_transmute.rs | 2 +- clippy_lints/src/transmute/transmute_float_to_int.rs | 3 ++- clippy_lints/src/transmute/transmute_int_to_bool.rs | 3 ++- clippy_lints/src/transmute/transmute_int_to_char.rs | 3 ++- clippy_lints/src/transmute/transmute_int_to_float.rs | 3 ++- clippy_lints/src/transmute/transmute_ptr_to_ptr.rs | 3 ++- clippy_lints/src/transmute/transmute_ptr_to_ref.rs | 3 ++- clippy_lints/src/transmute/transmute_ref_to_ref.rs | 3 ++- .../src/transmute/transmutes_expressible_as_ptr_casts.rs | 3 ++- clippy_lints/src/transmute/unsound_collection_transmute.rs | 3 ++- clippy_lints/src/transmute/useless_transmute.rs | 3 ++- clippy_lints/src/transmute/wrong_transmute.rs | 2 +- clippy_lints/src/transmuting_null.rs | 3 ++- clippy_lints/src/try_err.rs | 3 ++- clippy_lints/src/types/borrowed_box.rs | 3 ++- clippy_lints/src/types/box_vec.rs | 3 ++- clippy_lints/src/types/linked_list.rs | 3 ++- clippy_lints/src/types/mod.rs | 6 ++---- clippy_lints/src/types/option_option.rs | 3 ++- clippy_lints/src/types/rc_buffer.rs | 3 ++- clippy_lints/src/types/redundant_allocation.rs | 3 ++- clippy_lints/src/types/vec_box.rs | 3 ++- clippy_lints/src/undropped_manually_drops.rs | 3 ++- clippy_lints/src/unicode.rs | 3 ++- clippy_lints/src/unit_return_expecting_ord.rs | 3 ++- clippy_lints/src/unnamed_address.rs | 3 ++- clippy_lints/src/unnecessary_sort_by.rs | 6 +++--- clippy_lints/src/unnecessary_wraps.rs | 5 ++--- clippy_lints/src/unnested_or_patterns.rs | 3 ++- clippy_lints/src/unsafe_removed_from_name.rs | 2 +- clippy_lints/src/unused_io_amount.rs | 3 ++- clippy_lints/src/unused_self.rs | 2 +- clippy_lints/src/unused_unit.rs | 2 +- clippy_lints/src/unwrap.rs | 3 ++- clippy_lints/src/unwrap_in_result.rs | 3 ++- clippy_lints/src/upper_case_acronyms.rs | 4 ++-- clippy_lints/src/use_self.rs | 4 ++-- clippy_lints/src/useless_conversion.rs | 5 ++--- clippy_lints/src/utils/internal_lints.rs | 7 +++---- clippy_lints/src/vec.rs | 3 ++- clippy_lints/src/vec_init_then_push.rs | 3 ++- clippy_lints/src/vec_resize_to_zero.rs | 2 +- clippy_lints/src/verbose_file_reads.rs | 3 ++- clippy_lints/src/wildcard_dependencies.rs | 3 ++- clippy_lints/src/wildcard_imports.rs | 3 ++- clippy_lints/src/write.rs | 2 +- clippy_lints/src/zero_div_zero.rs | 2 +- clippy_lints/src/zero_sized_map_values.rs | 3 ++- clippy_utils/src/lib.rs | 3 +-- 307 files changed, 530 insertions(+), 368 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index 1d511a86c90..3d04abe094d 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{FloatTy, LitFloatType, LitKind}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/arithmetic.rs b/clippy_lints/src/arithmetic.rs index 61fdf9495b9..c560f545d6a 100644 --- a/clippy_lints/src/arithmetic.rs +++ b/clippy_lints/src/arithmetic.rs @@ -1,5 +1,5 @@ use crate::consts::constant_simple; -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; diff --git a/clippy_lints/src/as_conversions.rs b/clippy_lints/src/as_conversions.rs index c30d65bbc57..4b31e16094e 100644 --- a/clippy_lints/src/as_conversions.rs +++ b/clippy_lints/src/as_conversions.rs @@ -1,10 +1,9 @@ +use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Expr, ExprKind}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::span_lint_and_help; - declare_clippy_lint! { /// **What it does:** Checks for usage of `as` conversions. /// diff --git a/clippy_lints/src/asm_syntax.rs b/clippy_lints/src/asm_syntax.rs index ef1f1a14afc..b970c71b753 100644 --- a/clippy_lints/src/asm_syntax.rs +++ b/clippy_lints/src/asm_syntax.rs @@ -1,6 +1,6 @@ use std::fmt; -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions}; use rustc_lint::{EarlyContext, EarlyLintPass, Lint}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index 3b6f64e7769..bae4d4957a9 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -1,5 +1,6 @@ use crate::consts::{constant, Constant}; -use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call, span_lint_and_help}; +use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call}; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind, UnOp}; diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 031827e7e89..8581e176e0c 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -1,5 +1,6 @@ -use crate::utils::{eq_expr_value, get_trait_def_id, span_lint_and_then, trait_ref_of_method}; +use crate::utils::{eq_expr_value, get_trait_def_id, trait_ref_of_method}; use crate::utils::{higher, sugg}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_opt; use clippy_utils::ty::implements_trait; use if_chain::if_chain; diff --git a/clippy_lints/src/async_yields_async.rs b/clippy_lints/src/async_yields_async.rs index a5ed6016874..e6c7c68f91a 100644 --- a/clippy_lints/src/async_yields_async.rs +++ b/clippy_lints/src/async_yields_async.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_then; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use clippy_utils::ty::implements_trait; use rustc_errors::Applicability; diff --git a/clippy_lints/src/atomic_ordering.rs b/clippy_lints/src/atomic_ordering.rs index 703d8a6f62b..231e74e16c0 100644 --- a/clippy_lints/src/atomic_ordering.rs +++ b/clippy_lints/src/atomic_ordering.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, span_lint_and_help}; +use crate::utils::match_def_path; +use clippy_utils::diagnostics::span_lint_and_help; use if_chain::if_chain; use rustc_hir::def_id::DefId; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 04b0e71e4a3..6be6722375d 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -1,6 +1,7 @@ //! checks for attributes -use crate::utils::{match_panic_def_id, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; +use crate::utils::match_panic_def_id; +use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments}; use if_chain::if_chain; use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem}; diff --git a/clippy_lints/src/await_holding_invalid.rs b/clippy_lints/src/await_holding_invalid.rs index 14b6a156c62..3a3296c2c3d 100644 --- a/clippy_lints/src/await_holding_invalid.rs +++ b/clippy_lints/src/await_holding_invalid.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, paths, span_lint_and_note}; +use crate::utils::{match_def_path, paths}; +use clippy_utils::diagnostics::span_lint_and_note; use rustc_hir::def_id::DefId; use rustc_hir::{AsyncGeneratorKind, Body, BodyId, GeneratorKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index a4ee54076ee..2b8400344f5 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -1,6 +1,6 @@ use crate::consts::{constant, Constant}; use crate::utils::sugg::Sugg; -use crate::utils::{span_lint, span_lint_and_then}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/blacklisted_name.rs b/clippy_lints/src/blacklisted_name.rs index 153870fb416..b26ef33e056 100644 --- a/clippy_lints/src/blacklisted_name.rs +++ b/clippy_lints/src/blacklisted_name.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_data_structures::fx::FxHashSet; use rustc_hir::{Pat, PatKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/blocks_in_if_conditions.rs b/clippy_lints/src/blocks_in_if_conditions.rs index f43f98d1dc0..343c4821c56 100644 --- a/clippy_lints/src/blocks_in_if_conditions.rs +++ b/clippy_lints/src/blocks_in_if_conditions.rs @@ -1,4 +1,5 @@ -use crate::utils::{differing_macro_contexts, get_parent_expr, span_lint, span_lint_and_sugg}; +use crate::utils::{differing_macro_contexts, get_parent_expr}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet_block_with_applicability; use clippy_utils::ty::implements_trait; use if_chain::if_chain; diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 12a07c60438..1303613b8c4 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -1,4 +1,5 @@ -use crate::utils::{eq_expr_value, get_trait_def_id, in_macro, paths, span_lint_and_sugg, span_lint_and_then}; +use crate::utils::{eq_expr_value, get_trait_def_id, in_macro, paths}; +use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_opt; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use if_chain::if_chain; diff --git a/clippy_lints/src/bytecount.rs b/clippy_lints/src/bytecount.rs index d02861b1b1e..c1ca787c1e5 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -1,4 +1,5 @@ -use crate::utils::{contains_name, get_pat_name, paths, single_segment_path, span_lint_and_sugg}; +use crate::utils::{contains_name, get_pat_name, paths, single_segment_path}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::match_type; use if_chain::if_chain; diff --git a/clippy_lints/src/cargo_common_metadata.rs b/clippy_lints/src/cargo_common_metadata.rs index cc2869ab495..f0ef482164a 100644 --- a/clippy_lints/src/cargo_common_metadata.rs +++ b/clippy_lints/src/cargo_common_metadata.rs @@ -2,7 +2,8 @@ use std::path::PathBuf; -use crate::utils::{run_lints, span_lint}; +use crate::utils::run_lints; +use clippy_utils::diagnostics::span_lint; use rustc_hir::{hir_id::CRATE_HIR_ID, Crate}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; diff --git a/clippy_lints/src/case_sensitive_file_extension_comparisons.rs b/clippy_lints/src/case_sensitive_file_extension_comparisons.rs index b15fe65352a..c9ef379be56 100644 --- a/clippy_lints/src/case_sensitive_file_extension_comparisons.rs +++ b/clippy_lints/src/case_sensitive_file_extension_comparisons.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_hir::{Expr, ExprKind, PathSegment}; diff --git a/clippy_lints/src/casts/cast_lossless.rs b/clippy_lints/src/casts/cast_lossless.rs index 62ba19c0e16..4b660188d82 100644 --- a/clippy_lints/src/casts/cast_lossless.rs +++ b/clippy_lints/src/casts/cast_lossless.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_opt; use clippy_utils::ty::is_isize_or_usize; use rustc_errors::Applicability; @@ -5,7 +6,7 @@ use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, FloatTy, Ty}; -use crate::utils::{in_constant, span_lint_and_sugg}; +use crate::utils::in_constant; use super::{utils, CAST_LOSSLESS}; diff --git a/clippy_lints/src/casts/cast_possible_truncation.rs b/clippy_lints/src/casts/cast_possible_truncation.rs index 522ef5348be..75d7c55b637 100644 --- a/clippy_lints/src/casts/cast_possible_truncation.rs +++ b/clippy_lints/src/casts/cast_possible_truncation.rs @@ -3,7 +3,7 @@ use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, FloatTy, Ty}; -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use super::{utils, CAST_POSSIBLE_TRUNCATION}; diff --git a/clippy_lints/src/casts/cast_possible_wrap.rs b/clippy_lints/src/casts/cast_possible_wrap.rs index 931252415ad..2c5c1d7cb46 100644 --- a/clippy_lints/src/casts/cast_possible_wrap.rs +++ b/clippy_lints/src/casts/cast_possible_wrap.rs @@ -1,10 +1,9 @@ +use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::is_isize_or_usize; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::Ty; -use crate::utils::span_lint; - use super::{utils, CAST_POSSIBLE_WRAP}; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { diff --git a/clippy_lints/src/casts/cast_precision_loss.rs b/clippy_lints/src/casts/cast_precision_loss.rs index b6905c21c78..63ac8fd2dd2 100644 --- a/clippy_lints/src/casts/cast_precision_loss.rs +++ b/clippy_lints/src/casts/cast_precision_loss.rs @@ -1,10 +1,9 @@ +use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::is_isize_or_usize; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, FloatTy, Ty}; -use crate::utils::span_lint; - use super::{utils, CAST_PRECISION_LOSS}; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { diff --git a/clippy_lints/src/casts/cast_ptr_alignment.rs b/clippy_lints/src/casts/cast_ptr_alignment.rs index 87fb5557be0..6a45ec61c54 100644 --- a/clippy_lints/src/casts/cast_ptr_alignment.rs +++ b/clippy_lints/src/casts/cast_ptr_alignment.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint; use rustc_hir::{Expr, ExprKind, GenericArg}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; @@ -6,7 +7,7 @@ use rustc_target::abi::LayoutOf; use if_chain::if_chain; -use crate::utils::{is_hir_ty_cfg_dependant, span_lint}; +use crate::utils::is_hir_ty_cfg_dependant; use super::CAST_PTR_ALIGNMENT; diff --git a/clippy_lints/src/casts/cast_ref_to_mut.rs b/clippy_lints/src/casts/cast_ref_to_mut.rs index 3fdc1c6168b..d9bf1ea58b9 100644 --- a/clippy_lints/src/casts/cast_ref_to_mut.rs +++ b/clippy_lints/src/casts/cast_ref_to_mut.rs @@ -1,11 +1,9 @@ +use clippy_utils::diagnostics::span_lint; +use if_chain::if_chain; use rustc_hir::{Expr, ExprKind, MutTy, Mutability, TyKind, UnOp}; use rustc_lint::LateContext; use rustc_middle::ty; -use if_chain::if_chain; - -use crate::utils::span_lint; - use super::CAST_REF_TO_MUT; pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 9656fbebd77..2965a840a82 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -5,7 +5,8 @@ use rustc_middle::ty::{self, Ty}; use if_chain::if_chain; use crate::consts::{constant, Constant}; -use crate::utils::{method_chain_args, sext, span_lint}; +use crate::utils::{method_chain_args, sext}; +use clippy_utils::diagnostics::span_lint; use super::CAST_SIGN_LOSS; diff --git a/clippy_lints/src/casts/char_lit_as_u8.rs b/clippy_lints/src/casts/char_lit_as_u8.rs index 75aa559359c..099a0de881f 100644 --- a/clippy_lints/src/casts/char_lit_as_u8.rs +++ b/clippy_lints/src/casts/char_lit_as_u8.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_ast::LitKind; @@ -6,8 +7,6 @@ use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, UintTy}; -use crate::utils::span_lint_and_then; - use super::CHAR_LIT_AS_U8; pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { diff --git a/clippy_lints/src/casts/fn_to_numeric_cast.rs b/clippy_lints/src/casts/fn_to_numeric_cast.rs index 723bfa5befe..35350d8a25b 100644 --- a/clippy_lints/src/casts/fn_to_numeric_cast.rs +++ b/clippy_lints/src/casts/fn_to_numeric_cast.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::Expr; diff --git a/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs b/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs index a3108f8a983..6287f479b5b 100644 --- a/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs +++ b/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::Expr; diff --git a/clippy_lints/src/casts/ptr_as_ptr.rs b/clippy_lints/src/casts/ptr_as_ptr.rs index abfbadf3642..2c25f865cb8 100644 --- a/clippy_lints/src/casts/ptr_as_ptr.rs +++ b/clippy_lints/src/casts/ptr_as_ptr.rs @@ -8,8 +8,9 @@ use rustc_semver::RustcVersion; use if_chain::if_chain; +use crate::utils::meets_msrv; use crate::utils::sugg::Sugg; -use crate::utils::{meets_msrv, span_lint_and_sugg}; +use clippy_utils::diagnostics::span_lint_and_sugg; use super::PTR_AS_PTR; diff --git a/clippy_lints/src/casts/unnecessary_cast.rs b/clippy_lints/src/casts/unnecessary_cast.rs index eb0ee012e6c..a84e658024a 100644 --- a/clippy_lints/src/casts/unnecessary_cast.rs +++ b/clippy_lints/src/casts/unnecessary_cast.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_ast::{LitFloatType, LitIntType, LitKind}; @@ -7,7 +8,7 @@ use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, FloatTy, InferTy, Ty}; -use crate::utils::{numeric_literal::NumericLiteral, span_lint_and_sugg}; +use crate::utils::numeric_literal::NumericLiteral; use super::UNNECESSARY_CAST; diff --git a/clippy_lints/src/checked_conversions.rs b/clippy_lints/src/checked_conversions.rs index 4f3daa427e3..8b62e315e04 100644 --- a/clippy_lints/src/checked_conversions.rs +++ b/clippy_lints/src/checked_conversions.rs @@ -1,5 +1,6 @@ //! lint on manually implemented checked conversions that could be transformed into `try_from` +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_ast::ast::LitKind; @@ -10,7 +11,7 @@ use rustc_middle::lint::in_external_macro; use rustc_semver::RustcVersion; use rustc_session::{declare_tool_lint, impl_lint_pass}; -use crate::utils::{meets_msrv, span_lint_and_sugg, SpanlessEq}; +use crate::utils::{meets_msrv, SpanlessEq}; const CHECKED_CONVERSIONS_MSRV: RustcVersion = RustcVersion::new(1, 34, 0); diff --git a/clippy_lints/src/cognitive_complexity.rs b/clippy_lints/src/cognitive_complexity.rs index 5b8ef01505b..8134f3af3ef 100644 --- a/clippy_lints/src/cognitive_complexity.rs +++ b/clippy_lints/src/cognitive_complexity.rs @@ -1,5 +1,6 @@ //! calculate cognitive complexity and warn about overly complex functions +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet_opt; use clippy_utils::ty::is_type_diagnostic_item; use rustc_ast::ast::Attribute; @@ -11,7 +12,7 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::Span; use rustc_span::{sym, BytePos}; -use crate::utils::{span_lint_and_help, LimitStack}; +use crate::utils::LimitStack; declare_clippy_lint! { /// **What it does:** Checks for methods with high cognitive complexity. diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index c866f18ef3e..dbe70f90732 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -12,6 +12,7 @@ //! //! This lint is **warn** by default +use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::{snippet_block, snippet_block_with_applicability}; use if_chain::if_chain; use rustc_ast::ast; @@ -20,7 +21,6 @@ use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use crate::utils::sugg::Sugg; -use crate::utils::{span_lint_and_sugg, span_lint_and_then}; declare_clippy_lint! { /// **What it does:** Checks for nested `if` statements which can be collapsed diff --git a/clippy_lints/src/collapsible_match.rs b/clippy_lints/src/collapsible_match.rs index 3c45525684b..5ff2518bd94 100644 --- a/clippy_lints/src/collapsible_match.rs +++ b/clippy_lints/src/collapsible_match.rs @@ -1,5 +1,6 @@ use crate::utils::visitors::LocalUsedVisitor; -use crate::utils::{path_to_local, span_lint_and_then, SpanlessEq}; +use crate::utils::{path_to_local, SpanlessEq}; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, Pat, PatKind, QPath, StmtKind, UnOp}; diff --git a/clippy_lints/src/comparison_chain.rs b/clippy_lints/src/comparison_chain.rs index 9843033a2e0..5411905791c 100644 --- a/clippy_lints/src/comparison_chain.rs +++ b/clippy_lints/src/comparison_chain.rs @@ -1,4 +1,5 @@ -use crate::utils::{get_trait_def_id, if_sequence, parent_node_is_if_expr, paths, span_lint_and_help, SpanlessEq}; +use crate::utils::{get_trait_def_id, if_sequence, parent_node_is_if_expr, paths, SpanlessEq}; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::implements_trait; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 944aaafb46d..f86f0da6d6f 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -1,5 +1,6 @@ use crate::utils::{eq_expr_value, in_macro, search_same, SpanlessEq, SpanlessHash}; -use crate::utils::{get_parent_expr, if_sequence, span_lint_and_note}; +use crate::utils::{get_parent_expr, if_sequence}; +use clippy_utils::diagnostics::span_lint_and_note; use rustc_hir::{Block, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/copy_iterator.rs b/clippy_lints/src/copy_iterator.rs index 434d8958da5..35079c6bedc 100644 --- a/clippy_lints/src/copy_iterator.rs +++ b/clippy_lints/src/copy_iterator.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_note; +use clippy_utils::diagnostics::span_lint_and_note; use clippy_utils::ty::is_copy; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/create_dir.rs b/clippy_lints/src/create_dir.rs index 0785e25b0a2..01ca2837a99 100644 --- a/clippy_lints/src/create_dir.rs +++ b/clippy_lints/src/create_dir.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, paths, span_lint_and_sugg}; +use crate::utils::{match_def_path, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/dbg_macro.rs b/clippy_lints/src/dbg_macro.rs index 3171a945eb0..286cc7e223e 100644 --- a/clippy_lints/src/dbg_macro.rs +++ b/clippy_lints/src/dbg_macro.rs @@ -1,4 +1,4 @@ -use crate::utils::{span_lint_and_help, span_lint_and_sugg}; +use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::snippet_opt; use rustc_ast::ast; use rustc_ast::tokenstream::TokenStream; diff --git a/clippy_lints/src/default.rs b/clippy_lints/src/default.rs index 7d975b5a3d9..0b074c088d4 100644 --- a/clippy_lints/src/default.rs +++ b/clippy_lints/src/default.rs @@ -1,5 +1,5 @@ use crate::utils::{any_parent_is_automatically_derived, contains_name, match_def_path, paths}; -use crate::utils::{span_lint_and_note, span_lint_and_sugg}; +use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_sugg}; use clippy_utils::source::snippet_with_macro_callsite; use if_chain::if_chain; use rustc_data_structures::fx::FxHashSet; diff --git a/clippy_lints/src/default_numeric_fallback.rs b/clippy_lints/src/default_numeric_fallback.rs index e58dcb942c6..d136db9373c 100644 --- a/clippy_lints/src/default_numeric_fallback.rs +++ b/clippy_lints/src/default_numeric_fallback.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_ast::ast::{LitFloatType, LitIntType, LitKind}; @@ -13,8 +14,6 @@ use rustc_middle::{ }; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::span_lint_and_sugg; - declare_clippy_lint! { /// **What it does:** Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type /// inference. diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index e112338dfea..62ec2f8ce48 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -1,4 +1,5 @@ -use crate::utils::{get_parent_node, in_macro, is_allowed, span_lint_and_sugg}; +use crate::utils::{get_parent_node, in_macro, is_allowed}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_context; use clippy_utils::ty::peel_mid_ty_refs; use rustc_ast::util::parser::PREC_PREFIX; diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 460fe385272..a7f2106e357 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -1,8 +1,6 @@ use crate::utils::paths; -use crate::utils::{ - get_trait_def_id, is_allowed, is_automatically_derived, match_def_path, span_lint_and_help, span_lint_and_note, - span_lint_and_then, -}; +use crate::utils::{get_trait_def_id, is_allowed, is_automatically_derived, match_def_path}; +use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note, span_lint_and_then}; use clippy_utils::ty::is_copy; use if_chain::if_chain; use rustc_hir::def_id::DefId; diff --git a/clippy_lints/src/disallowed_method.rs b/clippy_lints/src/disallowed_method.rs index 56dc6d18a58..16023bc53b0 100644 --- a/clippy_lints/src/disallowed_method.rs +++ b/clippy_lints/src/disallowed_method.rs @@ -1,4 +1,5 @@ -use crate::utils::{fn_def_id, span_lint}; +use crate::utils::fn_def_id; +use clippy_utils::diagnostics::span_lint; use rustc_data_structures::fx::FxHashSet; use rustc_hir::Expr; diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 4f3c573691e..d9952325c4b 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -1,6 +1,5 @@ -use crate::utils::{ - is_entrypoint_fn, is_expn_of, match_panic_def_id, method_chain_args, return_ty, span_lint, span_lint_and_note, -}; +use crate::utils::{is_entrypoint_fn, is_expn_of, match_panic_def_id, method_chain_args, return_ty}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_note}; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use if_chain::if_chain; use itertools::Itertools; diff --git a/clippy_lints/src/double_comparison.rs b/clippy_lints/src/double_comparison.rs index 3de027b2cc6..549720feb2d 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -1,5 +1,6 @@ //! Lint on unnecessary double comparisons. Some examples: +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind}; @@ -7,7 +8,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; -use crate::utils::{eq_expr_value, span_lint_and_sugg}; +use crate::utils::eq_expr_value; declare_clippy_lint! { /// **What it does:** Checks for double comparisons that could be simplified to a single expression. diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index abbcaf43f41..5afdcb3c09f 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Expr, ExprKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index dd145ba6867..fe86adcec45 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, paths, span_lint_and_note}; +use crate::utils::{match_def_path, paths}; +use clippy_utils::diagnostics::span_lint_and_note; use clippy_utils::ty::is_copy; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/duration_subsec.rs b/clippy_lints/src/duration_subsec.rs index 195143d720d..40c75f568ae 100644 --- a/clippy_lints/src/duration_subsec.rs +++ b/clippy_lints/src/duration_subsec.rs @@ -9,7 +9,7 @@ use rustc_span::source_map::Spanned; use crate::consts::{constant, Constant}; use crate::utils::paths; -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; declare_clippy_lint! { /// **What it does:** Checks for calculation of subsecond microseconds or milliseconds diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs index 95123e6ff6f..26984df9539 100644 --- a/clippy_lints/src/else_if_without_else.rs +++ b/clippy_lints/src/else_if_without_else.rs @@ -1,12 +1,11 @@ //! Lint on if expressions with an else if, but without a final else branch. +use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Expr, ExprKind}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::span_lint_and_help; - declare_clippy_lint! { /// **What it does:** Checks for usage of if expressions with an `else if` branch, /// but without a final `else` branch. diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs index 077c3b75fb8..c92984a9834 100644 --- a/clippy_lints/src/empty_enum.rs +++ b/clippy_lints/src/empty_enum.rs @@ -1,6 +1,6 @@ //! lint when there is an enum with no variants -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 93723219594..cc774831491 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -1,6 +1,6 @@ -use crate::utils::span_lint_and_then; use crate::utils::SpanlessEq; use crate::utils::{get_item_name, paths}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability}; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; use if_chain::if_chain; diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index aa235642ac3..7a98ae39d3a 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -2,7 +2,7 @@ //! don't fit into an `i32` use crate::consts::{miri_to_const, Constant}; -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::util::IntTypeExt; diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index 660131cf176..d2d8acb443b 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 crate::utils::camel_case; -use crate::utils::{span_lint, span_lint_and_help}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use clippy_utils::source::is_present_in_source; use rustc_ast::ast::{EnumDef, Item, ItemKind, VisibilityKind}; use rustc_lint::{EarlyContext, EarlyLintPass, Lint}; diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index 0a5917c10ea..1b2f66fb628 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -1,7 +1,5 @@ -use crate::utils::{ - ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, in_macro, is_expn_of, multispan_sugg, span_lint, - span_lint_and_then, -}; +use crate::utils::{ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, in_macro, is_expn_of}; +use clippy_utils::diagnostics::{multispan_sugg, span_lint, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::ty::{implements_trait, is_copy}; use if_chain::if_chain; diff --git a/clippy_lints/src/erasing_op.rs b/clippy_lints/src/erasing_op.rs index dbd1ff514f0..59602616781 100644 --- a/clippy_lints/src/erasing_op.rs +++ b/clippy_lints/src/erasing_op.rs @@ -1,10 +1,10 @@ +use clippy_utils::diagnostics::span_lint; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use crate::consts::{constant_simple, Constant}; -use crate::utils::span_lint; declare_clippy_lint! { /// **What it does:** Checks for erasing operations, e.g., `x * 0`. diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index a7258eea0ad..06da14a9844 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::contains_ty; use rustc_hir::intravisit; use rustc_hir::{self, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node}; @@ -11,8 +12,6 @@ use rustc_target::abi::LayoutOf; use rustc_target::spec::abi::Abi; use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId}; -use crate::utils::span_lint; - #[derive(Copy, Clone)] pub struct BoxedLocal { pub too_large_for_stack: u64, diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index e8d5b992b63..2557e9f2796 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::higher; use clippy_utils::higher::VecArgs; use clippy_utils::source::snippet_opt; @@ -10,7 +11,7 @@ use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, Ty}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::{is_adjusted, iter_input_pats, span_lint_and_sugg, span_lint_and_then}; +use crate::utils::{is_adjusted, iter_input_pats}; declare_clippy_lint! { /// **What it does:** Checks for closures which just call another function where diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 83cee11c3a8..3711ba4a7ee 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -1,4 +1,5 @@ -use crate::utils::{get_parent_expr, path_to_local, path_to_local_id, span_lint, span_lint_and_note}; +use crate::utils::{get_parent_expr, path_to_local, path_to_local_id}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_note}; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc_hir::{BinOpKind, Block, Expr, ExprKind, Guard, HirId, Local, Node, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/excessive_bools.rs b/clippy_lints/src/excessive_bools.rs index 6a85b57af07..683e0435351 100644 --- a/clippy_lints/src/excessive_bools.rs +++ b/clippy_lints/src/excessive_bools.rs @@ -1,4 +1,5 @@ -use crate::utils::{attr_by_name, in_macro, match_path_ast, span_lint_and_help}; +use crate::utils::{attr_by_name, in_macro, match_path_ast}; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{AssocItemKind, Extern, FnKind, FnSig, ImplKind, Item, ItemKind, TraitKind, Ty, TyKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; diff --git a/clippy_lints/src/exhaustive_items.rs b/clippy_lints/src/exhaustive_items.rs index 5e31072523d..60ad2e8ee14 100644 --- a/clippy_lints/src/exhaustive_items.rs +++ b/clippy_lints/src/exhaustive_items.rs @@ -1,14 +1,12 @@ +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::indent_of; use if_chain::if_chain; - use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; -use crate::utils::span_lint_and_then; - declare_clippy_lint! { /// **What it does:** Warns on any exported `enum`s that are not tagged `#[non_exhaustive]` /// diff --git a/clippy_lints/src/exit.rs b/clippy_lints/src/exit.rs index 91585927000..adfb644b199 100644 --- a/clippy_lints/src/exit.rs +++ b/clippy_lints/src/exit.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_entrypoint_fn, match_def_path, paths, span_lint}; +use crate::utils::{is_entrypoint_fn, match_def_path, paths}; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index f8038d06e50..0861cba4675 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_expn_of, match_function_call, paths, span_lint, span_lint_and_sugg}; +use crate::utils::{is_expn_of, match_function_call, paths}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index cc4e570956b..5efe465a667 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_expn_of, match_panic_def_id, method_chain_args, span_lint_and_then}; +use crate::utils::{is_expn_of, match_panic_def_id, method_chain_args}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_hir as hir; diff --git a/clippy_lints/src/float_equality_without_abs.rs b/clippy_lints/src/float_equality_without_abs.rs index c1c08597ee6..b3593d328cc 100644 --- a/clippy_lints/src/float_equality_without_abs.rs +++ b/clippy_lints/src/float_equality_without_abs.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, paths, span_lint_and_then, sugg}; +use crate::utils::{match_def_path, paths, sugg}; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; use rustc_ast::util::parser::AssocOp; use rustc_errors::Applicability; diff --git a/clippy_lints/src/float_literal.rs b/clippy_lints/src/float_literal.rs index 8e256f34684..6446fe62a64 100644 --- a/clippy_lints/src/float_literal.rs +++ b/clippy_lints/src/float_literal.rs @@ -1,4 +1,5 @@ -use crate::utils::{numeric_literal, span_lint_and_sugg}; +use crate::utils::numeric_literal; +use clippy_utils::diagnostics::span_lint_and_sugg; use if_chain::if_chain; use rustc_ast::ast::{self, LitFloatType, LitKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/floating_point_arithmetic.rs b/clippy_lints/src/floating_point_arithmetic.rs index 086a791520f..8b53384ecbd 100644 --- a/clippy_lints/src/floating_point_arithmetic.rs +++ b/clippy_lints/src/floating_point_arithmetic.rs @@ -2,7 +2,8 @@ use crate::consts::{ constant, constant_simple, Constant, Constant::{Int, F32, F64}, }; -use crate::utils::{eq_expr_value, get_parent_expr, numeric_literal, span_lint_and_sugg, sugg}; +use crate::utils::{eq_expr_value, get_parent_expr, numeric_literal, sugg}; +use clippy_utils::diagnostics::span_lint_and_sugg; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment, UnOp}; diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index c0048bb2175..db27225707d 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -1,5 +1,6 @@ use crate::utils::paths; -use crate::utils::{is_expn_of, last_path_segment, match_def_path, match_function_call, span_lint_and_then}; +use crate::utils::{is_expn_of, last_path_segment, match_def_path, match_function_call}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::{snippet, snippet_opt}; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 590de04717a..4dadd2ba936 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -1,4 +1,5 @@ -use crate::utils::{differing_macro_contexts, span_lint_and_help, span_lint_and_note}; +use crate::utils::differing_macro_contexts; +use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note}; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_ast::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp}; diff --git a/clippy_lints/src/from_over_into.rs b/clippy_lints/src/from_over_into.rs index b644bb07990..5eea4d14759 100644 --- a/clippy_lints/src/from_over_into.rs +++ b/clippy_lints/src/from_over_into.rs @@ -1,5 +1,6 @@ use crate::utils::paths::INTO; -use crate::utils::{match_def_path, meets_msrv, span_lint_and_help}; +use crate::utils::{match_def_path, meets_msrv}; +use clippy_utils::diagnostics::span_lint_and_help; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass, LintContext}; diff --git a/clippy_lints/src/from_str_radix_10.rs b/clippy_lints/src/from_str_radix_10.rs index b92c8ccfb1b..b9a44f26381 100644 --- a/clippy_lints/src/from_str_radix_10.rs +++ b/clippy_lints/src/from_str_radix_10.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_errors::Applicability; @@ -7,7 +8,6 @@ use rustc_middle::ty::Ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; -use crate::utils::span_lint_and_sugg; use crate::utils::sugg::Sugg; declare_clippy_lint! { diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 104c692dcec..37288d7a0b2 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -1,7 +1,8 @@ use crate::utils::{ attr_by_name, attrs::is_proc_macro, is_trait_impl_item, iter_input_pats, match_def_path, must_use_attr, - path_to_local, return_ty, span_lint, span_lint_and_help, span_lint_and_then, trait_ref_of_method, + path_to_local, return_ty, trait_ref_of_method, }; +use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_then}; use clippy_utils::source::{snippet, snippet_opt}; use clippy_utils::ty::{is_must_use_ty, is_type_diagnostic_item, type_is_unsafe_function}; use if_chain::if_chain; diff --git a/clippy_lints/src/future_not_send.rs b/clippy_lints/src/future_not_send.rs index 9e1a8864a3e..36960e7f51b 100644 --- a/clippy_lints/src/future_not_send.rs +++ b/clippy_lints/src/future_not_send.rs @@ -1,4 +1,5 @@ use crate::utils; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl, HirId}; use rustc_infer::infer::TyCtxtInferExt; @@ -84,7 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend { fulfillment_cx.select_all_or_error(&infcx) }); if let Err(send_errors) = send_result { - utils::span_lint_and_then( + span_lint_and_then( cx, FUTURE_NOT_SEND, span, diff --git a/clippy_lints/src/get_last_with_len.rs b/clippy_lints/src/get_last_with_len.rs index 875cd33bc8f..6f14ede0ecb 100644 --- a/clippy_lints/src/get_last_with_len.rs +++ b/clippy_lints/src/get_last_with_len.rs @@ -1,6 +1,7 @@ //! lint on using `x.get(x.len() - 1)` instead of `x.last()` -use crate::utils::{span_lint_and_sugg, SpanlessEq}; +use crate::utils::SpanlessEq; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index fc93864c74a..385ea020328 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -7,7 +7,8 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use crate::consts::{constant_simple, Constant}; -use crate::utils::{clip, span_lint, unsext}; +use crate::utils::{clip, unsext}; +use clippy_utils::diagnostics::span_lint; declare_clippy_lint! { /// **What it does:** Checks for identity operations, e.g., `x + 0`. diff --git a/clippy_lints/src/if_let_mutex.rs b/clippy_lints/src/if_let_mutex.rs index f53d1b1cf3b..c2ec8b3ffd1 100644 --- a/clippy_lints/src/if_let_mutex.rs +++ b/clippy_lints/src/if_let_mutex.rs @@ -1,4 +1,5 @@ -use crate::utils::{span_lint_and_help, SpanlessEq}; +use crate::utils::SpanlessEq; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_hir::intravisit::{self as visit, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/if_let_some_result.rs b/clippy_lints/src/if_let_some_result.rs index 9f7ca95a8f3..59094d1147a 100644 --- a/clippy_lints/src/if_let_some_result.rs +++ b/clippy_lints/src/if_let_some_result.rs @@ -1,4 +1,5 @@ -use crate::utils::{method_chain_args, span_lint_and_sugg}; +use crate::utils::method_chain_args; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/if_not_else.rs b/clippy_lints/src/if_not_else.rs index b86d2e76656..c56f67df061 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -1,13 +1,12 @@ //! lint on if branches that could be swapped so no `!` operation is necessary //! on the condition +use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{BinOpKind, Expr, ExprKind, UnOp}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::span_lint_and_help; - declare_clippy_lint! { /// **What it does:** Checks for usage of `!` or `!=` in an if condition with an /// else branch. diff --git a/clippy_lints/src/if_then_some_else_none.rs b/clippy_lints/src/if_then_some_else_none.rs index 7e1807786ee..c4e87300b7b 100644 --- a/clippy_lints/src/if_then_some_else_none.rs +++ b/clippy_lints/src/if_then_some_else_none.rs @@ -1,4 +1,5 @@ use crate::utils; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet_with_macro_callsite; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; @@ -100,7 +101,7 @@ impl LateLintPass<'_> for IfThenSomeElseNone { cond_snip, closure_body, ); - utils::span_lint_and_help( + span_lint_and_help( cx, IF_THEN_SOME_ELSE_NONE, expr.span, diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index e86bd49251d..70ea9a92279 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_panic_def_id, span_lint_and_then}; +use crate::utils::match_panic_def_id; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/implicit_saturating_sub.rs b/clippy_lints/src/implicit_saturating_sub.rs index 16e162badb5..3d2798f3fb4 100644 --- a/clippy_lints/src/implicit_saturating_sub.rs +++ b/clippy_lints/src/implicit_saturating_sub.rs @@ -1,4 +1,5 @@ -use crate::utils::{in_macro, match_qpath, span_lint_and_sugg, SpanlessEq}; +use crate::utils::{in_macro, match_qpath, SpanlessEq}; +use clippy_utils::diagnostics::span_lint_and_sugg; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/inconsistent_struct_constructor.rs b/clippy_lints/src/inconsistent_struct_constructor.rs index 4762d5d40f3..b7986da7820 100644 --- a/clippy_lints/src/inconsistent_struct_constructor.rs +++ b/clippy_lints/src/inconsistent_struct_constructor.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_data_structures::fx::FxHashMap; @@ -7,8 +8,6 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::Symbol; -use crate::utils::span_lint_and_sugg; - declare_clippy_lint! { /// **What it does:** Checks for struct constructors where all fields are shorthand and /// the order of the field init shorthand in the constructor is inconsistent diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index c919ec097a2..4c0f976f79a 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -1,7 +1,8 @@ //! lint on indexing and slicing operations use crate::consts::{constant, Constant}; -use crate::utils::{higher, span_lint, span_lint_and_help}; +use crate::utils::higher; +use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use rustc_ast::ast::RangeLimits; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index 6bce205ec3a..addd95c6eae 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -1,9 +1,10 @@ +use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::{implements_trait, match_type}; use rustc_hir::{BorrowKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::{get_trait_def_id, higher, match_qpath, paths, span_lint}; +use crate::utils::{get_trait_def_id, higher, match_qpath, paths}; declare_clippy_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 005c461f105..f838ce190dc 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -1,6 +1,7 @@ //! lint on inherent implementations -use crate::utils::{in_macro, span_lint_and_then}; +use crate::utils::in_macro; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_data_structures::fx::FxHashMap; use rustc_hir::{def_id, Crate, Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index 9207413cd69..6b29feeb4ed 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use if_chain::if_chain; use rustc_hir::{ImplItem, ImplItemKind}; @@ -5,7 +6,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; -use crate::utils::{get_trait_def_id, paths, return_ty, span_lint_and_help, trait_ref_of_method}; +use crate::utils::{get_trait_def_id, paths, return_ty, trait_ref_of_method}; declare_clippy_lint! { /// **What it does:** Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`. diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index 00acbd6cc3f..87fe5123cf6 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 crate::utils::span_lint_and_then; use crate::utils::sugg::DiagnosticBuilderExt; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_ast::ast::Attribute; use rustc_errors::Applicability; use rustc_hir::{TraitFn, TraitItem, TraitItemKind}; diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index 9eae653dd67..c4a1222b51f 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -1,13 +1,12 @@ //! lint on blocks unnecessarily using >= with a + 1 or - 1 +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_opt; use rustc_ast::ast::{BinOpKind, Expr, ExprKind, Lit, LitKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::span_lint_and_sugg; - declare_clippy_lint! { /// **What it does:** Checks for usage of `x >= y + 1` or `x - 1 >= y` (and `<=`) in a block /// diff --git a/clippy_lints/src/integer_division.rs b/clippy_lints/src/integer_division.rs index 39b4605e72f..e5482f675e7 100644 --- a/clippy_lints/src/integer_division.rs +++ b/clippy_lints/src/integer_division.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index 0927d218446..c69571f32a2 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -1,6 +1,6 @@ //! lint when items are used after statements -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Block, ItemKind, StmtKind}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; diff --git a/clippy_lints/src/large_const_arrays.rs b/clippy_lints/src/large_const_arrays.rs index a76595ed089..48dc5fefe99 100644 --- a/clippy_lints/src/large_const_arrays.rs +++ b/clippy_lints/src/large_const_arrays.rs @@ -1,5 +1,5 @@ use crate::rustc_target::abi::LayoutOf; -use crate::utils::span_lint_and_then; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind}; diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index cbb5192bfd9..76584dc1822 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -1,6 +1,6 @@ //! lint when there is a large size difference between variants on an enum -use crate::utils::span_lint_and_then; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_opt; use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind, VariantData}; diff --git a/clippy_lints/src/large_stack_arrays.rs b/clippy_lints/src/large_stack_arrays.rs index ceae4243e63..c46b98022c6 100644 --- a/clippy_lints/src/large_stack_arrays.rs +++ b/clippy_lints/src/large_stack_arrays.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; @@ -7,7 +8,6 @@ use rustc_middle::ty::{self, ConstKind}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use crate::rustc_target::abi::LayoutOf; -use crate::utils::span_lint_and_help; declare_clippy_lint! { /// **What it does:** Checks for local arrays that may be too large. diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index e758a269fbe..a644a4113ae 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -1,4 +1,5 @@ -use crate::utils::{get_item_name, get_parent_as_impl, is_allowed, span_lint, span_lint_and_sugg, span_lint_and_then}; +use crate::utils::{get_item_name, get_parent_as_impl, is_allowed}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_ast::ast::LitKind; diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 7059ba21207..4b7e02398fb 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -1,4 +1,5 @@ -use crate::utils::{path_to_local_id, span_lint_and_then, visitors::LocalUsedVisitor}; +use crate::utils::{path_to_local_id, visitors::LocalUsedVisitor}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index 2da7137b48b..eee2503b481 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::{is_must_use_ty, match_type}; use if_chain::if_chain; use rustc_hir::{Local, PatKind}; @@ -6,7 +7,7 @@ use rustc_middle::lint::in_external_macro; use rustc_middle::ty::subst::GenericArgKind; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::{is_must_use_func_call, paths, span_lint_and_help}; +use crate::utils::{is_must_use_func_call, paths}; declare_clippy_lint! { /// **What it does:** Checks for `let _ = ` diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 33ff01a30e8..0848aaed815 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -1,4 +1,5 @@ -use crate::utils::{in_macro, span_lint, trait_ref_of_method}; +use crate::utils::{in_macro, trait_ref_of_method}; +use clippy_utils::diagnostics::span_lint; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::intravisit::{ walk_fn_decl, walk_generic_param, walk_generics, walk_item, walk_param_bound, walk_poly_trait_ref, walk_ty, diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index 8bc7bf37ef1..dd303bc0a01 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -4,8 +4,8 @@ use crate::utils::{ in_macro, numeric_literal::{NumericLiteral, Radix}, - span_lint_and_sugg, }; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_ast::ast::{Expr, ExprKind, Lit, LitKind}; diff --git a/clippy_lints/src/loops/empty_loop.rs b/clippy_lints/src/loops/empty_loop.rs index 43e85538f28..d52a061fc8f 100644 --- a/clippy_lints/src/loops/empty_loop.rs +++ b/clippy_lints/src/loops/empty_loop.rs @@ -1,5 +1,6 @@ use super::EMPTY_LOOP; -use crate::utils::{is_in_panic_handler, is_no_std_crate, span_lint_and_help}; +use crate::utils::{is_in_panic_handler, is_no_std_crate}; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir::{Block, Expr}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/loops/explicit_counter_loop.rs b/clippy_lints/src/loops/explicit_counter_loop.rs index 1f6d48fe915..87ce4e4c20c 100644 --- a/clippy_lints/src/loops/explicit_counter_loop.rs +++ b/clippy_lints/src/loops/explicit_counter_loop.rs @@ -1,7 +1,8 @@ use super::{ get_span_of_entire_for_loop, make_iterator_snippet, IncrementVisitor, InitializeVisitor, EXPLICIT_COUNTER_LOOP, }; -use crate::utils::{get_enclosing_block, is_integer_const, span_lint_and_sugg}; +use crate::utils::{get_enclosing_block, is_integer_const}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/loops/explicit_into_iter_loop.rs b/clippy_lints/src/loops/explicit_into_iter_loop.rs index e5b3dc7aad7..4871a031187 100644 --- a/clippy_lints/src/loops/explicit_into_iter_loop.rs +++ b/clippy_lints/src/loops/explicit_into_iter_loop.rs @@ -1,5 +1,5 @@ use super::EXPLICIT_INTO_ITER_LOOP; -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::Expr; diff --git a/clippy_lints/src/loops/explicit_iter_loop.rs b/clippy_lints/src/loops/explicit_iter_loop.rs index d2000d80ac1..259e95e5ef4 100644 --- a/clippy_lints/src/loops/explicit_iter_loop.rs +++ b/clippy_lints/src/loops/explicit_iter_loop.rs @@ -1,5 +1,6 @@ use super::EXPLICIT_ITER_LOOP; -use crate::utils::{match_trait_method, paths, span_lint_and_sugg}; +use crate::utils::{match_trait_method, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/loops/for_kv_map.rs b/clippy_lints/src/loops/for_kv_map.rs index 19a68dd78d1..bf037f392e0 100644 --- a/clippy_lints/src/loops/for_kv_map.rs +++ b/clippy_lints/src/loops/for_kv_map.rs @@ -1,6 +1,7 @@ use super::FOR_KV_MAP; use crate::utils::visitors::LocalUsedVisitor; -use crate::utils::{multispan_sugg, paths, span_lint_and_then, sugg}; +use crate::utils::{paths, sugg}; +use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Pat, PatKind}; diff --git a/clippy_lints/src/loops/for_loops_over_fallibles.rs b/clippy_lints/src/loops/for_loops_over_fallibles.rs index 5140448592d..d49b0517dcf 100644 --- a/clippy_lints/src/loops/for_loops_over_fallibles.rs +++ b/clippy_lints/src/loops/for_loops_over_fallibles.rs @@ -1,8 +1,7 @@ +use super::FOR_LOOPS_OVER_FALLIBLES; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; - -use super::FOR_LOOPS_OVER_FALLIBLES; -use crate::utils::span_lint_and_help; use rustc_hir::{Expr, Pat}; use rustc_lint::LateContext; use rustc_span::symbol::sym; diff --git a/clippy_lints/src/loops/iter_next_loop.rs b/clippy_lints/src/loops/iter_next_loop.rs index d6b40fa9fa8..27a03562800 100644 --- a/clippy_lints/src/loops/iter_next_loop.rs +++ b/clippy_lints/src/loops/iter_next_loop.rs @@ -1,9 +1,10 @@ use super::ITER_NEXT_LOOP; +use clippy_utils::diagnostics::span_lint; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_span::sym; -use crate::utils::{is_trait_method, span_lint}; +use crate::utils::is_trait_method; pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, expr: &Expr<'_>) -> bool { if is_trait_method(cx, arg, sym::Iterator) { diff --git a/clippy_lints/src/loops/manual_flatten.rs b/clippy_lints/src/loops/manual_flatten.rs index 3d3ae6f3152..43580d6071a 100644 --- a/clippy_lints/src/loops/manual_flatten.rs +++ b/clippy_lints/src/loops/manual_flatten.rs @@ -1,6 +1,7 @@ use super::utils::make_iterator_snippet; use super::MANUAL_FLATTEN; -use crate::utils::{is_ok_ctor, is_some_ctor, path_to_local_id, span_lint_and_then}; +use crate::utils::{is_ok_ctor, is_some_ctor, path_to_local_id}; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, MatchSource, Pat, PatKind, QPath, StmtKind}; diff --git a/clippy_lints/src/loops/manual_memcpy.rs b/clippy_lints/src/loops/manual_memcpy.rs index c9c25641160..ff68d136999 100644 --- a/clippy_lints/src/loops/manual_memcpy.rs +++ b/clippy_lints/src/loops/manual_memcpy.rs @@ -1,6 +1,7 @@ use super::{get_span_of_entire_for_loop, IncrementVisitor, InitializeVisitor, MANUAL_MEMCPY}; use crate::utils::sugg::Sugg; -use crate::utils::{get_enclosing_block, higher, path_to_local, span_lint_and_sugg, sugg}; +use crate::utils::{get_enclosing_block, higher, path_to_local, sugg}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/loops/mut_range_bound.rs b/clippy_lints/src/loops/mut_range_bound.rs index 3ae592950f1..175aee53a9a 100644 --- a/clippy_lints/src/loops/mut_range_bound.rs +++ b/clippy_lints/src/loops/mut_range_bound.rs @@ -1,5 +1,6 @@ use super::MUT_RANGE_BOUND; -use crate::utils::{higher, path_to_local, span_lint}; +use crate::utils::{higher, path_to_local}; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_hir::{BindingAnnotation, Expr, HirId, Node, PatKind}; use rustc_infer::infer::TyCtxtInferExt; diff --git a/clippy_lints/src/loops/needless_collect.rs b/clippy_lints/src/loops/needless_collect.rs index 59f7b23af75..a3b731eefa0 100644 --- a/clippy_lints/src/loops/needless_collect.rs +++ b/clippy_lints/src/loops/needless_collect.rs @@ -1,6 +1,7 @@ use super::NEEDLESS_COLLECT; use crate::utils::sugg::Sugg; -use crate::utils::{is_trait_method, path_to_local_id, paths, span_lint_and_sugg, span_lint_and_then}; +use crate::utils::{is_trait_method, path_to_local_id, paths}; +use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; use if_chain::if_chain; diff --git a/clippy_lints/src/loops/needless_range_loop.rs b/clippy_lints/src/loops/needless_range_loop.rs index 674cb34c37b..ca679d7ebe1 100644 --- a/clippy_lints/src/loops/needless_range_loop.rs +++ b/clippy_lints/src/loops/needless_range_loop.rs @@ -1,9 +1,9 @@ use super::NEEDLESS_RANGE_LOOP; use crate::utils::visitors::LocalUsedVisitor; use crate::utils::{ - contains_name, higher, is_integer_const, match_trait_method, multispan_sugg, path_to_local_id, paths, - span_lint_and_then, sugg, SpanlessEq, + contains_name, higher, is_integer_const, match_trait_method, path_to_local_id, paths, sugg, SpanlessEq, }; +use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::ty::has_iter_method; use if_chain::if_chain; diff --git a/clippy_lints/src/loops/never_loop.rs b/clippy_lints/src/loops/never_loop.rs index 45e1001d755..82ec2635aeb 100644 --- a/clippy_lints/src/loops/never_loop.rs +++ b/clippy_lints/src/loops/never_loop.rs @@ -1,5 +1,5 @@ use super::NEVER_LOOP; -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_hir::{Block, Expr, ExprKind, HirId, InlineAsmOperand, Stmt, StmtKind}; use rustc_lint::LateContext; use std::iter::{once, Iterator}; diff --git a/clippy_lints/src/loops/same_item_push.rs b/clippy_lints/src/loops/same_item_push.rs index 255d6de4a36..849d7ec718c 100644 --- a/clippy_lints/src/loops/same_item_push.rs +++ b/clippy_lints/src/loops/same_item_push.rs @@ -1,5 +1,5 @@ use super::SAME_ITEM_PUSH; -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet_with_macro_callsite; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use if_chain::if_chain; diff --git a/clippy_lints/src/loops/single_element_loop.rs b/clippy_lints/src/loops/single_element_loop.rs index 4f83191d919..172eb963ae3 100644 --- a/clippy_lints/src/loops/single_element_loop.rs +++ b/clippy_lints/src/loops/single_element_loop.rs @@ -1,5 +1,6 @@ use super::{get_span_of_entire_for_loop, SINGLE_ELEMENT_LOOP}; -use crate::utils::{single_segment_path, span_lint_and_sugg}; +use crate::utils::single_segment_path; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{indent_of, snippet}; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/loops/while_immutable_condition.rs b/clippy_lints/src/loops/while_immutable_condition.rs index 05e0a722563..a037a06de81 100644 --- a/clippy_lints/src/loops/while_immutable_condition.rs +++ b/clippy_lints/src/loops/while_immutable_condition.rs @@ -1,7 +1,7 @@ use super::WHILE_IMMUTABLE_CONDITION; use crate::consts::constant; -use crate::utils::span_lint_and_then; use crate::utils::usage::mutated_variables; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def::{DefKind, Res}; diff --git a/clippy_lints/src/loops/while_let_loop.rs b/clippy_lints/src/loops/while_let_loop.rs index dbd9126861f..ffe8c0c5494 100644 --- a/clippy_lints/src/loops/while_let_loop.rs +++ b/clippy_lints/src/loops/while_let_loop.rs @@ -1,5 +1,5 @@ use super::WHILE_LET_LOOP; -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::{Block, Expr, ExprKind, MatchSource, StmtKind}; diff --git a/clippy_lints/src/loops/while_let_on_iterator.rs b/clippy_lints/src/loops/while_let_on_iterator.rs index ccabe586c2b..29ad9e735cc 100644 --- a/clippy_lints/src/loops/while_let_on_iterator.rs +++ b/clippy_lints/src/loops/while_let_on_iterator.rs @@ -3,8 +3,8 @@ use super::WHILE_LET_ON_ITERATOR; use crate::utils::usage::mutated_variables; use crate::utils::{ get_enclosing_block, is_refutable, is_trait_method, last_path_segment, path_to_local, path_to_local_id, - span_lint_and_sugg, }; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::implements_trait; use if_chain::if_chain; diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs index 637f10f6609..92f95645734 100644 --- a/clippy_lints/src/macro_use.rs +++ b/clippy_lints/src/macro_use.rs @@ -1,4 +1,5 @@ -use crate::utils::{in_macro, span_lint_and_sugg}; +use crate::utils::in_macro; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use hir::def::{DefKind, Res}; use if_chain::if_chain; diff --git a/clippy_lints/src/main_recursion.rs b/clippy_lints/src/main_recursion.rs index 5db2968e42c..6c0308cbd92 100644 --- a/clippy_lints/src/main_recursion.rs +++ b/clippy_lints/src/main_recursion.rs @@ -1,10 +1,11 @@ +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_hir::{Crate, Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; -use crate::utils::{is_entrypoint_fn, is_no_std_crate, span_lint_and_help}; +use crate::utils::{is_entrypoint_fn, is_no_std_crate}; declare_clippy_lint! { /// **What it does:** Checks for recursion using the entrypoint. diff --git a/clippy_lints/src/manual_async_fn.rs b/clippy_lints/src/manual_async_fn.rs index ebc493c0f7e..1db5cf56962 100644 --- a/clippy_lints/src/manual_async_fn.rs +++ b/clippy_lints/src/manual_async_fn.rs @@ -1,5 +1,6 @@ +use crate::utils::match_function_call; use crate::utils::paths::FUTURE_FROM_GENERATOR; -use crate::utils::{match_function_call, span_lint_and_then}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt}; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/manual_map.rs b/clippy_lints/src/manual_map.rs index 3896645ca7d..fd563bec769 100644 --- a/clippy_lints/src/manual_map.rs +++ b/clippy_lints/src/manual_map.rs @@ -1,8 +1,9 @@ use crate::{ map_unit_fn::OPTION_MAP_UNIT_FN, matches::MATCH_AS_REF, - utils::{is_allowed, match_def_path, match_var, paths, peel_hir_expr_refs, span_lint_and_sugg}, + utils::{is_allowed, match_def_path, match_var, paths, peel_hir_expr_refs}, }; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{snippet_with_applicability, snippet_with_context}; use clippy_utils::ty::{can_partially_move_ty, is_type_diagnostic_item, peel_mid_ty_refs_is_mutable}; use rustc_ast::util::parser::PREC_POSTFIX; diff --git a/clippy_lints/src/manual_non_exhaustive.rs b/clippy_lints/src/manual_non_exhaustive.rs index 0b8c049b466..705c1ec1859 100644 --- a/clippy_lints/src/manual_non_exhaustive.rs +++ b/clippy_lints/src/manual_non_exhaustive.rs @@ -1,4 +1,5 @@ -use crate::utils::{meets_msrv, span_lint_and_then}; +use crate::utils::meets_msrv; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_ast::ast::{Attribute, Item, ItemKind, StructField, Variant, VariantData, VisibilityKind}; diff --git a/clippy_lints/src/manual_ok_or.rs b/clippy_lints/src/manual_ok_or.rs index f436eccc0dc..a1e5c752f83 100644 --- a/clippy_lints/src/manual_ok_or.rs +++ b/clippy_lints/src/manual_ok_or.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_qpath, path_to_local_id, paths, span_lint_and_sugg}; +use crate::utils::{match_qpath, path_to_local_id, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt}; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index 3bfca8bea40..bc4e255b03d 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -1,6 +1,7 @@ use crate::consts::{constant, Constant}; use crate::utils::usage::mutated_variables; -use crate::utils::{eq_expr_value, higher, match_def_path, meets_msrv, multispan_sugg, paths, span_lint_and_then}; +use crate::utils::{eq_expr_value, higher, match_def_path, meets_msrv, paths}; +use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_ast::ast::LitKind; diff --git a/clippy_lints/src/manual_unwrap_or.rs b/clippy_lints/src/manual_unwrap_or.rs index 7a4040539e3..0e030e0e261 100644 --- a/clippy_lints/src/manual_unwrap_or.rs +++ b/clippy_lints/src/manual_unwrap_or.rs @@ -1,6 +1,7 @@ use crate::consts::constant_simple; use crate::utils; use crate::utils::{path_to_local_id, sugg}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt}; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; @@ -112,7 +113,7 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { then { let reindented_or_body = reindent_multiline(or_body_snippet.into(), true, Some(indent)); - utils::span_lint_and_sugg( + span_lint_and_sugg( cx, MANUAL_UNWRAP_OR, expr.span, &format!("this pattern reimplements `{}`", case.unwrap_fn_path()), diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index e10d7647bcf..fd39052871b 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -1,5 +1,6 @@ use crate::utils::is_trait_method; -use crate::utils::{remove_blocks, span_lint_and_sugg}; +use crate::utils::remove_blocks; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_copy, is_type_diagnostic_item}; use if_chain::if_chain; diff --git a/clippy_lints/src/map_err_ignore.rs b/clippy_lints/src/map_err_ignore.rs index 76fe8e776ea..a6a63961be5 100644 --- a/clippy_lints/src/map_err_ignore.rs +++ b/clippy_lints/src/map_err_ignore.rs @@ -1,5 +1,4 @@ -use crate::utils::span_lint_and_help; - +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir::{CaptureBy, Expr, ExprKind, PatKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/map_identity.rs b/clippy_lints/src/map_identity.rs index 79570367ed9..84ec23c4e2f 100644 --- a/clippy_lints/src/map_identity.rs +++ b/clippy_lints/src/map_identity.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_adjusted, is_trait_method, match_path, match_var, paths, remove_blocks, span_lint_and_sugg}; +use crate::utils::{is_adjusted, is_trait_method, match_path, match_var, paths, remove_blocks}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 24bcc808585..3bd4a965765 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -1,4 +1,5 @@ -use crate::utils::{iter_input_pats, method_chain_args, span_lint_and_then}; +use crate::utils::{iter_input_pats, method_chain_args}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/match_on_vec_items.rs b/clippy_lints/src/match_on_vec_items.rs index 57dcd8709b8..ccaa5e98c83 100644 --- a/clippy_lints/src/match_on_vec_items.rs +++ b/clippy_lints/src/match_on_vec_items.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item}; use if_chain::if_chain; diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 4ae1ce977f4..1aa09b82822 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -2,11 +2,13 @@ use crate::consts::{constant, miri_to_const, Constant}; use crate::utils::sugg::Sugg; use crate::utils::visitors::LocalUsedVisitor; use crate::utils::{ - get_parent_expr, in_macro, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath, meets_msrv, multispan_sugg, - path_to_local, path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs, remove_blocks, span_lint_and_help, - span_lint_and_note, span_lint_and_sugg, span_lint_and_then, strip_pat_refs, + get_parent_expr, in_macro, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath, meets_msrv, path_to_local, + path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs, remove_blocks, strip_pat_refs, }; use crate::utils::{paths, search_same, SpanlessEq, SpanlessHash}; +use clippy_utils::diagnostics::{ + multispan_sugg, span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then, +}; use clippy_utils::source::{expr_block, indent_of, snippet, snippet_block, snippet_opt, snippet_with_applicability}; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type, peel_mid_ty_refs}; use if_chain::if_chain; @@ -1614,7 +1616,8 @@ where mod redundant_pattern_match { use super::REDUNDANT_PATTERN_MATCHING; - use crate::utils::{is_trait_method, match_qpath, paths, span_lint_and_then}; + use crate::utils::{is_trait_method, match_qpath, paths}; + use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_ast::ast::LitKind; diff --git a/clippy_lints/src/mem_discriminant.rs b/clippy_lints/src/mem_discriminant.rs index fbdc0cdb2d8..85353d4cdde 100644 --- a/clippy_lints/src/mem_discriminant.rs +++ b/clippy_lints/src/mem_discriminant.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, paths, span_lint_and_then}; +use crate::utils::{match_def_path, paths}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use clippy_utils::ty::walk_ptrs_ty_depth; use if_chain::if_chain; diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index d34f9761e26..1a8cb82514b 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, paths, span_lint}; +use crate::utils::{match_def_path, paths}; +use clippy_utils::diagnostics::span_lint; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index bf3f6f7f830..87cb66a6770 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -1,7 +1,5 @@ -use crate::utils::{ - in_macro, match_def_path, match_qpath, meets_msrv, paths, span_lint_and_help, span_lint_and_sugg, - span_lint_and_then, -}; +use crate::utils::{in_macro, match_def_path, match_qpath, meets_msrv, paths}; +use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::is_diagnostic_assoc_item; use clippy_utils::source::{snippet, snippet_with_applicability}; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/bind_instead_of_map.rs b/clippy_lints/src/methods/bind_instead_of_map.rs index 99b3be67f18..7d6104ebb7f 100644 --- a/clippy_lints/src/methods/bind_instead_of_map.rs +++ b/clippy_lints/src/methods/bind_instead_of_map.rs @@ -1,8 +1,6 @@ use super::{contains_return, BIND_INSTEAD_OF_MAP}; -use crate::utils::{ - in_macro, match_qpath, method_calls, multispan_sugg_with_applicability, paths, remove_blocks, span_lint_and_sugg, - span_lint_and_then, visitors::find_all_ret_expressions, -}; +use crate::utils::{in_macro, match_qpath, method_calls, paths, remove_blocks, visitors::find_all_ret_expressions}; +use clippy_utils::diagnostics::{multispan_sugg_with_applicability, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::{snippet, snippet_with_macro_callsite}; use clippy_utils::ty::match_type; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/bytes_nth.rs b/clippy_lints/src/methods/bytes_nth.rs index f81e9a8c524..4f88f80a304 100644 --- a/clippy_lints/src/methods/bytes_nth.rs +++ b/clippy_lints/src/methods/bytes_nth.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/clone_on_copy.rs b/clippy_lints/src/methods/clone_on_copy.rs index 954d589a47e..d1c7789a241 100644 --- a/clippy_lints/src/methods/clone_on_copy.rs +++ b/clippy_lints/src/methods/clone_on_copy.rs @@ -1,4 +1,5 @@ -use crate::utils::{span_lint_and_then, sugg}; +use crate::utils::sugg; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_copy; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/clone_on_ref_ptr.rs b/clippy_lints/src/methods/clone_on_ref_ptr.rs index 90ecb2382e7..b49ae42b12f 100644 --- a/clippy_lints/src/methods/clone_on_ref_ptr.rs +++ b/clippy_lints/src/methods/clone_on_ref_ptr.rs @@ -1,4 +1,5 @@ -use crate::utils::{paths, span_lint_and_sugg}; +use crate::utils::paths; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_macro_callsite; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/expect_fun_call.rs b/clippy_lints/src/methods/expect_fun_call.rs index 9e96d571337..1c673c11d65 100644 --- a/clippy_lints/src/methods/expect_fun_call.rs +++ b/clippy_lints/src/methods/expect_fun_call.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_expn_of, span_lint_and_sugg}; +use crate::utils::is_expn_of; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/expect_used.rs b/clippy_lints/src/methods/expect_used.rs index 37c41194b4a..64531b29ade 100644 --- a/clippy_lints/src/methods/expect_used.rs +++ b/clippy_lints/src/methods/expect_used.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::is_type_diagnostic_item; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/filetype_is_file.rs b/clippy_lints/src/methods/filetype_is_file.rs index 791fe3647cb..005c94a6018 100644 --- a/clippy_lints/src/methods/filetype_is_file.rs +++ b/clippy_lints/src/methods/filetype_is_file.rs @@ -1,4 +1,5 @@ -use crate::utils::{get_parent_expr, paths, span_lint_and_help}; +use crate::utils::{get_parent_expr, paths}; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::match_type; use if_chain::if_chain; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/filter_flat_map.rs b/clippy_lints/src/methods/filter_flat_map.rs index 42f05aa0b3a..4820bb137c1 100644 --- a/clippy_lints/src/methods/filter_flat_map.rs +++ b/clippy_lints/src/methods/filter_flat_map.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, span_lint_and_help}; +use crate::utils::is_trait_method; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/filter_map.rs b/clippy_lints/src/methods/filter_map.rs index 964c4903ed2..af91370df20 100644 --- a/clippy_lints/src/methods/filter_map.rs +++ b/clippy_lints/src/methods/filter_map.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, path_to_local_id, span_lint_and_sugg, SpanlessEq}; +use crate::utils::{is_trait_method, path_to_local_id, SpanlessEq}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/filter_map_flat_map.rs b/clippy_lints/src/methods/filter_map_flat_map.rs index e113f3f71b1..5294ef97528 100644 --- a/clippy_lints/src/methods/filter_map_flat_map.rs +++ b/clippy_lints/src/methods/filter_map_flat_map.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, span_lint_and_help}; +use crate::utils::is_trait_method; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/filter_map_identity.rs b/clippy_lints/src/methods/filter_map_identity.rs index 5f627b42abc..4461baf4f7c 100644 --- a/clippy_lints/src/methods/filter_map_identity.rs +++ b/clippy_lints/src/methods/filter_map_identity.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, match_qpath, path_to_local_id, paths, span_lint_and_sugg}; +use crate::utils::{is_trait_method, match_qpath, path_to_local_id, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/filter_map_map.rs b/clippy_lints/src/methods/filter_map_map.rs index 2e704c4c555..8f17350054b 100644 --- a/clippy_lints/src/methods/filter_map_map.rs +++ b/clippy_lints/src/methods/filter_map_map.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, span_lint_and_help}; +use crate::utils::is_trait_method; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/filter_map_next.rs b/clippy_lints/src/methods/filter_map_next.rs index ed75315b52c..8fbadd1d457 100644 --- a/clippy_lints/src/methods/filter_map_next.rs +++ b/clippy_lints/src/methods/filter_map_next.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, meets_msrv, span_lint, span_lint_and_sugg}; +use crate::utils::{is_trait_method, meets_msrv}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/filter_next.rs b/clippy_lints/src/methods/filter_next.rs index 097f9fdf2c4..af16ea19007 100644 --- a/clippy_lints/src/methods/filter_next.rs +++ b/clippy_lints/src/methods/filter_next.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, span_lint, span_lint_and_sugg}; +use crate::utils::is_trait_method; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/flat_map_identity.rs b/clippy_lints/src/methods/flat_map_identity.rs index 19ddceeccce..669ac1f743f 100644 --- a/clippy_lints/src/methods/flat_map_identity.rs +++ b/clippy_lints/src/methods/flat_map_identity.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, match_qpath, paths, span_lint_and_sugg}; +use crate::utils::{is_trait_method, match_qpath, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/from_iter_instead_of_collect.rs b/clippy_lints/src/methods/from_iter_instead_of_collect.rs index 9b46adaac58..5d0a07992c8 100644 --- a/clippy_lints/src/methods/from_iter_instead_of_collect.rs +++ b/clippy_lints/src/methods/from_iter_instead_of_collect.rs @@ -1,4 +1,5 @@ -use crate::utils::{get_trait_def_id, paths, span_lint_and_sugg, sugg}; +use crate::utils::{get_trait_def_id, paths, sugg}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::implements_trait; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/get_unwrap.rs b/clippy_lints/src/methods/get_unwrap.rs index b9d34b402bb..ac855419d00 100644 --- a/clippy_lints/src/methods/get_unwrap.rs +++ b/clippy_lints/src/methods/get_unwrap.rs @@ -1,5 +1,6 @@ use crate::methods::derefs_to_slice; -use crate::utils::{get_parent_expr, paths, span_lint_and_sugg}; +use crate::utils::{get_parent_expr, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/implicit_clone.rs b/clippy_lints/src/methods/implicit_clone.rs index a769493d11d..04461ad5c3a 100644 --- a/clippy_lints/src/methods/implicit_clone.rs +++ b/clippy_lints/src/methods/implicit_clone.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/inefficient_to_string.rs b/clippy_lints/src/methods/inefficient_to_string.rs index 19d05b5c693..56de7a8bc5e 100644 --- a/clippy_lints/src/methods/inefficient_to_string.rs +++ b/clippy_lints/src/methods/inefficient_to_string.rs @@ -1,5 +1,6 @@ use super::INEFFICIENT_TO_STRING; -use crate::utils::{match_def_path, paths, span_lint_and_then}; +use crate::utils::{match_def_path, paths}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_type_diagnostic_item, walk_ptrs_ty_depth}; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/inspect_for_each.rs b/clippy_lints/src/methods/inspect_for_each.rs index e7c3a433fe1..c9bbfbc37eb 100644 --- a/clippy_lints/src/methods/inspect_for_each.rs +++ b/clippy_lints/src/methods/inspect_for_each.rs @@ -1,8 +1,9 @@ +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::{source_map::Span, sym}; -use crate::utils::{is_trait_method, span_lint_and_help}; +use crate::utils::is_trait_method; use super::INSPECT_FOR_EACH; diff --git a/clippy_lints/src/methods/into_iter_on_ref.rs b/clippy_lints/src/methods/into_iter_on_ref.rs index f28f082e6fc..a862b55e139 100644 --- a/clippy_lints/src/methods/into_iter_on_ref.rs +++ b/clippy_lints/src/methods/into_iter_on_ref.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_trait_method, paths, span_lint_and_sugg}; +use crate::utils::{match_trait_method, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::has_iter_method; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/iter_cloned_collect.rs b/clippy_lints/src/methods/iter_cloned_collect.rs index 1e1d3fdcf70..cd575c9cb02 100644 --- a/clippy_lints/src/methods/iter_cloned_collect.rs +++ b/clippy_lints/src/methods/iter_cloned_collect.rs @@ -1,5 +1,5 @@ use crate::methods::derefs_to_slice; -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/iter_count.rs b/clippy_lints/src/methods/iter_count.rs index 0f393423b7d..bfd62ff1f0d 100644 --- a/clippy_lints/src/methods/iter_count.rs +++ b/clippy_lints/src/methods/iter_count.rs @@ -1,5 +1,6 @@ use crate::methods::derefs_to_slice; -use crate::utils::{paths, span_lint_and_sugg}; +use crate::utils::paths; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/iter_next_slice.rs b/clippy_lints/src/methods/iter_next_slice.rs index f79942576da..ce599682bbe 100644 --- a/clippy_lints/src/methods/iter_next_slice.rs +++ b/clippy_lints/src/methods/iter_next_slice.rs @@ -1,5 +1,6 @@ use crate::methods::derefs_to_slice; -use crate::utils::{get_parent_expr, higher, span_lint_and_sugg}; +use crate::utils::{get_parent_expr, higher}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/iter_nth.rs b/clippy_lints/src/methods/iter_nth.rs index 17600bb8153..2619793e1e2 100644 --- a/clippy_lints/src/methods/iter_nth.rs +++ b/clippy_lints/src/methods/iter_nth.rs @@ -1,6 +1,6 @@ use crate::methods::derefs_to_slice; use crate::methods::iter_nth_zero; -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::is_type_diagnostic_item; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/iter_nth_zero.rs b/clippy_lints/src/methods/iter_nth_zero.rs index 98ddfdfdf9c..f2b2dd8c097 100644 --- a/clippy_lints/src/methods/iter_nth_zero.rs +++ b/clippy_lints/src/methods/iter_nth_zero.rs @@ -1,5 +1,6 @@ use crate::consts::{constant, Constant}; -use crate::utils::{is_trait_method, span_lint_and_sugg}; +use crate::utils::is_trait_method; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/iter_skip_next.rs b/clippy_lints/src/methods/iter_skip_next.rs index d191ea0a831..6100613bcac 100644 --- a/clippy_lints/src/methods/iter_skip_next.rs +++ b/clippy_lints/src/methods/iter_skip_next.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, span_lint_and_sugg}; +use crate::utils::is_trait_method; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/iterator_step_by_zero.rs b/clippy_lints/src/methods/iterator_step_by_zero.rs index 019a08f746e..51c1ab0484e 100644 --- a/clippy_lints/src/methods/iterator_step_by_zero.rs +++ b/clippy_lints/src/methods/iterator_step_by_zero.rs @@ -1,5 +1,6 @@ use crate::consts::{constant, Constant}; -use crate::utils::{is_trait_method, span_lint}; +use crate::utils::is_trait_method; +use clippy_utils::diagnostics::span_lint; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/manual_saturating_arithmetic.rs b/clippy_lints/src/methods/manual_saturating_arithmetic.rs index d090a35a3cf..0c8a002e359 100644 --- a/clippy_lints/src/methods/manual_saturating_arithmetic.rs +++ b/clippy_lints/src/methods/manual_saturating_arithmetic.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_qpath, span_lint_and_sugg}; +use crate::utils::match_qpath; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_ast::ast; diff --git a/clippy_lints/src/methods/map_collect_result_unit.rs b/clippy_lints/src/methods/map_collect_result_unit.rs index 349b26b9d58..b59998fc8b4 100644 --- a/clippy_lints/src/methods/map_collect_result_unit.rs +++ b/clippy_lints/src/methods/map_collect_result_unit.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, span_lint_and_sugg}; +use crate::utils::is_trait_method; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/map_flatten.rs b/clippy_lints/src/methods/map_flatten.rs index 56719b3cff2..6f5e723fbfb 100644 --- a/clippy_lints/src/methods/map_flatten.rs +++ b/clippy_lints/src/methods/map_flatten.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, span_lint_and_sugg}; +use crate::utils::is_trait_method; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/map_unwrap_or.rs b/clippy_lints/src/methods/map_unwrap_or.rs index 96dbc7ddc63..8ef02b4a641 100644 --- a/clippy_lints/src/methods/map_unwrap_or.rs +++ b/clippy_lints/src/methods/map_unwrap_or.rs @@ -1,5 +1,6 @@ +use crate::utils::meets_msrv; use crate::utils::usage::mutated_variables; -use crate::utils::{meets_msrv, span_lint, span_lint_and_sugg}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 47617e4722e..af8fe7abd96 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -52,6 +52,7 @@ mod wrong_self_convention; mod zst_offset; use bind_instead_of_map::BindInsteadOfMap; +use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{contains_ty, implements_trait, is_copy, is_type_diagnostic_item}; use if_chain::if_chain; @@ -69,8 +70,7 @@ use rustc_typeck::hir_ty_to_ty; use crate::utils::{ contains_return, get_trait_def_id, in_macro, iter_input_pats, match_def_path, match_qpath, method_calls, - method_chain_args, paths, return_ty, single_segment_path, span_lint, span_lint_and_help, span_lint_and_sugg, - SpanlessEq, + method_chain_args, paths, return_ty, single_segment_path, SpanlessEq, }; declare_clippy_lint! { diff --git a/clippy_lints/src/methods/ok_expect.rs b/clippy_lints/src/methods/ok_expect.rs index 2618d04b242..e6ce9cac397 100644 --- a/clippy_lints/src/methods/ok_expect.rs +++ b/clippy_lints/src/methods/ok_expect.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use if_chain::if_chain; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/option_as_ref_deref.rs b/clippy_lints/src/methods/option_as_ref_deref.rs index 6597e9f96a8..f921d7b16c0 100644 --- a/clippy_lints/src/methods/option_as_ref_deref.rs +++ b/clippy_lints/src/methods/option_as_ref_deref.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, meets_msrv, path_to_local_id, paths, remove_blocks, span_lint_and_sugg}; +use crate::utils::{match_def_path, meets_msrv, path_to_local_id, paths, remove_blocks}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/option_map_or_none.rs b/clippy_lints/src/methods/option_map_or_none.rs index eed71d02467..e8b057c2d74 100644 --- a/clippy_lints/src/methods/option_map_or_none.rs +++ b/clippy_lints/src/methods/option_map_or_none.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_qpath, paths, span_lint_and_sugg}; +use crate::utils::{match_qpath, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs index 398d8f13bd4..c6459648cd5 100644 --- a/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -1,4 +1,5 @@ -use crate::utils::{differing_macro_contexts, span_lint_and_then}; +use crate::utils::differing_macro_contexts; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_copy; use clippy_utils::ty::is_type_diagnostic_item; diff --git a/clippy_lints/src/methods/or_fun_call.rs b/clippy_lints/src/methods/or_fun_call.rs index 634feebe54a..1b43802a08e 100644 --- a/clippy_lints/src/methods/or_fun_call.rs +++ b/clippy_lints/src/methods/or_fun_call.rs @@ -1,5 +1,6 @@ use crate::utils::eager_or_lazy::is_lazyness_candidate; -use crate::utils::{contains_return, get_trait_def_id, last_path_segment, paths, span_lint_and_sugg}; +use crate::utils::{contains_return, get_trait_def_id, last_path_segment, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{snippet, snippet_with_applicability, snippet_with_macro_callsite}; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type}; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/search_is_some.rs b/clippy_lints/src/methods/search_is_some.rs index 6054579d988..18e1064b018 100644 --- a/clippy_lints/src/methods/search_is_some.rs +++ b/clippy_lints/src/methods/search_is_some.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, span_lint_and_help, span_lint_and_sugg, strip_pat_refs}; +use crate::utils::{is_trait_method, strip_pat_refs}; +use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/single_char_insert_string.rs b/clippy_lints/src/methods/single_char_insert_string.rs index ff67564b39d..cd87d2c56b7 100644 --- a/clippy_lints/src/methods/single_char_insert_string.rs +++ b/clippy_lints/src/methods/single_char_insert_string.rs @@ -1,5 +1,5 @@ use crate::methods::get_hint_if_single_char_arg; -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/single_char_pattern.rs b/clippy_lints/src/methods/single_char_pattern.rs index 61cbc9d2f0a..12d6418d700 100644 --- a/clippy_lints/src/methods/single_char_pattern.rs +++ b/clippy_lints/src/methods/single_char_pattern.rs @@ -1,5 +1,5 @@ use crate::methods::get_hint_if_single_char_arg; -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/single_char_push_string.rs b/clippy_lints/src/methods/single_char_push_string.rs index 18df90c1ab3..882703a987d 100644 --- a/clippy_lints/src/methods/single_char_push_string.rs +++ b/clippy_lints/src/methods/single_char_push_string.rs @@ -1,5 +1,5 @@ use crate::methods::get_hint_if_single_char_arg; -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/skip_while_next.rs b/clippy_lints/src/methods/skip_while_next.rs index a9ff78c3260..8995226191b 100644 --- a/clippy_lints/src/methods/skip_while_next.rs +++ b/clippy_lints/src/methods/skip_while_next.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, span_lint_and_help}; +use crate::utils::is_trait_method; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/string_extend_chars.rs b/clippy_lints/src/methods/string_extend_chars.rs index 1b26e8314af..d9b97168490 100644 --- a/clippy_lints/src/methods/string_extend_chars.rs +++ b/clippy_lints/src/methods/string_extend_chars.rs @@ -1,4 +1,5 @@ -use crate::utils::{method_chain_args, span_lint_and_sugg}; +use crate::utils::method_chain_args; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/suspicious_map.rs b/clippy_lints/src/methods/suspicious_map.rs index 0ffa71de30c..fd4651dd182 100644 --- a/clippy_lints/src/methods/suspicious_map.rs +++ b/clippy_lints/src/methods/suspicious_map.rs @@ -1,5 +1,6 @@ use crate::utils::usage::mutated_variables; -use crate::utils::{expr_or_init, is_trait_method, span_lint_and_help}; +use crate::utils::{expr_or_init, is_trait_method}; +use clippy_utils::diagnostics::span_lint_and_help; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/uninit_assumed_init.rs b/clippy_lints/src/methods/uninit_assumed_init.rs index 798b66192c8..071856c3ba6 100644 --- a/clippy_lints/src/methods/uninit_assumed_init.rs +++ b/clippy_lints/src/methods/uninit_assumed_init.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, match_qpath, paths, span_lint}; +use crate::utils::{match_def_path, match_qpath, paths}; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/unnecessary_filter_map.rs b/clippy_lints/src/methods/unnecessary_filter_map.rs index 686874c0a24..670134c68f2 100644 --- a/clippy_lints/src/methods/unnecessary_filter_map.rs +++ b/clippy_lints/src/methods/unnecessary_filter_map.rs @@ -1,5 +1,6 @@ use crate::utils::usage::mutated_variables; -use crate::utils::{is_trait_method, match_qpath, path_to_local_id, paths, span_lint}; +use crate::utils::{is_trait_method, match_qpath, path_to_local_id, paths}; +use clippy_utils::diagnostics::span_lint; use rustc_hir as hir; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/unnecessary_fold.rs b/clippy_lints/src/methods/unnecessary_fold.rs index 4d5cbdd619d..3ccde57de3f 100644 --- a/clippy_lints/src/methods/unnecessary_fold.rs +++ b/clippy_lints/src/methods/unnecessary_fold.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_trait_method, path_to_local_id, remove_blocks, span_lint_and_sugg, strip_pat_refs}; +use crate::utils::{is_trait_method, path_to_local_id, remove_blocks, strip_pat_refs}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_ast::ast; diff --git a/clippy_lints/src/methods/unnecessary_lazy_eval.rs b/clippy_lints/src/methods/unnecessary_lazy_eval.rs index 444abde3d0f..3874673bf9f 100644 --- a/clippy_lints/src/methods/unnecessary_lazy_eval.rs +++ b/clippy_lints/src/methods/unnecessary_lazy_eval.rs @@ -1,5 +1,5 @@ -use crate::utils::span_lint_and_sugg; use crate::utils::{eager_or_lazy, usage}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/unwrap_used.rs b/clippy_lints/src/methods/unwrap_used.rs index efe43a6a952..2f5806115bd 100644 --- a/clippy_lints/src/methods/unwrap_used.rs +++ b/clippy_lints/src/methods/unwrap_used.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::is_type_diagnostic_item; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/useless_asref.rs b/clippy_lints/src/methods/useless_asref.rs index c6d84aedc0a..13c95e33fef 100644 --- a/clippy_lints/src/methods/useless_asref.rs +++ b/clippy_lints/src/methods/useless_asref.rs @@ -1,4 +1,5 @@ -use crate::utils::{get_parent_expr, match_trait_method, paths, span_lint_and_sugg}; +use crate::utils::{get_parent_expr, match_trait_method, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::walk_ptrs_ty_depth; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/wrong_self_convention.rs b/clippy_lints/src/methods/wrong_self_convention.rs index c8bcad7be3e..b728d7d8d08 100644 --- a/clippy_lints/src/methods/wrong_self_convention.rs +++ b/clippy_lints/src/methods/wrong_self_convention.rs @@ -1,5 +1,5 @@ use crate::methods::SelfKind; -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_lint::LateContext; use rustc_middle::ty::TyS; use rustc_span::source_map::Span; diff --git a/clippy_lints/src/methods/zst_offset.rs b/clippy_lints/src/methods/zst_offset.rs index f1335726736..9f6a7c4db17 100644 --- a/clippy_lints/src/methods/zst_offset.rs +++ b/clippy_lints/src/methods/zst_offset.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index 8d0c3b8e0fe..6a4e70e50af 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -1,5 +1,6 @@ use crate::consts::{constant_simple, Constant}; -use crate::utils::{match_def_path, match_trait_method, paths, span_lint}; +use crate::utils::{match_def_path, match_trait_method, paths}; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index f161054cc8c..03d07287005 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then, span_lint_hir_and_then}; use clippy_utils::source::{snippet, snippet_opt}; use clippy_utils::ty::implements_trait; use if_chain::if_chain; @@ -20,8 +21,7 @@ use crate::consts::{constant, Constant}; use crate::utils::sugg::Sugg; use crate::utils::{ get_item_name, get_parent_expr, higher, in_constant, is_diagnostic_assoc_item, is_integer_const, iter_input_pats, - last_path_segment, match_qpath, span_lint, span_lint_and_sugg, span_lint_and_then, span_lint_hir_and_then, unsext, - SpanlessEq, + last_path_segment, match_qpath, unsext, SpanlessEq, }; declare_clippy_lint! { diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index 6ec523498e1..3c6a7071c24 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -1,4 +1,4 @@ -use crate::utils::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_opt; use rustc_ast::ast::{ BindingMode, Expr, ExprKind, GenericParamKind, Generics, Lit, LitFloatType, LitIntType, LitKind, Mutability, diff --git a/clippy_lints/src/missing_const_for_fn.rs b/clippy_lints/src/missing_const_for_fn.rs index 4cc20b8d38c..aba4accccb1 100644 --- a/clippy_lints/src/missing_const_for_fn.rs +++ b/clippy_lints/src/missing_const_for_fn.rs @@ -1,5 +1,6 @@ use crate::utils::qualify_min_const_fn::is_min_const_fn; -use crate::utils::{fn_has_unsatisfiable_preds, is_entrypoint_fn, meets_msrv, span_lint, trait_ref_of_method}; +use crate::utils::{fn_has_unsatisfiable_preds, is_entrypoint_fn, meets_msrv, trait_ref_of_method}; +use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::has_drop; use rustc_hir as hir; use rustc_hir::intravisit::FnKind; diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 6ec4c38d0f9..fd6f31faa94 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -5,7 +5,7 @@ // [`missing_doc`]: https://github.com/rust-lang/rust/blob/cf9cf7c923eb01146971429044f216a3ca905e06/compiler/rustc_lint/src/builtin.rs#L415 // -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_ast::ast::{self, MetaItem, MetaItemKind}; use rustc_ast::attr; diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index da59c820999..dd4488f3f02 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_ast::ast; use rustc_hir as hir; use rustc_lint::{self, LateContext, LateLintPass, LintContext}; diff --git a/clippy_lints/src/modulo_arithmetic.rs b/clippy_lints/src/modulo_arithmetic.rs index da3ae1d652f..1b00cf2c75d 100644 --- a/clippy_lints/src/modulo_arithmetic.rs +++ b/clippy_lints/src/modulo_arithmetic.rs @@ -1,5 +1,6 @@ use crate::consts::{constant, Constant}; -use crate::utils::{sext, span_lint_and_then}; +use crate::utils::sext; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/multiple_crate_versions.rs b/clippy_lints/src/multiple_crate_versions.rs index c1773cef7a8..6eaeaebe781 100644 --- a/clippy_lints/src/multiple_crate_versions.rs +++ b/clippy_lints/src/multiple_crate_versions.rs @@ -1,6 +1,7 @@ //! lint on multiple versions of a crate being used -use crate::utils::{run_lints, span_lint}; +use crate::utils::run_lints; +use clippy_utils::diagnostics::span_lint; use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::{Crate, CRATE_HIR_ID}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/mut_key.rs b/clippy_lints/src/mut_key.rs index 908b7bb7ce0..39aec79734c 100644 --- a/clippy_lints/src/mut_key.rs +++ b/clippy_lints/src/mut_key.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, paths, span_lint, trait_ref_of_method}; +use crate::utils::{match_def_path, paths, trait_ref_of_method}; +use clippy_utils::diagnostics::span_lint; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::TypeFoldable; diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index d7239b328bb..c11ccc94890 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -1,4 +1,5 @@ -use crate::utils::{higher, span_lint}; +use crate::utils::higher; +use clippy_utils::diagnostics::span_lint; use rustc_hir as hir; use rustc_hir::intravisit; use rustc_lint::{LateContext, LateLintPass, LintContext}; diff --git a/clippy_lints/src/mut_mutex_lock.rs b/clippy_lints/src/mut_mutex_lock.rs index e4a57661f97..b9ba74c7d02 100644 --- a/clippy_lints/src/mut_mutex_lock.rs +++ b/clippy_lints/src/mut_mutex_lock.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 3f0b765df15..0c09ddb8073 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::subst::Subst; diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 9ac127abe0a..fb8895e08d0 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -1,4 +1,5 @@ -use crate::utils::{higher, is_direct_expn_of, span_lint}; +use crate::utils::{higher, is_direct_expn_of}; +use clippy_utils::diagnostics::span_lint; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc_hir::{BorrowKind, Expr, ExprKind, MatchSource, Mutability}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index 9f746ce2e1a..354e2c3fb74 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -2,7 +2,7 @@ //! //! This lint is **warn** by default -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::is_type_diagnostic_item; use rustc_hir::Expr; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/needless_arbitrary_self_type.rs b/clippy_lints/src/needless_arbitrary_self_type.rs index 7687962bdd9..c62ff7323f3 100644 --- a/clippy_lints/src/needless_arbitrary_self_type.rs +++ b/clippy_lints/src/needless_arbitrary_self_type.rs @@ -1,4 +1,5 @@ -use crate::utils::{in_macro, span_lint_and_sugg}; +use crate::utils::in_macro; +use clippy_utils::diagnostics::span_lint_and_sugg; use if_chain::if_chain; use rustc_ast::ast::{BindingMode, Lifetime, Mutability, Param, PatKind, Path, TyKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 22adbdf09a6..4c67304d23e 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -3,7 +3,8 @@ //! This lint is **warn** by default use crate::utils::sugg::Sugg; -use crate::utils::{is_expn_of, parent_node_is_if_expr, span_lint, span_lint_and_sugg}; +use crate::utils::{is_expn_of, parent_node_is_if_expr}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet_with_applicability; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index d8b574af1fe..72436b51dcb 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -2,7 +2,8 @@ //! //! This lint is **warn** by default -use crate::utils::{is_automatically_derived, span_lint_and_then}; +use crate::utils::is_automatically_derived; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index 5ee71f25694..7fbffe04a3f 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_then; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index 4ff90704207..91c97ef7c2a 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -33,6 +33,7 @@ //! ``` //! //! This lint is **warn** by default. +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::{indent_of, snippet, snippet_block}; use rustc_ast::ast; use rustc_lint::{EarlyContext, EarlyLintPass}; @@ -40,8 +41,6 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::{original_sp, DUMMY_SP}; use rustc_span::Span; -use crate::utils::span_lint_and_help; - declare_clippy_lint! { /// **What it does:** The lint checks for `if`-statements appearing in loops /// that contain a `continue` statement in either their main blocks or their diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 6f7a5d85480..fc8ee6cb8ef 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -1,5 +1,6 @@ use crate::utils::ptr::get_spans; -use crate::utils::{get_trait_def_id, is_self, multispan_sugg, paths, span_lint_and_then}; +use crate::utils::{get_trait_def_id, is_self, paths}; +use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then}; use clippy_utils::source::{snippet, snippet_opt}; use clippy_utils::ty::{implements_trait, is_copy, is_type_diagnostic_item}; use if_chain::if_chain; diff --git a/clippy_lints/src/needless_question_mark.rs b/clippy_lints/src/needless_question_mark.rs index bcc39ff855c..ecf48d082af 100644 --- a/clippy_lints/src/needless_question_mark.rs +++ b/clippy_lints/src/needless_question_mark.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; @@ -140,7 +141,7 @@ fn emit_lint(cx: &LateContext<'_>, expr: &SomeOkCall<'_>) { SomeOkCall::OkCall(outer, inner) | SomeOkCall::SomeCall(outer, inner) => (outer, inner), }; - utils::span_lint_and_sugg( + span_lint_and_sugg( cx, NEEDLESS_QUESTION_MARK, entire_expr.span, diff --git a/clippy_lints/src/needless_update.rs b/clippy_lints/src/needless_update.rs index 41cf541ecf5..e93de8a252a 100644 --- a/clippy_lints/src/needless_update.rs +++ b/clippy_lints/src/needless_update.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; 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 67d49f06ad9..e291885d34d 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::implements_trait; use if_chain::if_chain; use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; @@ -5,7 +6,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::{self, paths, span_lint}; +use crate::utils::{self, paths}; declare_clippy_lint! { /// **What it does:** diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index ef7cc65cfcf..7b00879251f 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; @@ -5,7 +6,6 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use crate::consts::{self, Constant}; -use crate::utils::span_lint; declare_clippy_lint! { /// **What it does:** Checks for multiplication by -1 as a form of negation. diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index de2899c3462..9fbb6b02742 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -1,6 +1,7 @@ use crate::utils::paths; use crate::utils::sugg::DiagnosticBuilderExt; -use crate::utils::{get_trait_def_id, return_ty, span_lint_hir_and_then}; +use crate::utils::{get_trait_def_id, return_ty}; +use clippy_utils::diagnostics::span_lint_hir_and_then; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 7a7bc7a44cd..83953a16bc8 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -1,4 +1,4 @@ -use crate::utils::{span_lint, span_lint_and_sugg}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet_opt; use clippy_utils::ty::has_drop; use rustc_errors::Applicability; diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 8aebce67917..5db614497e3 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -4,6 +4,7 @@ use std::ptr; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{ @@ -18,7 +19,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{InnerSpan, Span, DUMMY_SP}; use rustc_typeck::hir_ty_to_ty; -use crate::utils::{in_constant, span_lint_and_then}; +use crate::utils::in_constant; use if_chain::if_chain; // FIXME: this is a correctness problem but there's no suitable diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 7c74b316018..52661416de6 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -1,4 +1,4 @@ -use crate::utils::{span_lint, span_lint_and_then}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; use rustc_ast::ast::{ Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, FnKind, Item, ItemKind, Local, Pat, PatKind, }; diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index 71e77932f7a..8e8aaa67afa 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -1,4 +1,5 @@ -use crate::utils::{paths, span_lint}; +use crate::utils::paths; +use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::match_type; use rustc_ast::ast::LitKind; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/option_env_unwrap.rs b/clippy_lints/src/option_env_unwrap.rs index fd653044a1b..343159f9ae2 100644 --- a/clippy_lints/src/option_env_unwrap.rs +++ b/clippy_lints/src/option_env_unwrap.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_direct_expn_of, span_lint_and_help}; +use crate::utils::is_direct_expn_of; +use clippy_utils::diagnostics::span_lint_and_help; use if_chain::if_chain; use rustc_ast::ast::{Expr, ExprKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; diff --git a/clippy_lints/src/option_if_let_else.rs b/clippy_lints/src/option_if_let_else.rs index 8a6d257848f..eab08a58320 100644 --- a/clippy_lints/src/option_if_let_else.rs +++ b/clippy_lints/src/option_if_let_else.rs @@ -1,7 +1,8 @@ use crate::utils; use crate::utils::eager_or_lazy; +use crate::utils::paths; use crate::utils::sugg::Sugg; -use crate::utils::{paths, span_lint_and_sugg}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/overflow_check_conditional.rs b/clippy_lints/src/overflow_check_conditional.rs index 3c041bac234..524b96921fe 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -1,4 +1,5 @@ -use crate::utils::{span_lint, SpanlessEq}; +use crate::utils::SpanlessEq; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_hir::{BinOpKind, Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/panic_in_result_fn.rs b/clippy_lints/src/panic_in_result_fn.rs index 1821e2611ff..880951f3e3e 100644 --- a/clippy_lints/src/panic_in_result_fn.rs +++ b/clippy_lints/src/panic_in_result_fn.rs @@ -1,4 +1,5 @@ -use crate::utils::{find_macro_calls, return_ty, span_lint_and_then}; +use crate::utils::{find_macro_calls, return_ty}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use rustc_hir as hir; use rustc_hir::intravisit::FnKind; diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index 359620cc079..ad4ed831941 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_expn_of, match_panic_call, span_lint}; +use crate::utils::{is_expn_of, match_panic_call}; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_hir::Expr; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/partialeq_ne_impl.rs b/clippy_lints/src/partialeq_ne_impl.rs index aca1ed5ca65..06985cef4ff 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_automatically_derived, span_lint_hir}; +use crate::utils::is_automatically_derived; +use clippy_utils::diagnostics::span_lint_hir; use if_chain::if_chain; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index 757ead2c24c..c14273840c4 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -1,6 +1,7 @@ use std::cmp; -use crate::utils::{is_self_ty, span_lint_and_sugg}; +use crate::utils::is_self_ty; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_copy; use if_chain::if_chain; diff --git a/clippy_lints/src/path_buf_push_overwrite.rs b/clippy_lints/src/path_buf_push_overwrite.rs index 46533682d42..95ffae28d8c 100644 --- a/clippy_lints/src/path_buf_push_overwrite.rs +++ b/clippy_lints/src/path_buf_push_overwrite.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_ast::ast::LitKind; diff --git a/clippy_lints/src/pattern_type_mismatch.rs b/clippy_lints/src/pattern_type_mismatch.rs index 5539331d046..dd63cf99e42 100644 --- a/clippy_lints/src/pattern_type_mismatch.rs +++ b/clippy_lints/src/pattern_type_mismatch.rs @@ -1,4 +1,5 @@ -use crate::utils::{last_path_segment, span_lint_and_help}; +use crate::utils::last_path_segment; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir::{ intravisit, Body, Expr, ExprKind, FieldPat, FnDecl, HirId, LocalSource, MatchSource, Mutability, Pat, PatKind, QPath, Stmt, StmtKind, diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index fbe54e92ab9..9cf00c953b9 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_ast::ast::{BinOpKind, Expr, ExprKind, LitKind, UnOp}; diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index bfe8bf33f51..779eddcc170 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -1,7 +1,8 @@ //! Checks for usage of `&Vec[_]` and `&String`. use crate::utils::ptr::get_spans; -use crate::utils::{is_allowed, match_qpath, paths, span_lint, span_lint_and_sugg, span_lint_and_then}; +use crate::utils::{is_allowed, match_qpath, paths}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_opt; use clippy_utils::ty::{is_type_diagnostic_item, match_type, walk_ptrs_hir_ty}; use if_chain::if_chain; diff --git a/clippy_lints/src/ptr_eq.rs b/clippy_lints/src/ptr_eq.rs index 4f83e370c5f..82408c639b1 100644 --- a/clippy_lints/src/ptr_eq.rs +++ b/clippy_lints/src/ptr_eq.rs @@ -1,4 +1,5 @@ use crate::utils; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_errors::Applicability; @@ -58,7 +59,7 @@ impl LateLintPass<'_> for PtrEq { if let Some(left_snip) = snippet_opt(cx, left_var.span); if let Some(right_snip) = snippet_opt(cx, right_var.span); then { - utils::span_lint_and_sugg( + span_lint_and_sugg( cx, PTR_EQ, expr.span, diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index b801defeb24..c04b4255256 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -1,4 +1,4 @@ -use crate::utils::{span_lint, span_lint_and_sugg}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet_opt; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index 43431425a43..c4686623487 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -9,7 +9,8 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; use crate::utils::sugg::Sugg; -use crate::utils::{eq_expr_value, match_def_path, match_qpath, paths, span_lint_and_sugg}; +use crate::utils::{eq_expr_value, match_def_path, match_qpath, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; declare_clippy_lint! { /// **What it does:** Checks for expressions that could be replaced by the question mark operator. diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 3ce8949bf8b..d476d95256f 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -1,4 +1,5 @@ use crate::consts::{constant, Constant}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability}; use if_chain::if_chain; use rustc_ast::ast::RangeLimits; @@ -14,10 +15,7 @@ use rustc_span::symbol::Ident; use std::cmp::Ordering; use crate::utils::sugg::Sugg; -use crate::utils::{ - get_parent_expr, in_constant, is_integer_const, meets_msrv, single_segment_path, span_lint, span_lint_and_sugg, - span_lint_and_then, -}; +use crate::utils::{get_parent_expr, in_constant, is_integer_const, meets_msrv, single_segment_path}; use crate::utils::{higher, SpanlessEq}; declare_clippy_lint! { diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 84723acd034..3d799328bb5 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -1,4 +1,5 @@ -use crate::utils::{fn_has_unsatisfiable_preds, match_def_path, paths, span_lint_hir, span_lint_hir_and_then}; +use crate::utils::{fn_has_unsatisfiable_preds, match_def_path, paths}; +use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then}; use clippy_utils::source::snippet_opt; use clippy_utils::ty::{has_drop, is_copy, is_type_diagnostic_item, walk_ptrs_ty_depth}; use if_chain::if_chain; diff --git a/clippy_lints/src/redundant_closure_call.rs b/clippy_lints/src/redundant_closure_call.rs index 283e25553cf..2977a108d14 100644 --- a/clippy_lints/src/redundant_closure_call.rs +++ b/clippy_lints/src/redundant_closure_call.rs @@ -1,4 +1,4 @@ -use crate::utils::{span_lint, span_lint_and_then}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_ast::ast; diff --git a/clippy_lints/src/redundant_else.rs b/clippy_lints/src/redundant_else.rs index 3d585cd27a3..061526c6f09 100644 --- a/clippy_lints/src/redundant_else.rs +++ b/clippy_lints/src/redundant_else.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Block, Expr, ExprKind, Stmt, StmtKind}; use rustc_ast::visit::{walk_expr, Visitor}; use rustc_lint::{EarlyContext, EarlyLintPass}; diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index 38dcf7a192c..fd11150bce2 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -1,4 +1,5 @@ -use crate::utils::{meets_msrv, span_lint_and_sugg}; +use crate::utils::meets_msrv; +use clippy_utils::diagnostics::span_lint_and_sugg; use rustc_ast::ast::{Expr, ExprKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; diff --git a/clippy_lints/src/redundant_pub_crate.rs b/clippy_lints/src/redundant_pub_crate.rs index c876bae2303..e091095de13 100644 --- a/clippy_lints/src/redundant_pub_crate.rs +++ b/clippy_lints/src/redundant_pub_crate.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_then; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind, VisibilityKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/redundant_slicing.rs b/clippy_lints/src/redundant_slicing.rs index 85ea91a387b..6da7b5fbcc8 100644 --- a/clippy_lints/src/redundant_slicing.rs +++ b/clippy_lints/src/redundant_slicing.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_lang_item; use if_chain::if_chain; @@ -7,8 +8,6 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::{lint::in_external_macro, ty::TyS}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::span_lint_and_sugg; - declare_clippy_lint! { /// **What it does:** Checks for redundant slicing expressions which use the full range, and /// do not change the type. diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index 1352a651723..da8339a795a 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -1,4 +1,5 @@ -use crate::utils::{meets_msrv, span_lint_and_then}; +use crate::utils::meets_msrv; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use rustc_ast::ast::{Item, ItemKind, Ty, TyKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/ref_option_ref.rs b/clippy_lints/src/ref_option_ref.rs index cec6b06262b..452fef0694f 100644 --- a/clippy_lints/src/ref_option_ref.rs +++ b/clippy_lints/src/ref_option_ref.rs @@ -1,4 +1,5 @@ -use crate::utils::{last_path_segment, span_lint_and_sugg}; +use crate::utils::last_path_segment; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs index 31e834ac174..ec2acb6a0ab 100644 --- a/clippy_lints/src/reference.rs +++ b/clippy_lints/src/reference.rs @@ -1,5 +1,6 @@ +use crate::utils::in_macro; use crate::utils::sugg::Sugg; -use crate::utils::{in_macro, span_lint_and_sugg}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{snippet_opt, snippet_with_applicability}; use if_chain::if_chain; use rustc_ast::ast::{Expr, ExprKind, Mutability, UnOp}; diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 1edea613148..bfa21ba9c97 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -1,5 +1,6 @@ use crate::consts::{constant, Constant}; -use crate::utils::{match_def_path, paths, span_lint, span_lint_and_help}; +use crate::utils::{match_def_path, paths}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use if_chain::if_chain; use rustc_ast::ast::{LitKind, StrStyle}; use rustc_data_structures::fx::FxHashSet; diff --git a/clippy_lints/src/repeat_once.rs b/clippy_lints/src/repeat_once.rs index a88078c12a3..b39e9d5a78c 100644 --- a/clippy_lints/src/repeat_once.rs +++ b/clippy_lints/src/repeat_once.rs @@ -1,5 +1,6 @@ use crate::consts::{constant_context, Constant}; -use crate::utils::{in_macro, span_lint_and_sugg}; +use crate::utils::in_macro; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index eb7fe403fd7..59d3c0ca5f0 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_ast::ast::Attribute; @@ -12,7 +13,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use rustc_span::sym; -use crate::utils::{fn_def_id, in_macro, match_qpath, span_lint_and_sugg, span_lint_and_then}; +use crate::utils::{fn_def_id, in_macro, match_qpath}; declare_clippy_lint! { /// **What it does:** Checks for `let`-bindings, which are subsequently diff --git a/clippy_lints/src/self_assignment.rs b/clippy_lints/src/self_assignment.rs index e62b75de4ca..320d1a8dbe3 100644 --- a/clippy_lints/src/self_assignment.rs +++ b/clippy_lints/src/self_assignment.rs @@ -1,4 +1,5 @@ -use crate::utils::{eq_expr_value, span_lint}; +use crate::utils::eq_expr_value; +use clippy_utils::diagnostics::span_lint; use clippy_utils::source::snippet; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/semicolon_if_nothing_returned.rs b/clippy_lints/src/semicolon_if_nothing_returned.rs index 695d7233af2..e43947025b9 100644 --- a/clippy_lints/src/semicolon_if_nothing_returned.rs +++ b/clippy_lints/src/semicolon_if_nothing_returned.rs @@ -1,4 +1,5 @@ -use crate::utils::{in_macro, span_lint_and_sugg, sugg}; +use crate::utils::{in_macro, sugg}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_macro_callsite; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs index 90cf1b6c861..632715852c5 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -1,4 +1,5 @@ -use crate::utils::{get_trait_def_id, paths, span_lint}; +use crate::utils::{get_trait_def_id, paths}; +use clippy_utils::diagnostics::span_lint; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 4a8cacb31fd..8ef58b6d563 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -1,4 +1,5 @@ -use crate::utils::{contains_name, higher, iter_input_pats, span_lint_and_then}; +use crate::utils::{contains_name, higher, iter_input_pats}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use rustc_hir::intravisit::FnKind; use rustc_hir::{ diff --git a/clippy_lints/src/single_component_path_imports.rs b/clippy_lints/src/single_component_path_imports.rs index 1fc4ff5c2e6..6d15a6c444e 100644 --- a/clippy_lints/src/single_component_path_imports.rs +++ b/clippy_lints/src/single_component_path_imports.rs @@ -1,4 +1,5 @@ -use crate::utils::{in_macro, span_lint_and_sugg}; +use crate::utils::in_macro; +use clippy_utils::diagnostics::span_lint_and_sugg; use if_chain::if_chain; use rustc_ast::{Item, ItemKind, UseTreeKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/size_of_in_element_count.rs b/clippy_lints/src/size_of_in_element_count.rs index 87e386baadc..8920d446b9c 100644 --- a/clippy_lints/src/size_of_in_element_count.rs +++ b/clippy_lints/src/size_of_in_element_count.rs @@ -1,7 +1,8 @@ //! Lint on use of `size_of` or `size_of_val` of T in an expression //! expecting a count of T -use crate::utils::{match_def_path, paths, span_lint_and_help}; +use crate::utils::{match_def_path, paths}; +use clippy_utils::diagnostics::span_lint_and_help; use if_chain::if_chain; use rustc_hir::BinOpKind; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index 96f6881556c..7f0f21084af 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -1,5 +1,6 @@ use crate::utils::sugg::Sugg; -use crate::utils::{get_enclosing_block, match_qpath, span_lint_and_then, SpanlessEq}; +use crate::utils::{get_enclosing_block, match_qpath, SpanlessEq}; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/stable_sort_primitive.rs b/clippy_lints/src/stable_sort_primitive.rs index 276a9338819..85e4bb806e7 100644 --- a/clippy_lints/src/stable_sort_primitive.rs +++ b/clippy_lints/src/stable_sort_primitive.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_slice_of_primitives, span_lint_and_then, sugg::Sugg}; +use crate::utils::{is_slice_of_primitives, sugg::Sugg}; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index ce93ab23b2f..626166f9008 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -1,8 +1,6 @@ use crate::utils::SpanlessEq; -use crate::utils::{ - get_parent_expr, is_allowed, match_function_call, method_calls, paths, span_lint, span_lint_and_help, - span_lint_and_sugg, -}; +use crate::utils::{get_parent_expr, is_allowed, match_function_call, method_calls, paths}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/suspicious_operation_groupings.rs b/clippy_lints/src/suspicious_operation_groupings.rs index 3bdd9b7e4cb..364c99adc69 100644 --- a/clippy_lints/src/suspicious_operation_groupings.rs +++ b/clippy_lints/src/suspicious_operation_groupings.rs @@ -1,5 +1,5 @@ use crate::utils::ast_utils::{eq_id, is_useless_with_eq_exprs, IdentIter}; -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use core::ops::{Add, AddAssign}; use if_chain::if_chain; diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index 0b7d08cb164..ef14b6c5136 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -1,4 +1,5 @@ -use crate::utils::{get_trait_def_id, span_lint, trait_ref_of_method}; +use crate::utils::{get_trait_def_id, trait_ref_of_method}; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_hir as hir; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index d4a495f3ea9..83fe3c49959 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -1,5 +1,6 @@ use crate::utils::sugg::Sugg; -use crate::utils::{differing_macro_contexts, eq_expr_value, span_lint_and_then}; +use crate::utils::{differing_macro_contexts, eq_expr_value}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/tabs_in_doc_comments.rs b/clippy_lints/src/tabs_in_doc_comments.rs index 74ccd9235de..88bd2feaadd 100644 --- a/clippy_lints/src/tabs_in_doc_comments.rs +++ b/clippy_lints/src/tabs_in_doc_comments.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use rustc_ast::ast; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; diff --git a/clippy_lints/src/temporary_assignment.rs b/clippy_lints/src/temporary_assignment.rs index fb891866364..75a13cb9187 100644 --- a/clippy_lints/src/temporary_assignment.rs +++ b/clippy_lints/src/temporary_assignment.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_adjusted, span_lint}; +use crate::utils::is_adjusted; +use clippy_utils::diagnostics::span_lint; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/to_digit_is_some.rs b/clippy_lints/src/to_digit_is_some.rs index 940273afc57..abc9b2fe88e 100644 --- a/clippy_lints/src/to_digit_is_some.rs +++ b/clippy_lints/src/to_digit_is_some.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, span_lint_and_sugg}; +use crate::utils::match_def_path; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/to_string_in_display.rs b/clippy_lints/src/to_string_in_display.rs index 84ec2aa18ab..42605c01089 100644 --- a/clippy_lints/src/to_string_in_display.rs +++ b/clippy_lints/src/to_string_in_display.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_diagnostic_assoc_item, match_def_path, path_to_local_id, paths, span_lint}; +use crate::utils::{is_diagnostic_assoc_item, match_def_path, path_to_local_id, paths}; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind, HirId, Impl, ImplItem, ImplItemKind, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index d3314271c21..cfcc8da9910 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -1,4 +1,5 @@ -use crate::utils::{in_macro, span_lint_and_help, SpanlessHash}; +use crate::utils::{in_macro, SpanlessHash}; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::{snippet, snippet_with_applicability}; use if_chain::if_chain; use rustc_data_structures::fx::FxHashMap; diff --git a/clippy_lints/src/transmute/crosspointer_transmute.rs b/clippy_lints/src/transmute/crosspointer_transmute.rs index ce87defaa94..25d0543c861 100644 --- a/clippy_lints/src/transmute/crosspointer_transmute.rs +++ b/clippy_lints/src/transmute/crosspointer_transmute.rs @@ -1,5 +1,5 @@ use super::CROSSPOINTER_TRANSMUTE; -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; diff --git a/clippy_lints/src/transmute/transmute_float_to_int.rs b/clippy_lints/src/transmute/transmute_float_to_int.rs index 562d880e39a..f61b5362b5a 100644 --- a/clippy_lints/src/transmute/transmute_float_to_int.rs +++ b/clippy_lints/src/transmute/transmute_float_to_int.rs @@ -1,5 +1,6 @@ use super::TRANSMUTE_FLOAT_TO_INT; -use crate::utils::{span_lint_and_then, sugg}; +use crate::utils::sugg; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; use rustc_ast as ast; use rustc_errors::Applicability; diff --git a/clippy_lints/src/transmute/transmute_int_to_bool.rs b/clippy_lints/src/transmute/transmute_int_to_bool.rs index 5b609f906a3..ebdd1eba744 100644 --- a/clippy_lints/src/transmute/transmute_int_to_bool.rs +++ b/clippy_lints/src/transmute/transmute_int_to_bool.rs @@ -1,5 +1,6 @@ use super::TRANSMUTE_INT_TO_BOOL; -use crate::utils::{span_lint_and_then, sugg}; +use crate::utils::sugg; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_ast as ast; use rustc_errors::Applicability; use rustc_hir::Expr; diff --git a/clippy_lints/src/transmute/transmute_int_to_char.rs b/clippy_lints/src/transmute/transmute_int_to_char.rs index 29d2450618a..afecfc3d701 100644 --- a/clippy_lints/src/transmute/transmute_int_to_char.rs +++ b/clippy_lints/src/transmute/transmute_int_to_char.rs @@ -1,5 +1,6 @@ use super::TRANSMUTE_INT_TO_CHAR; -use crate::utils::{span_lint_and_then, sugg}; +use crate::utils::sugg; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_ast as ast; use rustc_errors::Applicability; use rustc_hir::Expr; diff --git a/clippy_lints/src/transmute/transmute_int_to_float.rs b/clippy_lints/src/transmute/transmute_int_to_float.rs index f83fba8966a..c762a7ab885 100644 --- a/clippy_lints/src/transmute/transmute_int_to_float.rs +++ b/clippy_lints/src/transmute/transmute_int_to_float.rs @@ -1,5 +1,6 @@ use super::TRANSMUTE_INT_TO_FLOAT; -use crate::utils::{span_lint_and_then, sugg}; +use crate::utils::sugg; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; diff --git a/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs b/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs index f4e60a3020c..820c56a215e 100644 --- a/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs +++ b/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs @@ -1,5 +1,6 @@ use super::TRANSMUTE_PTR_TO_PTR; -use crate::utils::{span_lint_and_then, sugg}; +use crate::utils::sugg; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; diff --git a/clippy_lints/src/transmute/transmute_ptr_to_ref.rs b/clippy_lints/src/transmute/transmute_ptr_to_ref.rs index f5dbbbe33bc..049210e555c 100644 --- a/clippy_lints/src/transmute/transmute_ptr_to_ref.rs +++ b/clippy_lints/src/transmute/transmute_ptr_to_ref.rs @@ -1,6 +1,7 @@ use super::utils::get_type_snippet; use super::TRANSMUTE_PTR_TO_REF; -use crate::utils::{span_lint_and_then, sugg}; +use crate::utils::sugg; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability, QPath}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/transmute/transmute_ref_to_ref.rs b/clippy_lints/src/transmute/transmute_ref_to_ref.rs index 4780eb9b14e..993ef8698f8 100644 --- a/clippy_lints/src/transmute/transmute_ref_to_ref.rs +++ b/clippy_lints/src/transmute/transmute_ref_to_ref.rs @@ -1,5 +1,6 @@ use super::{TRANSMUTE_BYTES_TO_STR, TRANSMUTE_PTR_TO_PTR}; -use crate::utils::{span_lint_and_sugg, span_lint_and_then, sugg}; +use crate::utils::sugg; +use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs index dea896622f1..da7d1016d97 100644 --- a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs +++ b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs @@ -1,6 +1,7 @@ use super::utils::can_be_expressed_as_pointer_cast; use super::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS; -use crate::utils::{span_lint_and_then, sugg}; +use crate::utils::sugg; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; diff --git a/clippy_lints/src/transmute/unsound_collection_transmute.rs b/clippy_lints/src/transmute/unsound_collection_transmute.rs index 503c5e0ff38..9bea88be7da 100644 --- a/clippy_lints/src/transmute/unsound_collection_transmute.rs +++ b/clippy_lints/src/transmute/unsound_collection_transmute.rs @@ -1,6 +1,7 @@ use super::utils::is_layout_incompatible; use super::UNSOUND_COLLECTION_TRANSMUTE; -use crate::utils::{match_def_path, paths, span_lint}; +use crate::utils::{match_def_path, paths}; +use clippy_utils::diagnostics::span_lint; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; diff --git a/clippy_lints/src/transmute/useless_transmute.rs b/clippy_lints/src/transmute/useless_transmute.rs index 83441514af0..29ffe03b673 100644 --- a/clippy_lints/src/transmute/useless_transmute.rs +++ b/clippy_lints/src/transmute/useless_transmute.rs @@ -1,5 +1,6 @@ use super::USELESS_TRANSMUTE; -use crate::utils::{span_lint, span_lint_and_then, sugg}; +use crate::utils::sugg; +use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; diff --git a/clippy_lints/src/transmute/wrong_transmute.rs b/clippy_lints/src/transmute/wrong_transmute.rs index d6d77f2c834..2118f3d6950 100644 --- a/clippy_lints/src/transmute/wrong_transmute.rs +++ b/clippy_lints/src/transmute/wrong_transmute.rs @@ -1,5 +1,5 @@ use super::WRONG_TRANSMUTE; -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; diff --git a/clippy_lints/src/transmuting_null.rs b/clippy_lints/src/transmuting_null.rs index 2ba2b646f00..3a2b1359a54 100644 --- a/clippy_lints/src/transmuting_null.rs +++ b/clippy_lints/src/transmuting_null.rs @@ -1,5 +1,6 @@ use crate::consts::{constant_context, Constant}; -use crate::utils::{match_qpath, paths, span_lint}; +use crate::utils::{match_qpath, paths}; +use clippy_utils::diagnostics::span_lint; use if_chain::if_chain; use rustc_ast::LitKind; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/try_err.rs b/clippy_lints/src/try_err.rs index e356add8e9d..1fce03b4f47 100644 --- a/clippy_lints/src/try_err.rs +++ b/clippy_lints/src/try_err.rs @@ -1,4 +1,5 @@ -use crate::utils::{differing_macro_contexts, in_macro, match_def_path, match_qpath, paths, span_lint_and_sugg}; +use crate::utils::{differing_macro_contexts, in_macro, match_def_path, match_qpath, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{snippet, snippet_with_macro_callsite}; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/types/borrowed_box.rs b/clippy_lints/src/types/borrowed_box.rs index 01aeea7a67f..eab81b1e246 100644 --- a/clippy_lints/src/types/borrowed_box.rs +++ b/clippy_lints/src/types/borrowed_box.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_path, paths, span_lint_and_sugg}; +use crate::utils::{match_path, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/types/box_vec.rs b/clippy_lints/src/types/box_vec.rs index 6aa98e435e1..6d04a47a5c8 100644 --- a/clippy_lints/src/types/box_vec.rs +++ b/clippy_lints/src/types/box_vec.rs @@ -1,8 +1,9 @@ +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir::{self as hir, def_id::DefId, QPath}; use rustc_lint::LateContext; use rustc_span::symbol::sym; -use crate::utils::{is_ty_param_diagnostic_item, span_lint_and_help}; +use crate::utils::is_ty_param_diagnostic_item; use super::BOX_VEC; diff --git a/clippy_lints/src/types/linked_list.rs b/clippy_lints/src/types/linked_list.rs index 47eb4ede4e4..e9e1995f6a5 100644 --- a/clippy_lints/src/types/linked_list.rs +++ b/clippy_lints/src/types/linked_list.rs @@ -1,7 +1,8 @@ +use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir::{self as hir, def_id::DefId}; use rustc_lint::LateContext; -use crate::utils::{match_def_path, paths, span_lint_and_help}; +use crate::utils::{match_def_path, paths}; use super::LINKEDLIST; diff --git a/clippy_lints/src/types/mod.rs b/clippy_lints/src/types/mod.rs index 279a971318c..ac4fe502a7a 100644 --- a/clippy_lints/src/types/mod.rs +++ b/clippy_lints/src/types/mod.rs @@ -13,6 +13,7 @@ use std::borrow::Cow; use std::cmp::Ordering; use std::collections::BTreeMap; +use clippy_utils::diagnostics::{multispan_sugg, span_lint, span_lint_and_help, span_lint_and_then}; use clippy_utils::source::{indent_of, reindent_multiline, snippet, snippet_opt, snippet_with_macro_callsite}; use clippy_utils::ty::{is_isize_or_usize, is_type_diagnostic_item}; use if_chain::if_chain; @@ -38,10 +39,7 @@ use rustc_typeck::hir_ty_to_ty; use crate::consts::{constant, Constant}; use crate::utils::paths; -use crate::utils::{ - clip, comparisons, differing_macro_contexts, higher, int_bits, match_path, multispan_sugg, sext, span_lint, - span_lint_and_help, span_lint_and_then, unsext, -}; +use crate::utils::{clip, comparisons, differing_macro_contexts, higher, int_bits, match_path, sext, unsext}; declare_clippy_lint! { /// **What it does:** Checks for use of `Box>` anywhere in the code. diff --git a/clippy_lints/src/types/option_option.rs b/clippy_lints/src/types/option_option.rs index dc5db963b4e..79c5a32de2c 100644 --- a/clippy_lints/src/types/option_option.rs +++ b/clippy_lints/src/types/option_option.rs @@ -1,8 +1,9 @@ +use clippy_utils::diagnostics::span_lint; use rustc_hir::{self as hir, def_id::DefId, QPath}; use rustc_lint::LateContext; use rustc_span::symbol::sym; -use crate::utils::{is_ty_param_diagnostic_item, span_lint}; +use crate::utils::is_ty_param_diagnostic_item; use super::OPTION_OPTION; diff --git a/clippy_lints/src/types/rc_buffer.rs b/clippy_lints/src/types/rc_buffer.rs index 0ace1807535..d5fc23f2e39 100644 --- a/clippy_lints/src/types/rc_buffer.rs +++ b/clippy_lints/src/types/rc_buffer.rs @@ -1,10 +1,11 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::{self as hir, def_id::DefId, QPath, TyKind}; use rustc_lint::LateContext; use rustc_span::symbol::sym; -use crate::utils::{get_qpath_generic_tys, is_ty_param_diagnostic_item, span_lint_and_sugg}; +use crate::utils::{get_qpath_generic_tys, is_ty_param_diagnostic_item}; use super::RC_BUFFER; diff --git a/clippy_lints/src/types/redundant_allocation.rs b/clippy_lints/src/types/redundant_allocation.rs index c6f6a2f6564..71c014f96f7 100644 --- a/clippy_lints/src/types/redundant_allocation.rs +++ b/clippy_lints/src/types/redundant_allocation.rs @@ -1,10 +1,11 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::{self as hir, def_id::DefId, LangItem, QPath, TyKind}; use rustc_lint::LateContext; use rustc_span::symbol::sym; -use crate::utils::{get_qpath_generic_tys, is_ty_param_diagnostic_item, is_ty_param_lang_item, span_lint_and_sugg}; +use crate::utils::{get_qpath_generic_tys, is_ty_param_diagnostic_item, is_ty_param_lang_item}; use super::{utils, REDUNDANT_ALLOCATION}; diff --git a/clippy_lints/src/types/vec_box.rs b/clippy_lints/src/types/vec_box.rs index 6f45442b9ba..8cedb0ede2b 100644 --- a/clippy_lints/src/types/vec_box.rs +++ b/clippy_lints/src/types/vec_box.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_errors::Applicability; @@ -8,7 +9,7 @@ use rustc_span::symbol::sym; use rustc_target::abi::LayoutOf; use rustc_typeck::hir_ty_to_ty; -use crate::utils::{last_path_segment, span_lint_and_sugg}; +use crate::utils::last_path_segment; use super::VEC_BOX; diff --git a/clippy_lints/src/undropped_manually_drops.rs b/clippy_lints/src/undropped_manually_drops.rs index 8c34ca16e6f..943573a2b53 100644 --- a/clippy_lints/src/undropped_manually_drops.rs +++ b/clippy_lints/src/undropped_manually_drops.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_function_call, paths, span_lint_and_help}; +use crate::utils::{match_function_call, paths}; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::is_type_lang_item; use rustc_hir::{lang_items, Expr}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/unicode.rs b/clippy_lints/src/unicode.rs index e44fec7ad8e..c37bbf297f8 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_allowed, span_lint_and_sugg}; +use crate::utils::is_allowed; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/unit_return_expecting_ord.rs b/clippy_lints/src/unit_return_expecting_ord.rs index c6ae8b9b598..d0456347f8a 100644 --- a/clippy_lints/src/unit_return_expecting_ord.rs +++ b/clippy_lints/src/unit_return_expecting_ord.rs @@ -1,4 +1,5 @@ -use crate::utils::{get_trait_def_id, paths, span_lint, span_lint_and_help}; +use crate::utils::{get_trait_def_id, paths}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use if_chain::if_chain; use rustc_hir::def_id::DefId; use rustc_hir::{Expr, ExprKind, StmtKind}; diff --git a/clippy_lints/src/unnamed_address.rs b/clippy_lints/src/unnamed_address.rs index 9582c162e77..2c51a8556d9 100644 --- a/clippy_lints/src/unnamed_address.rs +++ b/clippy_lints/src/unnamed_address.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, paths, span_lint, span_lint_and_help}; +use crate::utils::{match_def_path, paths}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use if_chain::if_chain; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/unnecessary_sort_by.rs b/clippy_lints/src/unnecessary_sort_by.rs index 7e385b00646..aa83f6a74be 100644 --- a/clippy_lints/src/unnecessary_sort_by.rs +++ b/clippy_lints/src/unnecessary_sort_by.rs @@ -1,5 +1,5 @@ -use crate::utils; use crate::utils::sugg::Sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_errors::Applicability; @@ -233,7 +233,7 @@ fn expr_borrows(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { impl LateLintPass<'_> for UnnecessarySortBy { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { match detect_lint(cx, expr) { - Some(LintTrigger::SortByKey(trigger)) => utils::span_lint_and_sugg( + Some(LintTrigger::SortByKey(trigger)) => span_lint_and_sugg( cx, UNNECESSARY_SORT_BY, expr.span, @@ -256,7 +256,7 @@ impl LateLintPass<'_> for UnnecessarySortBy { Applicability::MachineApplicable }, ), - Some(LintTrigger::Sort(trigger)) => utils::span_lint_and_sugg( + Some(LintTrigger::Sort(trigger)) => span_lint_and_sugg( cx, UNNECESSARY_SORT_BY, expr.span, diff --git a/clippy_lints/src/unnecessary_wraps.rs b/clippy_lints/src/unnecessary_wraps.rs index 01497de3211..cb20192b683 100644 --- a/clippy_lints/src/unnecessary_wraps.rs +++ b/clippy_lints/src/unnecessary_wraps.rs @@ -1,6 +1,5 @@ -use crate::utils::{ - contains_return, in_macro, match_qpath, paths, return_ty, span_lint_and_then, visitors::find_all_ret_expressions, -}; +use crate::utils::{contains_return, in_macro, match_qpath, paths, return_ty, visitors::find_all_ret_expressions}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/unnested_or_patterns.rs b/clippy_lints/src/unnested_or_patterns.rs index 7f4f16f8faf..42ff1809ff4 100644 --- a/clippy_lints/src/unnested_or_patterns.rs +++ b/clippy_lints/src/unnested_or_patterns.rs @@ -1,7 +1,8 @@ #![allow(clippy::wildcard_imports, clippy::enum_glob_use)] use crate::utils::ast_utils::{eq_field_pat, eq_id, eq_pat, eq_path}; -use crate::utils::{over, span_lint_and_then}; +use crate::utils::over; +use clippy_utils::diagnostics::span_lint_and_then; use rustc_ast::mut_visit::*; use rustc_ast::ptr::P; use rustc_ast::{self as ast, Pat, PatKind, PatKind::*, DUMMY_NODE_ID}; diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index 154082a0fdb..16ad9d2dfd3 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint; +use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Item, ItemKind, UseTree, UseTreeKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index 43166d26787..31fd61f99f2 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -1,4 +1,5 @@ -use crate::utils::{is_try, match_trait_method, paths, span_lint}; +use crate::utils::{is_try, match_trait_method, paths}; +use clippy_utils::diagnostics::span_lint; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/unused_self.rs b/clippy_lints/src/unused_self.rs index 812482cf5cf..4642bf07c45 100644 --- a/clippy_lints/src/unused_self.rs +++ b/clippy_lints/src/unused_self.rs @@ -1,9 +1,9 @@ +use clippy_utils::diagnostics::span_lint_and_help; use if_chain::if_chain; use rustc_hir::{Impl, ImplItem, ImplItemKind, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::span_lint_and_help; use crate::utils::visitors::LocalUsedVisitor; declare_clippy_lint! { diff --git a/clippy_lints/src/unused_unit.rs b/clippy_lints/src/unused_unit.rs index a90d26fc95c..c45b851211c 100644 --- a/clippy_lints/src/unused_unit.rs +++ b/clippy_lints/src/unused_unit.rs @@ -8,7 +8,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use rustc_span::BytePos; -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; declare_clippy_lint! { /// **What it does:** Checks for unit (`()`) expressions that can be removed. diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 43b5f138a42..75b2f2da602 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -1,4 +1,5 @@ -use crate::utils::{differing_macro_contexts, span_lint_and_then, usage::is_potentially_mutated}; +use crate::utils::{differing_macro_contexts, usage::is_potentially_mutated}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_hir::intravisit::{walk_expr, walk_fn, FnKind, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/unwrap_in_result.rs b/clippy_lints/src/unwrap_in_result.rs index 6a8f8211566..a85f3ce5c9c 100644 --- a/clippy_lints/src/unwrap_in_result.rs +++ b/clippy_lints/src/unwrap_in_result.rs @@ -1,4 +1,5 @@ -use crate::utils::{method_chain_args, return_ty, span_lint_and_then}; +use crate::utils::{method_chain_args, return_ty}; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_hir as hir; diff --git a/clippy_lints/src/upper_case_acronyms.rs b/clippy_lints/src/upper_case_acronyms.rs index 0470e1dbbb8..7ce9aa13184 100644 --- a/clippy_lints/src/upper_case_acronyms.rs +++ b/clippy_lints/src/upper_case_acronyms.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_sugg; +use clippy_utils::diagnostics::span_lint_and_sugg; use if_chain::if_chain; use itertools::Itertools; use rustc_ast::ast::{Item, ItemKind, Variant}; @@ -81,7 +81,7 @@ fn check_ident(cx: &EarlyContext<'_>, ident: &Ident, be_aggressive: bool) { // assume that two-letter words are some kind of valid abbreviation like FP for false positive // (and don't warn) if (ident.chars().all(|c| c.is_ascii_uppercase()) && ident.len() > 2) - // otherwise, warn if we have SOmeTHING lIKE THIs but only warn with the aggressive + // otherwise, warn if we have SOmeTHING lIKE THIs but only warn with the aggressive // upper-case-acronyms-aggressive config option enabled || (be_aggressive && ident != &corrected) { diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index de7eb42d56d..9a42c833470 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -1,7 +1,7 @@ +use crate::utils::{in_macro, meets_msrv}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_opt; use if_chain::if_chain; - -use crate::utils::{in_macro, meets_msrv, span_lint_and_sugg}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::def::DefKind; diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index e6b4fde560f..1eb152daac8 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -1,7 +1,6 @@ use crate::utils::sugg::Sugg; -use crate::utils::{ - get_parent_expr, match_def_path, match_trait_method, paths, span_lint_and_help, span_lint_and_sugg, -}; +use crate::utils::{get_parent_expr, match_def_path, match_trait_method, paths}; +use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::{snippet, snippet_with_macro_callsite}; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index 04b8d9ee2c7..a566362ae78 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -1,8 +1,7 @@ use crate::consts::{constant_simple, Constant}; -use crate::utils::{ - is_expn_of, match_def_path, match_qpath, method_calls, path_to_res, paths, run_lints, span_lint, - span_lint_and_help, span_lint_and_sugg, SpanlessEq, -}; +use crate::utils::{is_expn_of, match_def_path, match_qpath, method_calls, path_to_res, paths, run_lints, SpanlessEq}; + +use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::snippet; use clippy_utils::ty::match_type; use if_chain::if_chain; diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index cd09a5b53e0..9e142413365 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -1,6 +1,7 @@ use crate::consts::{constant, Constant}; use crate::rustc_target::abi::LayoutOf; -use crate::utils::{higher, span_lint_and_sugg}; +use crate::utils::higher; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_copy; use if_chain::if_chain; diff --git a/clippy_lints/src/vec_init_then_push.rs b/clippy_lints/src/vec_init_then_push.rs index 4ad787ecf66..3ef55a82a17 100644 --- a/clippy_lints/src/vec_init_then_push.rs +++ b/clippy_lints/src/vec_init_then_push.rs @@ -1,4 +1,5 @@ -use crate::utils::{match_def_path, path_to_local, path_to_local_id, paths, span_lint_and_sugg}; +use crate::utils::{match_def_path, path_to_local, path_to_local_id, paths}; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/vec_resize_to_zero.rs b/clippy_lints/src/vec_resize_to_zero.rs index d2494b321ef..9a2fb1414a1 100644 --- a/clippy_lints/src/vec_resize_to_zero.rs +++ b/clippy_lints/src/vec_resize_to_zero.rs @@ -1,4 +1,4 @@ -use crate::utils::span_lint_and_then; +use clippy_utils::diagnostics::span_lint_and_then; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/verbose_file_reads.rs b/clippy_lints/src/verbose_file_reads.rs index 079a4279c60..01dc54dc5fd 100644 --- a/clippy_lints/src/verbose_file_reads.rs +++ b/clippy_lints/src/verbose_file_reads.rs @@ -1,4 +1,5 @@ -use crate::utils::{paths, span_lint_and_help}; +use crate::utils::paths; +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::match_type; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind, QPath}; diff --git a/clippy_lints/src/wildcard_dependencies.rs b/clippy_lints/src/wildcard_dependencies.rs index cd1864f461d..8f96b962279 100644 --- a/clippy_lints/src/wildcard_dependencies.rs +++ b/clippy_lints/src/wildcard_dependencies.rs @@ -1,4 +1,5 @@ -use crate::utils::{run_lints, span_lint}; +use crate::utils::run_lints; +use clippy_utils::diagnostics::span_lint; use rustc_hir::{hir_id::CRATE_HIR_ID, Crate}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index e12ca49fd4c..424ca2a4c2f 100644 --- a/clippy_lints/src/wildcard_imports.rs +++ b/clippy_lints/src/wildcard_imports.rs @@ -1,4 +1,5 @@ -use crate::utils::{in_macro, span_lint_and_sugg}; +use crate::utils::in_macro; +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{snippet, snippet_with_applicability}; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index f2fef73a641..fd3e5a7ce91 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use std::ops::Range; -use crate::utils::{span_lint, span_lint_and_sugg, span_lint_and_then}; +use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_ast::ast::{Expr, ExprKind, ImplKind, Item, ItemKind, LitKind, MacCall, StrLit, StrStyle}; diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index 11d96e15ff1..3b4890ad560 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -1,5 +1,5 @@ use crate::consts::{constant_simple, Constant}; -use crate::utils::span_lint_and_help; +use clippy_utils::diagnostics::span_lint_and_help; use if_chain::if_chain; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/zero_sized_map_values.rs b/clippy_lints/src/zero_sized_map_values.rs index ab27b60cfa4..82466da6862 100644 --- a/clippy_lints/src/zero_sized_map_values.rs +++ b/clippy_lints/src/zero_sized_map_values.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::{is_normalizable, is_type_diagnostic_item, match_type}; use if_chain::if_chain; use rustc_hir::{self as hir, HirId, ItemKind, Node}; @@ -8,7 +9,7 @@ use rustc_span::sym; use rustc_target::abi::LayoutOf as _; use rustc_typeck::hir_ty_to_ty; -use crate::utils::{paths, span_lint_and_help}; +use crate::utils::paths; declare_clippy_lint! { /// **What it does:** Checks for maps with zero-sized value types anywhere in the code. diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index d895d798b5e..d3cf2a34709 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -33,7 +33,7 @@ pub mod attrs; pub mod camel_case; pub mod comparisons; pub mod consts; -mod diagnostics; +pub mod diagnostics; pub mod eager_or_lazy; pub mod higher; mod hir_utils; @@ -48,7 +48,6 @@ pub mod usage; pub mod visitors; pub use self::attrs::*; -pub use self::diagnostics::*; pub use self::hir_utils::{both, eq_expr_value, over, SpanlessEq, SpanlessHash}; use std::collections::hash_map::Entry; -- cgit 1.4.1-3-g733a5 From 0743e841f07b7c41f65187fbf71f90bb5dc71982 Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Tue, 16 Mar 2021 11:06:34 -0500 Subject: Don't re-export clippy_utils::* --- clippy_lints/src/assertions_on_constants.rs | 2 +- clippy_lints/src/assign_ops.rs | 6 +++--- clippy_lints/src/atomic_ordering.rs | 2 +- clippy_lints/src/attrs.rs | 2 +- clippy_lints/src/await_holding_invalid.rs | 2 +- clippy_lints/src/bit_mask.rs | 2 +- clippy_lints/src/blocks_in_if_conditions.rs | 2 +- clippy_lints/src/booleans.rs | 2 +- clippy_lints/src/bytecount.rs | 2 +- clippy_lints/src/cargo_common_metadata.rs | 2 +- clippy_lints/src/casts/cast_lossless.rs | 3 +-- clippy_lints/src/casts/cast_possible_truncation.rs | 3 +-- clippy_lints/src/casts/cast_ptr_alignment.rs | 6 ++---- clippy_lints/src/casts/cast_sign_loss.rs | 10 ++++------ clippy_lints/src/casts/mod.rs | 3 +-- clippy_lints/src/casts/ptr_as_ptr.rs | 10 ++++------ clippy_lints/src/casts/unnecessary_cast.rs | 3 +-- clippy_lints/src/checked_conversions.rs | 3 +-- clippy_lints/src/cognitive_complexity.rs | 3 +-- clippy_lints/src/collapsible_if.rs | 3 +-- clippy_lints/src/collapsible_match.rs | 4 ++-- clippy_lints/src/comparison_chain.rs | 2 +- clippy_lints/src/copies.rs | 4 ++-- clippy_lints/src/create_dir.rs | 2 +- clippy_lints/src/default.rs | 2 +- clippy_lints/src/dereference.rs | 2 +- clippy_lints/src/derive.rs | 4 ++-- clippy_lints/src/disallowed_method.rs | 2 +- clippy_lints/src/doc.rs | 2 +- clippy_lints/src/double_comparison.rs | 3 +-- clippy_lints/src/drop_forget_ref.rs | 2 +- clippy_lints/src/duration_subsec.rs | 2 +- clippy_lints/src/entry.rs | 4 ++-- clippy_lints/src/enum_variants.rs | 2 +- clippy_lints/src/eq_op.rs | 2 +- clippy_lints/src/eta_reduction.rs | 3 +-- clippy_lints/src/eval_order_dependence.rs | 2 +- clippy_lints/src/excessive_bools.rs | 2 +- clippy_lints/src/exit.rs | 2 +- clippy_lints/src/explicit_write.rs | 2 +- clippy_lints/src/fallible_impl_from.rs | 2 +- clippy_lints/src/float_equality_without_abs.rs | 2 +- clippy_lints/src/float_literal.rs | 2 +- clippy_lints/src/floating_point_arithmetic.rs | 2 +- clippy_lints/src/format.rs | 4 ++-- clippy_lints/src/formatting.rs | 2 +- clippy_lints/src/from_over_into.rs | 4 ++-- clippy_lints/src/from_str_radix_10.rs | 3 +-- clippy_lints/src/functions.rs | 8 ++++---- clippy_lints/src/future_not_send.rs | 4 ++-- clippy_lints/src/get_last_with_len.rs | 2 +- clippy_lints/src/identity_op.rs | 2 +- clippy_lints/src/if_let_mutex.rs | 2 +- clippy_lints/src/if_let_some_result.rs | 2 +- clippy_lints/src/if_then_some_else_none.rs | 10 +++++----- clippy_lints/src/implicit_return.rs | 2 +- clippy_lints/src/implicit_saturating_sub.rs | 2 +- clippy_lints/src/indexing_slicing.rs | 2 +- clippy_lints/src/infinite_iter.rs | 3 +-- clippy_lints/src/inherent_impl.rs | 2 +- clippy_lints/src/inherent_to_string.rs | 3 +-- clippy_lints/src/inline_fn_without_body.rs | 2 +- clippy_lints/src/len_zero.rs | 2 +- clippy_lints/src/let_if_seq.rs | 2 +- clippy_lints/src/let_underscore.rs | 3 +-- clippy_lints/src/lib.rs | 2 +- clippy_lints/src/lifetimes.rs | 2 +- clippy_lints/src/literal_representation.rs | 6 +++--- clippy_lints/src/loops/empty_loop.rs | 2 +- clippy_lints/src/loops/explicit_counter_loop.rs | 2 +- clippy_lints/src/loops/explicit_iter_loop.rs | 2 +- clippy_lints/src/loops/for_kv_map.rs | 4 ++-- clippy_lints/src/loops/iter_next_loop.rs | 3 +-- clippy_lints/src/loops/manual_flatten.rs | 2 +- clippy_lints/src/loops/manual_memcpy.rs | 4 ++-- clippy_lints/src/loops/mod.rs | 2 +- clippy_lints/src/loops/mut_range_bound.rs | 2 +- clippy_lints/src/loops/needless_collect.rs | 4 ++-- clippy_lints/src/loops/needless_range_loop.rs | 8 ++++---- clippy_lints/src/loops/single_element_loop.rs | 2 +- clippy_lints/src/loops/utils.rs | 2 +- clippy_lints/src/loops/while_immutable_condition.rs | 2 +- clippy_lints/src/loops/while_let_on_iterator.rs | 8 ++++---- clippy_lints/src/macro_use.rs | 2 +- clippy_lints/src/main_recursion.rs | 3 +-- clippy_lints/src/manual_async_fn.rs | 4 ++-- clippy_lints/src/manual_map.rs | 7 ++----- clippy_lints/src/manual_non_exhaustive.rs | 2 +- clippy_lints/src/manual_ok_or.rs | 2 +- clippy_lints/src/manual_strip.rs | 4 ++-- clippy_lints/src/manual_unwrap_or.rs | 14 +++++++------- clippy_lints/src/map_clone.rs | 4 ++-- clippy_lints/src/map_identity.rs | 2 +- clippy_lints/src/map_unit_fn.rs | 2 +- clippy_lints/src/matches.rs | 16 ++++++++-------- clippy_lints/src/mem_discriminant.rs | 2 +- clippy_lints/src/mem_forget.rs | 2 +- clippy_lints/src/mem_replace.rs | 2 +- clippy_lints/src/methods/bind_instead_of_map.rs | 2 +- clippy_lints/src/methods/clone_on_copy.rs | 2 +- clippy_lints/src/methods/clone_on_ref_ptr.rs | 2 +- clippy_lints/src/methods/expect_fun_call.rs | 2 +- clippy_lints/src/methods/filetype_is_file.rs | 2 +- clippy_lints/src/methods/filter_flat_map.rs | 2 +- clippy_lints/src/methods/filter_map.rs | 2 +- clippy_lints/src/methods/filter_map_flat_map.rs | 2 +- clippy_lints/src/methods/filter_map_identity.rs | 2 +- clippy_lints/src/methods/filter_map_map.rs | 2 +- clippy_lints/src/methods/filter_map_next.rs | 2 +- clippy_lints/src/methods/filter_next.rs | 2 +- clippy_lints/src/methods/flat_map_identity.rs | 2 +- .../src/methods/from_iter_instead_of_collect.rs | 2 +- clippy_lints/src/methods/get_unwrap.rs | 2 +- clippy_lints/src/methods/inefficient_to_string.rs | 2 +- clippy_lints/src/methods/inspect_for_each.rs | 3 +-- clippy_lints/src/methods/into_iter_on_ref.rs | 2 +- clippy_lints/src/methods/iter_count.rs | 2 +- clippy_lints/src/methods/iter_next_slice.rs | 2 +- clippy_lints/src/methods/iter_nth_zero.rs | 2 +- clippy_lints/src/methods/iter_skip_next.rs | 2 +- clippy_lints/src/methods/iterator_step_by_zero.rs | 2 +- .../src/methods/manual_saturating_arithmetic.rs | 2 +- clippy_lints/src/methods/map_collect_result_unit.rs | 2 +- clippy_lints/src/methods/map_flatten.rs | 2 +- clippy_lints/src/methods/map_unwrap_or.rs | 4 ++-- clippy_lints/src/methods/mod.rs | 9 ++++----- clippy_lints/src/methods/option_as_ref_deref.rs | 2 +- clippy_lints/src/methods/option_map_or_none.rs | 2 +- clippy_lints/src/methods/option_map_unwrap_or.rs | 2 +- clippy_lints/src/methods/or_fun_call.rs | 4 ++-- clippy_lints/src/methods/search_is_some.rs | 2 +- clippy_lints/src/methods/skip_while_next.rs | 2 +- clippy_lints/src/methods/string_extend_chars.rs | 2 +- clippy_lints/src/methods/suspicious_map.rs | 4 ++-- clippy_lints/src/methods/uninit_assumed_init.rs | 2 +- clippy_lints/src/methods/unnecessary_filter_map.rs | 7 +++---- clippy_lints/src/methods/unnecessary_fold.rs | 2 +- clippy_lints/src/methods/unnecessary_lazy_eval.rs | 2 +- clippy_lints/src/methods/useless_asref.rs | 2 +- clippy_lints/src/minmax.rs | 2 +- clippy_lints/src/misc.rs | 4 ++-- clippy_lints/src/missing_const_for_fn.rs | 4 ++-- clippy_lints/src/modulo_arithmetic.rs | 2 +- clippy_lints/src/multiple_crate_versions.rs | 2 +- clippy_lints/src/mut_key.rs | 2 +- clippy_lints/src/mut_mut.rs | 2 +- clippy_lints/src/mutable_debug_assertion.rs | 2 +- clippy_lints/src/needless_arbitrary_self_type.rs | 2 +- clippy_lints/src/needless_bool.rs | 4 ++-- clippy_lints/src/needless_borrow.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 4 ++-- clippy_lints/src/needless_question_mark.rs | 11 +++++------ clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 5 ++--- clippy_lints/src/new_without_default.rs | 6 +++--- clippy_lints/src/non_copy_const.rs | 5 ++--- clippy_lints/src/open_options.rs | 2 +- clippy_lints/src/option_env_unwrap.rs | 2 +- clippy_lints/src/option_if_let_else.rs | 19 +++++++++---------- clippy_lints/src/overflow_check_conditional.rs | 2 +- clippy_lints/src/panic_in_result_fn.rs | 2 +- clippy_lints/src/panic_unimplemented.rs | 2 +- clippy_lints/src/partialeq_ne_impl.rs | 2 +- clippy_lints/src/pass_by_ref_or_value.rs | 2 +- clippy_lints/src/pattern_type_mismatch.rs | 2 +- clippy_lints/src/ptr.rs | 4 ++-- clippy_lints/src/ptr_eq.rs | 4 ++-- clippy_lints/src/question_mark.rs | 7 +++---- clippy_lints/src/ranges.rs | 7 +++---- clippy_lints/src/redundant_clone.rs | 2 +- clippy_lints/src/redundant_field_names.rs | 2 +- clippy_lints/src/redundant_static_lifetimes.rs | 2 +- clippy_lints/src/ref_option_ref.rs | 2 +- clippy_lints/src/reference.rs | 4 ++-- clippy_lints/src/regex.rs | 2 +- clippy_lints/src/repeat_once.rs | 2 +- clippy_lints/src/returns.rs | 3 +-- clippy_lints/src/self_assignment.rs | 2 +- clippy_lints/src/semicolon_if_nothing_returned.rs | 2 +- clippy_lints/src/serde_api.rs | 2 +- clippy_lints/src/shadow.rs | 2 +- clippy_lints/src/single_component_path_imports.rs | 2 +- clippy_lints/src/size_of_in_element_count.rs | 2 +- clippy_lints/src/slow_vector_initialization.rs | 4 ++-- clippy_lints/src/stable_sort_primitive.rs | 4 +--- clippy_lints/src/strings.rs | 4 ++-- clippy_lints/src/suspicious_operation_groupings.rs | 2 +- clippy_lints/src/suspicious_trait_impl.rs | 4 ++-- clippy_lints/src/swap.rs | 4 ++-- clippy_lints/src/temporary_assignment.rs | 2 +- clippy_lints/src/to_digit_is_some.rs | 2 +- clippy_lints/src/to_string_in_display.rs | 2 +- clippy_lints/src/trait_bounds.rs | 2 +- clippy_lints/src/transmute/mod.rs | 2 +- clippy_lints/src/transmute/transmute_float_to_int.rs | 2 +- clippy_lints/src/transmute/transmute_int_to_bool.rs | 2 +- clippy_lints/src/transmute/transmute_int_to_char.rs | 2 +- clippy_lints/src/transmute/transmute_int_to_float.rs | 2 +- clippy_lints/src/transmute/transmute_ptr_to_ptr.rs | 2 +- clippy_lints/src/transmute/transmute_ptr_to_ref.rs | 2 +- clippy_lints/src/transmute/transmute_ref_to_ref.rs | 2 +- .../transmute/transmutes_expressible_as_ptr_casts.rs | 2 +- .../src/transmute/unsound_collection_transmute.rs | 2 +- clippy_lints/src/transmute/useless_transmute.rs | 2 +- clippy_lints/src/transmute/utils.rs | 2 +- clippy_lints/src/transmuting_null.rs | 2 +- clippy_lints/src/try_err.rs | 2 +- clippy_lints/src/types/borrowed_box.rs | 2 +- clippy_lints/src/types/box_vec.rs | 3 +-- clippy_lints/src/types/linked_list.rs | 3 +-- clippy_lints/src/types/mod.rs | 8 ++++---- clippy_lints/src/types/option_option.rs | 3 +-- clippy_lints/src/types/rc_buffer.rs | 3 +-- clippy_lints/src/types/redundant_allocation.rs | 3 +-- clippy_lints/src/types/utils.rs | 6 ++---- clippy_lints/src/types/vec_box.rs | 3 +-- clippy_lints/src/undropped_manually_drops.rs | 2 +- clippy_lints/src/unicode.rs | 2 +- clippy_lints/src/unit_return_expecting_ord.rs | 2 +- clippy_lints/src/unit_types/let_unit_value.rs | 7 +++---- clippy_lints/src/unit_types/unit_arg.rs | 8 +++----- clippy_lints/src/unit_types/unit_cmp.rs | 3 +-- clippy_lints/src/unnamed_address.rs | 2 +- clippy_lints/src/unnecessary_sort_by.rs | 2 +- clippy_lints/src/unnecessary_wraps.rs | 2 +- clippy_lints/src/unnested_or_patterns.rs | 4 ++-- clippy_lints/src/unused_io_amount.rs | 2 +- clippy_lints/src/unused_self.rs | 3 +-- clippy_lints/src/unused_unit.rs | 3 +-- clippy_lints/src/unwrap.rs | 2 +- clippy_lints/src/unwrap_in_result.rs | 2 +- clippy_lints/src/use_self.rs | 2 +- clippy_lints/src/useless_conversion.rs | 4 ++-- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/inspector.rs | 2 +- clippy_lints/src/utils/internal_lints.rs | 3 +-- clippy_lints/src/utils/mod.rs | 2 -- clippy_lints/src/vec.rs | 2 +- clippy_lints/src/vec_init_then_push.rs | 2 +- clippy_lints/src/vec_resize_to_zero.rs | 7 +++---- clippy_lints/src/verbose_file_reads.rs | 2 +- clippy_lints/src/wildcard_dependencies.rs | 2 +- clippy_lints/src/wildcard_imports.rs | 2 +- clippy_lints/src/zero_sized_map_values.rs | 3 +-- 243 files changed, 344 insertions(+), 399 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index bae4d4957a9..16905781c56 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -1,7 +1,7 @@ use crate::consts::{constant, Constant}; -use crate::utils::{is_direct_expn_of, is_expn_of, match_panic_call}; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet_opt; +use clippy_utils::{is_direct_expn_of, is_expn_of, match_panic_call}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 8581e176e0c..5b8fb9b436a 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -1,8 +1,8 @@ -use crate::utils::{eq_expr_value, get_trait_def_id, trait_ref_of_method}; -use crate::utils::{higher, sugg}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_opt; use clippy_utils::ty::implements_trait; +use clippy_utils::{eq_expr_value, get_trait_def_id, trait_ref_of_method}; +use clippy_utils::{higher, sugg}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; @@ -93,7 +93,7 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps { $($trait_name:ident),+) => { match $op { $(hir::BinOpKind::$trait_name => { - let [krate, module] = crate::utils::paths::OPS_MODULE; + let [krate, module] = clippy_utils::paths::OPS_MODULE; let path: [&str; 3] = [krate, module, concat!(stringify!($trait_name), "Assign")]; let trait_id = if let Some(trait_id) = get_trait_def_id($cx, &path) { trait_id diff --git a/clippy_lints/src/atomic_ordering.rs b/clippy_lints/src/atomic_ordering.rs index 231e74e16c0..dfb18199325 100644 --- a/clippy_lints/src/atomic_ordering.rs +++ b/clippy_lints/src/atomic_ordering.rs @@ -1,5 +1,5 @@ -use crate::utils::match_def_path; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::match_def_path; use if_chain::if_chain; use rustc_hir::def_id::DefId; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 6be6722375d..f805f716e6b 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -1,7 +1,7 @@ //! checks for attributes -use crate::utils::match_panic_def_id; use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; +use clippy_utils::match_panic_def_id; use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments}; use if_chain::if_chain; use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem}; diff --git a/clippy_lints/src/await_holding_invalid.rs b/clippy_lints/src/await_holding_invalid.rs index 3a3296c2c3d..68eee0520b3 100644 --- a/clippy_lints/src/await_holding_invalid.rs +++ b/clippy_lints/src/await_holding_invalid.rs @@ -1,5 +1,5 @@ -use crate::utils::{match_def_path, paths}; use clippy_utils::diagnostics::span_lint_and_note; +use clippy_utils::{match_def_path, paths}; use rustc_hir::def_id::DefId; use rustc_hir::{AsyncGeneratorKind, Body, BodyId, GeneratorKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 2b8400344f5..f7daf3dab49 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -1,6 +1,6 @@ use crate::consts::{constant, Constant}; -use crate::utils::sugg::Sugg; use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; +use clippy_utils::sugg::Sugg; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/blocks_in_if_conditions.rs b/clippy_lints/src/blocks_in_if_conditions.rs index 343c4821c56..badcf8d2a43 100644 --- a/clippy_lints/src/blocks_in_if_conditions.rs +++ b/clippy_lints/src/blocks_in_if_conditions.rs @@ -1,7 +1,7 @@ -use crate::utils::{differing_macro_contexts, get_parent_expr}; use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet_block_with_applicability; use clippy_utils::ty::implements_trait; +use clippy_utils::{differing_macro_contexts, get_parent_expr}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 1303613b8c4..58d9aa9c005 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -1,7 +1,7 @@ -use crate::utils::{eq_expr_value, get_trait_def_id, in_macro, paths}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_opt; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; +use clippy_utils::{eq_expr_value, get_trait_def_id, in_macro, paths}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/bytecount.rs b/clippy_lints/src/bytecount.rs index c1ca787c1e5..846ac08e93a 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -1,7 +1,7 @@ -use crate::utils::{contains_name, get_pat_name, paths, single_segment_path}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::match_type; +use clippy_utils::{contains_name, get_pat_name, paths, single_segment_path}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, UnOp}; diff --git a/clippy_lints/src/cargo_common_metadata.rs b/clippy_lints/src/cargo_common_metadata.rs index f0ef482164a..fce5c559672 100644 --- a/clippy_lints/src/cargo_common_metadata.rs +++ b/clippy_lints/src/cargo_common_metadata.rs @@ -2,8 +2,8 @@ use std::path::PathBuf; -use crate::utils::run_lints; use clippy_utils::diagnostics::span_lint; +use clippy_utils::run_lints; use rustc_hir::{hir_id::CRATE_HIR_ID, Crate}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; diff --git a/clippy_lints/src/casts/cast_lossless.rs b/clippy_lints/src/casts/cast_lossless.rs index 4b660188d82..869deecfbd5 100644 --- a/clippy_lints/src/casts/cast_lossless.rs +++ b/clippy_lints/src/casts/cast_lossless.rs @@ -1,4 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::in_constant; use clippy_utils::source::snippet_opt; use clippy_utils::ty::is_isize_or_usize; use rustc_errors::Applicability; @@ -6,8 +7,6 @@ use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, FloatTy, Ty}; -use crate::utils::in_constant; - use super::{utils, CAST_LOSSLESS}; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { diff --git a/clippy_lints/src/casts/cast_possible_truncation.rs b/clippy_lints/src/casts/cast_possible_truncation.rs index 75d7c55b637..833ad122e0d 100644 --- a/clippy_lints/src/casts/cast_possible_truncation.rs +++ b/clippy_lints/src/casts/cast_possible_truncation.rs @@ -1,10 +1,9 @@ +use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::is_isize_or_usize; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, FloatTy, Ty}; -use clippy_utils::diagnostics::span_lint; - use super::{utils, CAST_POSSIBLE_TRUNCATION}; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { diff --git a/clippy_lints/src/casts/cast_ptr_alignment.rs b/clippy_lints/src/casts/cast_ptr_alignment.rs index 6a45ec61c54..5208156ffd2 100644 --- a/clippy_lints/src/casts/cast_ptr_alignment.rs +++ b/clippy_lints/src/casts/cast_ptr_alignment.rs @@ -1,14 +1,12 @@ use clippy_utils::diagnostics::span_lint; +use clippy_utils::is_hir_ty_cfg_dependant; +use if_chain::if_chain; use rustc_hir::{Expr, ExprKind, GenericArg}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use rustc_span::symbol::sym; use rustc_target::abi::LayoutOf; -use if_chain::if_chain; - -use crate::utils::is_hir_ty_cfg_dependant; - use super::CAST_PTR_ALIGNMENT; pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 2965a840a82..bf722d0a3f4 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -1,13 +1,11 @@ +use crate::consts::{constant, Constant}; +use clippy_utils::diagnostics::span_lint; +use clippy_utils::{method_chain_args, sext}; +use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; -use if_chain::if_chain; - -use crate::consts::{constant, Constant}; -use crate::utils::{method_chain_args, sext}; -use clippy_utils::diagnostics::span_lint; - use super::CAST_SIGN_LOSS; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index b726bd75f1d..d9e172c01a7 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -12,14 +12,13 @@ mod ptr_as_ptr; mod unnecessary_cast; mod utils; +use clippy_utils::is_hir_ty_cfg_dependant; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_semver::RustcVersion; use rustc_session::{declare_tool_lint, impl_lint_pass}; -use crate::utils::is_hir_ty_cfg_dependant; - declare_clippy_lint! { /// **What it does:** Checks for casts from any numerical to a float type where /// the receiving type cannot store all values from the original type without diff --git a/clippy_lints/src/casts/ptr_as_ptr.rs b/clippy_lints/src/casts/ptr_as_ptr.rs index 2c25f865cb8..9113e5a0920 100644 --- a/clippy_lints/src/casts/ptr_as_ptr.rs +++ b/clippy_lints/src/casts/ptr_as_ptr.rs @@ -1,17 +1,15 @@ use std::borrow::Cow; +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::meets_msrv; +use clippy_utils::sugg::Sugg; +use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, Mutability, TyKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, TypeAndMut}; use rustc_semver::RustcVersion; -use if_chain::if_chain; - -use crate::utils::meets_msrv; -use crate::utils::sugg::Sugg; -use clippy_utils::diagnostics::span_lint_and_sugg; - use super::PTR_AS_PTR; const PTR_AS_PTR_MSRV: RustcVersion = RustcVersion::new(1, 38, 0); diff --git a/clippy_lints/src/casts/unnecessary_cast.rs b/clippy_lints/src/casts/unnecessary_cast.rs index a84e658024a..9ed359922fd 100644 --- a/clippy_lints/src/casts/unnecessary_cast.rs +++ b/clippy_lints/src/casts/unnecessary_cast.rs @@ -1,4 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::numeric_literal::NumericLiteral; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_ast::{LitFloatType, LitIntType, LitKind}; @@ -8,8 +9,6 @@ use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, FloatTy, InferTy, Ty}; -use crate::utils::numeric_literal::NumericLiteral; - use super::UNNECESSARY_CAST; pub(super) fn check( diff --git a/clippy_lints/src/checked_conversions.rs b/clippy_lints/src/checked_conversions.rs index 8b62e315e04..ed46cac493a 100644 --- a/clippy_lints/src/checked_conversions.rs +++ b/clippy_lints/src/checked_conversions.rs @@ -2,6 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; +use clippy_utils::{meets_msrv, SpanlessEq}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; @@ -11,8 +12,6 @@ use rustc_middle::lint::in_external_macro; use rustc_semver::RustcVersion; use rustc_session::{declare_tool_lint, impl_lint_pass}; -use crate::utils::{meets_msrv, SpanlessEq}; - const CHECKED_CONVERSIONS_MSRV: RustcVersion = RustcVersion::new(1, 34, 0); declare_clippy_lint! { diff --git a/clippy_lints/src/cognitive_complexity.rs b/clippy_lints/src/cognitive_complexity.rs index 8134f3af3ef..4cc542f723c 100644 --- a/clippy_lints/src/cognitive_complexity.rs +++ b/clippy_lints/src/cognitive_complexity.rs @@ -3,6 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet_opt; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::LimitStack; use rustc_ast::ast::Attribute; use rustc_hir::intravisit::{walk_expr, FnKind, NestedVisitorMap, Visitor}; use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId}; @@ -12,8 +13,6 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::Span; use rustc_span::{sym, BytePos}; -use crate::utils::LimitStack; - declare_clippy_lint! { /// **What it does:** Checks for methods with high cognitive complexity. /// diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index dbe70f90732..dae5c86bd44 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -14,14 +14,13 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::{snippet_block, snippet_block_with_applicability}; +use clippy_utils::sugg::Sugg; use if_chain::if_chain; use rustc_ast::ast; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::sugg::Sugg; - declare_clippy_lint! { /// **What it does:** Checks for nested `if` statements which can be collapsed /// by `&&`-combining their conditions. diff --git a/clippy_lints/src/collapsible_match.rs b/clippy_lints/src/collapsible_match.rs index 5ff2518bd94..e2b3686ddf0 100644 --- a/clippy_lints/src/collapsible_match.rs +++ b/clippy_lints/src/collapsible_match.rs @@ -1,6 +1,6 @@ -use crate::utils::visitors::LocalUsedVisitor; -use crate::utils::{path_to_local, SpanlessEq}; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::visitors::LocalUsedVisitor; +use clippy_utils::{path_to_local, SpanlessEq}; use if_chain::if_chain; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, Pat, PatKind, QPath, StmtKind, UnOp}; diff --git a/clippy_lints/src/comparison_chain.rs b/clippy_lints/src/comparison_chain.rs index 5411905791c..d601cb7c224 100644 --- a/clippy_lints/src/comparison_chain.rs +++ b/clippy_lints/src/comparison_chain.rs @@ -1,6 +1,6 @@ -use crate::utils::{get_trait_def_id, if_sequence, parent_node_is_if_expr, paths, SpanlessEq}; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::implements_trait; +use clippy_utils::{get_trait_def_id, if_sequence, parent_node_is_if_expr, paths, SpanlessEq}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index f86f0da6d6f..46093a16571 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -1,6 +1,6 @@ -use crate::utils::{eq_expr_value, in_macro, search_same, SpanlessEq, SpanlessHash}; -use crate::utils::{get_parent_expr, if_sequence}; use clippy_utils::diagnostics::span_lint_and_note; +use clippy_utils::{eq_expr_value, in_macro, search_same, SpanlessEq, SpanlessHash}; +use clippy_utils::{get_parent_expr, if_sequence}; use rustc_hir::{Block, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/create_dir.rs b/clippy_lints/src/create_dir.rs index 01ca2837a99..ac890c90c97 100644 --- a/clippy_lints/src/create_dir.rs +++ b/clippy_lints/src/create_dir.rs @@ -1,6 +1,6 @@ -use crate::utils::{match_def_path, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; +use clippy_utils::{match_def_path, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/default.rs b/clippy_lints/src/default.rs index 0b074c088d4..d046e894792 100644 --- a/clippy_lints/src/default.rs +++ b/clippy_lints/src/default.rs @@ -1,6 +1,6 @@ -use crate::utils::{any_parent_is_automatically_derived, contains_name, match_def_path, paths}; use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_sugg}; use clippy_utils::source::snippet_with_macro_callsite; +use clippy_utils::{any_parent_is_automatically_derived, contains_name, match_def_path, paths}; use if_chain::if_chain; use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index 62ec2f8ce48..1415f8e235a 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -1,7 +1,7 @@ -use crate::utils::{get_parent_node, in_macro, is_allowed}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_context; use clippy_utils::ty::peel_mid_ty_refs; +use clippy_utils::{get_parent_node, in_macro, is_allowed}; use rustc_ast::util::parser::PREC_PREFIX; use rustc_errors::Applicability; use rustc_hir::{BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, UnOp}; diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index a7f2106e357..834136f910d 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -1,7 +1,7 @@ -use crate::utils::paths; -use crate::utils::{get_trait_def_id, is_allowed, is_automatically_derived, match_def_path}; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note, span_lint_and_then}; +use clippy_utils::paths; use clippy_utils::ty::is_copy; +use clippy_utils::{get_trait_def_id, is_allowed, is_automatically_derived, match_def_path}; use if_chain::if_chain; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/disallowed_method.rs b/clippy_lints/src/disallowed_method.rs index 16023bc53b0..ded0a0fff54 100644 --- a/clippy_lints/src/disallowed_method.rs +++ b/clippy_lints/src/disallowed_method.rs @@ -1,5 +1,5 @@ -use crate::utils::fn_def_id; use clippy_utils::diagnostics::span_lint; +use clippy_utils::fn_def_id; use rustc_data_structures::fx::FxHashSet; use rustc_hir::Expr; diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index d9952325c4b..5fa278b2897 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -1,6 +1,6 @@ -use crate::utils::{is_entrypoint_fn, is_expn_of, match_panic_def_id, method_chain_args, return_ty}; use clippy_utils::diagnostics::{span_lint, span_lint_and_note}; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; +use clippy_utils::{is_entrypoint_fn, is_expn_of, match_panic_def_id, method_chain_args, return_ty}; use if_chain::if_chain; use itertools::Itertools; use rustc_ast::ast::{Async, AttrKind, Attribute, FnKind, FnRetTy, ItemKind}; diff --git a/clippy_lints/src/double_comparison.rs b/clippy_lints/src/double_comparison.rs index 549720feb2d..1d291565ec1 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -1,6 +1,7 @@ //! Lint on unnecessary double comparisons. Some examples: use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::eq_expr_value; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind}; @@ -8,8 +9,6 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; -use crate::utils::eq_expr_value; - declare_clippy_lint! { /// **What it does:** Checks for double comparisons that could be simplified to a single expression. /// diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index fe86adcec45..7e7ec017bbb 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -1,6 +1,6 @@ -use crate::utils::{match_def_path, paths}; use clippy_utils::diagnostics::span_lint_and_note; use clippy_utils::ty::is_copy; +use clippy_utils::{match_def_path, paths}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/duration_subsec.rs b/clippy_lints/src/duration_subsec.rs index 40c75f568ae..746c1f6df91 100644 --- a/clippy_lints/src/duration_subsec.rs +++ b/clippy_lints/src/duration_subsec.rs @@ -8,8 +8,8 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Spanned; use crate::consts::{constant, Constant}; -use crate::utils::paths; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::paths; declare_clippy_lint! { /// **What it does:** Checks for calculation of subsecond microseconds or milliseconds diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index cc774831491..25eb048448c 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -1,8 +1,8 @@ -use crate::utils::SpanlessEq; -use crate::utils::{get_item_name, paths}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability}; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; +use clippy_utils::SpanlessEq; +use clippy_utils::{get_item_name, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index d2d8acb443b..0ecc0bc3eb6 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -1,6 +1,6 @@ //! lint on enum variants that are prefixed or suffixed by the same characters -use crate::utils::camel_case; +use clippy_utils::camel_case; use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use clippy_utils::source::is_present_in_source; use rustc_ast::ast::{EnumDef, Item, ItemKind, VisibilityKind}; diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index 1b2f66fb628..6d7046ac8b7 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -1,7 +1,7 @@ -use crate::utils::{ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, in_macro, is_expn_of}; use clippy_utils::diagnostics::{multispan_sugg, span_lint, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::ty::{implements_trait, is_copy}; +use clippy_utils::{ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, in_macro, is_expn_of}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, StmtKind}; diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 2557e9f2796..99253555a95 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -3,6 +3,7 @@ use clippy_utils::higher; use clippy_utils::higher::VecArgs; use clippy_utils::source::snippet_opt; use clippy_utils::ty::{implements_trait, type_is_unsafe_function}; +use clippy_utils::{is_adjusted, iter_input_pats}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{def_id, Expr, ExprKind, Param, PatKind, QPath}; @@ -11,8 +12,6 @@ use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, Ty}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::{is_adjusted, iter_input_pats}; - declare_clippy_lint! { /// **What it does:** Checks for closures which just call another function where /// the function can be called directly. `unsafe` functions or calls where types diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 3711ba4a7ee..5d5b67de843 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -1,5 +1,5 @@ -use crate::utils::{get_parent_expr, path_to_local, path_to_local_id}; use clippy_utils::diagnostics::{span_lint, span_lint_and_note}; +use clippy_utils::{get_parent_expr, path_to_local, path_to_local_id}; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc_hir::{BinOpKind, Block, Expr, ExprKind, Guard, HirId, Local, Node, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/excessive_bools.rs b/clippy_lints/src/excessive_bools.rs index 683e0435351..6c9652fd87d 100644 --- a/clippy_lints/src/excessive_bools.rs +++ b/clippy_lints/src/excessive_bools.rs @@ -1,5 +1,5 @@ -use crate::utils::{attr_by_name, in_macro, match_path_ast}; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::{attr_by_name, in_macro, match_path_ast}; use rustc_ast::ast::{AssocItemKind, Extern, FnKind, FnSig, ImplKind, Item, ItemKind, TraitKind, Ty, TyKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; diff --git a/clippy_lints/src/exit.rs b/clippy_lints/src/exit.rs index adfb644b199..635b6d83eab 100644 --- a/clippy_lints/src/exit.rs +++ b/clippy_lints/src/exit.rs @@ -1,5 +1,5 @@ -use crate::utils::{is_entrypoint_fn, match_def_path, paths}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{is_entrypoint_fn, match_def_path, paths}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index 0861cba4675..4146b7baa10 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -1,5 +1,5 @@ -use crate::utils::{is_expn_of, match_function_call, paths}; use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; +use clippy_utils::{is_expn_of, match_function_call, paths}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 5efe465a667..52a5a7acf0d 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -1,6 +1,6 @@ -use crate::utils::{is_expn_of, match_panic_def_id, method_chain_args}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{is_expn_of, match_panic_def_id, method_chain_args}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/float_equality_without_abs.rs b/clippy_lints/src/float_equality_without_abs.rs index b3593d328cc..0c59db360f9 100644 --- a/clippy_lints/src/float_equality_without_abs.rs +++ b/clippy_lints/src/float_equality_without_abs.rs @@ -1,5 +1,5 @@ -use crate::utils::{match_def_path, paths, sugg}; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::{match_def_path, paths, sugg}; use if_chain::if_chain; use rustc_ast::util::parser::AssocOp; use rustc_errors::Applicability; diff --git a/clippy_lints/src/float_literal.rs b/clippy_lints/src/float_literal.rs index 6446fe62a64..1ca5c685a75 100644 --- a/clippy_lints/src/float_literal.rs +++ b/clippy_lints/src/float_literal.rs @@ -1,5 +1,5 @@ -use crate::utils::numeric_literal; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::numeric_literal; use if_chain::if_chain; use rustc_ast::ast::{self, LitFloatType, LitKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/floating_point_arithmetic.rs b/clippy_lints/src/floating_point_arithmetic.rs index 8b53384ecbd..0b5f0379ce6 100644 --- a/clippy_lints/src/floating_point_arithmetic.rs +++ b/clippy_lints/src/floating_point_arithmetic.rs @@ -2,8 +2,8 @@ use crate::consts::{ constant, constant_simple, Constant, Constant::{Int, F32, F64}, }; -use crate::utils::{eq_expr_value, get_parent_expr, numeric_literal, sugg}; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::{eq_expr_value, get_parent_expr, numeric_literal, sugg}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment, UnOp}; diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index db27225707d..a33f987b423 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -1,8 +1,8 @@ -use crate::utils::paths; -use crate::utils::{is_expn_of, last_path_segment, match_def_path, match_function_call}; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::paths; use clippy_utils::source::{snippet, snippet_opt}; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{is_expn_of, last_path_segment, match_def_path, match_function_call}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 4dadd2ba936..b10e83c0ea8 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -1,5 +1,5 @@ -use crate::utils::differing_macro_contexts; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note}; +use clippy_utils::differing_macro_contexts; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_ast::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp}; diff --git a/clippy_lints/src/from_over_into.rs b/clippy_lints/src/from_over_into.rs index 5eea4d14759..e5ec245e502 100644 --- a/clippy_lints/src/from_over_into.rs +++ b/clippy_lints/src/from_over_into.rs @@ -1,6 +1,6 @@ -use crate::utils::paths::INTO; -use crate::utils::{match_def_path, meets_msrv}; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::paths::INTO; +use clippy_utils::{match_def_path, meets_msrv}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass, LintContext}; diff --git a/clippy_lints/src/from_str_radix_10.rs b/clippy_lints/src/from_str_radix_10.rs index b9a44f26381..3da5bc95b6d 100644 --- a/clippy_lints/src/from_str_radix_10.rs +++ b/clippy_lints/src/from_str_radix_10.rs @@ -1,4 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_errors::Applicability; @@ -8,8 +9,6 @@ use rustc_middle::ty::Ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; -use crate::utils::sugg::Sugg; - declare_clippy_lint! { /// **What it does:** /// Checks for function invocations of the form `primitive::from_str_radix(s, 10)` diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 37288d7a0b2..730492fc7e3 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -1,10 +1,10 @@ -use crate::utils::{ - attr_by_name, attrs::is_proc_macro, is_trait_impl_item, iter_input_pats, match_def_path, must_use_attr, - path_to_local, return_ty, trait_ref_of_method, -}; use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_then}; use clippy_utils::source::{snippet, snippet_opt}; use clippy_utils::ty::{is_must_use_ty, is_type_diagnostic_item, type_is_unsafe_function}; +use clippy_utils::{ + attr_by_name, attrs::is_proc_macro, is_trait_impl_item, iter_input_pats, match_def_path, must_use_attr, + path_to_local, return_ty, trait_ref_of_method, +}; use if_chain::if_chain; use rustc_ast::ast::Attribute; use rustc_data_structures::fx::FxHashSet; diff --git a/clippy_lints/src/future_not_send.rs b/clippy_lints/src/future_not_send.rs index 36960e7f51b..04730ace887 100644 --- a/clippy_lints/src/future_not_send.rs +++ b/clippy_lints/src/future_not_send.rs @@ -1,5 +1,5 @@ -use crate::utils; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::return_ty; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl, HirId}; use rustc_infer::infer::TyCtxtInferExt; @@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend { if let FnKind::Closure = kind { return; } - let ret_ty = utils::return_ty(cx, hir_id); + let ret_ty = return_ty(cx, hir_id); if let Opaque(id, subst) = *ret_ty.kind() { let preds = cx.tcx.explicit_item_bounds(id); let mut is_future = false; diff --git a/clippy_lints/src/get_last_with_len.rs b/clippy_lints/src/get_last_with_len.rs index 6f14ede0ecb..cbcef567c53 100644 --- a/clippy_lints/src/get_last_with_len.rs +++ b/clippy_lints/src/get_last_with_len.rs @@ -1,9 +1,9 @@ //! lint on using `x.get(x.len() - 1)` instead of `x.last()` -use crate::utils::SpanlessEq; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::SpanlessEq; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index 385ea020328..8bed5e1bf64 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -7,8 +7,8 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use crate::consts::{constant_simple, Constant}; -use crate::utils::{clip, unsext}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{clip, unsext}; declare_clippy_lint! { /// **What it does:** Checks for identity operations, e.g., `x + 0`. diff --git a/clippy_lints/src/if_let_mutex.rs b/clippy_lints/src/if_let_mutex.rs index c2ec8b3ffd1..4aab43256bf 100644 --- a/clippy_lints/src/if_let_mutex.rs +++ b/clippy_lints/src/if_let_mutex.rs @@ -1,6 +1,6 @@ -use crate::utils::SpanlessEq; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::SpanlessEq; use if_chain::if_chain; use rustc_hir::intravisit::{self as visit, NestedVisitorMap, Visitor}; use rustc_hir::{Expr, ExprKind, MatchSource}; diff --git a/clippy_lints/src/if_let_some_result.rs b/clippy_lints/src/if_let_some_result.rs index 59094d1147a..6e9280c8c7e 100644 --- a/clippy_lints/src/if_let_some_result.rs +++ b/clippy_lints/src/if_let_some_result.rs @@ -1,5 +1,5 @@ -use crate::utils::method_chain_args; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::method_chain_args; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/if_then_some_else_none.rs b/clippy_lints/src/if_then_some_else_none.rs index c4e87300b7b..0b5bf060d4c 100644 --- a/clippy_lints/src/if_then_some_else_none.rs +++ b/clippy_lints/src/if_then_some_else_none.rs @@ -1,6 +1,6 @@ -use crate::utils; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet_with_macro_callsite; +use clippy_utils::{match_qpath, meets_msrv, parent_node_is_if_expr}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; @@ -58,7 +58,7 @@ impl_lint_pass!(IfThenSomeElseNone => [IF_THEN_SOME_ELSE_NONE]); impl LateLintPass<'_> for IfThenSomeElseNone { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'tcx Expr<'_>) { - if !utils::meets_msrv(self.msrv.as_ref(), &IF_THEN_SOME_ELSE_NONE_MSRV) { + if !meets_msrv(self.msrv.as_ref(), &IF_THEN_SOME_ELSE_NONE_MSRV) { return; } @@ -67,7 +67,7 @@ impl LateLintPass<'_> for IfThenSomeElseNone { } // We only care about the top-most `if` in the chain - if utils::parent_node_is_if_expr(expr, cx) { + if parent_node_is_if_expr(expr, cx) { return; } @@ -77,12 +77,12 @@ impl LateLintPass<'_> for IfThenSomeElseNone { if let Some(ref then_expr) = then_block.expr; if let ExprKind::Call(ref then_call, [then_arg]) = then_expr.kind; if let ExprKind::Path(ref then_call_qpath) = then_call.kind; - if utils::match_qpath(then_call_qpath, &utils::paths::OPTION_SOME); + if match_qpath(then_call_qpath, &clippy_utils::paths::OPTION_SOME); if let ExprKind::Block(ref els_block, _) = els.kind; if els_block.stmts.is_empty(); if let Some(ref els_expr) = els_block.expr; if let ExprKind::Path(ref els_call_qpath) = els_expr.kind; - if utils::match_qpath(els_call_qpath, &utils::paths::OPTION_NONE); + if match_qpath(els_call_qpath, &clippy_utils::paths::OPTION_NONE); then { let cond_snip = snippet_with_macro_callsite(cx, cond.span, "[condition]"); let cond_snip = if matches!(cond.kind, ExprKind::Unary(_, _) | ExprKind::Binary(_, _, _)) { diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index 70ea9a92279..6863645a92d 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -1,5 +1,5 @@ -use crate::utils::match_panic_def_id; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::match_panic_def_id; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/implicit_saturating_sub.rs b/clippy_lints/src/implicit_saturating_sub.rs index 3d2798f3fb4..5207c628987 100644 --- a/clippy_lints/src/implicit_saturating_sub.rs +++ b/clippy_lints/src/implicit_saturating_sub.rs @@ -1,5 +1,5 @@ -use crate::utils::{in_macro, match_qpath, SpanlessEq}; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::{in_macro, match_qpath, SpanlessEq}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index 4c0f976f79a..94d39019608 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -1,8 +1,8 @@ //! lint on indexing and slicing operations use crate::consts::{constant, Constant}; -use crate::utils::higher; use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; +use clippy_utils::higher; use rustc_ast::ast::RangeLimits; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index addd95c6eae..fb35bc1e780 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -1,11 +1,10 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::{implements_trait, match_type}; +use clippy_utils::{get_trait_def_id, higher, match_qpath, paths}; use rustc_hir::{BorrowKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::{get_trait_def_id, higher, match_qpath, paths}; - declare_clippy_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 f838ce190dc..5b2e70e3ce9 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -1,7 +1,7 @@ //! lint on inherent implementations -use crate::utils::in_macro; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::in_macro; use rustc_data_structures::fx::FxHashMap; use rustc_hir::{def_id, Crate, Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index 6b29feeb4ed..b023e13e846 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -1,13 +1,12 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; +use clippy_utils::{get_trait_def_id, paths, return_ty, trait_ref_of_method}; use if_chain::if_chain; use rustc_hir::{ImplItem, ImplItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; -use crate::utils::{get_trait_def_id, paths, return_ty, trait_ref_of_method}; - declare_clippy_lint! { /// **What it does:** Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`. /// diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index 87fe5123cf6..20f00bd51ba 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 crate::utils::sugg::DiagnosticBuilderExt; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg::DiagnosticBuilderExt; use rustc_ast::ast::Attribute; use rustc_errors::Applicability; use rustc_hir::{TraitFn, TraitItem, TraitItemKind}; diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index a644a4113ae..717f2ea84f4 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -1,6 +1,6 @@ -use crate::utils::{get_item_name, get_parent_as_impl, is_allowed}; use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_with_applicability; +use clippy_utils::{get_item_name, get_parent_as_impl, is_allowed}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_data_structures::fx::FxHashSet; diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 4b7e02398fb..2d7d9c9befb 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -1,6 +1,6 @@ -use crate::utils::{path_to_local_id, visitors::LocalUsedVisitor}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; +use clippy_utils::{path_to_local_id, visitors::LocalUsedVisitor}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index eee2503b481..7e3a76ded2c 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -1,5 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::{is_must_use_ty, match_type}; +use clippy_utils::{is_must_use_func_call, paths}; use if_chain::if_chain; use rustc_hir::{Local, PatKind}; use rustc_lint::{LateContext, LateLintPass}; @@ -7,8 +8,6 @@ use rustc_middle::lint::in_external_macro; use rustc_middle::ty::subst::GenericArgKind; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::{is_must_use_func_call, paths}; - declare_clippy_lint! { /// **What it does:** Checks for `let _ = ` /// where expr is #[must_use] diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index f479d756a33..9b2876ddc11 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -42,7 +42,7 @@ extern crate rustc_target; extern crate rustc_trait_selection; extern crate rustc_typeck; -use crate::utils::parse_msrv; +use clippy_utils::parse_msrv; use rustc_data_structures::fx::FxHashSet; use rustc_lint::LintId; use rustc_session::Session; diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 0848aaed815..a2f093e6ef7 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -1,5 +1,5 @@ -use crate::utils::{in_macro, trait_ref_of_method}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{in_macro, trait_ref_of_method}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::intravisit::{ walk_fn_decl, walk_generic_param, walk_generics, walk_item, walk_param_bound, walk_poly_trait_ref, walk_ty, diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index dd303bc0a01..7fd55151226 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -1,12 +1,12 @@ //! Lints concerned with the grouping of digits with underscores in integral or //! floating-point literal expressions. -use crate::utils::{ +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::source::snippet_opt; +use clippy_utils::{ in_macro, numeric_literal::{NumericLiteral, Radix}, }; -use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_ast::ast::{Expr, ExprKind, Lit, LitKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/loops/empty_loop.rs b/clippy_lints/src/loops/empty_loop.rs index d52a061fc8f..dda09fecdf9 100644 --- a/clippy_lints/src/loops/empty_loop.rs +++ b/clippy_lints/src/loops/empty_loop.rs @@ -1,6 +1,6 @@ use super::EMPTY_LOOP; -use crate::utils::{is_in_panic_handler, is_no_std_crate}; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::{is_in_panic_handler, is_no_std_crate}; use rustc_hir::{Block, Expr}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/loops/explicit_counter_loop.rs b/clippy_lints/src/loops/explicit_counter_loop.rs index 87ce4e4c20c..f14dbb1d642 100644 --- a/clippy_lints/src/loops/explicit_counter_loop.rs +++ b/clippy_lints/src/loops/explicit_counter_loop.rs @@ -1,9 +1,9 @@ use super::{ get_span_of_entire_for_loop, make_iterator_snippet, IncrementVisitor, InitializeVisitor, EXPLICIT_COUNTER_LOOP, }; -use crate::utils::{get_enclosing_block, is_integer_const}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; +use clippy_utils::{get_enclosing_block, is_integer_const}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_block, walk_expr}; diff --git a/clippy_lints/src/loops/explicit_iter_loop.rs b/clippy_lints/src/loops/explicit_iter_loop.rs index 259e95e5ef4..92aa2beb66d 100644 --- a/clippy_lints/src/loops/explicit_iter_loop.rs +++ b/clippy_lints/src/loops/explicit_iter_loop.rs @@ -1,8 +1,8 @@ use super::EXPLICIT_ITER_LOOP; -use crate::utils::{match_trait_method, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; +use clippy_utils::{match_trait_method, paths}; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/loops/for_kv_map.rs b/clippy_lints/src/loops/for_kv_map.rs index bf037f392e0..8f18f54119b 100644 --- a/clippy_lints/src/loops/for_kv_map.rs +++ b/clippy_lints/src/loops/for_kv_map.rs @@ -1,9 +1,9 @@ use super::FOR_KV_MAP; -use crate::utils::visitors::LocalUsedVisitor; -use crate::utils::{paths, sugg}; use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; +use clippy_utils::visitors::LocalUsedVisitor; +use clippy_utils::{paths, sugg}; use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Pat, PatKind}; use rustc_lint::LateContext; use rustc_middle::ty; diff --git a/clippy_lints/src/loops/iter_next_loop.rs b/clippy_lints/src/loops/iter_next_loop.rs index 27a03562800..9148fbfd497 100644 --- a/clippy_lints/src/loops/iter_next_loop.rs +++ b/clippy_lints/src/loops/iter_next_loop.rs @@ -1,11 +1,10 @@ use super::ITER_NEXT_LOOP; use clippy_utils::diagnostics::span_lint; +use clippy_utils::is_trait_method; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_span::sym; -use crate::utils::is_trait_method; - pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, expr: &Expr<'_>) -> bool { if is_trait_method(cx, arg, sym::Iterator) { span_lint( diff --git a/clippy_lints/src/loops/manual_flatten.rs b/clippy_lints/src/loops/manual_flatten.rs index 43580d6071a..be87f67d300 100644 --- a/clippy_lints/src/loops/manual_flatten.rs +++ b/clippy_lints/src/loops/manual_flatten.rs @@ -1,7 +1,7 @@ use super::utils::make_iterator_snippet; use super::MANUAL_FLATTEN; -use crate::utils::{is_ok_ctor, is_some_ctor, path_to_local_id}; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::{is_ok_ctor, is_some_ctor, path_to_local_id}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, MatchSource, Pat, PatKind, QPath, StmtKind}; diff --git a/clippy_lints/src/loops/manual_memcpy.rs b/clippy_lints/src/loops/manual_memcpy.rs index ff68d136999..af6d56a89af 100644 --- a/clippy_lints/src/loops/manual_memcpy.rs +++ b/clippy_lints/src/loops/manual_memcpy.rs @@ -1,9 +1,9 @@ use super::{get_span_of_entire_for_loop, IncrementVisitor, InitializeVisitor, MANUAL_MEMCPY}; -use crate::utils::sugg::Sugg; -use crate::utils::{get_enclosing_block, higher, path_to_local, sugg}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; +use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{get_enclosing_block, higher, path_to_local, sugg}; use if_chain::if_chain; use rustc_ast::ast; use rustc_errors::Applicability; diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 2a372c6307e..20291491998 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -18,7 +18,7 @@ mod while_immutable_condition; mod while_let_loop; mod while_let_on_iterator; -use crate::utils::higher; +use clippy_utils::higher; use rustc_hir::{Expr, ExprKind, LoopSource, Pat}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/loops/mut_range_bound.rs b/clippy_lints/src/loops/mut_range_bound.rs index 175aee53a9a..f4e4064ba1d 100644 --- a/clippy_lints/src/loops/mut_range_bound.rs +++ b/clippy_lints/src/loops/mut_range_bound.rs @@ -1,6 +1,6 @@ use super::MUT_RANGE_BOUND; -use crate::utils::{higher, path_to_local}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{higher, path_to_local}; use if_chain::if_chain; use rustc_hir::{BindingAnnotation, Expr, HirId, Node, PatKind}; use rustc_infer::infer::TyCtxtInferExt; diff --git a/clippy_lints/src/loops/needless_collect.rs b/clippy_lints/src/loops/needless_collect.rs index a3b731eefa0..5594fc7b046 100644 --- a/clippy_lints/src/loops/needless_collect.rs +++ b/clippy_lints/src/loops/needless_collect.rs @@ -1,9 +1,9 @@ use super::NEEDLESS_COLLECT; -use crate::utils::sugg::Sugg; -use crate::utils::{is_trait_method, path_to_local_id, paths}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet; +use clippy_utils::sugg::Sugg; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; +use clippy_utils::{is_trait_method, path_to_local_id, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_block, walk_expr, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/loops/needless_range_loop.rs b/clippy_lints/src/loops/needless_range_loop.rs index ca679d7ebe1..3c40d54cb42 100644 --- a/clippy_lints/src/loops/needless_range_loop.rs +++ b/clippy_lints/src/loops/needless_range_loop.rs @@ -1,11 +1,11 @@ use super::NEEDLESS_RANGE_LOOP; -use crate::utils::visitors::LocalUsedVisitor; -use crate::utils::{ - contains_name, higher, is_integer_const, match_trait_method, path_to_local_id, paths, sugg, SpanlessEq, -}; use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::ty::has_iter_method; +use clippy_utils::visitors::LocalUsedVisitor; +use clippy_utils::{ + contains_name, higher, is_integer_const, match_trait_method, path_to_local_id, paths, sugg, SpanlessEq, +}; use if_chain::if_chain; use rustc_ast::ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; diff --git a/clippy_lints/src/loops/single_element_loop.rs b/clippy_lints/src/loops/single_element_loop.rs index 172eb963ae3..8451c1c6130 100644 --- a/clippy_lints/src/loops/single_element_loop.rs +++ b/clippy_lints/src/loops/single_element_loop.rs @@ -1,6 +1,6 @@ use super::{get_span_of_entire_for_loop, SINGLE_ELEMENT_LOOP}; -use crate::utils::single_segment_path; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::single_segment_path; use clippy_utils::source::{indent_of, snippet}; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/loops/utils.rs b/clippy_lints/src/loops/utils.rs index b85676570b4..bb409c48532 100644 --- a/clippy_lints/src/loops/utils.rs +++ b/clippy_lints/src/loops/utils.rs @@ -1,5 +1,5 @@ -use crate::utils::{get_parent_expr, is_integer_const, path_to_local, path_to_local_id, sugg}; use clippy_utils::ty::{has_iter_method, implements_trait}; +use clippy_utils::{get_parent_expr, is_integer_const, path_to_local, path_to_local_id, sugg}; use if_chain::if_chain; use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; diff --git a/clippy_lints/src/loops/while_immutable_condition.rs b/clippy_lints/src/loops/while_immutable_condition.rs index a037a06de81..cad9ff8489a 100644 --- a/clippy_lints/src/loops/while_immutable_condition.rs +++ b/clippy_lints/src/loops/while_immutable_condition.rs @@ -1,7 +1,7 @@ use super::WHILE_IMMUTABLE_CONDITION; use crate::consts::constant; -use crate::utils::usage::mutated_variables; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::usage::mutated_variables; use if_chain::if_chain; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def::{DefKind, Res}; diff --git a/clippy_lints/src/loops/while_let_on_iterator.rs b/clippy_lints/src/loops/while_let_on_iterator.rs index 29ad9e735cc..57fc6250a9a 100644 --- a/clippy_lints/src/loops/while_let_on_iterator.rs +++ b/clippy_lints/src/loops/while_let_on_iterator.rs @@ -1,12 +1,12 @@ use super::utils::{LoopNestVisitor, Nesting}; use super::WHILE_LET_ON_ITERATOR; -use crate::utils::usage::mutated_variables; -use crate::utils::{ - get_enclosing_block, is_refutable, is_trait_method, last_path_segment, path_to_local, path_to_local_id, -}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::implements_trait; +use clippy_utils::usage::mutated_variables; +use clippy_utils::{ + get_enclosing_block, is_refutable, is_trait_method, last_path_segment, path_to_local, path_to_local_id, +}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_block, walk_expr, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs index 92f95645734..d573c297838 100644 --- a/clippy_lints/src/macro_use.rs +++ b/clippy_lints/src/macro_use.rs @@ -1,5 +1,5 @@ -use crate::utils::in_macro; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::in_macro; use clippy_utils::source::snippet; use hir::def::{DefKind, Res}; use if_chain::if_chain; diff --git a/clippy_lints/src/main_recursion.rs b/clippy_lints/src/main_recursion.rs index 6c0308cbd92..07d8a440aea 100644 --- a/clippy_lints/src/main_recursion.rs +++ b/clippy_lints/src/main_recursion.rs @@ -1,12 +1,11 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet; +use clippy_utils::{is_entrypoint_fn, is_no_std_crate}; use if_chain::if_chain; use rustc_hir::{Crate, Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; -use crate::utils::{is_entrypoint_fn, is_no_std_crate}; - declare_clippy_lint! { /// **What it does:** Checks for recursion using the entrypoint. /// diff --git a/clippy_lints/src/manual_async_fn.rs b/clippy_lints/src/manual_async_fn.rs index 1db5cf56962..5d88ff3b99f 100644 --- a/clippy_lints/src/manual_async_fn.rs +++ b/clippy_lints/src/manual_async_fn.rs @@ -1,6 +1,6 @@ -use crate::utils::match_function_call; -use crate::utils::paths::FUTURE_FROM_GENERATOR; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::match_function_call; +use clippy_utils::paths::FUTURE_FROM_GENERATOR; use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt}; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/manual_map.rs b/clippy_lints/src/manual_map.rs index fd563bec769..cd9594737bf 100644 --- a/clippy_lints/src/manual_map.rs +++ b/clippy_lints/src/manual_map.rs @@ -1,11 +1,8 @@ -use crate::{ - map_unit_fn::OPTION_MAP_UNIT_FN, - matches::MATCH_AS_REF, - utils::{is_allowed, match_def_path, match_var, paths, peel_hir_expr_refs}, -}; +use crate::{map_unit_fn::OPTION_MAP_UNIT_FN, matches::MATCH_AS_REF}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{snippet_with_applicability, snippet_with_context}; use clippy_utils::ty::{can_partially_move_ty, is_type_diagnostic_item, peel_mid_ty_refs_is_mutable}; +use clippy_utils::{is_allowed, match_def_path, match_var, paths, peel_hir_expr_refs}; use rustc_ast::util::parser::PREC_POSTFIX; use rustc_errors::Applicability; use rustc_hir::{ diff --git a/clippy_lints/src/manual_non_exhaustive.rs b/clippy_lints/src/manual_non_exhaustive.rs index 705c1ec1859..a9a89ae5659 100644 --- a/clippy_lints/src/manual_non_exhaustive.rs +++ b/clippy_lints/src/manual_non_exhaustive.rs @@ -1,5 +1,5 @@ -use crate::utils::meets_msrv; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::meets_msrv; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_ast::ast::{Attribute, Item, ItemKind, StructField, Variant, VariantData, VisibilityKind}; diff --git a/clippy_lints/src/manual_ok_or.rs b/clippy_lints/src/manual_ok_or.rs index a1e5c752f83..9bfae602c40 100644 --- a/clippy_lints/src/manual_ok_or.rs +++ b/clippy_lints/src/manual_ok_or.rs @@ -1,7 +1,7 @@ -use crate::utils::{match_qpath, path_to_local_id, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt}; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{match_qpath, path_to_local_id, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, PatKind}; diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index bc4e255b03d..9da37efddac 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -1,8 +1,8 @@ use crate::consts::{constant, Constant}; -use crate::utils::usage::mutated_variables; -use crate::utils::{eq_expr_value, higher, match_def_path, meets_msrv, paths}; use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then}; use clippy_utils::source::snippet; +use clippy_utils::usage::mutated_variables; +use clippy_utils::{eq_expr_value, higher, match_def_path, meets_msrv, paths}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_hir::def::Res; diff --git a/clippy_lints/src/manual_unwrap_or.rs b/clippy_lints/src/manual_unwrap_or.rs index 615e2d5c2af..4f139f8d39a 100644 --- a/clippy_lints/src/manual_unwrap_or.rs +++ b/clippy_lints/src/manual_unwrap_or.rs @@ -1,9 +1,9 @@ use crate::consts::constant_simple; -use crate::utils; -use crate::utils::{in_constant, path_to_local_id, sugg}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt}; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::usage::contains_return_break_continue_macro; +use clippy_utils::{in_constant, match_qpath, path_to_local_id, sugg}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Arm, Expr, ExprKind, Pat, PatKind}; @@ -75,19 +75,19 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { if let Some((idx, or_arm)) = arms.iter().enumerate().find(|(_, arm)| match arm.pat.kind { PatKind::Path(ref some_qpath) => - utils::match_qpath(some_qpath, &utils::paths::OPTION_NONE), + match_qpath(some_qpath, &clippy_utils::paths::OPTION_NONE), PatKind::TupleStruct(ref err_qpath, &[Pat { kind: PatKind::Wild, .. }], _) => - utils::match_qpath(err_qpath, &utils::paths::RESULT_ERR), + match_qpath(err_qpath, &clippy_utils::paths::RESULT_ERR), _ => false, } ); let unwrap_arm = &arms[1 - idx]; if let PatKind::TupleStruct(ref unwrap_qpath, &[unwrap_pat], _) = unwrap_arm.pat.kind; - if utils::match_qpath(unwrap_qpath, &utils::paths::OPTION_SOME) - || utils::match_qpath(unwrap_qpath, &utils::paths::RESULT_OK); + if match_qpath(unwrap_qpath, &clippy_utils::paths::OPTION_SOME) + || match_qpath(unwrap_qpath, &clippy_utils::paths::RESULT_OK); if let PatKind::Binding(_, binding_hir_id, ..) = unwrap_pat.kind; if path_to_local_id(unwrap_arm.body, binding_hir_id); - if !utils::usage::contains_return_break_continue_macro(or_arm.body); + if !contains_return_break_continue_macro(or_arm.body); then { Some(or_arm) } else { diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index fd39052871b..cfcc705eabc 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -1,6 +1,6 @@ -use crate::utils::is_trait_method; -use crate::utils::remove_blocks; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_trait_method; +use clippy_utils::remove_blocks; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_copy, is_type_diagnostic_item}; use if_chain::if_chain; diff --git a/clippy_lints/src/map_identity.rs b/clippy_lints/src/map_identity.rs index 84ec23c4e2f..75191e1f9ee 100644 --- a/clippy_lints/src/map_identity.rs +++ b/clippy_lints/src/map_identity.rs @@ -1,6 +1,6 @@ -use crate::utils::{is_adjusted, is_trait_method, match_path, match_var, paths, remove_blocks}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{is_adjusted, is_trait_method, match_path, match_var, paths, remove_blocks}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Body, Expr, ExprKind, Pat, PatKind, QPath, StmtKind}; diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 3bd4a965765..d4764b5ccff 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -1,7 +1,7 @@ -use crate::utils::{iter_input_pats, method_chain_args}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{iter_input_pats, method_chain_args}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 1aa09b82822..e94c7094cac 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -1,16 +1,16 @@ use crate::consts::{constant, miri_to_const, Constant}; -use crate::utils::sugg::Sugg; -use crate::utils::visitors::LocalUsedVisitor; -use crate::utils::{ - get_parent_expr, in_macro, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath, meets_msrv, path_to_local, - path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs, remove_blocks, strip_pat_refs, -}; -use crate::utils::{paths, search_same, SpanlessEq, SpanlessHash}; use clippy_utils::diagnostics::{ multispan_sugg, span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then, }; use clippy_utils::source::{expr_block, indent_of, snippet, snippet_block, snippet_opt, snippet_with_applicability}; +use clippy_utils::sugg::Sugg; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type, peel_mid_ty_refs}; +use clippy_utils::visitors::LocalUsedVisitor; +use clippy_utils::{ + get_parent_expr, in_macro, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath, meets_msrv, path_to_local, + path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs, remove_blocks, strip_pat_refs, +}; +use clippy_utils::{paths, search_same, SpanlessEq, SpanlessHash}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -1616,9 +1616,9 @@ where mod redundant_pattern_match { use super::REDUNDANT_PATTERN_MATCHING; - use crate::utils::{is_trait_method, match_qpath, paths}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; + use clippy_utils::{is_trait_method, match_qpath, paths}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/mem_discriminant.rs b/clippy_lints/src/mem_discriminant.rs index 85353d4cdde..7895ba9f1e0 100644 --- a/clippy_lints/src/mem_discriminant.rs +++ b/clippy_lints/src/mem_discriminant.rs @@ -1,7 +1,7 @@ -use crate::utils::{match_def_path, paths}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use clippy_utils::ty::walk_ptrs_ty_depth; +use clippy_utils::{match_def_path, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{BorrowKind, Expr, ExprKind}; diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index 1a8cb82514b..c13802e3953 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -1,5 +1,5 @@ -use crate::utils::{match_def_path, paths}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{match_def_path, paths}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index 87cb66a6770..426c108d89f 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -1,7 +1,7 @@ -use crate::utils::{in_macro, match_def_path, match_qpath, meets_msrv, paths}; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::is_diagnostic_assoc_item; use clippy_utils::source::{snippet, snippet_with_applicability}; +use clippy_utils::{in_macro, match_def_path, match_qpath, meets_msrv, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::def_id::DefId; diff --git a/clippy_lints/src/methods/bind_instead_of_map.rs b/clippy_lints/src/methods/bind_instead_of_map.rs index 7d6104ebb7f..0ba8a98a018 100644 --- a/clippy_lints/src/methods/bind_instead_of_map.rs +++ b/clippy_lints/src/methods/bind_instead_of_map.rs @@ -1,8 +1,8 @@ use super::{contains_return, BIND_INSTEAD_OF_MAP}; -use crate::utils::{in_macro, match_qpath, method_calls, paths, remove_blocks, visitors::find_all_ret_expressions}; use clippy_utils::diagnostics::{multispan_sugg_with_applicability, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::{snippet, snippet_with_macro_callsite}; use clippy_utils::ty::match_type; +use clippy_utils::{in_macro, match_qpath, method_calls, paths, remove_blocks, visitors::find_all_ret_expressions}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/clone_on_copy.rs b/clippy_lints/src/methods/clone_on_copy.rs index d1c7789a241..949152cf789 100644 --- a/clippy_lints/src/methods/clone_on_copy.rs +++ b/clippy_lints/src/methods/clone_on_copy.rs @@ -1,5 +1,5 @@ -use crate::utils::sugg; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg; use clippy_utils::ty::is_copy; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/clone_on_ref_ptr.rs b/clippy_lints/src/methods/clone_on_ref_ptr.rs index b49ae42b12f..03c949d5c31 100644 --- a/clippy_lints/src/methods/clone_on_ref_ptr.rs +++ b/clippy_lints/src/methods/clone_on_ref_ptr.rs @@ -1,5 +1,5 @@ -use crate::utils::paths; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::paths; use clippy_utils::source::snippet_with_macro_callsite; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/expect_fun_call.rs b/clippy_lints/src/methods/expect_fun_call.rs index 1c673c11d65..e7bffa66b3f 100644 --- a/clippy_lints/src/methods/expect_fun_call.rs +++ b/clippy_lints/src/methods/expect_fun_call.rs @@ -1,5 +1,5 @@ -use crate::utils::is_expn_of; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_expn_of; use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/filetype_is_file.rs b/clippy_lints/src/methods/filetype_is_file.rs index 005c94a6018..39d2f15dbc8 100644 --- a/clippy_lints/src/methods/filetype_is_file.rs +++ b/clippy_lints/src/methods/filetype_is_file.rs @@ -1,6 +1,6 @@ -use crate::utils::{get_parent_expr, paths}; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::match_type; +use clippy_utils::{get_parent_expr, paths}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/filter_flat_map.rs b/clippy_lints/src/methods/filter_flat_map.rs index 4820bb137c1..2f3a3c55ab5 100644 --- a/clippy_lints/src/methods/filter_flat_map.rs +++ b/clippy_lints/src/methods/filter_flat_map.rs @@ -1,5 +1,5 @@ -use crate::utils::is_trait_method; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::is_trait_method; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/filter_map.rs b/clippy_lints/src/methods/filter_map.rs index af91370df20..2cb476acb2b 100644 --- a/clippy_lints/src/methods/filter_map.rs +++ b/clippy_lints/src/methods/filter_map.rs @@ -1,6 +1,6 @@ -use crate::utils::{is_trait_method, path_to_local_id, SpanlessEq}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; +use clippy_utils::{is_trait_method, path_to_local_id, SpanlessEq}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/filter_map_flat_map.rs b/clippy_lints/src/methods/filter_map_flat_map.rs index 5294ef97528..b1a4dc98eb8 100644 --- a/clippy_lints/src/methods/filter_map_flat_map.rs +++ b/clippy_lints/src/methods/filter_map_flat_map.rs @@ -1,5 +1,5 @@ -use crate::utils::is_trait_method; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::is_trait_method; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/filter_map_identity.rs b/clippy_lints/src/methods/filter_map_identity.rs index 4461baf4f7c..80598d88508 100644 --- a/clippy_lints/src/methods/filter_map_identity.rs +++ b/clippy_lints/src/methods/filter_map_identity.rs @@ -1,5 +1,5 @@ -use crate::utils::{is_trait_method, match_qpath, path_to_local_id, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::{is_trait_method, match_qpath, path_to_local_id, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/filter_map_map.rs b/clippy_lints/src/methods/filter_map_map.rs index 8f17350054b..0b0a8b1dd3b 100644 --- a/clippy_lints/src/methods/filter_map_map.rs +++ b/clippy_lints/src/methods/filter_map_map.rs @@ -1,5 +1,5 @@ -use crate::utils::is_trait_method; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::is_trait_method; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/filter_map_next.rs b/clippy_lints/src/methods/filter_map_next.rs index 8fbadd1d457..ba57abd16c9 100644 --- a/clippy_lints/src/methods/filter_map_next.rs +++ b/clippy_lints/src/methods/filter_map_next.rs @@ -1,6 +1,6 @@ -use crate::utils::{is_trait_method, meets_msrv}; use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet; +use clippy_utils::{is_trait_method, meets_msrv}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/filter_next.rs b/clippy_lints/src/methods/filter_next.rs index af16ea19007..6cd24334414 100644 --- a/clippy_lints/src/methods/filter_next.rs +++ b/clippy_lints/src/methods/filter_next.rs @@ -1,5 +1,5 @@ -use crate::utils::is_trait_method; use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; +use clippy_utils::is_trait_method; use clippy_utils::source::snippet; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/flat_map_identity.rs b/clippy_lints/src/methods/flat_map_identity.rs index 669ac1f743f..034ea6c6562 100644 --- a/clippy_lints/src/methods/flat_map_identity.rs +++ b/clippy_lints/src/methods/flat_map_identity.rs @@ -1,5 +1,5 @@ -use crate::utils::{is_trait_method, match_qpath, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::{is_trait_method, match_qpath, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/from_iter_instead_of_collect.rs b/clippy_lints/src/methods/from_iter_instead_of_collect.rs index 5d0a07992c8..2095a60e44b 100644 --- a/clippy_lints/src/methods/from_iter_instead_of_collect.rs +++ b/clippy_lints/src/methods/from_iter_instead_of_collect.rs @@ -1,6 +1,6 @@ -use crate::utils::{get_trait_def_id, paths, sugg}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::implements_trait; +use clippy_utils::{get_trait_def_id, paths, sugg}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/get_unwrap.rs b/clippy_lints/src/methods/get_unwrap.rs index ac855419d00..b122a0a0b89 100644 --- a/clippy_lints/src/methods/get_unwrap.rs +++ b/clippy_lints/src/methods/get_unwrap.rs @@ -1,8 +1,8 @@ use crate::methods::derefs_to_slice; -use crate::utils::{get_parent_expr, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; +use clippy_utils::{get_parent_expr, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/inefficient_to_string.rs b/clippy_lints/src/methods/inefficient_to_string.rs index 56de7a8bc5e..d10a540c24e 100644 --- a/clippy_lints/src/methods/inefficient_to_string.rs +++ b/clippy_lints/src/methods/inefficient_to_string.rs @@ -1,8 +1,8 @@ use super::INEFFICIENT_TO_STRING; -use crate::utils::{match_def_path, paths}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_type_diagnostic_item, walk_ptrs_ty_depth}; +use clippy_utils::{match_def_path, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/inspect_for_each.rs b/clippy_lints/src/methods/inspect_for_each.rs index c9bbfbc37eb..7fd3ef1a622 100644 --- a/clippy_lints/src/methods/inspect_for_each.rs +++ b/clippy_lints/src/methods/inspect_for_each.rs @@ -1,10 +1,9 @@ use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::is_trait_method; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::{source_map::Span, sym}; -use crate::utils::is_trait_method; - use super::INSPECT_FOR_EACH; /// lint use of `inspect().for_each()` for `Iterators` diff --git a/clippy_lints/src/methods/into_iter_on_ref.rs b/clippy_lints/src/methods/into_iter_on_ref.rs index a862b55e139..cfe749cf361 100644 --- a/clippy_lints/src/methods/into_iter_on_ref.rs +++ b/clippy_lints/src/methods/into_iter_on_ref.rs @@ -1,6 +1,6 @@ -use crate::utils::{match_trait_method, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::has_iter_method; +use clippy_utils::{match_trait_method, paths}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/iter_count.rs b/clippy_lints/src/methods/iter_count.rs index bfd62ff1f0d..fd3d53816a1 100644 --- a/clippy_lints/src/methods/iter_count.rs +++ b/clippy_lints/src/methods/iter_count.rs @@ -1,6 +1,6 @@ use crate::methods::derefs_to_slice; -use crate::utils::paths; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::paths; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_type_diagnostic_item, match_type}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/iter_next_slice.rs b/clippy_lints/src/methods/iter_next_slice.rs index ce599682bbe..feebf8b8209 100644 --- a/clippy_lints/src/methods/iter_next_slice.rs +++ b/clippy_lints/src/methods/iter_next_slice.rs @@ -1,8 +1,8 @@ use crate::methods::derefs_to_slice; -use crate::utils::{get_parent_expr, higher}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{get_parent_expr, higher}; use if_chain::if_chain; use rustc_ast::ast; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/iter_nth_zero.rs b/clippy_lints/src/methods/iter_nth_zero.rs index f2b2dd8c097..a12f672739c 100644 --- a/clippy_lints/src/methods/iter_nth_zero.rs +++ b/clippy_lints/src/methods/iter_nth_zero.rs @@ -1,6 +1,6 @@ use crate::consts::{constant, Constant}; -use crate::utils::is_trait_method; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_trait_method; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/iter_skip_next.rs b/clippy_lints/src/methods/iter_skip_next.rs index 6100613bcac..ea01860b456 100644 --- a/clippy_lints/src/methods/iter_skip_next.rs +++ b/clippy_lints/src/methods/iter_skip_next.rs @@ -1,5 +1,5 @@ -use crate::utils::is_trait_method; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_trait_method; use clippy_utils::source::snippet; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/iterator_step_by_zero.rs b/clippy_lints/src/methods/iterator_step_by_zero.rs index 51c1ab0484e..3baa580314f 100644 --- a/clippy_lints/src/methods/iterator_step_by_zero.rs +++ b/clippy_lints/src/methods/iterator_step_by_zero.rs @@ -1,6 +1,6 @@ use crate::consts::{constant, Constant}; -use crate::utils::is_trait_method; use clippy_utils::diagnostics::span_lint; +use clippy_utils::is_trait_method; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/manual_saturating_arithmetic.rs b/clippy_lints/src/methods/manual_saturating_arithmetic.rs index 0c8a002e359..f16699322d1 100644 --- a/clippy_lints/src/methods/manual_saturating_arithmetic.rs +++ b/clippy_lints/src/methods/manual_saturating_arithmetic.rs @@ -1,5 +1,5 @@ -use crate::utils::match_qpath; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::match_qpath; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_ast::ast; diff --git a/clippy_lints/src/methods/map_collect_result_unit.rs b/clippy_lints/src/methods/map_collect_result_unit.rs index b59998fc8b4..e4402b2da21 100644 --- a/clippy_lints/src/methods/map_collect_result_unit.rs +++ b/clippy_lints/src/methods/map_collect_result_unit.rs @@ -1,5 +1,5 @@ -use crate::utils::is_trait_method; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_trait_method; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/methods/map_flatten.rs b/clippy_lints/src/methods/map_flatten.rs index 6f5e723fbfb..4bc52b036a8 100644 --- a/clippy_lints/src/methods/map_flatten.rs +++ b/clippy_lints/src/methods/map_flatten.rs @@ -1,5 +1,5 @@ -use crate::utils::is_trait_method; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_trait_method; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/map_unwrap_or.rs b/clippy_lints/src/methods/map_unwrap_or.rs index 8ef02b4a641..deb4b4492b5 100644 --- a/clippy_lints/src/methods/map_unwrap_or.rs +++ b/clippy_lints/src/methods/map_unwrap_or.rs @@ -1,8 +1,8 @@ -use crate::utils::meets_msrv; -use crate::utils::usage::mutated_variables; use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; +use clippy_utils::meets_msrv; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::usage::mutated_variables; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index af8fe7abd96..cbfb350ebb1 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -55,6 +55,10 @@ use bind_instead_of_map::BindInsteadOfMap; use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{contains_ty, implements_trait, is_copy, is_type_diagnostic_item}; +use clippy_utils::{ + contains_return, get_trait_def_id, in_macro, iter_input_pats, match_def_path, match_qpath, method_calls, + method_chain_args, paths, return_ty, single_segment_path, SpanlessEq, +}; use if_chain::if_chain; use rustc_ast::ast; use rustc_errors::Applicability; @@ -68,11 +72,6 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::symbol::{sym, SymbolStr}; use rustc_typeck::hir_ty_to_ty; -use crate::utils::{ - contains_return, get_trait_def_id, in_macro, iter_input_pats, match_def_path, match_qpath, method_calls, - method_chain_args, paths, return_ty, single_segment_path, SpanlessEq, -}; - declare_clippy_lint! { /// **What it does:** Checks for `.unwrap()` calls on `Option`s and on `Result`s. /// diff --git a/clippy_lints/src/methods/option_as_ref_deref.rs b/clippy_lints/src/methods/option_as_ref_deref.rs index f921d7b16c0..d11ede080dc 100644 --- a/clippy_lints/src/methods/option_as_ref_deref.rs +++ b/clippy_lints/src/methods/option_as_ref_deref.rs @@ -1,7 +1,7 @@ -use crate::utils::{match_def_path, meets_msrv, path_to_local_id, paths, remove_blocks}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{match_def_path, meets_msrv, path_to_local_id, paths, remove_blocks}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/option_map_or_none.rs b/clippy_lints/src/methods/option_map_or_none.rs index e8b057c2d74..d93db2c22e4 100644 --- a/clippy_lints/src/methods/option_map_or_none.rs +++ b/clippy_lints/src/methods/option_map_or_none.rs @@ -1,7 +1,7 @@ -use crate::utils::{match_qpath, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{match_qpath, paths}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs index c6459648cd5..e252abc177a 100644 --- a/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -1,5 +1,5 @@ -use crate::utils::differing_macro_contexts; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::differing_macro_contexts; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_copy; use clippy_utils::ty::is_type_diagnostic_item; diff --git a/clippy_lints/src/methods/or_fun_call.rs b/clippy_lints/src/methods/or_fun_call.rs index 1b43802a08e..4880d13f39a 100644 --- a/clippy_lints/src/methods/or_fun_call.rs +++ b/clippy_lints/src/methods/or_fun_call.rs @@ -1,8 +1,8 @@ -use crate::utils::eager_or_lazy::is_lazyness_candidate; -use crate::utils::{contains_return, get_trait_def_id, last_path_segment, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::eager_or_lazy::is_lazyness_candidate; use clippy_utils::source::{snippet, snippet_with_applicability, snippet_with_macro_callsite}; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type}; +use clippy_utils::{contains_return, get_trait_def_id, last_path_segment, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/search_is_some.rs b/clippy_lints/src/methods/search_is_some.rs index 18e1064b018..13546dc1779 100644 --- a/clippy_lints/src/methods/search_is_some.rs +++ b/clippy_lints/src/methods/search_is_some.rs @@ -1,7 +1,7 @@ -use crate::utils::{is_trait_method, strip_pat_refs}; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{is_trait_method, strip_pat_refs}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/skip_while_next.rs b/clippy_lints/src/methods/skip_while_next.rs index 8995226191b..3db83785b59 100644 --- a/clippy_lints/src/methods/skip_while_next.rs +++ b/clippy_lints/src/methods/skip_while_next.rs @@ -1,5 +1,5 @@ -use crate::utils::is_trait_method; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::is_trait_method; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/string_extend_chars.rs b/clippy_lints/src/methods/string_extend_chars.rs index d9b97168490..52b26a36fe3 100644 --- a/clippy_lints/src/methods/string_extend_chars.rs +++ b/clippy_lints/src/methods/string_extend_chars.rs @@ -1,5 +1,5 @@ -use crate::utils::method_chain_args; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::method_chain_args; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/suspicious_map.rs b/clippy_lints/src/methods/suspicious_map.rs index fd4651dd182..7015bd54c35 100644 --- a/clippy_lints/src/methods/suspicious_map.rs +++ b/clippy_lints/src/methods/suspicious_map.rs @@ -1,6 +1,6 @@ -use crate::utils::usage::mutated_variables; -use crate::utils::{expr_or_init, is_trait_method}; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::usage::mutated_variables; +use clippy_utils::{expr_or_init, is_trait_method}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/uninit_assumed_init.rs b/clippy_lints/src/methods/uninit_assumed_init.rs index 071856c3ba6..f2f6ef4be6c 100644 --- a/clippy_lints/src/methods/uninit_assumed_init.rs +++ b/clippy_lints/src/methods/uninit_assumed_init.rs @@ -1,5 +1,5 @@ -use crate::utils::{match_def_path, match_qpath, paths}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{match_def_path, match_qpath, paths}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/unnecessary_filter_map.rs b/clippy_lints/src/methods/unnecessary_filter_map.rs index 670134c68f2..48d905ab833 100644 --- a/clippy_lints/src/methods/unnecessary_filter_map.rs +++ b/clippy_lints/src/methods/unnecessary_filter_map.rs @@ -1,14 +1,13 @@ -use crate::utils::usage::mutated_variables; -use crate::utils::{is_trait_method, match_qpath, path_to_local_id, paths}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::usage::mutated_variables; +use clippy_utils::{is_trait_method, match_qpath, path_to_local_id, paths}; +use if_chain::if_chain; use rustc_hir as hir; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc_lint::LateContext; use rustc_middle::hir::map::Map; use rustc_span::sym; -use if_chain::if_chain; - use super::UNNECESSARY_FILTER_MAP; pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Expr<'_>]) { diff --git a/clippy_lints/src/methods/unnecessary_fold.rs b/clippy_lints/src/methods/unnecessary_fold.rs index 3ccde57de3f..1268fd4bda9 100644 --- a/clippy_lints/src/methods/unnecessary_fold.rs +++ b/clippy_lints/src/methods/unnecessary_fold.rs @@ -1,6 +1,6 @@ -use crate::utils::{is_trait_method, path_to_local_id, remove_blocks, strip_pat_refs}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; +use clippy_utils::{is_trait_method, path_to_local_id, remove_blocks, strip_pat_refs}; use if_chain::if_chain; use rustc_ast::ast; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/unnecessary_lazy_eval.rs b/clippy_lints/src/methods/unnecessary_lazy_eval.rs index 3874673bf9f..a86185bf0a6 100644 --- a/clippy_lints/src/methods/unnecessary_lazy_eval.rs +++ b/clippy_lints/src/methods/unnecessary_lazy_eval.rs @@ -1,7 +1,7 @@ -use crate::utils::{eager_or_lazy, usage}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{eager_or_lazy, usage}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/useless_asref.rs b/clippy_lints/src/methods/useless_asref.rs index 13c95e33fef..b5505af0f7e 100644 --- a/clippy_lints/src/methods/useless_asref.rs +++ b/clippy_lints/src/methods/useless_asref.rs @@ -1,7 +1,7 @@ -use crate::utils::{get_parent_expr, match_trait_method, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::walk_ptrs_ty_depth; +use clippy_utils::{get_parent_expr, match_trait_method, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index 6a4e70e50af..776f4c7b741 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -1,6 +1,6 @@ use crate::consts::{constant_simple, Constant}; -use crate::utils::{match_def_path, match_trait_method, paths}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{match_def_path, match_trait_method, paths}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 03d07287005..026ea50936a 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -18,8 +18,8 @@ use rustc_span::source_map::{ExpnKind, Span}; use rustc_span::symbol::sym; use crate::consts::{constant, Constant}; -use crate::utils::sugg::Sugg; -use crate::utils::{ +use clippy_utils::sugg::Sugg; +use clippy_utils::{ get_item_name, get_parent_expr, higher, in_constant, is_diagnostic_assoc_item, is_integer_const, iter_input_pats, last_path_segment, match_qpath, unsext, SpanlessEq, }; diff --git a/clippy_lints/src/missing_const_for_fn.rs b/clippy_lints/src/missing_const_for_fn.rs index aba4accccb1..23554669d97 100644 --- a/clippy_lints/src/missing_const_for_fn.rs +++ b/clippy_lints/src/missing_const_for_fn.rs @@ -1,7 +1,7 @@ -use crate::utils::qualify_min_const_fn::is_min_const_fn; -use crate::utils::{fn_has_unsatisfiable_preds, is_entrypoint_fn, meets_msrv, trait_ref_of_method}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::qualify_min_const_fn::is_min_const_fn; use clippy_utils::ty::has_drop; +use clippy_utils::{fn_has_unsatisfiable_preds, is_entrypoint_fn, meets_msrv, trait_ref_of_method}; use rustc_hir as hir; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, Constness, FnDecl, GenericParamKind, HirId}; diff --git a/clippy_lints/src/modulo_arithmetic.rs b/clippy_lints/src/modulo_arithmetic.rs index 1b00cf2c75d..6a52de4f713 100644 --- a/clippy_lints/src/modulo_arithmetic.rs +++ b/clippy_lints/src/modulo_arithmetic.rs @@ -1,6 +1,6 @@ use crate::consts::{constant, Constant}; -use crate::utils::sext; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sext; use if_chain::if_chain; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/multiple_crate_versions.rs b/clippy_lints/src/multiple_crate_versions.rs index 6eaeaebe781..584daa5e119 100644 --- a/clippy_lints/src/multiple_crate_versions.rs +++ b/clippy_lints/src/multiple_crate_versions.rs @@ -1,7 +1,7 @@ //! lint on multiple versions of a crate being used -use crate::utils::run_lints; use clippy_utils::diagnostics::span_lint; +use clippy_utils::run_lints; use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::{Crate, CRATE_HIR_ID}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/mut_key.rs b/clippy_lints/src/mut_key.rs index 39aec79734c..41bd07bcf1e 100644 --- a/clippy_lints/src/mut_key.rs +++ b/clippy_lints/src/mut_key.rs @@ -1,5 +1,5 @@ -use crate::utils::{match_def_path, paths, trait_ref_of_method}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{match_def_path, paths, trait_ref_of_method}; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::TypeFoldable; diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index c11ccc94890..ef33e41a5fa 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -1,5 +1,5 @@ -use crate::utils::higher; use clippy_utils::diagnostics::span_lint; +use clippy_utils::higher; use rustc_hir as hir; use rustc_hir::intravisit; use rustc_lint::{LateContext, LateLintPass, LintContext}; diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index fb8895e08d0..533c5a22db0 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -1,5 +1,5 @@ -use crate::utils::{higher, is_direct_expn_of}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{higher, is_direct_expn_of}; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc_hir::{BorrowKind, Expr, ExprKind, MatchSource, Mutability}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/needless_arbitrary_self_type.rs b/clippy_lints/src/needless_arbitrary_self_type.rs index c62ff7323f3..3e2b2782ed5 100644 --- a/clippy_lints/src/needless_arbitrary_self_type.rs +++ b/clippy_lints/src/needless_arbitrary_self_type.rs @@ -1,5 +1,5 @@ -use crate::utils::in_macro; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::in_macro; use if_chain::if_chain; use rustc_ast::ast::{BindingMode, Lifetime, Mutability, Param, PatKind, Path, TyKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 4c67304d23e..db7b3423ad9 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -2,10 +2,10 @@ //! //! This lint is **warn** by default -use crate::utils::sugg::Sugg; -use crate::utils::{is_expn_of, parent_node_is_if_expr}; use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet_with_applicability; +use clippy_utils::sugg::Sugg; +use clippy_utils::{is_expn_of, parent_node_is_if_expr}; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp}; diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index 72436b51dcb..79d84da2dfc 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 crate::utils::is_automatically_derived; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::is_automatically_derived; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index fc8ee6cb8ef..075bbf9a426 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -1,8 +1,8 @@ -use crate::utils::ptr::get_spans; -use crate::utils::{get_trait_def_id, is_self, paths}; use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then}; +use clippy_utils::ptr::get_spans; use clippy_utils::source::{snippet, snippet_opt}; use clippy_utils::ty::{implements_trait, is_copy, is_type_diagnostic_item}; +use clippy_utils::{get_trait_def_id, is_self, paths}; use if_chain::if_chain; use rustc_ast::ast::Attribute; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; diff --git a/clippy_lints/src/needless_question_mark.rs b/clippy_lints/src/needless_question_mark.rs index ecf48d082af..99e85e6683c 100644 --- a/clippy_lints/src/needless_question_mark.rs +++ b/clippy_lints/src/needless_question_mark.rs @@ -1,6 +1,8 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{is_ok_ctor, is_some_ctor, meets_msrv}; +use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Body, Expr, ExprKind, LangItem, MatchSource, QPath}; use rustc_lint::{LateContext, LateLintPass, LintContext}; @@ -8,9 +10,6 @@ use rustc_semver::RustcVersion; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::sym; -use crate::utils; -use if_chain::if_chain; - declare_clippy_lint! { /// **What it does:** /// Suggests alternatives for useless applications of `?` in terminating expressions @@ -161,7 +160,7 @@ fn is_some_or_ok_call<'a>( // Check outer expression matches CALL_IDENT(ARGUMENT) format if let ExprKind::Call(path, args) = &expr.kind; if let ExprKind::Path(QPath::Resolved(None, path)) = &path.kind; - if utils::is_some_ctor(cx, path.res) || utils::is_ok_ctor(cx, path.res); + if is_some_ctor(cx, path.res) || is_ok_ctor(cx, path.res); // Extract inner expression from ARGUMENT if let ExprKind::Match(inner_expr_with_q, _, MatchSource::TryDesugar) = &args[0].kind; @@ -182,7 +181,7 @@ fn is_some_or_ok_call<'a>( let inner_is_some = is_type_diagnostic_item(cx, inner_ty, sym::option_type); // Check for Option MSRV - let meets_option_msrv = utils::meets_msrv(nqml.msrv.as_ref(), &NEEDLESS_QUESTION_MARK_OPTION_MSRV); + let meets_option_msrv = meets_msrv(nqml.msrv.as_ref(), &NEEDLESS_QUESTION_MARK_OPTION_MSRV); if outer_is_some && inner_is_some && meets_option_msrv { return Some(SomeOkCall::SomeCall(expr, inner_expr)); } @@ -196,7 +195,7 @@ fn is_some_or_ok_call<'a>( let does_not_call_from = !has_implicit_error_from(cx, expr, inner_expr); // Must meet Result MSRV - let meets_result_msrv = utils::meets_msrv(nqml.msrv.as_ref(), &NEEDLESS_QUESTION_MARK_RESULT_MSRV); + let meets_result_msrv = meets_msrv(nqml.msrv.as_ref(), &NEEDLESS_QUESTION_MARK_RESULT_MSRV); if outer_is_result && inner_is_result && does_not_call_from && meets_result_msrv { return Some(SomeOkCall::OkCall(expr, inner_expr)); } 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 e291885d34d..4b935c7b906 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -1,13 +1,12 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::implements_trait; +use clippy_utils::{self, get_trait_def_id, paths}; use if_chain::if_chain; use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::{self, paths}; - declare_clippy_lint! { /// **What it does:** /// Checks for the usage of negated comparison operators on types which only implement @@ -61,7 +60,7 @@ impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd { let ty = cx.typeck_results().expr_ty(left); let implements_ord = { - if let Some(id) = utils::get_trait_def_id(cx, &paths::ORD) { + if let Some(id) = get_trait_def_id(cx, &paths::ORD) { implements_trait(cx, ty, id, &[]) } else { return; diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 9fbb6b02742..502e5e4bf37 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -1,7 +1,7 @@ -use crate::utils::paths; -use crate::utils::sugg::DiagnosticBuilderExt; -use crate::utils::{get_trait_def_id, return_ty}; use clippy_utils::diagnostics::span_lint_hir_and_then; +use clippy_utils::paths; +use clippy_utils::sugg::DiagnosticBuilderExt; +use clippy_utils::{get_trait_def_id, return_ty}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 5db614497e3..b86ae1426ef 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -5,6 +5,8 @@ use std::ptr; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::in_constant; +use if_chain::if_chain; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{ @@ -19,9 +21,6 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{InnerSpan, Span, DUMMY_SP}; use rustc_typeck::hir_ty_to_ty; -use crate::utils::in_constant; -use if_chain::if_chain; - // FIXME: this is a correctness problem but there's no suitable // warn-by-default category. declare_clippy_lint! { diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index 8e8aaa67afa..c61dff4b8e0 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -1,5 +1,5 @@ -use crate::utils::paths; use clippy_utils::diagnostics::span_lint; +use clippy_utils::paths; use clippy_utils::ty::match_type; use rustc_ast::ast::LitKind; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/option_env_unwrap.rs b/clippy_lints/src/option_env_unwrap.rs index 343159f9ae2..a0bc324e026 100644 --- a/clippy_lints/src/option_env_unwrap.rs +++ b/clippy_lints/src/option_env_unwrap.rs @@ -1,5 +1,5 @@ -use crate::utils::is_direct_expn_of; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::is_direct_expn_of; use if_chain::if_chain; use rustc_ast::ast::{Expr, ExprKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; diff --git a/clippy_lints/src/option_if_let_else.rs b/clippy_lints/src/option_if_let_else.rs index eab08a58320..a76a4a33f1f 100644 --- a/clippy_lints/src/option_if_let_else.rs +++ b/clippy_lints/src/option_if_let_else.rs @@ -1,11 +1,10 @@ -use crate::utils; -use crate::utils::eager_or_lazy; -use crate::utils::paths; -use crate::utils::sugg::Sugg; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::paths; +use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::usage::contains_return_break_continue_macro; +use clippy_utils::{eager_or_lazy, get_enclosing_block, in_macro, match_qpath}; use if_chain::if_chain; - use rustc_errors::Applicability; use rustc_hir::{Arm, BindingAnnotation, Block, Expr, ExprKind, MatchSource, Mutability, PatKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; @@ -110,7 +109,7 @@ fn extract_body_from_arm<'a>(arm: &'a Arm<'a>) -> Option<&'a Expr<'a>> { /// If this is the else body of an if/else expression, then we need to wrap /// it in curly braces. Otherwise, we don't. fn should_wrap_in_braces(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - utils::get_enclosing_block(cx, expr.hir_id).map_or(false, |parent| { + get_enclosing_block(cx, expr.hir_id).map_or(false, |parent| { let mut should_wrap = false; if let Some(Expr { @@ -160,15 +159,15 @@ fn detect_option_if_let_else<'tcx>( expr: &'_ Expr<'tcx>, ) -> Option { if_chain! { - if !utils::in_macro(expr.span); // Don't lint macros, because it behaves weirdly + if !in_macro(expr.span); // Don't lint macros, because it behaves weirdly if let ExprKind::Match(cond_expr, arms, MatchSource::IfLetDesugar{contains_else_clause: true}) = &expr.kind; if arms.len() == 2; if !is_result_ok(cx, cond_expr); // Don't lint on Result::ok because a different lint does it already if let PatKind::TupleStruct(struct_qpath, &[inner_pat], _) = &arms[0].pat.kind; - if utils::match_qpath(struct_qpath, &paths::OPTION_SOME); + if match_qpath(struct_qpath, &paths::OPTION_SOME); if let PatKind::Binding(bind_annotation, _, id, _) = &inner_pat.kind; - if !utils::usage::contains_return_break_continue_macro(arms[0].body); - if !utils::usage::contains_return_break_continue_macro(arms[1].body); + if !contains_return_break_continue_macro(arms[0].body); + if !contains_return_break_continue_macro(arms[1].body); then { let capture_mut = if bind_annotation == &BindingAnnotation::Mutable { "mut " } else { "" }; let some_body = extract_body_from_arm(&arms[0])?; diff --git a/clippy_lints/src/overflow_check_conditional.rs b/clippy_lints/src/overflow_check_conditional.rs index 524b96921fe..cf667c6e805 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -1,5 +1,5 @@ -use crate::utils::SpanlessEq; use clippy_utils::diagnostics::span_lint; +use clippy_utils::SpanlessEq; use if_chain::if_chain; use rustc_hir::{BinOpKind, Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/panic_in_result_fn.rs b/clippy_lints/src/panic_in_result_fn.rs index 880951f3e3e..d32b937b209 100644 --- a/clippy_lints/src/panic_in_result_fn.rs +++ b/clippy_lints/src/panic_in_result_fn.rs @@ -1,6 +1,6 @@ -use crate::utils::{find_macro_calls, return_ty}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{find_macro_calls, return_ty}; use rustc_hir as hir; use rustc_hir::intravisit::FnKind; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index ad4ed831941..d06e7f8fe1e 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -1,5 +1,5 @@ -use crate::utils::{is_expn_of, match_panic_call}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{is_expn_of, match_panic_call}; use if_chain::if_chain; use rustc_hir::Expr; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/partialeq_ne_impl.rs b/clippy_lints/src/partialeq_ne_impl.rs index 06985cef4ff..1251ddd9a02 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -1,5 +1,5 @@ -use crate::utils::is_automatically_derived; use clippy_utils::diagnostics::span_lint_hir; +use clippy_utils::is_automatically_derived; use if_chain::if_chain; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index c14273840c4..9a5b1c3b944 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -1,7 +1,7 @@ use std::cmp; -use crate::utils::is_self_ty; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_self_ty; use clippy_utils::source::snippet; use clippy_utils::ty::is_copy; use if_chain::if_chain; diff --git a/clippy_lints/src/pattern_type_mismatch.rs b/clippy_lints/src/pattern_type_mismatch.rs index dd63cf99e42..288e0e4586e 100644 --- a/clippy_lints/src/pattern_type_mismatch.rs +++ b/clippy_lints/src/pattern_type_mismatch.rs @@ -1,5 +1,5 @@ -use crate::utils::last_path_segment; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::last_path_segment; use rustc_hir::{ intravisit, Body, Expr, ExprKind, FieldPat, FnDecl, HirId, LocalSource, MatchSource, Mutability, Pat, PatKind, QPath, Stmt, StmtKind, diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index 779eddcc170..be686b1b0cd 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -1,10 +1,10 @@ //! Checks for usage of `&Vec[_]` and `&String`. -use crate::utils::ptr::get_spans; -use crate::utils::{is_allowed, match_qpath, paths}; use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then}; +use clippy_utils::ptr::get_spans; use clippy_utils::source::snippet_opt; use clippy_utils::ty::{is_type_diagnostic_item, match_type, walk_ptrs_hir_ty}; +use clippy_utils::{is_allowed, match_qpath, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{ diff --git a/clippy_lints/src/ptr_eq.rs b/clippy_lints/src/ptr_eq.rs index 82408c639b1..5796c59c8b3 100644 --- a/clippy_lints/src/ptr_eq.rs +++ b/clippy_lints/src/ptr_eq.rs @@ -1,5 +1,5 @@ -use crate::utils; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::in_macro; use clippy_utils::source::snippet_opt; use if_chain::if_chain; use rustc_errors::Applicability; @@ -42,7 +42,7 @@ static LINT_MSG: &str = "use `std::ptr::eq` when comparing raw pointers"; impl LateLintPass<'_> for PtrEq { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { - if utils::in_macro(expr.span) { + if in_macro(expr.span) { return; } diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index c4686623487..2054255a7c9 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -1,5 +1,8 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; +use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{eq_expr_value, match_def_path, match_qpath, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; @@ -8,10 +11,6 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; -use crate::utils::sugg::Sugg; -use crate::utils::{eq_expr_value, match_def_path, match_qpath, paths}; -use clippy_utils::diagnostics::span_lint_and_sugg; - declare_clippy_lint! { /// **What it does:** Checks for expressions that could be replaced by the question mark operator. /// diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index d476d95256f..95b21489eb5 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -1,6 +1,9 @@ use crate::consts::{constant, Constant}; use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability}; +use clippy_utils::sugg::Sugg; +use clippy_utils::{get_parent_expr, in_constant, is_integer_const, meets_msrv, single_segment_path}; +use clippy_utils::{higher, SpanlessEq}; use if_chain::if_chain; use rustc_ast::ast::RangeLimits; use rustc_errors::Applicability; @@ -14,10 +17,6 @@ use rustc_span::sym; use rustc_span::symbol::Ident; use std::cmp::Ordering; -use crate::utils::sugg::Sugg; -use crate::utils::{get_parent_expr, in_constant, is_integer_const, meets_msrv, single_segment_path}; -use crate::utils::{higher, SpanlessEq}; - declare_clippy_lint! { /// **What it does:** Checks for zipping a collection with the range of /// `0.._.len()`. diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 3d799328bb5..60da2bcb04a 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -1,7 +1,7 @@ -use crate::utils::{fn_has_unsatisfiable_preds, match_def_path, paths}; use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then}; use clippy_utils::source::snippet_opt; use clippy_utils::ty::{has_drop, is_copy, is_type_diagnostic_item, walk_ptrs_ty_depth}; +use clippy_utils::{fn_has_unsatisfiable_preds, match_def_path, paths}; use if_chain::if_chain; use rustc_data_structures::{fx::FxHashMap, transitive_relation::TransitiveRelation}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index fd11150bce2..f77be6fdf04 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -1,5 +1,5 @@ -use crate::utils::meets_msrv; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::meets_msrv; use rustc_ast::ast::{Expr, ExprKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index da8339a795a..32b57698ec5 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -1,5 +1,5 @@ -use crate::utils::meets_msrv; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::meets_msrv; use clippy_utils::source::snippet; use rustc_ast::ast::{Item, ItemKind, Ty, TyKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/ref_option_ref.rs b/clippy_lints/src/ref_option_ref.rs index 452fef0694f..0922cfa494e 100644 --- a/clippy_lints/src/ref_option_ref.rs +++ b/clippy_lints/src/ref_option_ref.rs @@ -1,5 +1,5 @@ -use crate::utils::last_path_segment; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::last_path_segment; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs index ec2acb6a0ab..d6336389b0a 100644 --- a/clippy_lints/src/reference.rs +++ b/clippy_lints/src/reference.rs @@ -1,7 +1,7 @@ -use crate::utils::in_macro; -use crate::utils::sugg::Sugg; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::in_macro; use clippy_utils::source::{snippet_opt, snippet_with_applicability}; +use clippy_utils::sugg::Sugg; use if_chain::if_chain; use rustc_ast::ast::{Expr, ExprKind, Mutability, UnOp}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index bfa21ba9c97..1cc332de894 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -1,6 +1,6 @@ use crate::consts::{constant, Constant}; -use crate::utils::{match_def_path, paths}; use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; +use clippy_utils::{match_def_path, paths}; use if_chain::if_chain; use rustc_ast::ast::{LitKind, StrStyle}; use rustc_data_structures::fx::FxHashSet; diff --git a/clippy_lints/src/repeat_once.rs b/clippy_lints/src/repeat_once.rs index b39e9d5a78c..63e5ec69e66 100644 --- a/clippy_lints/src/repeat_once.rs +++ b/clippy_lints/src/repeat_once.rs @@ -1,6 +1,6 @@ use crate::consts::{constant_context, Constant}; -use crate::utils::in_macro; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::in_macro; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 59d3c0ca5f0..8995ae431ad 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -1,5 +1,6 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_opt; +use clippy_utils::{fn_def_id, in_macro, match_qpath}; use if_chain::if_chain; use rustc_ast::ast::Attribute; use rustc_errors::Applicability; @@ -13,8 +14,6 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use rustc_span::sym; -use crate::utils::{fn_def_id, in_macro, match_qpath}; - declare_clippy_lint! { /// **What it does:** Checks for `let`-bindings, which are subsequently /// returned. diff --git a/clippy_lints/src/self_assignment.rs b/clippy_lints/src/self_assignment.rs index 320d1a8dbe3..e7925c4fbde 100644 --- a/clippy_lints/src/self_assignment.rs +++ b/clippy_lints/src/self_assignment.rs @@ -1,5 +1,5 @@ -use crate::utils::eq_expr_value; use clippy_utils::diagnostics::span_lint; +use clippy_utils::eq_expr_value; use clippy_utils::source::snippet; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/semicolon_if_nothing_returned.rs b/clippy_lints/src/semicolon_if_nothing_returned.rs index e43947025b9..f61af15fbed 100644 --- a/clippy_lints/src/semicolon_if_nothing_returned.rs +++ b/clippy_lints/src/semicolon_if_nothing_returned.rs @@ -1,6 +1,6 @@ -use crate::utils::{in_macro, sugg}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_macro_callsite; +use clippy_utils::{in_macro, sugg}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Block, ExprKind}; diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs index 632715852c5..169f7d26285 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -1,5 +1,5 @@ -use crate::utils::{get_trait_def_id, paths}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{get_trait_def_id, paths}; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 8ef58b6d563..612d2fd84cb 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -1,6 +1,6 @@ -use crate::utils::{contains_name, higher, iter_input_pats}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; +use clippy_utils::{contains_name, higher, iter_input_pats}; use rustc_hir::intravisit::FnKind; use rustc_hir::{ Block, Body, Expr, ExprKind, FnDecl, Guard, HirId, Local, MutTy, Pat, PatKind, Path, QPath, StmtKind, Ty, TyKind, diff --git a/clippy_lints/src/single_component_path_imports.rs b/clippy_lints/src/single_component_path_imports.rs index 6d15a6c444e..c9d72aabb6a 100644 --- a/clippy_lints/src/single_component_path_imports.rs +++ b/clippy_lints/src/single_component_path_imports.rs @@ -1,5 +1,5 @@ -use crate::utils::in_macro; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::in_macro; use if_chain::if_chain; use rustc_ast::{Item, ItemKind, UseTreeKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/size_of_in_element_count.rs b/clippy_lints/src/size_of_in_element_count.rs index 8920d446b9c..09e00866815 100644 --- a/clippy_lints/src/size_of_in_element_count.rs +++ b/clippy_lints/src/size_of_in_element_count.rs @@ -1,8 +1,8 @@ //! Lint on use of `size_of` or `size_of_val` of T in an expression //! expecting a count of T -use crate::utils::{match_def_path, paths}; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::{match_def_path, paths}; use if_chain::if_chain; use rustc_hir::BinOpKind; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index 7f0f21084af..d55a83f1613 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -1,6 +1,6 @@ -use crate::utils::sugg::Sugg; -use crate::utils::{get_enclosing_block, match_qpath, SpanlessEq}; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg::Sugg; +use clippy_utils::{get_enclosing_block, match_qpath, SpanlessEq}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/stable_sort_primitive.rs b/clippy_lints/src/stable_sort_primitive.rs index 85e4bb806e7..65790375c73 100644 --- a/clippy_lints/src/stable_sort_primitive.rs +++ b/clippy_lints/src/stable_sort_primitive.rs @@ -1,8 +1,6 @@ -use crate::utils::{is_slice_of_primitives, sugg::Sugg}; use clippy_utils::diagnostics::span_lint_and_then; - +use clippy_utils::{is_slice_of_primitives, sugg::Sugg}; use if_chain::if_chain; - use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 626166f9008..760f5e3b432 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -1,8 +1,8 @@ -use crate::utils::SpanlessEq; -use crate::utils::{get_parent_expr, is_allowed, match_function_call, method_calls, paths}; use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::SpanlessEq; +use clippy_utils::{get_parent_expr, is_allowed, match_function_call, method_calls, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, LangItem, QPath}; diff --git a/clippy_lints/src/suspicious_operation_groupings.rs b/clippy_lints/src/suspicious_operation_groupings.rs index 364c99adc69..1e5d3c17e3b 100644 --- a/clippy_lints/src/suspicious_operation_groupings.rs +++ b/clippy_lints/src/suspicious_operation_groupings.rs @@ -1,4 +1,4 @@ -use crate::utils::ast_utils::{eq_id, is_useless_with_eq_exprs, IdentIter}; +use clippy_utils::ast_utils::{eq_id, is_useless_with_eq_exprs, IdentIter}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use core::ops::{Add, AddAssign}; diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index ef14b6c5136..0f024c9a11e 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -1,5 +1,5 @@ -use crate::utils::{get_trait_def_id, trait_ref_of_method}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{get_trait_def_id, trait_ref_of_method}; use if_chain::if_chain; use rustc_hir as hir; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; @@ -159,7 +159,7 @@ fn check_binop( expected_ops: &[hir::BinOpKind], ) -> Option<&'static str> { let mut trait_ids = vec![]; - let [krate, module] = crate::utils::paths::OPS_MODULE; + let [krate, module] = clippy_utils::paths::OPS_MODULE; for &t in traits { let path = [krate, module, t]; diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 83fe3c49959..14519eaa962 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -1,8 +1,8 @@ -use crate::utils::sugg::Sugg; -use crate::utils::{differing_macro_contexts, eq_expr_value}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_with_applicability; +use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{differing_macro_contexts, eq_expr_value}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Block, Expr, ExprKind, PatKind, QPath, StmtKind}; diff --git a/clippy_lints/src/temporary_assignment.rs b/clippy_lints/src/temporary_assignment.rs index 75a13cb9187..8ef25dc816c 100644 --- a/clippy_lints/src/temporary_assignment.rs +++ b/clippy_lints/src/temporary_assignment.rs @@ -1,5 +1,5 @@ -use crate::utils::is_adjusted; use clippy_utils::diagnostics::span_lint; +use clippy_utils::is_adjusted; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/to_digit_is_some.rs b/clippy_lints/src/to_digit_is_some.rs index abc9b2fe88e..c66a596c784 100644 --- a/clippy_lints/src/to_digit_is_some.rs +++ b/clippy_lints/src/to_digit_is_some.rs @@ -1,5 +1,5 @@ -use crate::utils::match_def_path; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::match_def_path; use clippy_utils::source::snippet_with_applicability; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/to_string_in_display.rs b/clippy_lints/src/to_string_in_display.rs index 42605c01089..42ec14c31b5 100644 --- a/clippy_lints/src/to_string_in_display.rs +++ b/clippy_lints/src/to_string_in_display.rs @@ -1,5 +1,5 @@ -use crate::utils::{is_diagnostic_assoc_item, match_def_path, path_to_local_id, paths}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{is_diagnostic_assoc_item, match_def_path, path_to_local_id, paths}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind, HirId, Impl, ImplItem, ImplItemKind, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index cfcc8da9910..3ff27c3bcf4 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -1,6 +1,6 @@ -use crate::utils::{in_macro, SpanlessHash}; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::{snippet, snippet_with_applicability}; +use clippy_utils::{in_macro, SpanlessHash}; use if_chain::if_chain; use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; diff --git a/clippy_lints/src/transmute/mod.rs b/clippy_lints/src/transmute/mod.rs index c1870f5208b..47d58bd30db 100644 --- a/clippy_lints/src/transmute/mod.rs +++ b/clippy_lints/src/transmute/mod.rs @@ -12,7 +12,7 @@ mod useless_transmute; mod utils; mod wrong_transmute; -use crate::utils::{in_constant, match_def_path, paths}; +use clippy_utils::{in_constant, match_def_path, paths}; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/transmute/transmute_float_to_int.rs b/clippy_lints/src/transmute/transmute_float_to_int.rs index f61b5362b5a..72489f27cd3 100644 --- a/clippy_lints/src/transmute/transmute_float_to_int.rs +++ b/clippy_lints/src/transmute/transmute_float_to_int.rs @@ -1,6 +1,6 @@ use super::TRANSMUTE_FLOAT_TO_INT; -use crate::utils::sugg; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg; use if_chain::if_chain; use rustc_ast as ast; use rustc_errors::Applicability; diff --git a/clippy_lints/src/transmute/transmute_int_to_bool.rs b/clippy_lints/src/transmute/transmute_int_to_bool.rs index ebdd1eba744..cc0a5643e2a 100644 --- a/clippy_lints/src/transmute/transmute_int_to_bool.rs +++ b/clippy_lints/src/transmute/transmute_int_to_bool.rs @@ -1,6 +1,6 @@ use super::TRANSMUTE_INT_TO_BOOL; -use crate::utils::sugg; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg; use rustc_ast as ast; use rustc_errors::Applicability; use rustc_hir::Expr; diff --git a/clippy_lints/src/transmute/transmute_int_to_char.rs b/clippy_lints/src/transmute/transmute_int_to_char.rs index afecfc3d701..8f884e6a4a1 100644 --- a/clippy_lints/src/transmute/transmute_int_to_char.rs +++ b/clippy_lints/src/transmute/transmute_int_to_char.rs @@ -1,6 +1,6 @@ use super::TRANSMUTE_INT_TO_CHAR; -use crate::utils::sugg; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg; use rustc_ast as ast; use rustc_errors::Applicability; use rustc_hir::Expr; diff --git a/clippy_lints/src/transmute/transmute_int_to_float.rs b/clippy_lints/src/transmute/transmute_int_to_float.rs index c762a7ab885..2b6a4cff81e 100644 --- a/clippy_lints/src/transmute/transmute_int_to_float.rs +++ b/clippy_lints/src/transmute/transmute_int_to_float.rs @@ -1,6 +1,6 @@ use super::TRANSMUTE_INT_TO_FLOAT; -use crate::utils::sugg; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; diff --git a/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs b/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs index 820c56a215e..7b646bfc0c6 100644 --- a/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs +++ b/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs @@ -1,6 +1,6 @@ use super::TRANSMUTE_PTR_TO_PTR; -use crate::utils::sugg; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; diff --git a/clippy_lints/src/transmute/transmute_ptr_to_ref.rs b/clippy_lints/src/transmute/transmute_ptr_to_ref.rs index 049210e555c..f14eef93645 100644 --- a/clippy_lints/src/transmute/transmute_ptr_to_ref.rs +++ b/clippy_lints/src/transmute/transmute_ptr_to_ref.rs @@ -1,7 +1,7 @@ use super::utils::get_type_snippet; use super::TRANSMUTE_PTR_TO_REF; -use crate::utils::sugg; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability, QPath}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/transmute/transmute_ref_to_ref.rs b/clippy_lints/src/transmute/transmute_ref_to_ref.rs index 993ef8698f8..d105e37abf9 100644 --- a/clippy_lints/src/transmute/transmute_ref_to_ref.rs +++ b/clippy_lints/src/transmute/transmute_ref_to_ref.rs @@ -1,7 +1,7 @@ use super::{TRANSMUTE_BYTES_TO_STR, TRANSMUTE_PTR_TO_PTR}; -use crate::utils::sugg; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet; +use clippy_utils::sugg; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability}; diff --git a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs index da7d1016d97..e2c6d130f3c 100644 --- a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs +++ b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs @@ -1,7 +1,7 @@ use super::utils::can_be_expressed_as_pointer_cast; use super::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS; -use crate::utils::sugg; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::sugg; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; diff --git a/clippy_lints/src/transmute/unsound_collection_transmute.rs b/clippy_lints/src/transmute/unsound_collection_transmute.rs index 9bea88be7da..de9277e016e 100644 --- a/clippy_lints/src/transmute/unsound_collection_transmute.rs +++ b/clippy_lints/src/transmute/unsound_collection_transmute.rs @@ -1,7 +1,7 @@ use super::utils::is_layout_incompatible; use super::UNSOUND_COLLECTION_TRANSMUTE; -use crate::utils::{match_def_path, paths}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{match_def_path, paths}; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; diff --git a/clippy_lints/src/transmute/useless_transmute.rs b/clippy_lints/src/transmute/useless_transmute.rs index 29ffe03b673..445bcf60fa7 100644 --- a/clippy_lints/src/transmute/useless_transmute.rs +++ b/clippy_lints/src/transmute/useless_transmute.rs @@ -1,6 +1,6 @@ use super::USELESS_TRANSMUTE; -use crate::utils::sugg; use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; +use clippy_utils::sugg; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; diff --git a/clippy_lints/src/transmute/utils.rs b/clippy_lints/src/transmute/utils.rs index 0633697687a..c6d0d63b0b5 100644 --- a/clippy_lints/src/transmute/utils.rs +++ b/clippy_lints/src/transmute/utils.rs @@ -1,4 +1,4 @@ -use crate::utils::last_path_segment; +use clippy_utils::last_path_segment; use clippy_utils::source::snippet; use clippy_utils::ty::is_normalizable; use if_chain::if_chain; diff --git a/clippy_lints/src/transmuting_null.rs b/clippy_lints/src/transmuting_null.rs index 3a2b1359a54..d42cdde110e 100644 --- a/clippy_lints/src/transmuting_null.rs +++ b/clippy_lints/src/transmuting_null.rs @@ -1,6 +1,6 @@ use crate::consts::{constant_context, Constant}; -use crate::utils::{match_qpath, paths}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{match_qpath, paths}; use if_chain::if_chain; use rustc_ast::LitKind; use rustc_hir::{Expr, ExprKind}; diff --git a/clippy_lints/src/try_err.rs b/clippy_lints/src/try_err.rs index 1fce03b4f47..e61058c2749 100644 --- a/clippy_lints/src/try_err.rs +++ b/clippy_lints/src/try_err.rs @@ -1,7 +1,7 @@ -use crate::utils::{differing_macro_contexts, in_macro, match_def_path, match_qpath, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{snippet, snippet_with_macro_callsite}; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{differing_macro_contexts, in_macro, match_def_path, match_qpath, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, LangItem, MatchSource, QPath}; diff --git a/clippy_lints/src/types/borrowed_box.rs b/clippy_lints/src/types/borrowed_box.rs index eab81b1e246..1721fcfdcf4 100644 --- a/clippy_lints/src/types/borrowed_box.rs +++ b/clippy_lints/src/types/borrowed_box.rs @@ -1,6 +1,6 @@ -use crate::utils::{match_path, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; +use clippy_utils::{match_path, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{ diff --git a/clippy_lints/src/types/box_vec.rs b/clippy_lints/src/types/box_vec.rs index 6d04a47a5c8..d8b1953457c 100644 --- a/clippy_lints/src/types/box_vec.rs +++ b/clippy_lints/src/types/box_vec.rs @@ -1,10 +1,9 @@ use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::is_ty_param_diagnostic_item; use rustc_hir::{self as hir, def_id::DefId, QPath}; use rustc_lint::LateContext; use rustc_span::symbol::sym; -use crate::utils::is_ty_param_diagnostic_item; - use super::BOX_VEC; pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool { diff --git a/clippy_lints/src/types/linked_list.rs b/clippy_lints/src/types/linked_list.rs index e9e1995f6a5..a9fbe7aa315 100644 --- a/clippy_lints/src/types/linked_list.rs +++ b/clippy_lints/src/types/linked_list.rs @@ -1,9 +1,8 @@ use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::{match_def_path, paths}; use rustc_hir::{self as hir, def_id::DefId}; use rustc_lint::LateContext; -use crate::utils::{match_def_path, paths}; - use super::LINKEDLIST; pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, def_id: DefId) -> bool { diff --git a/clippy_lints/src/types/mod.rs b/clippy_lints/src/types/mod.rs index 5103a259559..c0cd48e94b2 100644 --- a/clippy_lints/src/types/mod.rs +++ b/clippy_lints/src/types/mod.rs @@ -36,8 +36,8 @@ use rustc_target::spec::abi::Abi; use rustc_typeck::hir_ty_to_ty; use crate::consts::{constant, Constant}; -use crate::utils::paths; -use crate::utils::{clip, comparisons, differing_macro_contexts, int_bits, match_path, sext, unsext}; +use clippy_utils::paths; +use clippy_utils::{clip, comparisons, differing_macro_contexts, int_bits, match_path, sext, unsext}; declare_clippy_lint! { /// **What it does:** Checks for use of `Box>` anywhere in the code. @@ -618,7 +618,7 @@ fn detect_absurd_comparison<'tcx>( ) -> Option<(ExtremeExpr<'tcx>, AbsurdComparisonResult)> { use crate::types::AbsurdComparisonResult::{AlwaysFalse, AlwaysTrue, InequalityImpossible}; use crate::types::ExtremeType::{Maximum, Minimum}; - use crate::utils::comparisons::{normalize_comparison, Rel}; + use clippy_utils::comparisons::{normalize_comparison, Rel}; // absurd comparison only makes sense on primitive types // primitive types don't implement comparison operators with each other @@ -860,7 +860,7 @@ fn upcast_comparison_bounds_err<'tcx>( rhs: &'tcx Expr<'_>, invert: bool, ) { - use crate::utils::comparisons::Rel; + use clippy_utils::comparisons::Rel; if let Some((lb, ub)) = lhs_bounds { if let Some(norm_rhs_val) = node_as_const_fullint(cx, rhs) { diff --git a/clippy_lints/src/types/option_option.rs b/clippy_lints/src/types/option_option.rs index 79c5a32de2c..b2692c48076 100644 --- a/clippy_lints/src/types/option_option.rs +++ b/clippy_lints/src/types/option_option.rs @@ -1,10 +1,9 @@ use clippy_utils::diagnostics::span_lint; +use clippy_utils::is_ty_param_diagnostic_item; use rustc_hir::{self as hir, def_id::DefId, QPath}; use rustc_lint::LateContext; use rustc_span::symbol::sym; -use crate::utils::is_ty_param_diagnostic_item; - use super::OPTION_OPTION; pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool { diff --git a/clippy_lints/src/types/rc_buffer.rs b/clippy_lints/src/types/rc_buffer.rs index d5fc23f2e39..ef629a35d10 100644 --- a/clippy_lints/src/types/rc_buffer.rs +++ b/clippy_lints/src/types/rc_buffer.rs @@ -1,12 +1,11 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; +use clippy_utils::{get_qpath_generic_tys, is_ty_param_diagnostic_item}; use rustc_errors::Applicability; use rustc_hir::{self as hir, def_id::DefId, QPath, TyKind}; use rustc_lint::LateContext; use rustc_span::symbol::sym; -use crate::utils::{get_qpath_generic_tys, is_ty_param_diagnostic_item}; - use super::RC_BUFFER; pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool { diff --git a/clippy_lints/src/types/redundant_allocation.rs b/clippy_lints/src/types/redundant_allocation.rs index 71c014f96f7..c0c1f340583 100644 --- a/clippy_lints/src/types/redundant_allocation.rs +++ b/clippy_lints/src/types/redundant_allocation.rs @@ -1,12 +1,11 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; +use clippy_utils::{get_qpath_generic_tys, is_ty_param_diagnostic_item, is_ty_param_lang_item}; use rustc_errors::Applicability; use rustc_hir::{self as hir, def_id::DefId, LangItem, QPath, TyKind}; use rustc_lint::LateContext; use rustc_span::symbol::sym; -use crate::utils::{get_qpath_generic_tys, is_ty_param_diagnostic_item, is_ty_param_lang_item}; - use super::{utils, REDUNDANT_ALLOCATION}; pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool { diff --git a/clippy_lints/src/types/utils.rs b/clippy_lints/src/types/utils.rs index 4d64748f998..45f891ed718 100644 --- a/clippy_lints/src/types/utils.rs +++ b/clippy_lints/src/types/utils.rs @@ -1,11 +1,9 @@ +use clippy_utils::last_path_segment; +use if_chain::if_chain; use rustc_hir::{GenericArg, QPath, TyKind}; use rustc_lint::LateContext; use rustc_span::source_map::Span; -use crate::utils::last_path_segment; - -use if_chain::if_chain; - pub(super) fn match_borrows_parameter(_cx: &LateContext<'_>, qpath: &QPath<'_>) -> Option { let last = last_path_segment(qpath); if_chain! { diff --git a/clippy_lints/src/types/vec_box.rs b/clippy_lints/src/types/vec_box.rs index 8cedb0ede2b..d2c373db261 100644 --- a/clippy_lints/src/types/vec_box.rs +++ b/clippy_lints/src/types/vec_box.rs @@ -1,4 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::last_path_segment; use clippy_utils::source::snippet; use if_chain::if_chain; use rustc_errors::Applicability; @@ -9,8 +10,6 @@ use rustc_span::symbol::sym; use rustc_target::abi::LayoutOf; use rustc_typeck::hir_ty_to_ty; -use crate::utils::last_path_segment; - use super::VEC_BOX; pub(super) fn check( diff --git a/clippy_lints/src/undropped_manually_drops.rs b/clippy_lints/src/undropped_manually_drops.rs index 943573a2b53..b6749069176 100644 --- a/clippy_lints/src/undropped_manually_drops.rs +++ b/clippy_lints/src/undropped_manually_drops.rs @@ -1,6 +1,6 @@ -use crate::utils::{match_function_call, paths}; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::is_type_lang_item; +use clippy_utils::{match_function_call, paths}; use rustc_hir::{lang_items, Expr}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/unicode.rs b/clippy_lints/src/unicode.rs index c37bbf297f8..d81e31f5a21 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -1,5 +1,5 @@ -use crate::utils::is_allowed; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_allowed; use clippy_utils::source::snippet; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/unit_return_expecting_ord.rs b/clippy_lints/src/unit_return_expecting_ord.rs index d0456347f8a..bad3e488bb6 100644 --- a/clippy_lints/src/unit_return_expecting_ord.rs +++ b/clippy_lints/src/unit_return_expecting_ord.rs @@ -1,5 +1,5 @@ -use crate::utils::{get_trait_def_id, paths}; use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; +use clippy_utils::{get_trait_def_id, paths}; use if_chain::if_chain; use rustc_hir::def_id::DefId; use rustc_hir::{Expr, ExprKind, StmtKind}; diff --git a/clippy_lints/src/unit_types/let_unit_value.rs b/clippy_lints/src/unit_types/let_unit_value.rs index 55715cc6bf3..8698a718bbd 100644 --- a/clippy_lints/src/unit_types/let_unit_value.rs +++ b/clippy_lints/src/unit_types/let_unit_value.rs @@ -1,12 +1,11 @@ +use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::higher; +use clippy_utils::source::snippet_with_macro_callsite; use rustc_errors::Applicability; use rustc_hir::{Stmt, StmtKind}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; -use crate::utils::diagnostics::span_lint_and_then; -use crate::utils::higher; -use crate::utils::source::snippet_with_macro_callsite; - use super::LET_UNIT_VALUE; pub(super) fn check(cx: &LateContext<'_>, stmt: &Stmt<'_>) { diff --git a/clippy_lints/src/unit_types/unit_arg.rs b/clippy_lints/src/unit_types/unit_arg.rs index d4ef645fc8d..925ab577099 100644 --- a/clippy_lints/src/unit_types/unit_arg.rs +++ b/clippy_lints/src/unit_types/unit_arg.rs @@ -1,12 +1,10 @@ +use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt}; +use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{self as hir, Block, Expr, ExprKind, MatchSource, Node, StmtKind}; use rustc_lint::LateContext; -use if_chain::if_chain; - -use crate::utils::diagnostics::span_lint_and_then; -use crate::utils::source::{indent_of, reindent_multiline, snippet_opt}; - use super::{utils, UNIT_ARG}; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { diff --git a/clippy_lints/src/unit_types/unit_cmp.rs b/clippy_lints/src/unit_types/unit_cmp.rs index f9c0374c86d..b3077dec5d8 100644 --- a/clippy_lints/src/unit_types/unit_cmp.rs +++ b/clippy_lints/src/unit_types/unit_cmp.rs @@ -1,9 +1,8 @@ +use clippy_utils::diagnostics::span_lint; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; use rustc_span::hygiene::{ExpnKind, MacroKind}; -use crate::utils::diagnostics::span_lint; - use super::UNIT_CMP; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { diff --git a/clippy_lints/src/unnamed_address.rs b/clippy_lints/src/unnamed_address.rs index 2c51a8556d9..d5bc3de6698 100644 --- a/clippy_lints/src/unnamed_address.rs +++ b/clippy_lints/src/unnamed_address.rs @@ -1,5 +1,5 @@ -use crate::utils::{match_def_path, paths}; use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; +use clippy_utils::{match_def_path, paths}; use if_chain::if_chain; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/unnecessary_sort_by.rs b/clippy_lints/src/unnecessary_sort_by.rs index aa83f6a74be..e23bab5eba0 100644 --- a/clippy_lints/src/unnecessary_sort_by.rs +++ b/clippy_lints/src/unnecessary_sort_by.rs @@ -1,5 +1,5 @@ -use crate::utils::sugg::Sugg; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_type_diagnostic_item; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/unnecessary_wraps.rs b/clippy_lints/src/unnecessary_wraps.rs index cb20192b683..9e227164695 100644 --- a/clippy_lints/src/unnecessary_wraps.rs +++ b/clippy_lints/src/unnecessary_wraps.rs @@ -1,6 +1,6 @@ -use crate::utils::{contains_return, in_macro, match_qpath, paths, return_ty, visitors::find_all_ret_expressions}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; +use clippy_utils::{contains_return, in_macro, match_qpath, paths, return_ty, visitors::find_all_ret_expressions}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::intravisit::FnKind; diff --git a/clippy_lints/src/unnested_or_patterns.rs b/clippy_lints/src/unnested_or_patterns.rs index 42ff1809ff4..512d505dfb5 100644 --- a/clippy_lints/src/unnested_or_patterns.rs +++ b/clippy_lints/src/unnested_or_patterns.rs @@ -1,8 +1,8 @@ #![allow(clippy::wildcard_imports, clippy::enum_glob_use)] -use crate::utils::ast_utils::{eq_field_pat, eq_id, eq_pat, eq_path}; -use crate::utils::over; +use clippy_utils::ast_utils::{eq_field_pat, eq_id, eq_pat, eq_path}; use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::over; use rustc_ast::mut_visit::*; use rustc_ast::ptr::P; use rustc_ast::{self as ast, Pat, PatKind, PatKind::*, DUMMY_NODE_ID}; diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index 31fd61f99f2..9990052e114 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -1,5 +1,5 @@ -use crate::utils::{is_try, match_trait_method, paths}; use clippy_utils::diagnostics::span_lint; +use clippy_utils::{is_try, match_trait_method, paths}; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/unused_self.rs b/clippy_lints/src/unused_self.rs index 4642bf07c45..aef4ce75915 100644 --- a/clippy_lints/src/unused_self.rs +++ b/clippy_lints/src/unused_self.rs @@ -1,11 +1,10 @@ use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::visitors::LocalUsedVisitor; use if_chain::if_chain; use rustc_hir::{Impl, ImplItem, ImplItemKind, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use crate::utils::visitors::LocalUsedVisitor; - declare_clippy_lint! { /// **What it does:** Checks methods that contain a `self` argument but don't use it /// diff --git a/clippy_lints/src/unused_unit.rs b/clippy_lints/src/unused_unit.rs index c45b851211c..329ea49024b 100644 --- a/clippy_lints/src/unused_unit.rs +++ b/clippy_lints/src/unused_unit.rs @@ -1,3 +1,4 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::position_before_rarrow; use if_chain::if_chain; use rustc_ast::ast; @@ -8,8 +9,6 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; use rustc_span::BytePos; -use clippy_utils::diagnostics::span_lint_and_sugg; - declare_clippy_lint! { /// **What it does:** Checks for unit (`()`) expressions that can be removed. /// diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 75b2f2da602..fb29acca18a 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -1,6 +1,6 @@ -use crate::utils::{differing_macro_contexts, usage::is_potentially_mutated}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{differing_macro_contexts, usage::is_potentially_mutated}; use if_chain::if_chain; use rustc_hir::intravisit::{walk_expr, walk_fn, FnKind, NestedVisitorMap, Visitor}; use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, HirId, Path, QPath, UnOp}; diff --git a/clippy_lints/src/unwrap_in_result.rs b/clippy_lints/src/unwrap_in_result.rs index a85f3ce5c9c..0d745813beb 100644 --- a/clippy_lints/src/unwrap_in_result.rs +++ b/clippy_lints/src/unwrap_in_result.rs @@ -1,6 +1,6 @@ -use crate::utils::{method_chain_args, return_ty}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{method_chain_args, return_ty}; use if_chain::if_chain; use rustc_hir as hir; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index 9a42c833470..116cb8b1e1c 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -1,6 +1,6 @@ -use crate::utils::{in_macro, meets_msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_opt; +use clippy_utils::{in_macro, meets_msrv}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index 1eb152daac8..3e1b69e676b 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -1,8 +1,8 @@ -use crate::utils::sugg::Sugg; -use crate::utils::{get_parent_expr, match_def_path, match_trait_method, paths}; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::{snippet, snippet_with_macro_callsite}; +use clippy_utils::sugg::Sugg; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{get_parent_expr, match_def_path, match_trait_method, paths}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, HirId, MatchSource}; diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 3dd190ba440..2de5b1a628e 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -1,7 +1,7 @@ //! A group of attributes that can be attached to Rust code in order //! to generate a clippy lint detecting said code automatically. -use crate::utils::get_attr; +use clippy_utils::get_attr; use rustc_ast::ast::{LitFloatType, LitKind}; use rustc_ast::walk_list; use rustc_data_structures::fx::FxHashMap; diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 9e3973e1d51..191ff6e4f16 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -1,6 +1,6 @@ //! checks for attributes -use crate::utils::get_attr; +use clippy_utils::get_attr; use rustc_ast::ast::{Attribute, InlineAsmTemplatePiece}; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass, LintContext}; diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index a566362ae78..c496ff1fb24 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -1,9 +1,8 @@ use crate::consts::{constant_simple, Constant}; -use crate::utils::{is_expn_of, match_def_path, match_qpath, method_calls, path_to_res, paths, run_lints, SpanlessEq}; - use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg}; use clippy_utils::source::snippet; use clippy_utils::ty::match_type; +use clippy_utils::{is_expn_of, match_def_path, match_qpath, method_calls, path_to_res, paths, run_lints, SpanlessEq}; use if_chain::if_chain; use rustc_ast::ast::{Crate as AstCrate, ItemKind, LitKind, ModKind, NodeId}; use rustc_ast::visit::FnKind; diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index be9a07f8d7c..d8b31344e6d 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -3,5 +3,3 @@ pub mod conf; pub mod inspector; #[cfg(feature = "internal-lints")] pub mod internal_lints; - -pub use clippy_utils::*; diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index 9e142413365..1af9583887f 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -1,7 +1,7 @@ use crate::consts::{constant, Constant}; use crate::rustc_target::abi::LayoutOf; -use crate::utils::higher; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::higher; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_copy; use if_chain::if_chain; diff --git a/clippy_lints/src/vec_init_then_push.rs b/clippy_lints/src/vec_init_then_push.rs index 3ef55a82a17..8b696ed1c84 100644 --- a/clippy_lints/src/vec_init_then_push.rs +++ b/clippy_lints/src/vec_init_then_push.rs @@ -1,7 +1,7 @@ -use crate::utils::{match_def_path, path_to_local, path_to_local_id, paths}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; +use clippy_utils::{match_def_path, path_to_local, path_to_local_id, paths}; use if_chain::if_chain; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/vec_resize_to_zero.rs b/clippy_lints/src/vec_resize_to_zero.rs index 9a2fb1414a1..e035d3c5cad 100644 --- a/clippy_lints/src/vec_resize_to_zero.rs +++ b/clippy_lints/src/vec_resize_to_zero.rs @@ -1,15 +1,14 @@ use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::{match_def_path, paths}; use if_chain::if_chain; +use rustc_ast::LitKind; use rustc_errors::Applicability; +use rustc_hir as hir; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Spanned; -use crate::utils::{match_def_path, paths}; -use rustc_ast::LitKind; -use rustc_hir as hir; - declare_clippy_lint! { /// **What it does:** Finds occurrences of `Vec::resize(0, an_int)` /// diff --git a/clippy_lints/src/verbose_file_reads.rs b/clippy_lints/src/verbose_file_reads.rs index 01dc54dc5fd..ec209b30951 100644 --- a/clippy_lints/src/verbose_file_reads.rs +++ b/clippy_lints/src/verbose_file_reads.rs @@ -1,5 +1,5 @@ -use crate::utils::paths; use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::paths; use clippy_utils::ty::match_type; use if_chain::if_chain; use rustc_hir::{Expr, ExprKind, QPath}; diff --git a/clippy_lints/src/wildcard_dependencies.rs b/clippy_lints/src/wildcard_dependencies.rs index 8f96b962279..60c3489a449 100644 --- a/clippy_lints/src/wildcard_dependencies.rs +++ b/clippy_lints/src/wildcard_dependencies.rs @@ -1,5 +1,5 @@ -use crate::utils::run_lints; use clippy_utils::diagnostics::span_lint; +use clippy_utils::run_lints; use rustc_hir::{hir_id::CRATE_HIR_ID, Crate}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index 424ca2a4c2f..51c1117d206 100644 --- a/clippy_lints/src/wildcard_imports.rs +++ b/clippy_lints/src/wildcard_imports.rs @@ -1,5 +1,5 @@ -use crate::utils::in_macro; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::in_macro; use clippy_utils::source::{snippet, snippet_with_applicability}; use if_chain::if_chain; use rustc_errors::Applicability; diff --git a/clippy_lints/src/zero_sized_map_values.rs b/clippy_lints/src/zero_sized_map_values.rs index 82466da6862..2abd033e2a0 100644 --- a/clippy_lints/src/zero_sized_map_values.rs +++ b/clippy_lints/src/zero_sized_map_values.rs @@ -1,4 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::paths; use clippy_utils::ty::{is_normalizable, is_type_diagnostic_item, match_type}; use if_chain::if_chain; use rustc_hir::{self as hir, HirId, ItemKind, Node}; @@ -9,8 +10,6 @@ use rustc_span::sym; use rustc_target::abi::LayoutOf as _; use rustc_typeck::hir_ty_to_ty; -use crate::utils::paths; - declare_clippy_lint! { /// **What it does:** Checks for maps with zero-sized value types anywhere in the code. /// -- cgit 1.4.1-3-g733a5 From cadad20da1e970e62ea28f32a2f4a9177e8ca859 Mon Sep 17 00:00:00 2001 From: mbartlett21 <29034492+mbartlett21@users.noreply.github.com> Date: Tue, 25 May 2021 00:54:50 +0000 Subject: Add semicolons up to `needless_for_each.rs` --- clippy_lints/src/assertions_on_constants.rs | 2 +- clippy_lints/src/attrs.rs | 6 +++--- clippy_lints/src/bit_mask.rs | 6 +++--- clippy_lints/src/booleans.rs | 6 +++--- clippy_lints/src/collapsible_if.rs | 2 +- clippy_lints/src/comparison_chain.rs | 2 +- clippy_lints/src/copies.rs | 2 +- clippy_lints/src/default_numeric_fallback.rs | 4 ++-- clippy_lints/src/double_comparison.rs | 8 ++++---- clippy_lints/src/entry.rs | 2 +- clippy_lints/src/eq_op.rs | 12 ++++++------ clippy_lints/src/eta_reduction.rs | 7 ++++--- clippy_lints/src/eval_order_dependence.rs | 2 +- clippy_lints/src/functions/must_use.rs | 2 +- clippy_lints/src/functions/too_many_lines.rs | 2 +- clippy_lints/src/future_not_send.rs | 2 +- clippy_lints/src/implicit_return.rs | 2 +- clippy_lints/src/infinite_iter.rs | 2 +- clippy_lints/src/invalid_upcast_comparisons.rs | 4 ++-- clippy_lints/src/len_zero.rs | 4 ++-- clippy_lints/src/let_underscore.rs | 8 ++++---- clippy_lints/src/lifetimes.rs | 4 ++-- clippy_lints/src/literal_representation.rs | 8 ++++---- clippy_lints/src/loops/explicit_iter_loop.rs | 2 +- clippy_lints/src/loops/mut_range_bound.rs | 8 ++++---- clippy_lints/src/loops/same_item_push.rs | 4 ++-- clippy_lints/src/loops/utils.rs | 8 ++++---- clippy_lints/src/macro_use.rs | 6 +++--- clippy_lints/src/manual_strip.rs | 2 +- clippy_lints/src/map_clone.rs | 6 +++--- clippy_lints/src/matches.rs | 10 +++++----- clippy_lints/src/methods/bind_instead_of_map.rs | 2 +- clippy_lints/src/methods/cloned_instead_of_copied.rs | 2 +- clippy_lints/src/methods/flat_map_option.rs | 2 +- clippy_lints/src/methods/mod.rs | 8 ++++---- clippy_lints/src/methods/unnecessary_fold.rs | 2 +- clippy_lints/src/misc_early/mod.rs | 10 +++++----- clippy_lints/src/mut_reference.rs | 2 +- clippy_lints/src/mutable_debug_assertion.rs | 2 +- clippy_lints/src/needless_arbitrary_self_type.rs | 4 ++-- clippy_lints/src/needless_bool.rs | 18 +++++++++--------- clippy_lints/src/needless_borrow.rs | 2 +- clippy_lints/src/needless_for_each.rs | 2 +- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/internal_lints.rs | 4 ++-- .../src/utils/internal_lints/metadata_collector.rs | 2 +- 46 files changed, 105 insertions(+), 104 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index c565e29d078..6c9ceaa45c2 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants { &format!("`assert!(false, {})` should probably be replaced", panic_message), None, &format!("use `panic!({})` or `unreachable!({})`", panic_message, panic_message), - ) + ); }; if let Some(debug_assert_span) = is_expn_of(e.span, "debug_assert") { diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index c5b01461c1c..932cd58bf62 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -273,7 +273,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) { let attrs = cx.tcx.hir().attrs(item.hir_id()); if is_relevant_item(cx, item) { - check_attrs(cx, item.span, item.ident.name, attrs) + check_attrs(cx, item.span, item.ident.name, attrs); } match item.kind { ItemKind::ExternCrate(..) | ItemKind::Use(..) => { @@ -343,13 +343,13 @@ impl<'tcx> LateLintPass<'tcx> for Attributes { fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) { if is_relevant_impl(cx, item) { - check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id())) + check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id())); } } fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) { if is_relevant_trait(cx, item) { - check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id())) + check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id())); } } } diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index f7daf3dab49..0ac6dc28e73 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -115,9 +115,9 @@ impl<'tcx> LateLintPass<'tcx> for BitMask { if let ExprKind::Binary(cmp, left, right) = &e.kind { if cmp.node.is_comparison() { if let Some(cmp_opt) = fetch_int_literal(cx, right) { - check_compare(cx, left, cmp.node, cmp_opt, e.span) + check_compare(cx, left, cmp.node, cmp_opt, e.span); } else if let Some(cmp_val) = fetch_int_literal(cx, left) { - check_compare(cx, right, invert_cmp(cmp.node), cmp_val, e.span) + check_compare(cx, right, invert_cmp(cmp.node), cmp_val, e.span); } } } @@ -171,7 +171,7 @@ fn check_compare(cx: &LateContext<'_>, bit_op: &Expr<'_>, cmp_op: BinOpKind, cmp } fetch_int_literal(cx, right) .or_else(|| fetch_int_literal(cx, left)) - .map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span)) + .map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span)); } } diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 67f0e0c7870..e72399af232 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool { _: Span, _: HirId, ) { - NonminimalBoolVisitor { cx }.visit_body(body) + NonminimalBoolVisitor { cx }.visit_body(body); } } @@ -184,7 +184,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> { Term(n) => { let terminal = self.terminals[n as usize]; if let Some(str) = simplify_not(self.cx, terminal) { - self.output.push_str(&str) + self.output.push_str(&str); } else { self.output.push('!'); let snip = snippet_opt(self.cx, terminal.span)?; @@ -452,7 +452,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> { } match &e.kind { ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => { - self.bool_expr(e) + self.bool_expr(e); }, ExprKind::Unary(UnOp::Not, inner) => { if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() { diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index dae5c86bd44..6e950738239 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -92,7 +92,7 @@ declare_lint_pass!(CollapsibleIf => [COLLAPSIBLE_IF, COLLAPSIBLE_ELSE_IF]); impl EarlyLintPass for CollapsibleIf { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) { if !expr.span.from_expansion() { - check_if(cx, expr) + check_if(cx, expr); } } } diff --git a/clippy_lints/src/comparison_chain.rs b/clippy_lints/src/comparison_chain.rs index 2a61d58e653..b6999bef6e7 100644 --- a/clippy_lints/src/comparison_chain.rs +++ b/clippy_lints/src/comparison_chain.rs @@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain { "`if` chain can be rewritten with `match`", None, "consider rewriting the `if` chain to use `cmp` and `match`", - ) + ); } } diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index f956d171bfb..376a14b8181 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -476,7 +476,7 @@ fn emit_branches_sharing_code_lint( } suggestions.push(("end", span, suggestion.to_string())); - add_expr_note = !cx.typeck_results().expr_ty(if_expr).is_unit() + add_expr_note = !cx.typeck_results().expr_ty(if_expr).is_unit(); } let add_optional_msgs = |diag: &mut DiagnosticBuilder<'_>| { diff --git a/clippy_lints/src/default_numeric_fallback.rs b/clippy_lints/src/default_numeric_fallback.rs index 6e883942680..759f7d4062d 100644 --- a/clippy_lints/src/default_numeric_fallback.rs +++ b/clippy_lints/src/default_numeric_fallback.rs @@ -181,9 +181,9 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> { match stmt.kind { StmtKind::Local(local) => { if local.ty.is_some() { - self.ty_bounds.push(TyBound::Any) + self.ty_bounds.push(TyBound::Any); } else { - self.ty_bounds.push(TyBound::Nothing) + self.ty_bounds.push(TyBound::Nothing); } }, diff --git a/clippy_lints/src/double_comparison.rs b/clippy_lints/src/double_comparison.rs index 58543ae6e4e..4966638cb1b 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -70,16 +70,16 @@ impl<'tcx> DoubleComparisons { #[rustfmt::skip] match (op, lkind, rkind) { (BinOpKind::Or, BinOpKind::Eq, BinOpKind::Lt) | (BinOpKind::Or, BinOpKind::Lt, BinOpKind::Eq) => { - lint_double_comparison!(<=) + lint_double_comparison!(<=); }, (BinOpKind::Or, BinOpKind::Eq, BinOpKind::Gt) | (BinOpKind::Or, BinOpKind::Gt, BinOpKind::Eq) => { - lint_double_comparison!(>=) + lint_double_comparison!(>=); }, (BinOpKind::Or, BinOpKind::Lt, BinOpKind::Gt) | (BinOpKind::Or, BinOpKind::Gt, BinOpKind::Lt) => { - lint_double_comparison!(!=) + lint_double_comparison!(!=); }, (BinOpKind::And, BinOpKind::Le, BinOpKind::Ge) | (BinOpKind::And, BinOpKind::Ge, BinOpKind::Le) => { - lint_double_comparison!(==) + lint_double_comparison!(==); }, _ => (), }; diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 8db5050a5ac..2eb8b1422ed 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -469,7 +469,7 @@ impl<'tcx> Visitor<'tcx> for InsertSearcher<'_, 'tcx> { let mut is_map_used = self.is_map_used; for arm in arms { if let Some(Guard::If(guard) | Guard::IfLet(_, guard)) = arm.guard { - self.visit_non_tail_expr(guard) + self.visit_non_tail_expr(guard); } is_map_used |= self.visit_cond_arm(arm.body); } diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index 90f391b5f5c..47fe4e0de0d 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -156,7 +156,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { vec![(left.span, lsnip), (right.span, rsnip)], ); }, - ) + ); } else if lcpy && !rcpy && implements_trait(cx, lty, trait_id, &[cx.typeck_results().expr_ty(right).into()]) @@ -175,7 +175,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { Applicability::MaybeIncorrect, // FIXME #2597 ); }, - ) + ); } else if !lcpy && rcpy && implements_trait(cx, cx.typeck_results().expr_ty(left), trait_id, &[rty.into()]) @@ -194,7 +194,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { Applicability::MaybeIncorrect, // FIXME #2597 ); }, - ) + ); } }, // &foo == bar @@ -218,9 +218,9 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { Applicability::MaybeIncorrect, // FIXME #2597 ); }, - ) + ); } - }, + }, // foo == &bar (_, &ExprKind::AddrOf(BorrowKind::Ref, _, r)) => { let rty = cx.typeck_results().expr_ty(r); @@ -236,7 +236,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { rsnip, Applicability::MaybeIncorrect, // FIXME #2597 ); - }) + }); } }, _ => {}, diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index afc5d546474..8d066f305ee 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -77,7 +77,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction { for arg in args { // skip `foo(macro!())` if arg.span.ctxt() == expr.span.ctxt() { - check_closure(cx, arg) + check_closure(cx, arg); } } }, @@ -190,9 +190,10 @@ fn get_ufcs_type_name(cx: &LateContext<'_>, method_def_id: def_id::DefId, self_a cx.tcx.impl_of_method(method_def_id).and_then(|_| { //a type may implicitly implement other type's methods (e.g. Deref) if match_types(expected_type_of_self, actual_type_of_self) { - return Some(get_type_name(cx, actual_type_of_self)); + Some(get_type_name(cx, actual_type_of_self)) + } else { + None } - None }) } diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 41acf55dd7d..5fdf5bc9e9d 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -110,7 +110,7 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> { self.visit_expr(e); for arm in arms { if let Some(Guard::If(if_expr)) = arm.guard { - self.visit_expr(if_expr) + self.visit_expr(if_expr); } // make sure top level arm expressions aren't linted self.maybe_walk_expr(&*arm.body); diff --git a/clippy_lints/src/functions/must_use.rs b/clippy_lints/src/functions/must_use.rs index 20288427b4a..7f4fb68cf2f 100644 --- a/clippy_lints/src/functions/must_use.rs +++ b/clippy_lints/src/functions/must_use.rs @@ -240,7 +240,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> { } }, Assign(target, ..) | AssignOp(_, target, _) | AddrOf(_, hir::Mutability::Mut, target) => { - self.mutates_static |= is_mutated_static(target) + self.mutates_static |= is_mutated_static(target); }, _ => {}, } diff --git a/clippy_lints/src/functions/too_many_lines.rs b/clippy_lints/src/functions/too_many_lines.rs index aa5494d5a7d..c02c343dc58 100644 --- a/clippy_lints/src/functions/too_many_lines.rs +++ b/clippy_lints/src/functions/too_many_lines.rs @@ -63,6 +63,6 @@ pub(super) fn check_fn(cx: &LateContext<'_>, span: Span, body: &'tcx hir::Body<' "this function has too many lines ({}/{})", line_count, too_many_lines_threshold ), - ) + ); } } diff --git a/clippy_lints/src/future_not_send.rs b/clippy_lints/src/future_not_send.rs index 04730ace887..515b8887453 100644 --- a/clippy_lints/src/future_not_send.rs +++ b/clippy_lints/src/future_not_send.rs @@ -102,7 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend { )); } } - }) + }); }, ); } diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index 260a8f50157..f2f830ca5c0 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -67,7 +67,7 @@ fn lint_break(cx: &LateContext<'_>, break_span: Span, expr_span: Span) { "change `break` to `return` as shown", format!("return {}", snip), app, - ) + ); } #[derive(Clone, Copy, PartialEq, Eq)] diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index afee20ce43e..6b887da2630 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for InfiniteIter { return; }, }; - span_lint(cx, lint, expr.span, msg) + span_lint(cx, lint, expr.span, msg); } } diff --git a/clippy_lints/src/invalid_upcast_comparisons.rs b/clippy_lints/src/invalid_upcast_comparisons.rs index c67c02eefa5..aafdebef248 100644 --- a/clippy_lints/src/invalid_upcast_comparisons.rs +++ b/clippy_lints/src/invalid_upcast_comparisons.rs @@ -177,7 +177,7 @@ fn upcast_comparison_bounds_err<'tcx>( }, Rel::Eq | Rel::Ne => unreachable!(), } { - err_upcast_comparison(cx, span, lhs, true) + err_upcast_comparison(cx, span, lhs, true); } else if match rel { Rel::Lt => { if invert { @@ -195,7 +195,7 @@ fn upcast_comparison_bounds_err<'tcx>( }, Rel::Eq | Rel::Ne => unreachable!(), } { - err_upcast_comparison(cx, span, lhs, false) + err_upcast_comparison(cx, span, lhs, false); } } } diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index bb57adff7be..583514b22f9 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -380,9 +380,9 @@ fn check_cmp(cx: &LateContext<'_>, span: Span, method: &Expr<'_>, lit: &Expr<'_> } } - check_len(cx, span, method_path.ident.name, args, &lit.node, op, compare_to) + check_len(cx, span, method_path.ident.name, args, &lit.node, op, compare_to); } else { - check_empty_expr(cx, span, method, lit, op) + check_empty_expr(cx, span, method, lit, op); } } diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index 17e23781db7..e627b1385bc 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -135,7 +135,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore { None, "consider using an underscore-prefixed named \ binding or dropping explicitly with `std::mem::drop`" - ) + ); } else if init_ty.needs_drop(cx.tcx, cx.param_env) { span_lint_and_help( cx, @@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore { None, "consider using an underscore-prefixed named \ binding or dropping explicitly with `std::mem::drop`" - ) + ); } else if is_must_use_ty(cx, cx.typeck_results().expr_ty(init)) { span_lint_and_help( cx, @@ -154,7 +154,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore { "non-binding let on an expression with `#[must_use]` type", None, "consider explicitly using expression value" - ) + ); } else if is_must_use_func_call(cx, init) { span_lint_and_help( cx, @@ -163,7 +163,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore { "non-binding let on a result of a `#[must_use]` function", None, "consider explicitly using function result" - ) + ); } } } diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 116ad072837..5ae68ba5b2f 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -205,7 +205,7 @@ fn could_use_elision<'tcx>( output_visitor.visit_ty(ty); } for lt in named_generics { - input_visitor.visit_generic_param(lt) + input_visitor.visit_generic_param(lt); } if input_visitor.abort() || output_visitor.abort() { @@ -463,7 +463,7 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker { // `'b` in `'a: 'b` is useless unless used elsewhere in // a non-lifetime bound if let GenericParamKind::Type { .. } = param.kind { - walk_generic_param(self, param) + walk_generic_param(self, param); } } fn nested_visit_map(&mut self) -> NestedVisitorMap { diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index e93b2e36b86..e0c5578bd60 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -231,7 +231,7 @@ impl EarlyLintPass for LiteralDigitGrouping { } if let ExprKind::Lit(ref lit) = expr.kind { - self.check_lit(cx, lit) + self.check_lit(cx, lit); } } } @@ -294,7 +294,7 @@ impl LiteralDigitGrouping { } }; if should_warn { - warning_type.display(num_lit.format(), cx, lit.span) + warning_type.display(num_lit.format(), cx, lit.span); } } } @@ -424,7 +424,7 @@ impl EarlyLintPass for DecimalLiteralRepresentation { } if let ExprKind::Lit(ref lit) = expr.kind { - self.check_lit(cx, lit) + self.check_lit(cx, lit); } } } @@ -446,7 +446,7 @@ impl DecimalLiteralRepresentation { let hex = format!("{:#X}", val); let num_lit = NumericLiteral::new(&hex, num_lit.suffix, false); let _ = Self::do_lint(num_lit.integer).map_err(|warning_type| { - warning_type.display(num_lit.format(), cx, lit.span) + warning_type.display(num_lit.format(), cx, lit.span); }); } } diff --git a/clippy_lints/src/loops/explicit_iter_loop.rs b/clippy_lints/src/loops/explicit_iter_loop.rs index ce02ad013be..f0327b5d777 100644 --- a/clippy_lints/src/loops/explicit_iter_loop.rs +++ b/clippy_lints/src/loops/explicit_iter_loop.rs @@ -43,7 +43,7 @@ pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, arg: &Expr<'_>, m "to write this more concisely, try", format!("&{}{}", muta, object), applicability, - ) + ); } /// Returns `true` if the type of expr is one that provides `IntoIterator` impls diff --git a/clippy_lints/src/loops/mut_range_bound.rs b/clippy_lints/src/loops/mut_range_bound.rs index 1425d50f560..d07b5a93b67 100644 --- a/clippy_lints/src/loops/mut_range_bound.rs +++ b/clippy_lints/src/loops/mut_range_bound.rs @@ -88,10 +88,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> { if let ty::BorrowKind::MutBorrow = bk { if let PlaceBase::Local(id) = cmt.place.base { if Some(id) == self.hir_id_low { - self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id)) + self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id)); } if Some(id) == self.hir_id_high { - self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id)) + self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id)); } } } @@ -100,10 +100,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> { fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) { if let PlaceBase::Local(id) = cmt.place.base { if Some(id) == self.hir_id_low { - self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id)) + self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id)); } if Some(id) == self.hir_id_high { - self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id)) + self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id)); } } } diff --git a/clippy_lints/src/loops/same_item_push.rs b/clippy_lints/src/loops/same_item_push.rs index cb2c83e9029..f2e0a0f7003 100644 --- a/clippy_lints/src/loops/same_item_push.rs +++ b/clippy_lints/src/loops/same_item_push.rs @@ -32,10 +32,10 @@ pub(super) fn check<'tcx>( "it looks like the same item is being pushed into this Vec", None, &format!( - "try using vec![{};SIZE] or {}.resize(NEW_SIZE, {})", + "try using vec![{}; SIZE] or {}.resize(NEW_SIZE, {})", item_str, vec_str, item_str ), - ) + ); } if !matches!(pat.kind, PatKind::Wild) { diff --git a/clippy_lints/src/loops/utils.rs b/clippy_lints/src/loops/utils.rs index 4db6644b9d7..2f7360210ba 100644 --- a/clippy_lints/src/loops/utils.rs +++ b/clippy_lints/src/loops/utils.rs @@ -80,10 +80,10 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> { } }, ExprKind::Assign(lhs, _, _) if lhs.hir_id == expr.hir_id => { - *state = IncrementVisitorVarState::DontWarn + *state = IncrementVisitorVarState::DontWarn; }, ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mut => { - *state = IncrementVisitorVarState::DontWarn + *state = IncrementVisitorVarState::DontWarn; }, _ => (), } @@ -207,7 +207,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> { } }, ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mut => { - self.state = InitializeVisitorState::DontWarn + self.state = InitializeVisitorState::DontWarn; }, _ => (), } @@ -292,7 +292,7 @@ impl<'tcx> Visitor<'tcx> for LoopNestVisitor { return; } } - walk_pat(self, pat) + walk_pat(self, pat); } fn nested_visit_map(&mut self) -> NestedVisitorMap { diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs index 914b583186c..66479ae264e 100644 --- a/clippy_lints/src/macro_use.rs +++ b/clippy_lints/src/macro_use.rs @@ -212,9 +212,9 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports { let mut suggestions = vec![]; for ((root, span), path) in used { if path.len() == 1 { - suggestions.push((span, format!("{}::{}", root, path[0]))) + suggestions.push((span, format!("{}::{}", root, path[0]))); } else { - suggestions.push((span, format!("{}::{{{}}}", root, path.join(", ")))) + suggestions.push((span, format!("{}::{{{}}}", root, path.join(", ")))); } } @@ -231,7 +231,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports { "remove the attribute and import the macro directly, try", help, Applicability::MaybeIncorrect, - ) + ); } } } diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index 23428524dee..6a06090f6e2 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -123,7 +123,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip { kind_word, snippet(cx, pattern.span, "..")))] .into_iter().chain(strippings.into_iter().map(|span| (span, "".into()))), - ) + ); }); } } diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index 99c35ae3bbf..e1f80ab025c 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -125,7 +125,7 @@ fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) { "remove the `map` call", String::new(), Applicability::MachineApplicable, - ) + ); } fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) { @@ -142,7 +142,7 @@ fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) { snippet_with_applicability(cx, root, "..", &mut applicability) ), applicability, - ) + ); } else { span_lint_and_sugg( cx, @@ -155,6 +155,6 @@ fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) { snippet_with_applicability(cx, root, "..", &mut applicability) ), applicability, - ) + ); } } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index fcd37687010..e07d8ea56e4 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -1144,7 +1144,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) "try this", suggestions.join(" | "), Applicability::MaybeIncorrect, - ) + ); }, }; } @@ -1242,7 +1242,7 @@ fn check_match_as_ref(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp cast, ), applicability, - ) + ); } } } @@ -1494,7 +1494,7 @@ fn check_match_single_binding<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[A "consider using the scrutinee and body instead", sugg, applicability, - ) + ); } else { span_lint_and_sugg( cx, @@ -1747,7 +1747,7 @@ mod redundant_pattern_match { match match_source { MatchSource::Normal => find_sugg_for_match(cx, expr, op, arms), MatchSource::IfLetDesugar { contains_else_clause } => { - find_sugg_for_if_let(cx, expr, op, &arms[0], "if", *contains_else_clause) + find_sugg_for_if_let(cx, expr, op, &arms[0], "if", *contains_else_clause); }, MatchSource::WhileLetDesugar => find_sugg_for_if_let(cx, expr, op, &arms[0], "while", false), _ => {}, @@ -1876,7 +1876,7 @@ mod redundant_pattern_match { { self.res = true; } else { - self.visit_expr(self_arg) + self.visit_expr(self_arg); } } args.iter().for_each(|arg| self.visit_expr(arg)); diff --git a/clippy_lints/src/methods/bind_instead_of_map.rs b/clippy_lints/src/methods/bind_instead_of_map.rs index 287bff886bf..da428a7b487 100644 --- a/clippy_lints/src/methods/bind_instead_of_map.rs +++ b/clippy_lints/src/methods/bind_instead_of_map.rs @@ -135,7 +135,7 @@ pub(crate) trait BindInsteadOfMap { .into_iter() .map(|(span1, span2)| (span1, snippet(cx, span2, "_").into())), ), - ) + ); }); true } diff --git a/clippy_lints/src/methods/cloned_instead_of_copied.rs b/clippy_lints/src/methods/cloned_instead_of_copied.rs index ecec6da3aa0..f5b4b6bf8ea 100644 --- a/clippy_lints/src/methods/cloned_instead_of_copied.rs +++ b/clippy_lints/src/methods/cloned_instead_of_copied.rs @@ -41,5 +41,5 @@ pub fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, span: Span, "try", "copied".into(), Applicability::MachineApplicable, - ) + ); } diff --git a/clippy_lints/src/methods/flat_map_option.rs b/clippy_lints/src/methods/flat_map_option.rs index 12d560653ed..32d40d97bf4 100644 --- a/clippy_lints/src/methods/flat_map_option.rs +++ b/clippy_lints/src/methods/flat_map_option.rs @@ -30,5 +30,5 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, arg "try", "filter_map".into(), Applicability::MachineApplicable, - ) + ); } diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index e0d29682146..cabfe8023ef 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1951,7 +1951,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio if let Some((name, [recv, args @ ..], span)) = method_call!(expr) { match (name, args) { ("add" | "offset" | "sub" | "wrapping_offset" | "wrapping_add" | "wrapping_sub", [recv, _]) => { - zst_offset::check(cx, expr, recv) + zst_offset::check(cx, expr, recv); }, ("and_then", [arg]) => { let biom_option_linted = bind_instead_of_map::OptionAndThenSome::check(cx, expr, recv, arg); @@ -2012,7 +2012,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio ("as_mut", []) => option_as_ref_deref::check(cx, expr, recv2, m_arg, true, msrv), ("as_ref", []) => option_as_ref_deref::check(cx, expr, recv2, m_arg, false, msrv), ("filter", [f_arg]) => { - filter_map::check(cx, expr, recv2, f_arg, span2, recv, m_arg, span, false) + filter_map::check(cx, expr, recv2, f_arg, span2, recv, m_arg, span, false); }, ("find", [f_arg]) => filter_map::check(cx, expr, recv2, f_arg, span2, recv, m_arg, span, true), _ => {}, @@ -2058,7 +2058,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio manual_saturating_arithmetic::check(cx, expr, lhs, rhs, u_arg, &arith["checked_".len()..]); }, Some(("map", [m_recv, m_arg], span)) => { - option_map_unwrap_or::check(cx, expr, m_recv, m_arg, recv, u_arg, span) + option_map_unwrap_or::check(cx, expr, m_recv, m_arg, recv, u_arg, span); }, _ => {}, }, @@ -2073,7 +2073,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio fn check_is_some_is_none(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, is_some: bool) { if let Some((name @ ("find" | "position" | "rposition"), [f_recv, arg], span)) = method_call!(recv) { - search_is_some::check(cx, expr, name, is_some, f_recv, arg, recv, span) + search_is_some::check(cx, expr, name, is_some, f_recv, arg, recv, span); } } diff --git a/clippy_lints/src/methods/unnecessary_fold.rs b/clippy_lints/src/methods/unnecessary_fold.rs index 75517c48a21..4c4034437da 100644 --- a/clippy_lints/src/methods/unnecessary_fold.rs +++ b/clippy_lints/src/methods/unnecessary_fold.rs @@ -87,7 +87,7 @@ pub(super) fn check( ast::LitKind::Bool(true) => check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::And, "all", true), ast::LitKind::Int(0, _) => check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Add, "sum", false), ast::LitKind::Int(1, _) => { - check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Mul, "product", false) + check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Mul, "product", false); }, _ => (), } diff --git a/clippy_lints/src/misc_early/mod.rs b/clippy_lints/src/misc_early/mod.rs index dd38316fa25..050b6805b7c 100644 --- a/clippy_lints/src/misc_early/mod.rs +++ b/clippy_lints/src/misc_early/mod.rs @@ -310,7 +310,7 @@ impl EarlyLintPass for MiscEarlyLints { if in_external_macro(cx.sess(), expr.span) { return; } - double_neg::check(cx, expr) + double_neg::check(cx, expr); } } @@ -334,15 +334,15 @@ impl MiscEarlyLints { }; unseparated_literal_suffix::check(cx, lit, &lit_snip, suffix, "integer"); if lit_snip.starts_with("0x") { - mixed_case_hex_literals::check(cx, lit, suffix, &lit_snip) + mixed_case_hex_literals::check(cx, lit, suffix, &lit_snip); } else if lit_snip.starts_with("0b") || lit_snip.starts_with("0o") { - /* nothing to do */ + // nothing to do } else if value != 0 && lit_snip.starts_with('0') { - zero_prefixed_literal::check(cx, lit, &lit_snip) + zero_prefixed_literal::check(cx, lit, &lit_snip); } } else if let LitKind::Float(_, LitFloatType::Suffixed(float_ty)) = lit.kind { let suffix = float_ty.name_str(); - unseparated_literal_suffix::check(cx, lit, &lit_snip, suffix, "float") + unseparated_literal_suffix::check(cx, lit, &lit_snip, suffix, "float"); } } } diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index cea6fce1195..6efe8ffcde0 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -48,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMutPassed { let def_id = cx.typeck_results().type_dependent_def_id(e.hir_id).unwrap(); let substs = cx.typeck_results().node_substs(e.hir_id); let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs); - check_arguments(cx, arguments, method_type, &path.ident.as_str(), "method") + check_arguments(cx, arguments, method_type, &path.ident.as_str(), "method"); }, _ => (), } diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 533c5a22db0..81bf853300f 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -103,7 +103,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> { _ if !self.found => self.expr_span = Some(expr.span), _ => return, } - walk_expr(self, expr) + walk_expr(self, expr); } fn nested_visit_map(&mut self) -> NestedVisitorMap { diff --git a/clippy_lints/src/needless_arbitrary_self_type.rs b/clippy_lints/src/needless_arbitrary_self_type.rs index 3e2b2782ed5..fe3c4455be5 100644 --- a/clippy_lints/src/needless_arbitrary_self_type.rs +++ b/clippy_lints/src/needless_arbitrary_self_type.rs @@ -121,7 +121,7 @@ impl EarlyLintPass for NeedlessArbitrarySelfType { match &p.ty.kind { TyKind::Path(None, path) => { if let PatKind::Ident(BindingMode::ByValue(mutbl), _, _) = p.pat.kind { - check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl) + check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl); } }, TyKind::Rptr(lifetime, mut_ty) => { @@ -129,7 +129,7 @@ impl EarlyLintPass for NeedlessArbitrarySelfType { if let TyKind::Path(None, path) = &mut_ty.ty.kind; if let PatKind::Ident(BindingMode::ByValue(Mutability::Not), _, _) = p.pat.kind; then { - check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Ref(*lifetime), mut_ty.mutbl) + check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Ref(*lifetime), mut_ty.mutbl); } } }, diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index dd458198637..3b3736fd3a1 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -82,7 +82,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBool { } if is_else_clause(cx.tcx, e) { - snip = snip.blockify() + snip = snip.blockify(); } span_lint_and_sugg( @@ -144,7 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolComparison { |h: Sugg<'_>| !h, "equality checks against false can be replaced by a negation", )); - check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal) + check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal); }, BinOpKind::Ne => { let true_case = Some(( @@ -152,7 +152,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolComparison { "inequality checks against true can be replaced by a negation", )); let false_case = Some((|h| h, "inequality checks against false are unnecessary")); - check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal) + check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal); }, BinOpKind::Lt => check_comparison( cx, @@ -251,22 +251,22 @@ fn check_comparison<'a, 'tcx>( snippet_with_applicability(cx, expression_info.right_span, "..", &mut applicability) ), applicability, - ) + ); } } match (fetch_bool_expr(left_side), fetch_bool_expr(right_side)) { (Bool(true), Other) => left_true.map_or((), |(h, m)| { - suggest_bool_comparison(cx, e, right_side, applicability, m, h) + suggest_bool_comparison(cx, e, right_side, applicability, m, h); }), (Other, Bool(true)) => right_true.map_or((), |(h, m)| { - suggest_bool_comparison(cx, e, left_side, applicability, m, h) + suggest_bool_comparison(cx, e, left_side, applicability, m, h); }), (Bool(false), Other) => left_false.map_or((), |(h, m)| { - suggest_bool_comparison(cx, e, right_side, applicability, m, h) + suggest_bool_comparison(cx, e, right_side, applicability, m, h); }), (Other, Bool(false)) => right_false.map_or((), |(h, m)| { - suggest_bool_comparison(cx, e, left_side, applicability, m, h) + suggest_bool_comparison(cx, e, left_side, applicability, m, h); }), (Other, Other) => no_literal.map_or((), |(h, m)| { let left_side = Sugg::hir_with_applicability(cx, left_side, "..", &mut applicability); @@ -279,7 +279,7 @@ fn check_comparison<'a, 'tcx>( "try simplifying it as shown", h(left_side, right_side).to_string(), applicability, - ) + ); }), _ => (), } diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index bcedebfccc7..dd1dfa2bdfb 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -199,7 +199,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrow { |diag| { diag.multipart_suggestion("try this", replacements, app); }, - ) + ); } self.current_body = None; } diff --git a/clippy_lints/src/needless_for_each.rs b/clippy_lints/src/needless_for_each.rs index 079b6642d58..3b936e6aaef 100644 --- a/clippy_lints/src/needless_for_each.rs +++ b/clippy_lints/src/needless_for_each.rs @@ -145,7 +145,7 @@ impl<'tcx> Visitor<'tcx> for RetCollector { self.ret_in_loop = true } - self.spans.push(expr.span) + self.spans.push(expr.span); }, ExprKind::Loop(..) => { diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index e70f8a09ebe..39ef170ae36 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -292,7 +292,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { LitKind::Str(ref text, _) => { let str_pat = self.next("s"); println!(" if let LitKind::Str(ref {}, _) = {}.node;", str_pat, lit_pat); - println!(" if {}.as_str() == {:?}", str_pat, &*text.as_str()) + println!(" if {}.as_str() == {:?}", str_pat, &*text.as_str()); }, } }, diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index ee7be24eae8..2c73c3d929b 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -1100,7 +1100,7 @@ impl<'tcx> LateLintPass<'tcx> for IfChainStyle { IF_CHAIN_STYLE, if_chain_local_span(cx, local, if_chain_span), "`let` expression should be inside `then { .. }`", - ) + ); } } @@ -1141,7 +1141,7 @@ impl<'tcx> LateLintPass<'tcx> for IfChainStyle { if is_first_if_chain_expr(cx, expr.hir_id, if_chain_span) && is_if_chain_then(then_block.stmts, then_block.expr, if_chain_span) { - span_lint(cx, IF_CHAIN_STYLE, expr.span, "`if_chain!` only has one `if`") + span_lint(cx, IF_CHAIN_STYLE, expr.span, "`if_chain!` only has one `if`"); } } } diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index a672af88271..46af03663b8 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -818,7 +818,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for IsMultiSpanScanner<'a, 'hir> { .any(|func_path| match_function_call(self.cx, fn_expr, func_path).is_some()); if found_function { // These functions are all multi part suggestions - self.add_single_span_suggestion() + self.add_single_span_suggestion(); } }, ExprKind::MethodCall(path, _path_span, arg, _arg_span) => { -- cgit 1.4.1-3-g733a5 From 12c61612f7a91df64121dd9c991828c26d665325 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Fri, 2 Jul 2021 20:37:11 +0200 Subject: Update lint documentation to use markdown headlines --- clippy_dev/src/new_lint.rs | 9 +- clippy_lints/src/absurd_extreme_comparisons.rs | 12 +- clippy_lints/src/approx_const.rs | 10 +- clippy_lints/src/arithmetic.rs | 20 +- clippy_lints/src/as_conversions.rs | 10 +- clippy_lints/src/asm_syntax.rs | 20 +- clippy_lints/src/assertions_on_constants.rs | 11 +- clippy_lints/src/assign_ops.rs | 22 +- clippy_lints/src/async_yields_async.rs | 11 +- clippy_lints/src/atomic_ordering.rs | 10 +- clippy_lints/src/attrs.rs | 74 +-- clippy_lints/src/await_holding_invalid.rs | 24 +- clippy_lints/src/bit_mask.rs | 32 +- clippy_lints/src/blacklisted_name.rs | 10 +- clippy_lints/src/blocks_in_if_conditions.rs | 10 +- clippy_lints/src/bool_assert_comparison.rs | 11 +- clippy_lints/src/booleans.rs | 22 +- clippy_lints/src/bytecount.rs | 12 +- clippy_lints/src/cargo_common_metadata.rs | 10 +- .../case_sensitive_file_extension_comparisons.rs | 9 +- clippy_lints/src/casts/mod.rs | 116 ++-- clippy_lints/src/checked_conversions.rs | 10 +- clippy_lints/src/cognitive_complexity.rs | 12 +- clippy_lints/src/collapsible_if.rs | 20 +- clippy_lints/src/collapsible_match.rs | 11 +- clippy_lints/src/comparison_chain.rs | 11 +- clippy_lints/src/copies.rs | 40 +- clippy_lints/src/copy_iterator.rs | 10 +- clippy_lints/src/create_dir.rs | 10 +- clippy_lints/src/dbg_macro.rs | 10 +- clippy_lints/src/default.rs | 21 +- clippy_lints/src/default_numeric_fallback.rs | 11 +- clippy_lints/src/deprecated_lints.rs | 96 ++-- clippy_lints/src/dereference.rs | 8 +- clippy_lints/src/derive.rs | 43 +- clippy_lints/src/disallowed_method.rs | 11 +- clippy_lints/src/disallowed_script_idents.rs | 10 +- clippy_lints/src/disallowed_type.rs | 11 +- clippy_lints/src/doc.rs | 53 +- clippy_lints/src/double_comparison.rs | 10 +- clippy_lints/src/double_parens.rs | 10 +- clippy_lints/src/drop_forget_ref.rs | 40 +- clippy_lints/src/duration_subsec.rs | 10 +- clippy_lints/src/else_if_without_else.rs | 10 +- clippy_lints/src/empty_enum.rs | 11 +- clippy_lints/src/entry.rs | 11 +- clippy_lints/src/enum_clike.rs | 10 +- clippy_lints/src/enum_variants.rs | 30 +- clippy_lints/src/eq_op.rs | 22 +- clippy_lints/src/erasing_op.rs | 10 +- clippy_lints/src/escape.rs | 10 +- clippy_lints/src/eta_reduction.rs | 22 +- clippy_lints/src/eval_order_dependence.rs | 22 +- clippy_lints/src/excessive_bools.rs | 20 +- clippy_lints/src/exhaustive_items.rs | 22 +- clippy_lints/src/exit.rs | 10 +- clippy_lints/src/explicit_write.rs | 10 +- clippy_lints/src/fallible_impl_from.rs | 10 +- clippy_lints/src/float_equality_without_abs.rs | 50 +- clippy_lints/src/float_literal.rs | 22 +- clippy_lints/src/floating_point_arithmetic.rs | 22 +- clippy_lints/src/format.rs | 10 +- clippy_lints/src/formatting.rs | 40 +- clippy_lints/src/from_over_into.rs | 11 +- clippy_lints/src/from_str_radix_10.rs | 12 +- clippy_lints/src/functions/mod.rs | 73 +-- clippy_lints/src/future_not_send.rs | 11 +- clippy_lints/src/get_last_with_len.rs | 11 +- clippy_lints/src/identity_op.rs | 10 +- clippy_lints/src/if_let_mutex.rs | 11 +- clippy_lints/src/if_let_some_result.rs | 10 +- clippy_lints/src/if_not_else.rs | 10 +- clippy_lints/src/if_then_some_else_none.rs | 11 +- clippy_lints/src/implicit_hasher.rs | 11 +- clippy_lints/src/implicit_return.rs | 10 +- clippy_lints/src/implicit_saturating_sub.rs | 11 +- .../src/inconsistent_struct_constructor.rs | 11 +- clippy_lints/src/indexing_slicing.rs | 22 +- clippy_lints/src/infinite_iter.rs | 21 +- clippy_lints/src/inherent_impl.rs | 10 +- clippy_lints/src/inherent_to_string.rs | 24 +- clippy_lints/src/inline_fn_without_body.rs | 10 +- clippy_lints/src/int_plus_one.rs | 10 +- clippy_lints/src/integer_division.rs | 10 +- clippy_lints/src/invalid_upcast_comparisons.rs | 10 +- clippy_lints/src/items_after_statements.rs | 10 +- clippy_lints/src/large_const_arrays.rs | 10 +- clippy_lints/src/large_enum_variant.rs | 12 +- clippy_lints/src/large_stack_arrays.rs | 10 +- clippy_lints/src/len_zero.rs | 30 +- clippy_lints/src/let_if_seq.rs | 10 +- clippy_lints/src/let_underscore.rs | 30 +- clippy_lints/src/lib.rs | 11 +- clippy_lints/src/lifetimes.rs | 20 +- clippy_lints/src/literal_representation.rs | 66 +-- clippy_lints/src/loops/mod.rs | 182 +++--- clippy_lints/src/macro_use.rs | 10 +- clippy_lints/src/main_recursion.rs | 10 +- clippy_lints/src/manual_async_fn.rs | 11 +- clippy_lints/src/manual_map.rs | 11 +- clippy_lints/src/manual_non_exhaustive.rs | 11 +- clippy_lints/src/manual_ok_or.rs | 10 +- clippy_lints/src/manual_strip.rs | 10 +- clippy_lints/src/manual_unwrap_or.rs | 8 +- clippy_lints/src/map_clone.rs | 11 +- clippy_lints/src/map_err_ignore.rs | 10 +- clippy_lints/src/map_unit_fn.rs | 22 +- clippy_lints/src/match_on_vec_items.rs | 10 +- clippy_lints/src/matches.rs | 170 +++--- clippy_lints/src/mem_discriminant.rs | 10 +- clippy_lints/src/mem_forget.rs | 10 +- clippy_lints/src/mem_replace.rs | 31 +- clippy_lints/src/methods/mod.rs | 636 +++++++++++---------- clippy_lints/src/minmax.rs | 10 +- clippy_lints/src/misc.rs | 93 +-- clippy_lints/src/misc_early/mod.rs | 90 +-- clippy_lints/src/missing_const_for_fn.rs | 12 +- clippy_lints/src/missing_doc.rs | 8 +- clippy_lints/src/missing_enforced_import_rename.rs | 11 +- clippy_lints/src/missing_inline.rs | 10 +- clippy_lints/src/modulo_arithmetic.rs | 10 +- clippy_lints/src/multiple_crate_versions.rs | 11 +- clippy_lints/src/mut_key.rs | 11 +- clippy_lints/src/mut_mut.rs | 10 +- clippy_lints/src/mut_mutex_lock.rs | 11 +- clippy_lints/src/mut_reference.rs | 10 +- clippy_lints/src/mutable_debug_assertion.rs | 10 +- clippy_lints/src/mutex_atomic.rs | 22 +- clippy_lints/src/needless_arbitrary_self_type.rs | 10 +- clippy_lints/src/needless_bitwise_bool.rs | 9 +- clippy_lints/src/needless_bool.rs | 21 +- clippy_lints/src/needless_borrow.rs | 20 +- clippy_lints/src/needless_borrowed_ref.rs | 11 +- clippy_lints/src/needless_continue.rs | 10 +- clippy_lints/src/needless_for_each.rs | 11 +- clippy_lints/src/needless_pass_by_value.rs | 10 +- clippy_lints/src/needless_question_mark.rs | 10 +- clippy_lints/src/needless_update.rs | 10 +- clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 9 +- clippy_lints/src/neg_multiply.rs | 11 +- clippy_lints/src/new_without_default.rs | 11 +- clippy_lints/src/no_effect.rs | 20 +- clippy_lints/src/non_copy_const.rs | 22 +- clippy_lints/src/non_expressive_names.rs | 30 +- clippy_lints/src/non_octal_unix_permissions.rs | 11 +- clippy_lints/src/nonstandard_macro_braces.rs | 12 +- clippy_lints/src/open_options.rs | 10 +- clippy_lints/src/option_env_unwrap.rs | 11 +- clippy_lints/src/option_if_let_else.rs | 9 +- clippy_lints/src/overflow_check_conditional.rs | 10 +- clippy_lints/src/panic_in_result_fn.rs | 12 +- clippy_lints/src/panic_unimplemented.rs | 40 +- clippy_lints/src/partialeq_ne_impl.rs | 10 +- clippy_lints/src/pass_by_ref_or_value.rs | 20 +- clippy_lints/src/path_buf_push_overwrite.rs | 10 +- clippy_lints/src/pattern_type_mismatch.rs | 11 +- clippy_lints/src/precedence.rs | 10 +- clippy_lints/src/ptr.rs | 42 +- clippy_lints/src/ptr_eq.rs | 11 +- clippy_lints/src/ptr_offset_with_cast.rs | 10 +- clippy_lints/src/question_mark.rs | 10 +- clippy_lints/src/ranges.rs | 54 +- clippy_lints/src/redundant_clone.rs | 11 +- clippy_lints/src/redundant_closure_call.rs | 10 +- clippy_lints/src/redundant_else.rs | 12 +- clippy_lints/src/redundant_field_names.rs | 10 +- clippy_lints/src/redundant_pub_crate.rs | 11 +- clippy_lints/src/redundant_slicing.rs | 12 +- clippy_lints/src/redundant_static_lifetimes.rs | 10 +- clippy_lints/src/ref_option_ref.rs | 12 +- clippy_lints/src/reference.rs | 19 +- clippy_lints/src/regex.rs | 21 +- clippy_lints/src/repeat_once.rs | 11 +- clippy_lints/src/returns.rs | 20 +- clippy_lints/src/self_assignment.rs | 12 +- clippy_lints/src/self_named_constructor.rs | 11 +- clippy_lints/src/semicolon_if_nothing_returned.rs | 11 +- clippy_lints/src/serde_api.rs | 11 +- clippy_lints/src/shadow.rs | 33 +- clippy_lints/src/single_component_path_imports.rs | 11 +- clippy_lints/src/size_of_in_element_count.rs | 10 +- clippy_lints/src/slow_vector_initialization.rs | 10 +- clippy_lints/src/stable_sort_primitive.rs | 10 +- clippy_lints/src/strings.rs | 63 +- clippy_lints/src/strlen_on_c_strings.rs | 11 +- clippy_lints/src/suspicious_operation_groupings.rs | 11 +- clippy_lints/src/suspicious_trait_impl.rs | 20 +- clippy_lints/src/swap.rs | 20 +- clippy_lints/src/tabs_in_doc_comments.rs | 10 +- clippy_lints/src/temporary_assignment.rs | 10 +- clippy_lints/src/to_digit_is_some.rs | 8 +- clippy_lints/src/to_string_in_display.rs | 10 +- clippy_lints/src/trait_bounds.rs | 20 +- clippy_lints/src/transmute/mod.rs | 122 ++-- clippy_lints/src/transmuting_null.rs | 11 +- clippy_lints/src/try_err.rs | 10 +- clippy_lints/src/types/mod.rs | 94 +-- clippy_lints/src/undropped_manually_drops.rs | 12 +- clippy_lints/src/unicode.rs | 32 +- clippy_lints/src/unit_return_expecting_ord.rs | 12 +- clippy_lints/src/unit_types/mod.rs | 30 +- clippy_lints/src/unnamed_address.rs | 22 +- clippy_lints/src/unnecessary_self_imports.rs | 12 +- clippy_lints/src/unnecessary_sort_by.rs | 9 +- clippy_lints/src/unnecessary_wraps.rs | 12 +- clippy_lints/src/unnested_or_patterns.rs | 11 +- clippy_lints/src/unsafe_removed_from_name.rs | 10 +- clippy_lints/src/unused_async.rs | 11 +- clippy_lints/src/unused_io_amount.rs | 11 +- clippy_lints/src/unused_self.rs | 10 +- clippy_lints/src/unused_unit.rs | 10 +- clippy_lints/src/unwrap.rs | 21 +- clippy_lints/src/unwrap_in_result.rs | 11 +- clippy_lints/src/upper_case_acronyms.rs | 12 +- clippy_lints/src/use_self.rs | 11 +- clippy_lints/src/useless_conversion.rs | 11 +- clippy_lints/src/utils/author.rs | 5 +- clippy_lints/src/utils/inspector.rs | 5 +- clippy_lints/src/utils/internal_lints.rs | 109 ++-- .../src/utils/internal_lints/metadata_collector.rs | 16 +- clippy_lints/src/vec.rs | 10 +- clippy_lints/src/vec_init_then_push.rs | 11 +- clippy_lints/src/vec_resize_to_zero.rs | 10 +- clippy_lints/src/verbose_file_reads.rs | 11 +- clippy_lints/src/wildcard_dependencies.rs | 11 +- clippy_lints/src/wildcard_imports.rs | 26 +- clippy_lints/src/write.rs | 92 +-- clippy_lints/src/zero_div_zero.rs | 10 +- clippy_lints/src/zero_sized_map_values.rs | 11 +- doc/adding_lints.md | 20 +- 230 files changed, 2717 insertions(+), 2474 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_dev/src/new_lint.rs b/clippy_dev/src/new_lint.rs index 4676c2affad..3a81aaba6de 100644 --- a/clippy_dev/src/new_lint.rs +++ b/clippy_dev/src/new_lint.rs @@ -169,14 +169,11 @@ use rustc_session::{{declare_lint_pass, declare_tool_lint}}; {pass_import} declare_clippy_lint! {{ - /// **What it does:** + /// ### What it does /// - /// **Why is this bad?** - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? /// + /// ### Example /// ```rust /// // example code where clippy issues a warning /// ``` diff --git a/clippy_lints/src/absurd_extreme_comparisons.rs b/clippy_lints/src/absurd_extreme_comparisons.rs index 49d4350123f..1483f3f9185 100644 --- a/clippy_lints/src/absurd_extreme_comparisons.rs +++ b/clippy_lints/src/absurd_extreme_comparisons.rs @@ -11,24 +11,26 @@ use clippy_utils::ty::is_isize_or_usize; use clippy_utils::{clip, int_bits, unsext}; declare_clippy_lint! { - /// **What it does:** Checks for comparisons where one side of the relation is + /// ### What it does + /// Checks for comparisons where one side of the relation is /// either the minimum or maximum value for its type and warns if it involves a /// case that is always true or always false. Only integer and boolean types are /// checked. /// - /// **Why is this bad?** An expression like `min <= x` may misleadingly imply + /// ### Why is this bad? + /// An expression like `min <= x` may misleadingly imply /// that it is possible for `x` to be less than the minimum. Expressions like /// `max < x` are probably mistakes. /// - /// **Known problems:** For `usize` the size of the current compile target will + /// ### Known problems + /// For `usize` the size of the current compile target will /// be assumed (e.g., 64 bits on 64 bit systems). This means code that uses such /// a comparison to detect target pointer width will trigger this lint. One can /// use `mem::sizeof` and compare its value or conditional compilation /// attributes /// like `#[cfg(target_pointer_width = "64")] ..` instead. /// - /// **Example:** - /// + /// ### Example /// ```rust /// let vec: Vec = Vec::new(); /// if vec.len() <= 0 {} diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index 3d04abe094d..6100f4e435a 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -7,21 +7,21 @@ use rustc_span::symbol; use std::f64::consts as f64; declare_clippy_lint! { - /// **What it does:** Checks for floating point literals that approximate + /// ### What it does + /// Checks for floating point literals that approximate /// constants which are defined in /// [`std::f32::consts`](https://doc.rust-lang.org/stable/std/f32/consts/#constants) /// or /// [`std::f64::consts`](https://doc.rust-lang.org/stable/std/f64/consts/#constants), /// respectively, suggesting to use the predefined constant. /// - /// **Why is this bad?** Usually, the definition in the standard library is more + /// ### Why is this bad? + /// Usually, the definition in the standard library is more /// precise than what people come up with. If you find that your definition is /// actually more precise, please [file a Rust /// issue](https://github.com/rust-lang/rust/issues). /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x = 3.14; /// let y = 1_f64 / x; diff --git a/clippy_lints/src/arithmetic.rs b/clippy_lints/src/arithmetic.rs index 24c2a972811..36fe7b7a867 100644 --- a/clippy_lints/src/arithmetic.rs +++ b/clippy_lints/src/arithmetic.rs @@ -6,7 +6,8 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::Span; declare_clippy_lint! { - /// **What it does:** Checks for integer arithmetic operations which could overflow or panic. + /// ### What it does + /// Checks for integer arithmetic operations which could overflow or panic. /// /// Specifically, checks for any operators (`+`, `-`, `*`, `<<`, etc) which are capable /// of overflowing according to the [Rust @@ -14,13 +15,12 @@ declare_clippy_lint! { /// or which can panic (`/`, `%`). No bounds analysis or sophisticated reasoning is /// attempted. /// - /// **Why is this bad?** Integer overflow will trigger a panic in debug builds or will wrap in + /// ### Why is this bad? + /// Integer overflow will trigger a panic in debug builds or will wrap in /// release mode. Division by zero will cause a panic in either mode. In some applications one /// wants explicitly checked, wrapping or saturating arithmetic. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let a = 0; /// a + 1; @@ -31,14 +31,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for float arithmetic. + /// ### What it does + /// Checks for float arithmetic. /// - /// **Why is this bad?** For some embedded systems or kernel development, it + /// ### Why is this bad? + /// For some embedded systems or kernel development, it /// can be useful to rule out floating-point numbers. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let a = 0.0; /// a + 1.0; diff --git a/clippy_lints/src/as_conversions.rs b/clippy_lints/src/as_conversions.rs index 4b31e16094e..7c39a3e2ce3 100644 --- a/clippy_lints/src/as_conversions.rs +++ b/clippy_lints/src/as_conversions.rs @@ -5,7 +5,8 @@ use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for usage of `as` conversions. + /// ### What it does + /// Checks for usage of `as` conversions. /// /// Note that this lint is specialized in linting *every single* use of `as` /// regardless of whether good alternatives exist or not. @@ -15,14 +16,13 @@ declare_clippy_lint! { /// There is a good explanation the reason why this lint should work in this way and how it is useful /// [in this issue](https://github.com/rust-lang/rust-clippy/issues/5122). /// - /// **Why is this bad?** `as` conversions will perform many kinds of + /// ### Why is this bad? + /// `as` conversions will perform many kinds of /// conversions, including silently lossy conversions and dangerous coercions. /// There are cases when it makes sense to use `as`, so the lint is /// Allow by default. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// let a: u32; /// ... diff --git a/clippy_lints/src/asm_syntax.rs b/clippy_lints/src/asm_syntax.rs index b970c71b753..825832eb79d 100644 --- a/clippy_lints/src/asm_syntax.rs +++ b/clippy_lints/src/asm_syntax.rs @@ -53,14 +53,14 @@ fn check_expr_asm_syntax(lint: &'static Lint, cx: &EarlyContext<'_>, expr: &Expr } declare_clippy_lint! { - /// **What it does:** Checks for usage of Intel x86 assembly syntax. + /// ### What it does + /// Checks for usage of Intel x86 assembly syntax. /// - /// **Why is this bad?** The lint has been enabled to indicate a preference + /// ### Why is this bad? + /// The lint has been enabled to indicate a preference /// for AT&T x86 assembly syntax. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// /// ```rust,no_run /// # #![feature(asm)] @@ -89,14 +89,14 @@ impl EarlyLintPass for InlineAsmX86IntelSyntax { } declare_clippy_lint! { - /// **What it does:** Checks for usage of AT&T x86 assembly syntax. + /// ### What it does + /// Checks for usage of AT&T x86 assembly syntax. /// - /// **Why is this bad?** The lint has been enabled to indicate a preference + /// ### Why is this bad? + /// The lint has been enabled to indicate a preference /// for Intel x86 assembly syntax. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// /// ```rust,no_run /// # #![feature(asm)] diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index 5235b2642d1..cb9347a923d 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -8,14 +8,17 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for `assert!(true)` and `assert!(false)` calls. + /// ### What it does + /// Checks for `assert!(true)` and `assert!(false)` calls. /// - /// **Why is this bad?** Will be optimized out by the compiler or should probably be replaced by a + /// ### Why is this bad? + /// Will be optimized out by the compiler or should probably be replaced by a /// `panic!()` or `unreachable!()` /// - /// **Known problems:** None + /// ### Known problems + /// None /// - /// **Example:** + /// ### Example /// ```rust,ignore /// assert!(false) /// assert!(true) diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 17ce3cd809f..2097a1feff9 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -12,15 +12,18 @@ use rustc_middle::hir::map::Map; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for `a = a op b` or `a = b commutative_op a` + /// ### What it does + /// Checks for `a = a op b` or `a = b commutative_op a` /// patterns. /// - /// **Why is this bad?** These can be written as the shorter `a op= b`. + /// ### Why is this bad? + /// These can be written as the shorter `a op= b`. /// - /// **Known problems:** While forbidden by the spec, `OpAssign` traits may have + /// ### Known problems + /// While forbidden by the spec, `OpAssign` traits may have /// implementations that differ from the regular `Op` impl. /// - /// **Example:** + /// ### Example /// ```rust /// let mut a = 5; /// let b = 0; @@ -37,17 +40,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `a op= a op b` or `a op= b op a` patterns. + /// ### What it does + /// Checks for `a op= a op b` or `a op= b op a` patterns. /// - /// **Why is this bad?** Most likely these are bugs where one meant to write `a + /// ### Why is this bad? + /// Most likely these are bugs where one meant to write `a /// op= b`. /// - /// **Known problems:** Clippy cannot know for sure if `a op= a op b` should have + /// ### Known problems + /// Clippy cannot know for sure if `a op= a op b` should have /// been `a = a op a op b` or `a = a op b`/`a op= b`. Therefore, it suggests both. /// If `a op= a op b` is really the correct behaviour it should be /// written as `a = a op a op b` as it's less confusing. /// - /// **Example:** + /// ### Example /// ```rust /// let mut a = 5; /// let b = 2; diff --git a/clippy_lints/src/async_yields_async.rs b/clippy_lints/src/async_yields_async.rs index e6c7c68f91a..182736a5a20 100644 --- a/clippy_lints/src/async_yields_async.rs +++ b/clippy_lints/src/async_yields_async.rs @@ -7,15 +7,14 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for async blocks that yield values of types + /// ### What it does + /// Checks for async blocks that yield values of types /// that can themselves be awaited. /// - /// **Why is this bad?** An await is likely missing. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// An await is likely missing. /// + /// ### Example /// ```rust /// async fn foo() {} /// diff --git a/clippy_lints/src/atomic_ordering.rs b/clippy_lints/src/atomic_ordering.rs index 7ceb01f5590..cece28e8b3c 100644 --- a/clippy_lints/src/atomic_ordering.rs +++ b/clippy_lints/src/atomic_ordering.rs @@ -8,16 +8,16 @@ use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for usage of invalid atomic + /// ### What it does + /// Checks for usage of invalid atomic /// ordering in atomic loads/stores/exchanges/updates and /// memory fences. /// - /// **Why is this bad?** Using an invalid atomic ordering + /// ### Why is this bad? + /// Using an invalid atomic ordering /// will cause a panic at run-time. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,no_run /// # use std::sync::atomic::{self, AtomicU8, Ordering}; /// diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index f272ed010a1..c9ff468874b 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -41,10 +41,12 @@ static UNIX_SYSTEMS: &[&str] = &[ static NON_UNIX_SYSTEMS: &[&str] = &["hermit", "none", "wasi"]; declare_clippy_lint! { - /// **What it does:** Checks for items annotated with `#[inline(always)]`, + /// ### What it does + /// Checks for items annotated with `#[inline(always)]`, /// unless the annotated function is empty or simply panics. /// - /// **Why is this bad?** While there are valid uses of this annotation (and once + /// ### Why is this bad? + /// While there are valid uses of this annotation (and once /// you know when to use it, by all means `allow` this lint), it's a common /// newbie-mistake to pepper one's code with it. /// @@ -52,11 +54,12 @@ declare_clippy_lint! { /// measure if that additional function call really affects your runtime profile /// sufficiently to make up for the increase in compile time. /// - /// **Known problems:** False positives, big time. This lint is meant to be + /// ### Known problems + /// False positives, big time. This lint is meant to be /// deactivated by everyone doing serious performance work. This means having /// done the measurement. /// - /// **Example:** + /// ### Example /// ```ignore /// #[inline(always)] /// fn not_quite_hot_code(..) { ... } @@ -67,7 +70,8 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `extern crate` and `use` items annotated with + /// ### What it does + /// Checks for `extern crate` and `use` items annotated with /// lint attributes. /// /// This lint permits `#[allow(unused_imports)]`, `#[allow(deprecated)]`, @@ -75,12 +79,11 @@ declare_clippy_lint! { /// `#[allow(clippy::enum_glob_use)]` on `use` items and `#[allow(unused_imports)]` on /// `extern crate` items with a `#[macro_use]` attribute. /// - /// **Why is this bad?** Lint attributes have no effect on crate imports. Most + /// ### Why is this bad? + /// Lint attributes have no effect on crate imports. Most /// likely a `!` was forgotten. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// // Bad /// #[deny(dead_code)] @@ -101,15 +104,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `#[deprecated]` annotations with a `since` + /// ### What it does + /// Checks for `#[deprecated]` annotations with a `since` /// field that is not a valid semantic version. /// - /// **Why is this bad?** For checking the version of the deprecation, it must be + /// ### Why is this bad? + /// For checking the version of the deprecation, it must be /// a valid semver. Failing that, the contained information is useless. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// #[deprecated(since = "forever")] /// fn something_else() { /* ... */ } @@ -120,20 +123,22 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for empty lines after outer attributes + /// ### What it does + /// Checks for empty lines after outer attributes /// - /// **Why is this bad?** + /// ### Why is this bad? /// Most likely the attribute was meant to be an inner attribute using a '!'. /// If it was meant to be an outer attribute, then the following item /// should not be separated by empty lines. /// - /// **Known problems:** Can cause false positives. + /// ### Known problems + /// Can cause false positives. /// /// From the clippy side it's difficult to detect empty lines between an attributes and the /// following item because empty lines and comments are not part of the AST. The parsing /// currently works for basic cases but is not perfect. /// - /// **Example:** + /// ### Example /// ```rust /// // Good (as inner attribute) /// #![allow(dead_code)] @@ -155,14 +160,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `warn`/`deny`/`forbid` attributes targeting the whole clippy::restriction category. + /// ### What it does + /// Checks for `warn`/`deny`/`forbid` attributes targeting the whole clippy::restriction category. /// - /// **Why is this bad?** Restriction lints sometimes are in contrast with other lints or even go against idiomatic rust. + /// ### Why is this bad? + /// Restriction lints sometimes are in contrast with other lints or even go against idiomatic rust. /// These lints should only be enabled on a lint-by-lint basis and with careful consideration. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// Bad: /// ```rust /// #![deny(clippy::restriction)] @@ -178,18 +183,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `#[cfg_attr(rustfmt, rustfmt_skip)]` and suggests to replace it + /// ### What it does + /// Checks for `#[cfg_attr(rustfmt, rustfmt_skip)]` and suggests to replace it /// with `#[rustfmt::skip]`. /// - /// **Why is this bad?** Since tool_attributes ([rust-lang/rust#44690](https://github.com/rust-lang/rust/issues/44690)) + /// ### Why is this bad? + /// Since tool_attributes ([rust-lang/rust#44690](https://github.com/rust-lang/rust/issues/44690)) /// are stable now, they should be used instead of the old `cfg_attr(rustfmt)` attributes. /// - /// **Known problems:** This lint doesn't detect crate level inner attributes, because they get + /// ### Known problems + /// This lint doesn't detect crate level inner attributes, because they get /// processed before the PreExpansionPass lints get executed. See /// [#3123](https://github.com/rust-lang/rust-clippy/pull/3123#issuecomment-422321765) /// - /// **Example:** - /// + /// ### Example /// Bad: /// ```rust /// #[cfg_attr(rustfmt, rustfmt_skip)] @@ -207,15 +214,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for cfg attributes having operating systems used in target family position. + /// ### What it does + /// Checks for cfg attributes having operating systems used in target family position. /// - /// **Why is this bad?** The configuration option will not be recognised and the related item will not be included + /// ### Why is this bad? + /// The configuration option will not be recognised and the related item will not be included /// by the conditional compilation engine. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// Bad: /// ```rust /// #[cfg(linux)] diff --git a/clippy_lints/src/await_holding_invalid.rs b/clippy_lints/src/await_holding_invalid.rs index 1739a57a240..0cc79c8b6e8 100644 --- a/clippy_lints/src/await_holding_invalid.rs +++ b/clippy_lints/src/await_holding_invalid.rs @@ -8,10 +8,12 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** Checks for calls to await while holding a + /// ### What it does + /// Checks for calls to await while holding a /// non-async-aware MutexGuard. /// - /// **Why is this bad?** The Mutex types found in std::sync and parking_lot + /// ### Why is this bad? + /// The Mutex types found in std::sync and parking_lot /// are not designed to operate in an async context across await points. /// /// There are two potential solutions. One is to use an asynx-aware Mutex @@ -19,10 +21,10 @@ declare_clippy_lint! { /// other solution is to ensure the mutex is unlocked before calling await, /// either by introducing a scope or an explicit call to Drop::drop. /// - /// **Known problems:** Will report false positive for explicitly dropped guards ([#6446](https://github.com/rust-lang/rust-clippy/issues/6446)). - /// - /// **Example:** + /// ### Known problems + /// Will report false positive for explicitly dropped guards ([#6446](https://github.com/rust-lang/rust-clippy/issues/6446)). /// + /// ### Example /// ```rust,ignore /// use std::sync::Mutex; /// @@ -51,17 +53,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to await while holding a + /// ### What it does + /// Checks for calls to await while holding a /// `RefCell` `Ref` or `RefMut`. /// - /// **Why is this bad?** `RefCell` refs only check for exclusive mutable access + /// ### Why is this bad? + /// `RefCell` refs only check for exclusive mutable access /// at runtime. Holding onto a `RefCell` ref across an `await` suspension point /// risks panics from a mutable ref shared while other refs are outstanding. /// - /// **Known problems:** Will report false positive for explicitly dropped refs ([#6353](https://github.com/rust-lang/rust-clippy/issues/6353)). - /// - /// **Example:** + /// ### Known problems + /// Will report false positive for explicitly dropped refs ([#6353](https://github.com/rust-lang/rust-clippy/issues/6353)). /// + /// ### Example /// ```rust,ignore /// use std::cell::RefCell; /// diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 991ed94572c..11346e7c96a 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -10,7 +10,8 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::Span; declare_clippy_lint! { - /// **What it does:** Checks for incompatible bit masks in comparisons. + /// ### What it does + /// Checks for incompatible bit masks in comparisons. /// /// The formula for detecting if an expression of the type `_ m /// c` (where `` is one of {`&`, `|`} and `` is one of @@ -26,7 +27,8 @@ declare_clippy_lint! { /// |`<` or `>=`| `|` |`x | 1 < 1` |`false` |`m >= c` | /// |`<=` or `>` | `|` |`x | 1 > 0` |`true` |`m > c` | /// - /// **Why is this bad?** If the bits that the comparison cares about are always + /// ### Why is this bad? + /// If the bits that the comparison cares about are always /// set to zero or one by the bit mask, the comparison is constant `true` or /// `false` (depending on mask, compared value, and operators). /// @@ -34,9 +36,7 @@ declare_clippy_lint! { /// this intentionally is to win an underhanded Rust contest or create a /// test-case for this lint. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let x = 1; /// if (x & 1 == 2) { } @@ -47,7 +47,8 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for bit masks in comparisons which can be removed + /// ### What it does + /// Checks for bit masks in comparisons which can be removed /// without changing the outcome. The basic structure can be seen in the /// following table: /// @@ -56,16 +57,18 @@ declare_clippy_lint! { /// |`>` / `<=`|`|` / `^`|`x | 2 > 3`|`x > 3`| /// |`<` / `>=`|`|` / `^`|`x ^ 1 < 4`|`x < 4`| /// - /// **Why is this bad?** Not equally evil as [`bad_bit_mask`](#bad_bit_mask), + /// ### Why is this bad? + /// Not equally evil as [`bad_bit_mask`](#bad_bit_mask), /// but still a bit misleading, because the bit mask is ineffective. /// - /// **Known problems:** False negatives: This lint will only match instances + /// ### Known problems + /// False negatives: This lint will only match instances /// where we have figured out the math (which is for a power-of-two compared /// value). This means things like `x | 1 >= 7` (which would be better written /// as `x >= 6`) will not be reported (but bit masks like this are fairly /// uncommon). /// - /// **Example:** + /// ### Example /// ```rust /// # let x = 1; /// if (x | 1 > 3) { } @@ -76,15 +79,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for bit masks that can be replaced by a call + /// ### What it does + /// Checks for bit masks that can be replaced by a call /// to `trailing_zeros` /// - /// **Why is this bad?** `x.trailing_zeros() > 4` is much clearer than `x & 15 + /// ### Why is this bad? + /// `x.trailing_zeros() > 4` is much clearer than `x & 15 /// == 0` /// - /// **Known problems:** llvm generates better code for `x & 15 == 0` on x86 + /// ### Known problems + /// llvm generates better code for `x & 15 == 0` on x86 /// - /// **Example:** + /// ### Example /// ```rust /// # let x = 1; /// if x & 0b1111 == 0 { } diff --git a/clippy_lints/src/blacklisted_name.rs b/clippy_lints/src/blacklisted_name.rs index 8eb94f3c28e..916c78c982a 100644 --- a/clippy_lints/src/blacklisted_name.rs +++ b/clippy_lints/src/blacklisted_name.rs @@ -5,15 +5,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; declare_clippy_lint! { - /// **What it does:** Checks for usage of blacklisted names for variables, such + /// ### What it does + /// Checks for usage of blacklisted names for variables, such /// as `foo`. /// - /// **Why is this bad?** These names are usually placeholder names and should be + /// ### Why is this bad? + /// These names are usually placeholder names and should be /// avoided. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let foo = 3.14; /// ``` diff --git a/clippy_lints/src/blocks_in_if_conditions.rs b/clippy_lints/src/blocks_in_if_conditions.rs index badcf8d2a43..9b2e4f8998e 100644 --- a/clippy_lints/src/blocks_in_if_conditions.rs +++ b/clippy_lints/src/blocks_in_if_conditions.rs @@ -13,14 +13,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for `if` conditions that use blocks containing an + /// ### What it does + /// Checks for `if` conditions that use blocks containing an /// expression, statements or conditions that use closures with blocks. /// - /// **Why is this bad?** Style, using blocks in the condition makes it hard to read. + /// ### Why is this bad? + /// Style, using blocks in the condition makes it hard to read. /// - /// **Known problems:** None. - /// - /// **Examples:** + /// ### Examples /// ```rust /// // Bad /// if { true } { /* ... */ } diff --git a/clippy_lints/src/bool_assert_comparison.rs b/clippy_lints/src/bool_assert_comparison.rs index bee706ed402..8d3f68565b2 100644 --- a/clippy_lints/src/bool_assert_comparison.rs +++ b/clippy_lints/src/bool_assert_comparison.rs @@ -6,14 +6,13 @@ use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** This lint warns about boolean comparisons in assert-like macros. + /// ### What it does + /// This lint warns about boolean comparisons in assert-like macros. /// - /// **Why is this bad?** It is shorter to use the equivalent. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// It is shorter to use the equivalent. /// + /// ### Example /// ```rust /// // Bad /// assert_eq!("a".is_empty(), false); diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index e72399af232..4a83d35a568 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -14,16 +14,19 @@ use rustc_span::source_map::Span; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for boolean expressions that can be written more + /// ### What it does + /// Checks for boolean expressions that can be written more /// concisely. /// - /// **Why is this bad?** Readability of boolean expressions suffers from + /// ### Why is this bad? + /// Readability of boolean expressions suffers from /// unnecessary duplication. /// - /// **Known problems:** Ignores short circuiting behavior of `||` and + /// ### Known problems + /// Ignores short circuiting behavior of `||` and /// `&&`. Ignores `|`, `&` and `^`. /// - /// **Example:** + /// ### Example /// ```ignore /// if a && true // should be: if a /// if !(a == b) // should be: if a != b @@ -34,14 +37,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for boolean expressions that contain terminals that + /// ### What it does + /// Checks for boolean expressions that contain terminals that /// can be eliminated. /// - /// **Why is this bad?** This is most likely a logic bug. + /// ### Why is this bad? + /// This is most likely a logic bug. /// - /// **Known problems:** Ignores short circuiting behavior. + /// ### Known problems + /// Ignores short circuiting behavior. /// - /// **Example:** + /// ### Example /// ```ignore /// if a && b || a { ... } /// ``` diff --git a/clippy_lints/src/bytecount.rs b/clippy_lints/src/bytecount.rs index 4f7ffdcdfb4..c444984bc13 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -12,18 +12,20 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for naive byte counts + /// ### What it does + /// Checks for naive byte counts /// - /// **Why is this bad?** The [`bytecount`](https://crates.io/crates/bytecount) + /// ### Why is this bad? + /// The [`bytecount`](https://crates.io/crates/bytecount) /// crate has methods to count your bytes faster, especially for large slices. /// - /// **Known problems:** If you have predominantly small slices, the + /// ### Known problems + /// If you have predominantly small slices, the /// `bytecount::count(..)` method may actually be slower. However, if you can /// ensure that less than 2³²-1 matches arise, the `naive_count_32(..)` can be /// faster in those cases. /// - /// **Example:** - /// + /// ### Example /// ```rust /// # let vec = vec![1_u8]; /// &vec.iter().filter(|x| **x == 0u8).count(); // use bytecount::count instead diff --git a/clippy_lints/src/cargo_common_metadata.rs b/clippy_lints/src/cargo_common_metadata.rs index 21c7b2448ce..bd5426ba707 100644 --- a/clippy_lints/src/cargo_common_metadata.rs +++ b/clippy_lints/src/cargo_common_metadata.rs @@ -9,15 +9,15 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::DUMMY_SP; declare_clippy_lint! { - /// **What it does:** Checks to see if all common metadata is defined in + /// ### What it does + /// Checks to see if all common metadata is defined in /// `Cargo.toml`. See: https://rust-lang-nursery.github.io/api-guidelines/documentation.html#cargotoml-includes-all-common-metadata-c-metadata /// - /// **Why is this bad?** It will be more difficult for users to discover the + /// ### Why is this bad? + /// It will be more difficult for users to discover the /// purpose of the crate, and key information related to it. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```toml /// # This `Cargo.toml` is missing a description field: /// [package] diff --git a/clippy_lints/src/case_sensitive_file_extension_comparisons.rs b/clippy_lints/src/case_sensitive_file_extension_comparisons.rs index c9ef379be56..86b32475ceb 100644 --- a/clippy_lints/src/case_sensitive_file_extension_comparisons.rs +++ b/clippy_lints/src/case_sensitive_file_extension_comparisons.rs @@ -8,17 +8,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{source_map::Spanned, symbol::sym, Span}; declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Checks for calls to `ends_with` with possible file extensions /// and suggests to use a case-insensitive approach instead. /// - /// **Why is this bad?** + /// ### Why is this bad? /// `ends_with` is case-sensitive and may not detect files with a valid extension. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// fn is_rust_file(filename: &str) -> bool { /// filename.ends_with(".rs") diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index ae4fdd12c41..27e1bea7993 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -20,7 +20,8 @@ use rustc_semver::RustcVersion; use rustc_session::{declare_tool_lint, impl_lint_pass}; declare_clippy_lint! { - /// **What it does:** Checks for casts from any numerical to a float type where + /// ### What it does + /// Checks for casts from any numerical to a float type where /// the receiving type cannot store all values from the original type without /// rounding errors. This possible rounding is to be expected, so this lint is /// `Allow` by default. @@ -28,13 +29,12 @@ declare_clippy_lint! { /// Basically, this warns on casting any integer with 32 or more bits to `f32` /// or any 64-bit integer to `f64`. /// - /// **Why is this bad?** It's not bad at all. But in some applications it can be + /// ### Why is this bad? + /// It's not bad at all. But in some applications it can be /// helpful to know where precision loss can take place. This lint can help find /// those places in the code. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x = u64::MAX; /// x as f64; @@ -45,17 +45,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for casts from a signed to an unsigned numerical + /// ### What it does + /// Checks for casts from a signed to an unsigned numerical /// type. In this case, negative values wrap around to large positive values, /// which can be quite surprising in practice. However, as the cast works as /// defined, this lint is `Allow` by default. /// - /// **Why is this bad?** Possibly surprising results. You can activate this lint + /// ### Why is this bad? + /// Possibly surprising results. You can activate this lint /// as a one-time check to see where numerical wrapping can arise. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let y: i8 = -1; /// y as u128; // will return 18446744073709551615 @@ -66,17 +66,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for casts between numerical types that may + /// ### What it does + /// Checks for casts between numerical types that may /// truncate large values. This is expected behavior, so the cast is `Allow` by /// default. /// - /// **Why is this bad?** In some problem domains, it is good practice to avoid + /// ### Why is this bad? + /// In some problem domains, it is good practice to avoid /// truncation. This lint can be activated to help assess where additional /// checks could be beneficial. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn as_u8(x: u64) -> u8 { /// x as u8 @@ -88,20 +88,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for casts from an unsigned type to a signed type of + /// ### What it does + /// Checks for casts from an unsigned type to a signed type of /// the same size. Performing such a cast is a 'no-op' for the compiler, /// i.e., nothing is changed at the bit level, and the binary representation of /// the value is reinterpreted. This can cause wrapping if the value is too big /// for the target signed type. However, the cast works as defined, so this lint /// is `Allow` by default. /// - /// **Why is this bad?** While such a cast is not bad in itself, the results can + /// ### Why is this bad? + /// While such a cast is not bad in itself, the results can /// be surprising when this is not the intended behavior, as demonstrated by the /// example below. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// u32::MAX as i32; // will yield a value of `-1` /// ``` @@ -111,19 +111,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for casts between numerical types that may + /// ### What it does + /// Checks for casts between numerical types that may /// be replaced by safe conversion functions. /// - /// **Why is this bad?** Rust's `as` keyword will perform many kinds of + /// ### Why is this bad? + /// Rust's `as` keyword will perform many kinds of /// conversions, including silently lossy conversions. Conversion functions such /// as `i32::from` will only perform lossless conversions. Using the conversion /// functions prevents conversions from turning into silent lossy conversions if /// the types of the input expressions ever change, and make it easier for /// people reading the code to know that the conversion is lossless. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn as_u64(x: u8) -> u64 { /// x as u64 @@ -143,14 +143,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for casts to the same type, casts of int literals to integer types + /// ### What it does + /// Checks for casts to the same type, casts of int literals to integer types /// and casts of float literals to float types. /// - /// **Why is this bad?** It's just unnecessary. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// It's just unnecessary. /// - /// **Example:** + /// ### Example /// ```rust /// let _ = 2i32 as i32; /// let _ = 0.5 as f32; @@ -168,17 +168,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for casts, using `as` or `pointer::cast`, + /// ### What it does + /// Checks for casts, using `as` or `pointer::cast`, /// from a less-strictly-aligned pointer to a more-strictly-aligned pointer /// - /// **Why is this bad?** Dereferencing the resulting pointer may be undefined + /// ### Why is this bad? + /// Dereferencing the resulting pointer may be undefined /// behavior. /// - /// **Known problems:** Using `std::ptr::read_unaligned` and `std::ptr::write_unaligned` or similar + /// ### Known problems + /// Using `std::ptr::read_unaligned` and `std::ptr::write_unaligned` or similar /// on the resulting pointer is fine. Is over-zealous: Casts with manual alignment checks or casts like /// u64-> u8 -> u16 can be fine. Miri is able to do a more in-depth analysis. /// - /// **Example:** + /// ### Example /// ```rust /// let _ = (&1u8 as *const u8) as *const u16; /// let _ = (&mut 1u8 as *mut u8) as *mut u16; @@ -192,9 +195,10 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for casts of function pointers to something other than usize + /// ### What it does + /// Checks for casts of function pointers to something other than usize /// - /// **Why is this bad?** + /// ### Why is this bad? /// Casting a function pointer to anything other than usize/isize is not portable across /// architectures, because you end up losing bits if the target type is too small or end up with a /// bunch of extra bits that waste space and add more instructions to the final binary than @@ -202,8 +206,7 @@ declare_clippy_lint! { /// /// Casting to isize also doesn't make sense since there are no signed addresses. /// - /// **Example** - /// + /// ### Example /// ```rust /// // Bad /// fn fun() -> i32 { 1 } @@ -219,16 +222,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for casts of a function pointer to a numeric type not wide enough to + /// ### What it does + /// Checks for casts of a function pointer to a numeric type not wide enough to /// store address. /// - /// **Why is this bad?** + /// ### Why is this bad? /// Such a cast discards some bits of the function's address. If this is intended, it would be more /// clearly expressed by casting to usize first, then casting the usize to the intended type (with /// a comment) to perform the truncation. /// - /// **Example** - /// + /// ### Example /// ```rust /// // Bad /// fn fn1() -> i16 { @@ -249,15 +252,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for casts of `&T` to `&mut T` anywhere in the code. + /// ### What it does + /// Checks for casts of `&T` to `&mut T` anywhere in the code. /// - /// **Why is this bad?** It’s basically guaranteed to be undefined behaviour. + /// ### Why is this bad? + /// It’s basically guaranteed to be undefined behaviour. /// `UnsafeCell` is the only way to obtain aliasable data that is considered /// mutable. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// fn x(r: &i32) { /// unsafe { @@ -283,18 +286,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for expressions where a character literal is cast + /// ### What it does + /// Checks for expressions where a character literal is cast /// to `u8` and suggests using a byte literal instead. /// - /// **Why is this bad?** In general, casting values to smaller types is + /// ### Why is this bad? + /// In general, casting values to smaller types is /// error-prone and should be avoided where possible. In the particular case of /// converting a character literal to u8, it is easy to avoid by just using a /// byte literal instead. As an added bonus, `b'a'` is even slightly shorter /// than `'a' as u8`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// 'x' as u8 /// ``` @@ -310,18 +313,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Checks for `as` casts between raw pointers without changing its mutability, /// namely `*const T` to `*const U` and `*mut T` to `*mut U`. /// - /// **Why is this bad?** + /// ### Why is this bad? /// Though `as` casts between raw pointers is not terrible, `pointer::cast` is safer because /// it cannot accidentally change the pointer's mutability nor cast the pointer to other types like `usize`. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let ptr: *const u32 = &42_u32; /// let mut_ptr: *mut u32 = &mut 42_u32; diff --git a/clippy_lints/src/checked_conversions.rs b/clippy_lints/src/checked_conversions.rs index 8d3123e1ec8..842bbf006cc 100644 --- a/clippy_lints/src/checked_conversions.rs +++ b/clippy_lints/src/checked_conversions.rs @@ -13,13 +13,13 @@ use rustc_semver::RustcVersion; use rustc_session::{declare_tool_lint, impl_lint_pass}; declare_clippy_lint! { - /// **What it does:** Checks for explicit bounds checking when casting. + /// ### What it does + /// Checks for explicit bounds checking when casting. /// - /// **Why is this bad?** Reduces the readability of statements & is error prone. + /// ### Why is this bad? + /// Reduces the readability of statements & is error prone. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let foo: u32 = 5; /// # let _ = diff --git a/clippy_lints/src/cognitive_complexity.rs b/clippy_lints/src/cognitive_complexity.rs index f62c6a9c325..96c30d57ee1 100644 --- a/clippy_lints/src/cognitive_complexity.rs +++ b/clippy_lints/src/cognitive_complexity.rs @@ -14,15 +14,19 @@ use rustc_span::source_map::Span; use rustc_span::{sym, BytePos}; declare_clippy_lint! { - /// **What it does:** Checks for methods with high cognitive complexity. + /// ### What it does + /// Checks for methods with high cognitive complexity. /// - /// **Why is this bad?** Methods of high cognitive complexity tend to be hard to + /// ### Why is this bad? + /// Methods of high cognitive complexity tend to be hard to /// both read and maintain. Also LLVM will tend to optimize small methods better. /// - /// **Known problems:** Sometimes it's hard to find a way to reduce the + /// ### Known problems + /// Sometimes it's hard to find a way to reduce the /// complexity. /// - /// **Example:** No. You'll see it when you get the warning. + /// ### Example + /// No. You'll see it when you get the warning. pub COGNITIVE_COMPLEXITY, nursery, "functions that should be split up into multiple functions" diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 6e950738239..4aa87980715 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -22,15 +22,15 @@ use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for nested `if` statements which can be collapsed + /// ### What it does + /// Checks for nested `if` statements which can be collapsed /// by `&&`-combining their conditions. /// - /// **Why is this bad?** Each `if`-statement adds one level of nesting, which + /// ### Why is this bad? + /// Each `if`-statement adds one level of nesting, which /// makes code look more complex than it really is. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// if x { /// if y { @@ -53,15 +53,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for collapsible `else { if ... }` expressions + /// ### What it does + /// Checks for collapsible `else { if ... }` expressions /// that can be collapsed to `else if ...`. /// - /// **Why is this bad?** Each `if`-statement adds one level of nesting, which + /// ### Why is this bad? + /// Each `if`-statement adds one level of nesting, which /// makes code look more complex than it really is. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// /// if x { diff --git a/clippy_lints/src/collapsible_match.rs b/clippy_lints/src/collapsible_match.rs index a6c3a5b0e83..a403a9846ba 100644 --- a/clippy_lints/src/collapsible_match.rs +++ b/clippy_lints/src/collapsible_match.rs @@ -9,18 +9,17 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{MultiSpan, Span}; declare_clippy_lint! { - /// **What it does:** Finds nested `match` or `if let` expressions where the patterns may be "collapsed" together + /// ### What it does + /// Finds nested `match` or `if let` expressions where the patterns may be "collapsed" together /// without adding any branches. /// /// Note that this lint is not intended to find _all_ cases where nested match patterns can be merged, but only /// cases where merging would most likely make the code more readable. /// - /// **Why is this bad?** It is unnecessarily verbose and complex. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// It is unnecessarily verbose and complex. /// + /// ### Example /// ```rust /// fn func(opt: Option>) { /// let n = match opt { diff --git a/clippy_lints/src/comparison_chain.rs b/clippy_lints/src/comparison_chain.rs index b6999bef6e7..597a3c67024 100644 --- a/clippy_lints/src/comparison_chain.rs +++ b/clippy_lints/src/comparison_chain.rs @@ -6,16 +6,19 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks comparison chains written with `if` that can be + /// ### What it does + /// Checks comparison chains written with `if` that can be /// rewritten with `match` and `cmp`. /// - /// **Why is this bad?** `if` is not guaranteed to be exhaustive and conditionals can get + /// ### Why is this bad? + /// `if` is not guaranteed to be exhaustive and conditionals can get /// repetitive /// - /// **Known problems:** The match statement may be slower due to the compiler + /// ### Known problems + /// The match statement may be slower due to the compiler /// not inlining the call to cmp. See issue [#5354](https://github.com/rust-lang/rust-clippy/issues/5354) /// - /// **Example:** + /// ### Example /// ```rust,ignore /// # fn a() {} /// # fn b() {} diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 9cbcde59768..2dcd5545799 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -16,13 +16,13 @@ use rustc_span::{source_map::Span, symbol::Symbol, BytePos}; use std::borrow::Cow; declare_clippy_lint! { - /// **What it does:** Checks for consecutive `if`s with the same condition. + /// ### What it does + /// Checks for consecutive `if`s with the same condition. /// - /// **Why is this bad?** This is probably a copy & paste error. + /// ### Why is this bad? + /// This is probably a copy & paste error. /// - /// **Known problems:** Hopefully none. - /// - /// **Example:** + /// ### Example /// ```ignore /// if a == b { /// … @@ -47,15 +47,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for consecutive `if`s with the same function call. + /// ### What it does + /// Checks for consecutive `if`s with the same function call. /// - /// **Why is this bad?** This is probably a copy & paste error. + /// ### Why is this bad? + /// This is probably a copy & paste error. /// Despite the fact that function can have side effects and `if` works as /// intended, such an approach is implicit and can be considered a "code smell". /// - /// **Known problems:** Hopefully none. - /// - /// **Example:** + /// ### Example /// ```ignore /// if foo() == bar { /// … @@ -94,14 +94,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `if/else` with the same body as the *then* part + /// ### What it does + /// Checks for `if/else` with the same body as the *then* part /// and the *else* part. /// - /// **Why is this bad?** This is probably a copy & paste error. - /// - /// **Known problems:** Hopefully none. + /// ### Why is this bad? + /// This is probably a copy & paste error. /// - /// **Example:** + /// ### Example /// ```ignore /// let foo = if … { /// 42 @@ -115,17 +115,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks if the `if` and `else` block contain shared code that can be + /// ### What it does + /// Checks if the `if` and `else` block contain shared code that can be /// moved out of the blocks. /// - /// **Why is this bad?** Duplicate code is less maintainable. + /// ### Why is this bad? + /// Duplicate code is less maintainable. /// - /// **Known problems:** + /// ### Known problems /// * The lint doesn't check if the moved expressions modify values that are beeing used in /// the if condition. The suggestion can in that case modify the behavior of the program. /// See [rust-clippy#7452](https://github.com/rust-lang/rust-clippy/issues/7452) /// - /// **Example:** + /// ### Example /// ```ignore /// let foo = if … { /// println!("Hello World"); diff --git a/clippy_lints/src/copy_iterator.rs b/clippy_lints/src/copy_iterator.rs index 35079c6bedc..c2e9e8b3ab7 100644 --- a/clippy_lints/src/copy_iterator.rs +++ b/clippy_lints/src/copy_iterator.rs @@ -8,15 +8,15 @@ use rustc_span::sym; use if_chain::if_chain; declare_clippy_lint! { - /// **What it does:** Checks for types that implement `Copy` as well as + /// ### What it does + /// Checks for types that implement `Copy` as well as /// `Iterator`. /// - /// **Why is this bad?** Implicit copies can be confusing when working with + /// ### Why is this bad? + /// Implicit copies can be confusing when working with /// iterator combinators. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// #[derive(Copy, Clone)] /// struct Countdown(u8); diff --git a/clippy_lints/src/create_dir.rs b/clippy_lints/src/create_dir.rs index 7b5cce6462a..e4ee2772483 100644 --- a/clippy_lints/src/create_dir.rs +++ b/clippy_lints/src/create_dir.rs @@ -8,13 +8,13 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks usage of `std::fs::create_dir` and suggest using `std::fs::create_dir_all` instead. + /// ### What it does + /// Checks usage of `std::fs::create_dir` and suggest using `std::fs::create_dir_all` instead. /// - /// **Why is this bad?** Sometimes `std::fs::create_dir` is mistakenly chosen over `std::fs::create_dir_all`. + /// ### Why is this bad? + /// Sometimes `std::fs::create_dir` is mistakenly chosen over `std::fs::create_dir_all`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// /// ```rust /// std::fs::create_dir("foo"); diff --git a/clippy_lints/src/dbg_macro.rs b/clippy_lints/src/dbg_macro.rs index 286cc7e223e..bab4a696f83 100644 --- a/clippy_lints/src/dbg_macro.rs +++ b/clippy_lints/src/dbg_macro.rs @@ -8,14 +8,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; declare_clippy_lint! { - /// **What it does:** Checks for usage of dbg!() macro. + /// ### What it does + /// Checks for usage of dbg!() macro. /// - /// **Why is this bad?** `dbg!` macro is intended as a debugging tool. It + /// ### Why is this bad? + /// `dbg!` macro is intended as a debugging tool. It /// should not be in version control. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // Bad /// dbg!(true) diff --git a/clippy_lints/src/default.rs b/clippy_lints/src/default.rs index 947479db8f5..db8f2171348 100644 --- a/clippy_lints/src/default.rs +++ b/clippy_lints/src/default.rs @@ -13,14 +13,14 @@ use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** Checks for literal calls to `Default::default()`. + /// ### What it does + /// Checks for literal calls to `Default::default()`. /// - /// **Why is this bad?** It's more clear to the reader to use the name of the type whose default is + /// ### Why is this bad? + /// It's more clear to the reader to use the name of the type whose default is /// being gotten than the generic `Default`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// let s: String = Default::default(); @@ -34,14 +34,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for immediate reassignment of fields initialized + /// ### What it does + /// Checks for immediate reassignment of fields initialized /// with Default::default(). /// - /// **Why is this bad?**It's more idiomatic to use the [functional update syntax](https://doc.rust-lang.org/reference/expressions/struct-expr.html#functional-update-syntax). + /// ### Why is this bad? + ///It's more idiomatic to use the [functional update syntax](https://doc.rust-lang.org/reference/expressions/struct-expr.html#functional-update-syntax). /// - /// **Known problems:** Assignments to patterns that are of tuple type are not linted. + /// ### Known problems + /// Assignments to patterns that are of tuple type are not linted. /// - /// **Example:** + /// ### Example /// Bad: /// ``` /// # #[derive(Default)] diff --git a/clippy_lints/src/default_numeric_fallback.rs b/clippy_lints/src/default_numeric_fallback.rs index e719a1b0abf..3f1b7ea6214 100644 --- a/clippy_lints/src/default_numeric_fallback.rs +++ b/clippy_lints/src/default_numeric_fallback.rs @@ -18,7 +18,8 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use std::iter; declare_clippy_lint! { - /// **What it does:** Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type + /// ### What it does + /// Checks for usage of unconstrained numeric literals which may cause default numeric fallback in type /// inference. /// /// Default numeric fallback means that if numeric types have not yet been bound to concrete @@ -27,12 +28,14 @@ declare_clippy_lint! { /// /// See [RFC0212](https://github.com/rust-lang/rfcs/blob/master/text/0212-restore-int-fallback.md) for more information about the fallback. /// - /// **Why is this bad?** For those who are very careful about types, default numeric fallback + /// ### Why is this bad? + /// For those who are very careful about types, default numeric fallback /// can be a pitfall that cause unexpected runtime behavior. /// - /// **Known problems:** This lint can only be allowed at the function level or above. + /// ### Known problems + /// This lint can only be allowed at the function level or above. /// - /// **Example:** + /// ### Example /// ```rust /// let i = 10; /// let f = 1.23; diff --git a/clippy_lints/src/deprecated_lints.rs b/clippy_lints/src/deprecated_lints.rs index 2933fbc9341..c604516742c 100644 --- a/clippy_lints/src/deprecated_lints.rs +++ b/clippy_lints/src/deprecated_lints.rs @@ -12,27 +12,33 @@ macro_rules! declare_deprecated_lint { } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** This used to check for `assert!(a == b)` and recommend + /// ### Deprecation reason + /// This used to check for `assert!(a == b)` and recommend /// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011. pub SHOULD_ASSERT_EQ, "`assert!()` will be more flexible with RFC 2011" } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** This used to check for `Vec::extend`, which was slower than + /// ### Deprecation reason + /// This used to check for `Vec::extend`, which was slower than /// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true. pub EXTEND_FROM_SLICE, "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice" } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** `Range::step_by(0)` used to be linted since it's + /// ### Deprecation reason + /// `Range::step_by(0)` used to be linted since it's /// an infinite iterator, which is better expressed by `iter::repeat`, /// but the method has been removed for `Iterator::step_by` which panics /// if given a zero @@ -41,27 +47,33 @@ declare_deprecated_lint! { } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** This used to check for `Vec::as_slice`, which was unstable with good + /// ### Deprecation reason + /// This used to check for `Vec::as_slice`, which was unstable with good /// stable alternatives. `Vec::as_slice` has now been stabilized. pub UNSTABLE_AS_SLICE, "`Vec::as_slice` has been stabilized in 1.7" } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** This used to check for `Vec::as_mut_slice`, which was unstable with good + /// ### Deprecation reason + /// This used to check for `Vec::as_mut_slice`, which was unstable with good /// stable alternatives. `Vec::as_mut_slice` has now been stabilized. pub UNSTABLE_AS_MUT_SLICE, "`Vec::as_mut_slice` has been stabilized in 1.7" } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** This lint should never have applied to non-pointer types, as transmuting + /// ### Deprecation reason + /// This lint should never have applied to non-pointer types, as transmuting /// between non-pointer types of differing alignment is well-defined behavior (it's semantically /// equivalent to a memcpy). This lint has thus been refactored into two separate lints: /// cast_ptr_alignment and transmute_ptr_to_ptr. @@ -70,9 +82,11 @@ declare_deprecated_lint! { } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** This lint is too subjective, not having a good reason for being in clippy. + /// ### Deprecation reason + /// This lint is too subjective, not having a good reason for being in clippy. /// Additionally, compound assignment operators may be overloaded separately from their non-assigning /// counterparts, so this lint may suggest a change in behavior or the code may not compile. pub ASSIGN_OPS, @@ -80,9 +94,11 @@ declare_deprecated_lint! { } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** The original rule will only lint for `if let`. After + /// ### Deprecation reason + /// The original rule will only lint for `if let`. After /// making it support to lint `match`, naming as `if let` is not suitable for it. /// So, this lint is deprecated. pub IF_LET_REDUNDANT_PATTERN_MATCHING, @@ -90,9 +106,11 @@ declare_deprecated_lint! { } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** This lint used to suggest replacing `let mut vec = + /// ### Deprecation reason + /// This lint used to suggest replacing `let mut vec = /// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The /// replacement has very different performance characteristics so the lint is /// deprecated. @@ -101,51 +119,63 @@ declare_deprecated_lint! { } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** This lint has been superseded by #[must_use] in rustc. + /// ### Deprecation reason + /// This lint has been superseded by #[must_use] in rustc. pub UNUSED_COLLECT, "`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint" } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** Associated-constants are now preferred. + /// ### Deprecation reason + /// Associated-constants are now preferred. pub REPLACE_CONSTS, "associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants" } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** The regex! macro does not exist anymore. + /// ### Deprecation reason + /// The regex! macro does not exist anymore. pub REGEX_MACRO, "the regex! macro has been removed from the regex crate in 2018" } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** This lint has been replaced by `manual_find_map`, a + /// ### Deprecation reason + /// This lint has been replaced by `manual_find_map`, a /// more specific lint. pub FIND_MAP, "this lint has been replaced by `manual_find_map`, a more specific lint" } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** This lint has been replaced by `manual_filter_map`, a + /// ### Deprecation reason + /// This lint has been replaced by `manual_filter_map`, a /// more specific lint. pub FILTER_MAP, "this lint has been replaced by `manual_filter_map`, a more specific lint" } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** The `avoid_breaking_exported_api` config option was added, which + /// ### Deprecation reason + /// The `avoid_breaking_exported_api` config option was added, which /// enables the `enum_variant_names` lint for public items. /// ``` pub PUB_ENUM_VARIANT_NAMES, @@ -153,9 +183,11 @@ declare_deprecated_lint! { } declare_deprecated_lint! { - /// **What it does:** Nothing. This lint has been deprecated. + /// ### What it does + /// Nothing. This lint has been deprecated. /// - /// **Deprecation reason:** The `avoid_breaking_exported_api` config option was added, which + /// ### Deprecation reason + /// The `avoid_breaking_exported_api` config option was added, which /// enables the `wrong_self_conversion` lint for public items. pub WRONG_PUB_SELF_CONVENTION, "set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items" diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index 682003f9c2c..ded7001ad8c 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -11,12 +11,14 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::{symbol::sym, Span}; declare_clippy_lint! { - /// **What it does:** Checks for explicit `deref()` or `deref_mut()` method calls. + /// ### What it does + /// Checks for explicit `deref()` or `deref_mut()` method calls. /// - /// **Why is this bad?** Dereferencing by `&*x` or `&mut *x` is clearer and more concise, + /// ### Why is this bad? + /// Dereferencing by `&*x` or `&mut *x` is clearer and more concise, /// when not part of a method chain. /// - /// **Example:** + /// ### Example /// ```rust /// use std::ops::Deref; /// let a: &mut String = &mut String::from("foo"); diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 7aafaf71383..dcfa5253f83 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -15,10 +15,12 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; declare_clippy_lint! { - /// **What it does:** Checks for deriving `Hash` but implementing `PartialEq` + /// ### What it does + /// Checks for deriving `Hash` but implementing `PartialEq` /// explicitly or vice versa. /// - /// **Why is this bad?** The implementation of these traits must agree (for + /// ### Why is this bad? + /// The implementation of these traits must agree (for /// example for use with `HashMap`) so it’s probably a bad idea to use a /// default-generated `Hash` implementation with an explicitly defined /// `PartialEq`. In particular, the following must hold for any type: @@ -27,9 +29,7 @@ declare_clippy_lint! { /// k1 == k2 ⇒ hash(k1) == hash(k2) /// ``` /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// #[derive(Hash)] /// struct Foo; @@ -44,10 +44,12 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for deriving `Ord` but implementing `PartialOrd` + /// ### What it does + /// Checks for deriving `Ord` but implementing `PartialOrd` /// explicitly or vice versa. /// - /// **Why is this bad?** The implementation of these traits must agree (for + /// ### Why is this bad? + /// The implementation of these traits must agree (for /// example for use with `sort`) so it’s probably a bad idea to use a /// default-generated `Ord` implementation with an explicitly defined /// `PartialOrd`. In particular, the following must hold for any type @@ -57,10 +59,7 @@ declare_clippy_lint! { /// k1.cmp(&k2) == k1.partial_cmp(&k2).unwrap() /// ``` /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust,ignore /// #[derive(Ord, PartialEq, Eq)] /// struct Foo; @@ -95,18 +94,21 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for explicit `Clone` implementations for `Copy` + /// ### What it does + /// Checks for explicit `Clone` implementations for `Copy` /// types. /// - /// **Why is this bad?** To avoid surprising behaviour, these traits should + /// ### Why is this bad? + /// To avoid surprising behaviour, these traits should /// agree and the behaviour of `Copy` cannot be overridden. In almost all /// situations a `Copy` type should have a `Clone` implementation that does /// nothing more than copy the object, which is what `#[derive(Copy, Clone)]` /// gets you. /// - /// **Known problems:** Bounds of generic types are sometimes wrong: https://github.com/rust-lang/rust/issues/26925 + /// ### Known problems + /// Bounds of generic types are sometimes wrong: https://github.com/rust-lang/rust/issues/26925 /// - /// **Example:** + /// ### Example /// ```rust,ignore /// #[derive(Copy)] /// struct Foo; @@ -121,16 +123,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for deriving `serde::Deserialize` on a type that + /// ### What it does + /// Checks for deriving `serde::Deserialize` on a type that /// has methods using `unsafe`. /// - /// **Why is this bad?** Deriving `serde::Deserialize` will create a constructor + /// ### Why is this bad? + /// Deriving `serde::Deserialize` will create a constructor /// that may violate invariants hold by another constructor. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust,ignore /// use serde::Deserialize; /// diff --git a/clippy_lints/src/disallowed_method.rs b/clippy_lints/src/disallowed_method.rs index aa1a609afed..7069cb4198c 100644 --- a/clippy_lints/src/disallowed_method.rs +++ b/clippy_lints/src/disallowed_method.rs @@ -8,15 +8,14 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::Symbol; declare_clippy_lint! { - /// **What it does:** Denies the configured methods and functions in clippy.toml + /// ### What it does + /// Denies the configured methods and functions in clippy.toml /// - /// **Why is this bad?** Some methods are undesirable in certain contexts, + /// ### Why is this bad? + /// Some methods are undesirable in certain contexts, /// and it's beneficial to lint for them as needed. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// An example clippy.toml configuration: /// ```toml /// # clippy.toml diff --git a/clippy_lints/src/disallowed_script_idents.rs b/clippy_lints/src/disallowed_script_idents.rs index 12c525634c5..6d38d30cd0b 100644 --- a/clippy_lints/src/disallowed_script_idents.rs +++ b/clippy_lints/src/disallowed_script_idents.rs @@ -6,7 +6,8 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use unicode_script::{Script, UnicodeScript}; declare_clippy_lint! { - /// **What it does:** Checks for usage of unicode scripts other than those explicitly allowed + /// ### What it does + /// Checks for usage of unicode scripts other than those explicitly allowed /// by the lint config. /// /// This lint doesn't take into account non-text scripts such as `Unknown` and `Linear_A`. @@ -19,7 +20,8 @@ declare_clippy_lint! { /// [aliases]: http://www.unicode.org/reports/tr24/tr24-31.html#Script_Value_Aliases /// [supported_scripts]: https://www.unicode.org/iso15924/iso15924-codes.html /// - /// **Why is this bad?** It may be not desired to have many different scripts for + /// ### Why is this bad? + /// It may be not desired to have many different scripts for /// identifiers in the codebase. /// /// Note that if you only want to allow plain English, you might want to use @@ -27,9 +29,7 @@ declare_clippy_lint! { /// /// [`non_ascii_idents`]: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#non-ascii-idents /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Assuming that `clippy.toml` contains the following line: /// // allowed-locales = ["Latin", "Cyrillic"] diff --git a/clippy_lints/src/disallowed_type.rs b/clippy_lints/src/disallowed_type.rs index 7c76e2322c2..e627168b932 100644 --- a/clippy_lints/src/disallowed_type.rs +++ b/clippy_lints/src/disallowed_type.rs @@ -9,14 +9,13 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::{Span, Symbol}; declare_clippy_lint! { - /// **What it does:** Denies the configured types in clippy.toml. + /// ### What it does + /// Denies the configured types in clippy.toml. /// - /// **Why is this bad?** Some types are undesirable in certain contexts. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Some types are undesirable in certain contexts. /// + /// ### Example: /// An example clippy.toml configuration: /// ```toml /// # clippy.toml diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 0c19988a975..c39829fdc7a 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -30,15 +30,18 @@ use std::thread; use url::Url; declare_clippy_lint! { - /// **What it does:** Checks for the presence of `_`, `::` or camel-case words + /// ### What it does + /// Checks for the presence of `_`, `::` or camel-case words /// outside ticks in documentation. /// - /// **Why is this bad?** *Rustdoc* supports markdown formatting, `_`, `::` and + /// ### Why is this bad? + /// *Rustdoc* supports markdown formatting, `_`, `::` and /// camel-case probably indicates some code which should be included between /// ticks. `_` can also be used for emphasis in markdown, this lint tries to /// consider that. /// - /// **Known problems:** Lots of bad docs won’t be fixed, what the lint checks + /// ### Known problems + /// Lots of bad docs won’t be fixed, what the lint checks /// for is limited, and there are still false positives. HTML elements and their /// content are not linted. /// @@ -47,7 +50,7 @@ declare_clippy_lint! { /// `[`SmallVec<[T; INLINE_CAPACITY]>`]` and then [`SmallVec<[T; INLINE_CAPACITY]>`]: SmallVec /// would fail. /// - /// **Examples:** + /// ### Examples /// ```rust /// /// Do something with the foo_bar parameter. See also /// /// that::other::module::foo. @@ -68,15 +71,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the doc comments of publicly visible + /// ### What it does + /// Checks for the doc comments of publicly visible /// unsafe functions and warns if there is no `# Safety` section. /// - /// **Why is this bad?** Unsafe functions should document their safety + /// ### Why is this bad? + /// Unsafe functions should document their safety /// preconditions, so that users can be sure they are using them safely. /// - /// **Known problems:** None. - /// - /// **Examples:** + /// ### Examples /// ```rust ///# type Universe = (); /// /// This function should really be documented @@ -102,16 +105,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks the doc comments of publicly visible functions that + /// ### What it does + /// Checks the doc comments of publicly visible functions that /// return a `Result` type and warns if there is no `# Errors` section. /// - /// **Why is this bad?** Documenting the type of errors that can be returned from a + /// ### Why is this bad? + /// Documenting the type of errors that can be returned from a /// function can help callers write code to handle the errors appropriately. /// - /// **Known problems:** None. - /// - /// **Examples:** - /// + /// ### Examples /// Since the following function returns a `Result` it has an `# Errors` section in /// its doc comment: /// @@ -131,16 +133,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks the doc comments of publicly visible functions that + /// ### What it does + /// Checks the doc comments of publicly visible functions that /// may panic and warns if there is no `# Panics` section. /// - /// **Why is this bad?** Documenting the scenarios in which panicking occurs + /// ### Why is this bad? + /// Documenting the scenarios in which panicking occurs /// can help callers who do not want to panic to avoid those situations. /// - /// **Known problems:** None. - /// - /// **Examples:** - /// + /// ### Examples /// Since the following function may panic it has a `# Panics` section in /// its doc comment: /// @@ -162,14 +163,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `fn main() { .. }` in doctests + /// ### What it does + /// Checks for `fn main() { .. }` in doctests /// - /// **Why is this bad?** The test can be shorter (and likely more readable) + /// ### Why is this bad? + /// The test can be shorter (and likely more readable) /// if the `fn main()` is left implicit. /// - /// **Known problems:** None. - /// - /// **Examples:** + /// ### Examples /// ``````rust /// /// An example of a doctest with a `main()` function /// /// diff --git a/clippy_lints/src/double_comparison.rs b/clippy_lints/src/double_comparison.rs index 4966638cb1b..6520bb91faf 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -10,14 +10,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; declare_clippy_lint! { - /// **What it does:** Checks for double comparisons that could be simplified to a single expression. + /// ### What it does + /// Checks for double comparisons that could be simplified to a single expression. /// /// - /// **Why is this bad?** Readability. + /// ### Why is this bad? + /// Readability. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let x = 1; /// # let y = 2; diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index e4e4a93b011..d0d87b6df9a 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -4,14 +4,14 @@ use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for unnecessary double parentheses. + /// ### What it does + /// Checks for unnecessary double parentheses. /// - /// **Why is this bad?** This makes code harder to read and might indicate a + /// ### Why is this bad? + /// This makes code harder to read and might indicate a /// mistake. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// fn simple_double_parens() -> i32 { diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index b5b29760636..0f3dc866afb 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -8,17 +8,17 @@ use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for calls to `std::mem::drop` with a reference + /// ### What it does + /// Checks for calls to `std::mem::drop` with a reference /// instead of an owned value. /// - /// **Why is this bad?** Calling `drop` on a reference will only drop the + /// ### Why is this bad? + /// Calling `drop` on a reference will only drop the /// reference itself, which is a no-op. It will not call the `drop` method (from /// the `Drop` trait implementation) on the underlying referenced value, which /// is likely what was intended. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// let mut lock_guard = mutex.lock(); /// std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex @@ -31,17 +31,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to `std::mem::forget` with a reference + /// ### What it does + /// Checks for calls to `std::mem::forget` with a reference /// instead of an owned value. /// - /// **Why is this bad?** Calling `forget` on a reference will only forget the + /// ### Why is this bad? + /// Calling `forget` on a reference will only forget the /// reference itself, which is a no-op. It will not forget the underlying /// referenced /// value, which is likely what was intended. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x = Box::new(1); /// std::mem::forget(&x) // Should have been forget(x), x will still be dropped @@ -52,16 +52,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to `std::mem::drop` with a value + /// ### What it does + /// Checks for calls to `std::mem::drop` with a value /// that derives the Copy trait /// - /// **Why is this bad?** Calling `std::mem::drop` [does nothing for types that + /// ### Why is this bad? + /// Calling `std::mem::drop` [does nothing for types that /// implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html), since the /// value will be copied and moved into the function on invocation. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x: i32 = 42; // i32 implements Copy /// std::mem::drop(x) // A copy of x is passed to the function, leaving the @@ -73,10 +73,12 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to `std::mem::forget` with a value that + /// ### What it does + /// Checks for calls to `std::mem::forget` with a value that /// derives the Copy trait /// - /// **Why is this bad?** Calling `std::mem::forget` [does nothing for types that + /// ### Why is this bad? + /// Calling `std::mem::forget` [does nothing for types that /// implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the /// value will be copied and moved into the function on invocation. /// @@ -86,9 +88,7 @@ declare_clippy_lint! { /// there /// is nothing for `std::mem::forget` to ignore. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x: i32 = 42; // i32 implements Copy /// std::mem::forget(x) // A copy of x is passed to the function, leaving the diff --git a/clippy_lints/src/duration_subsec.rs b/clippy_lints/src/duration_subsec.rs index 94b09bf7173..3774de62521 100644 --- a/clippy_lints/src/duration_subsec.rs +++ b/clippy_lints/src/duration_subsec.rs @@ -12,15 +12,15 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::paths; declare_clippy_lint! { - /// **What it does:** Checks for calculation of subsecond microseconds or milliseconds + /// ### What it does + /// Checks for calculation of subsecond microseconds or milliseconds /// from other `Duration` methods. /// - /// **Why is this bad?** It's more concise to call `Duration::subsec_micros()` or + /// ### Why is this bad? + /// It's more concise to call `Duration::subsec_micros()` or /// `Duration::subsec_millis()` than to calculate them. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # use std::time::Duration; /// let dur = Duration::new(5, 0); diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs index 26984df9539..0541ac5eccc 100644 --- a/clippy_lints/src/else_if_without_else.rs +++ b/clippy_lints/src/else_if_without_else.rs @@ -7,14 +7,14 @@ use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for usage of if expressions with an `else if` branch, + /// ### What it does + /// Checks for usage of if expressions with an `else if` branch, /// but without a final `else` branch. /// - /// **Why is this bad?** Some coding guidelines require this (e.g., MISRA-C:2004 Rule 14.10). + /// ### Why is this bad? + /// Some coding guidelines require this (e.g., MISRA-C:2004 Rule 14.10). /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # fn a() {} /// # fn b() {} diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs index c92984a9834..3453c2da278 100644 --- a/clippy_lints/src/empty_enum.rs +++ b/clippy_lints/src/empty_enum.rs @@ -6,13 +6,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for `enum`s with no variants. + /// ### What it does + /// Checks for `enum`s with no variants. /// /// As of this writing, the `never_type` is still a /// nightly-only experimental API. Therefore, this lint is only triggered /// if the `never_type` is enabled. /// - /// **Why is this bad?** If you want to introduce a type which + /// ### Why is this bad? + /// If you want to introduce a type which /// can't be instantiated, you should use `!` (the primitive type "never"), /// or a wrapper around it, because `!` has more extensive /// compiler support (type inference, etc...) and wrappers @@ -20,10 +22,7 @@ declare_clippy_lint! { /// For further information visit [never type documentation](https://doc.rust-lang.org/std/primitive.never.html) /// /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// Bad: /// ```rust /// enum Test {} diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 2eb8b1422ed..e1d0d65edb1 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -16,12 +16,15 @@ use rustc_span::{Span, SyntaxContext, DUMMY_SP}; use std::fmt::Write; declare_clippy_lint! { - /// **What it does:** Checks for uses of `contains_key` + `insert` on `HashMap` + /// ### What it does + /// Checks for uses of `contains_key` + `insert` on `HashMap` /// or `BTreeMap`. /// - /// **Why is this bad?** Using `entry` is more efficient. + /// ### Why is this bad? + /// Using `entry` is more efficient. /// - /// **Known problems:** The suggestion may have type inference errors in some cases. e.g. + /// ### Known problems + /// The suggestion may have type inference errors in some cases. e.g. /// ```rust /// let mut map = std::collections::HashMap::new(); /// let _ = if !map.contains_key(&0) { @@ -31,7 +34,7 @@ declare_clippy_lint! { /// }; /// ``` /// - /// **Example:** + /// ### Example /// ```rust /// # use std::collections::HashMap; /// # let mut map = HashMap::new(); diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index 021136ac5e0..a2c3c7a7b49 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -11,15 +11,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use std::convert::TryFrom; declare_clippy_lint! { - /// **What it does:** Checks for C-like enumerations that are + /// ### What it does + /// Checks for C-like enumerations that are /// `repr(isize/usize)` and have values that don't fit into an `i32`. /// - /// **Why is this bad?** This will truncate the variant value on 32 bit + /// ### Why is this bad? + /// This will truncate the variant value on 32 bit /// architectures, but works fine on 64 bit. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # #[cfg(target_pointer_width = "64")] /// #[repr(usize)] diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index b1a105a51c1..32b95745b64 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -10,15 +10,15 @@ use rustc_span::source_map::Span; use rustc_span::symbol::Symbol; declare_clippy_lint! { - /// **What it does:** Detects enumeration variants that are prefixed or suffixed + /// ### What it does + /// Detects enumeration variants that are prefixed or suffixed /// by the same characters. /// - /// **Why is this bad?** Enumeration variant names should specify their variant, + /// ### Why is this bad? + /// Enumeration variant names should specify their variant, /// not repeat the enumeration name. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// enum Cake { /// BlackForestCake, @@ -40,14 +40,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Detects type names that are prefixed or suffixed by the + /// ### What it does + /// Detects type names that are prefixed or suffixed by the /// containing module's name. /// - /// **Why is this bad?** It requires the user to type the module name twice. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// It requires the user to type the module name twice. /// - /// **Example:** + /// ### Example /// ```rust /// mod cake { /// struct BlackForestCake; @@ -65,10 +65,12 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for modules that have the same name as their + /// ### What it does + /// Checks for modules that have the same name as their /// parent module /// - /// **Why is this bad?** A typical beginner mistake is to have `mod foo;` and + /// ### Why is this bad? + /// A typical beginner mistake is to have `mod foo;` and /// again `mod foo { .. /// }` in `foo.rs`. /// The expectation is that items inside the inner `mod foo { .. }` are then @@ -78,9 +80,7 @@ declare_clippy_lint! { /// If this is done on purpose, it would be better to choose a more /// representative module name. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// // lib.rs /// mod foo; diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index d39cabfb282..51d5094e8c9 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -9,18 +9,21 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for equal operands to comparison, logical and + /// ### What it does + /// Checks for equal operands to comparison, logical and /// bitwise, difference and division binary operators (`==`, `>`, etc., `&&`, /// `||`, `&`, `|`, `^`, `-` and `/`). /// - /// **Why is this bad?** This is usually just a typo or a copy and paste error. + /// ### Why is this bad? + /// This is usually just a typo or a copy and paste error. /// - /// **Known problems:** False negatives: We had some false positives regarding + /// ### Known problems + /// False negatives: We had some false positives regarding /// calls (notably [racer](https://github.com/phildawes/racer) had one instance /// of `x.pop() && x.pop()`), so we removed matching any function or method /// calls. We may introduce a list of known pure functions in the future. /// - /// **Example:** + /// ### Example /// ```rust /// # let x = 1; /// if x + 1 == x + 1 {} @@ -37,15 +40,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for arguments to `==` which have their address + /// ### What it does + /// Checks for arguments to `==` which have their address /// taken to satisfy a bound /// and suggests to dereference the other argument instead /// - /// **Why is this bad?** It is more idiomatic to dereference the other argument. + /// ### Why is this bad? + /// It is more idiomatic to dereference the other argument. /// - /// **Known problems:** None + /// ### Known problems + /// None /// - /// **Example:** + /// ### Example /// ```ignore /// // Bad /// &x == y diff --git a/clippy_lints/src/erasing_op.rs b/clippy_lints/src/erasing_op.rs index 4aa9c25b1b0..026d14d0ea2 100644 --- a/clippy_lints/src/erasing_op.rs +++ b/clippy_lints/src/erasing_op.rs @@ -6,15 +6,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; declare_clippy_lint! { - /// **What it does:** Checks for erasing operations, e.g., `x * 0`. + /// ### What it does + /// Checks for erasing operations, e.g., `x * 0`. /// - /// **Why is this bad?** The whole expression can be replaced by zero. + /// ### Why is this bad? + /// The whole expression can be replaced by zero. /// This is most likely not the intended outcome and should probably be /// corrected /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x = 1; /// 0 / x; diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 5f400d079da..8b0e9e6bc9b 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -19,16 +19,16 @@ pub struct BoxedLocal { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `Box` where an unboxed `T` would + /// ### What it does + /// Checks for usage of `Box` where an unboxed `T` would /// work fine. /// - /// **Why is this bad?** This is an unnecessary allocation, and bad for + /// ### Why is this bad? + /// This is an unnecessary allocation, and bad for /// performance. It is only necessary to allocate if you wish to move the box /// into something. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # fn foo(bar: usize) {} /// // Bad diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 667eb8eb283..192b69e18f9 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -14,19 +14,22 @@ use rustc_middle::ty::{self, ClosureKind, Ty}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for closures which just call another function where + /// ### What it does + /// Checks for closures which just call another function where /// the function can be called directly. `unsafe` functions or calls where types /// get adjusted are ignored. /// - /// **Why is this bad?** Needlessly creating a closure adds code for no benefit + /// ### Why is this bad? + /// Needlessly creating a closure adds code for no benefit /// and gives the optimizer more work. /// - /// **Known problems:** If creating the closure inside the closure has a side- + /// ### Known problems + /// If creating the closure inside the closure has a side- /// effect then moving the closure creation out will change when that side- /// effect runs. /// See [#1439](https://github.com/rust-lang/rust-clippy/issues/1439) for more details. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // Bad /// xs.map(|x| foo(x)) @@ -42,17 +45,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for closures which only invoke a method on the closure + /// ### What it does + /// Checks for closures which only invoke a method on the closure /// argument and can be replaced by referencing the method directly. /// - /// **Why is this bad?** It's unnecessary to create the closure. + /// ### Why is this bad? + /// It's unnecessary to create the closure. /// - /// **Known problems:** [#3071](https://github.com/rust-lang/rust-clippy/issues/3071), + /// ### Known problems + /// [#3071](https://github.com/rust-lang/rust-clippy/issues/3071), /// [#3942](https://github.com/rust-lang/rust-clippy/issues/3942), /// [#4002](https://github.com/rust-lang/rust-clippy/issues/4002) /// /// - /// **Example:** + /// ### Example /// ```rust,ignore /// Some('a').map(|s| s.to_uppercase()); /// ``` diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 03a8b40df55..f72a1e446d5 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -9,17 +9,20 @@ use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for a read and a write to the same variable where + /// ### What it does + /// Checks for a read and a write to the same variable where /// whether the read occurs before or after the write depends on the evaluation /// order of sub-expressions. /// - /// **Why is this bad?** It is often confusing to read. In addition, the + /// ### Why is this bad? + /// It is often confusing to read. In addition, the /// sub-expression evaluation order for Rust is not well documented. /// - /// **Known problems:** Code which intentionally depends on the evaluation + /// ### Known problems + /// Code which intentionally depends on the evaluation /// order, or which is correct for any evaluation order. /// - /// **Example:** + /// ### Example /// ```rust /// let mut x = 0; /// @@ -43,16 +46,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for diverging calls that are not match arms or + /// ### What it does + /// Checks for diverging calls that are not match arms or /// statements. /// - /// **Why is this bad?** It is often confusing to read. In addition, the + /// ### Why is this bad? + /// It is often confusing to read. In addition, the /// sub-expression evaluation order for Rust is not well documented. /// - /// **Known problems:** Someone might want to use `some_bool || panic!()` as a + /// ### Known problems + /// Someone might want to use `some_bool || panic!()` as a /// shorthand. /// - /// **Example:** + /// ### Example /// ```rust,no_run /// # fn b() -> bool { true } /// # fn c() -> bool { true } diff --git a/clippy_lints/src/excessive_bools.rs b/clippy_lints/src/excessive_bools.rs index 4e2dbf005d5..476e6d23f12 100644 --- a/clippy_lints/src/excessive_bools.rs +++ b/clippy_lints/src/excessive_bools.rs @@ -8,19 +8,19 @@ use rustc_span::{sym, Span}; use std::convert::TryInto; declare_clippy_lint! { - /// **What it does:** Checks for excessive + /// ### What it does + /// Checks for excessive /// use of bools in structs. /// - /// **Why is this bad?** Excessive bools in a struct + /// ### Why is this bad? + /// Excessive bools in a struct /// is often a sign that it's used as a state machine, /// which is much better implemented as an enum. /// If it's not the case, excessive bools usually benefit /// from refactoring into two-variant enums for better /// readability and API. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// Bad: /// ```rust /// struct S { @@ -44,19 +44,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for excessive use of + /// ### What it does + /// Checks for excessive use of /// bools in function definitions. /// - /// **Why is this bad?** Calls to such functions + /// ### Why is this bad? + /// Calls to such functions /// are confusing and error prone, because it's /// hard to remember argument order and you have /// no type system support to back you up. Using /// two-variant enums instead of bools often makes /// API easier to use. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// Bad: /// ```rust,ignore /// fn f(is_round: bool, is_hot: bool) { ... } diff --git a/clippy_lints/src/exhaustive_items.rs b/clippy_lints/src/exhaustive_items.rs index 60ad2e8ee14..e00126046c0 100644 --- a/clippy_lints/src/exhaustive_items.rs +++ b/clippy_lints/src/exhaustive_items.rs @@ -8,16 +8,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Warns on any exported `enum`s that are not tagged `#[non_exhaustive]` + /// ### What it does + /// Warns on any exported `enum`s that are not tagged `#[non_exhaustive]` /// - /// **Why is this bad?** Exhaustive enums are typically fine, but a project which does + /// ### Why is this bad? + /// Exhaustive enums are typically fine, but a project which does /// not wish to make a stability commitment around exported enums may wish to /// disable them by default. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// enum Foo { /// Bar, @@ -38,16 +37,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns on any exported `structs`s that are not tagged `#[non_exhaustive]` + /// ### What it does + /// Warns on any exported `structs`s that are not tagged `#[non_exhaustive]` /// - /// **Why is this bad?** Exhaustive structs are typically fine, but a project which does + /// ### Why is this bad? + /// Exhaustive structs are typically fine, but a project which does /// not wish to make a stability commitment around exported structs may wish to /// disable them by default. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// struct Foo { /// bar: u8, diff --git a/clippy_lints/src/exit.rs b/clippy_lints/src/exit.rs index 16246e548b6..9cd5b2d9f44 100644 --- a/clippy_lints/src/exit.rs +++ b/clippy_lints/src/exit.rs @@ -6,15 +6,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** `exit()` terminates the program and doesn't provide a + /// ### What it does + /// `exit()` terminates the program and doesn't provide a /// stack trace. /// - /// **Why is this bad?** Ideally a program is terminated by finishing + /// ### Why is this bad? + /// Ideally a program is terminated by finishing /// the main function. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// std::process::exit(0) /// ``` diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index 66724294804..4f46ef906f4 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -9,14 +9,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for usage of `write!()` / `writeln()!` which can be + /// ### What it does + /// Checks for usage of `write!()` / `writeln()!` which can be /// replaced with `(e)print!()` / `(e)println!()` /// - /// **Why is this bad?** Using `(e)println! is clearer and more concise + /// ### Why is this bad? + /// Using `(e)println! is clearer and more concise /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # use std::io::Write; /// # let bar = "furchtbar"; diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 2937fcb9ca0..7e4d1b3ef9f 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -10,13 +10,13 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{sym, Span}; declare_clippy_lint! { - /// **What it does:** Checks for impls of `From<..>` that contain `panic!()` or `unwrap()` + /// ### What it does + /// Checks for impls of `From<..>` that contain `panic!()` or `unwrap()` /// - /// **Why is this bad?** `TryFrom` should be used if there's a possibility of failure. + /// ### Why is this bad? + /// `TryFrom` should be used if there's a possibility of failure. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// struct Foo(i32); /// diff --git a/clippy_lints/src/float_equality_without_abs.rs b/clippy_lints/src/float_equality_without_abs.rs index 1e503cc795c..c33d80b8e8e 100644 --- a/clippy_lints/src/float_equality_without_abs.rs +++ b/clippy_lints/src/float_equality_without_abs.rs @@ -11,30 +11,32 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Spanned; declare_clippy_lint! { - /// **What it does:** Checks for statements of the form `(a - b) < f32::EPSILON` or - /// `(a - b) < f64::EPSILON`. Notes the missing `.abs()`. - /// - /// **Why is this bad?** The code without `.abs()` is more likely to have a bug. - /// - /// **Known problems:** If the user can ensure that b is larger than a, the `.abs()` is - /// technically unneccessary. However, it will make the code more robust and doesn't have any - /// large performance implications. If the abs call was deliberately left out for performance - /// reasons, it is probably better to state this explicitly in the code, which then can be done - /// with an allow. - /// - /// **Example:** - /// - /// ```rust - /// pub fn is_roughly_equal(a: f32, b: f32) -> bool { - /// (a - b) < f32::EPSILON - /// } - /// ``` - /// Use instead: - /// ```rust - /// pub fn is_roughly_equal(a: f32, b: f32) -> bool { - /// (a - b).abs() < f32::EPSILON - /// } - /// ``` + /// ### What it does + /// Checks for statements of the form `(a - b) < f32::EPSILON` or + /// `(a - b) < f64::EPSILON`. Notes the missing `.abs()`. + /// + /// ### Why is this bad? + /// The code without `.abs()` is more likely to have a bug. + /// + /// ### Known problems + /// If the user can ensure that b is larger than a, the `.abs()` is + /// technically unneccessary. However, it will make the code more robust and doesn't have any + /// large performance implications. If the abs call was deliberately left out for performance + /// reasons, it is probably better to state this explicitly in the code, which then can be done + /// with an allow. + /// + /// ### Example + /// ```rust + /// pub fn is_roughly_equal(a: f32, b: f32) -> bool { + /// (a - b) < f32::EPSILON + /// } + /// ``` + /// Use instead: + /// ```rust + /// pub fn is_roughly_equal(a: f32, b: f32) -> bool { + /// (a - b).abs() < f32::EPSILON + /// } + /// ``` pub FLOAT_EQUALITY_WITHOUT_ABS, suspicious, "float equality check without `.abs()`" diff --git a/clippy_lints/src/float_literal.rs b/clippy_lints/src/float_literal.rs index 7968e7b764d..a3d70f31f00 100644 --- a/clippy_lints/src/float_literal.rs +++ b/clippy_lints/src/float_literal.rs @@ -10,15 +10,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use std::fmt; declare_clippy_lint! { - /// **What it does:** Checks for float literals with a precision greater + /// ### What it does + /// Checks for float literals with a precision greater /// than that supported by the underlying type. /// - /// **Why is this bad?** Rust will truncate the literal silently. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Rust will truncate the literal silently. /// + /// ### Example /// ```rust /// // Bad /// let v: f32 = 0.123_456_789_9; @@ -34,16 +33,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for whole number float literals that + /// ### What it does + /// Checks for whole number float literals that /// cannot be represented as the underlying type without loss. /// - /// **Why is this bad?** Rust will silently lose precision during + /// ### Why is this bad? + /// Rust will silently lose precision during /// conversion to a float. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Bad /// let _: f32 = 16_777_217.0; // 16_777_216.0 diff --git a/clippy_lints/src/floating_point_arithmetic.rs b/clippy_lints/src/floating_point_arithmetic.rs index e38384b01d4..b01c0cdd846 100644 --- a/clippy_lints/src/floating_point_arithmetic.rs +++ b/clippy_lints/src/floating_point_arithmetic.rs @@ -18,16 +18,15 @@ use std::f64::consts as f64_consts; use sugg::Sugg; declare_clippy_lint! { - /// **What it does:** Looks for floating-point expressions that + /// ### What it does + /// Looks for floating-point expressions that /// can be expressed using built-in methods to improve accuracy /// at the cost of performance. /// - /// **Why is this bad?** Negatively impacts accuracy. - /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Why is this bad? + /// Negatively impacts accuracy. /// + /// ### Example /// ```rust /// let a = 3f32; /// let _ = a.powf(1.0 / 3.0); @@ -49,16 +48,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Looks for floating-point expressions that + /// ### What it does + /// Looks for floating-point expressions that /// can be expressed using built-in methods to improve both /// accuracy and performance. /// - /// **Why is this bad?** Negatively impacts accuracy and performance. - /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Why is this bad? + /// Negatively impacts accuracy and performance. /// + /// ### Example /// ```rust /// use std::f32::consts::E; /// diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index ca3490d8eda..863c606f5a9 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -13,18 +13,18 @@ use rustc_span::symbol::kw; use rustc_span::{sym, Span}; declare_clippy_lint! { - /// **What it does:** Checks for the use of `format!("string literal with no + /// ### What it does + /// Checks for the use of `format!("string literal with no /// argument")` and `format!("{}", foo)` where `foo` is a string. /// - /// **Why is this bad?** There is no point of doing that. `format!("foo")` can + /// ### Why is this bad? + /// There is no point of doing that. `format!("foo")` can /// be replaced by `"foo".to_owned()` if you really need a `String`. The even /// worse `&format!("foo")` is often encountered in the wild. `format!("{}", /// foo)` can be replaced by `foo.clone()` if `foo: String` or `foo.to_owned()` /// if `foo: &str`. /// - /// **Known problems:** None. - /// - /// **Examples:** + /// ### Examples /// ```rust /// /// // Bad diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 8aefb8d46f6..b4cf1971d78 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -9,15 +9,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; declare_clippy_lint! { - /// **What it does:** Checks for use of the non-existent `=*`, `=!` and `=-` + /// ### What it does + /// Checks for use of the non-existent `=*`, `=!` and `=-` /// operators. /// - /// **Why is this bad?** This is either a typo of `*=`, `!=` or `-=` or + /// ### Why is this bad? + /// This is either a typo of `*=`, `!=` or `-=` or /// confusing. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// a =- 42; // confusing, should it be `a -= 42` or `a = -42`? /// ``` @@ -27,15 +27,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks the formatting of a unary operator on the right hand side + /// ### What it does + /// Checks the formatting of a unary operator on the right hand side /// of a binary operator. It lints if there is no space between the binary and unary operators, /// but there is a space between the unary and its operand. /// - /// **Why is this bad?** This is either a typo in the binary operator or confusing. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// This is either a typo in the binary operator or confusing. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// if foo <- 30 { // this should be `foo < -30` but looks like a different operator /// } @@ -49,15 +49,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for formatting of `else`. It lints if the `else` + /// ### What it does + /// Checks for formatting of `else`. It lints if the `else` /// is followed immediately by a newline or the `else` seems to be missing. /// - /// **Why is this bad?** This is probably some refactoring remnant, even if the + /// ### Why is this bad? + /// This is probably some refactoring remnant, even if the /// code is correct, it might look confusing. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// if foo { /// } { // looks like an `else` is missing here @@ -85,14 +85,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for possible missing comma in an array. It lints if + /// ### What it does + /// Checks for possible missing comma in an array. It lints if /// an array element is a binary operator expression and it lies on two lines. /// - /// **Why is this bad?** This could lead to unexpected results. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// This could lead to unexpected results. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// let a = &[ /// -1, -2, -3 // <= no comma here diff --git a/clippy_lints/src/from_over_into.rs b/clippy_lints/src/from_over_into.rs index 48316c3a61d..623546cd1de 100644 --- a/clippy_lints/src/from_over_into.rs +++ b/clippy_lints/src/from_over_into.rs @@ -8,14 +8,13 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::symbol::sym; declare_clippy_lint! { - /// **What it does:** Searches for implementations of the `Into<..>` trait and suggests to implement `From<..>` instead. + /// ### What it does + /// Searches for implementations of the `Into<..>` trait and suggests to implement `From<..>` instead. /// - /// **Why is this bad?** According the std docs implementing `From<..>` is preferred since it gives you `Into<..>` for free where the reverse isn't true. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// According the std docs implementing `From<..>` is preferred since it gives you `Into<..>` for free where the reverse isn't true. /// + /// ### Example /// ```rust /// struct StringWrapper(String); /// diff --git a/clippy_lints/src/from_str_radix_10.rs b/clippy_lints/src/from_str_radix_10.rs index 3da5bc95b6d..cc4bb85c50f 100644 --- a/clippy_lints/src/from_str_radix_10.rs +++ b/clippy_lints/src/from_str_radix_10.rs @@ -10,20 +10,22 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; declare_clippy_lint! { - /// **What it does:** + /// ### What it does + /// /// Checks for function invocations of the form `primitive::from_str_radix(s, 10)` /// - /// **Why is this bad?** + /// ### Why is this bad? + /// /// This specific common use case can be rewritten as `s.parse::()` /// (and in most cases, the turbofish can be removed), which reduces code length /// and complexity. /// - /// **Known problems:** + /// ### Known problems + /// /// This lint may suggest using (&).parse() instead of .parse() directly /// in some cases, which is correct but adds unnecessary complexity to the code. /// - /// **Example:** - /// + /// ### Example /// ```ignore /// let input: &str = get_input(); /// let num = u16::from_str_radix(input, 10)?; diff --git a/clippy_lints/src/functions/mod.rs b/clippy_lints/src/functions/mod.rs index 2beb9bc94bf..ce23c0ce4a0 100644 --- a/clippy_lints/src/functions/mod.rs +++ b/clippy_lints/src/functions/mod.rs @@ -11,15 +11,15 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** Checks for functions with too many parameters. + /// ### What it does + /// Checks for functions with too many parameters. /// - /// **Why is this bad?** Functions with lots of parameters are considered bad + /// ### Why is this bad? + /// Functions with lots of parameters are considered bad /// style and reduce readability (“what does the 5th parameter mean?”). Consider /// grouping some parameters into a new type. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # struct Color; /// fn foo(x: u32, y: u32, name: &str, c: Color, w: f32, h: f32, a: f32, b: f32) { @@ -32,16 +32,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for functions with a large amount of lines. + /// ### What it does + /// Checks for functions with a large amount of lines. /// - /// **Why is this bad?** Functions with a lot of lines are harder to understand + /// ### Why is this bad? + /// Functions with a lot of lines are harder to understand /// due to having to look at a larger amount of code to understand what the /// function is doing. Consider splitting the body of the function into /// multiple functions. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn im_too_long() { /// println!(""); @@ -55,15 +55,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for public functions that dereference raw pointer + /// ### What it does + /// Checks for public functions that dereference raw pointer /// arguments but are not marked `unsafe`. /// - /// **Why is this bad?** The function should probably be marked `unsafe`, since + /// ### Why is this bad? + /// The function should probably be marked `unsafe`, since /// for an arbitrary raw pointer, there is no way of telling for sure if it is /// valid. /// - /// **Known problems:** - /// + /// ### Known problems /// * It does not check functions recursively so if the pointer is passed to a /// private non-`unsafe` function which does the dereferencing, the lint won't /// trigger. @@ -71,7 +72,7 @@ declare_clippy_lint! { /// got from an argument in some other way (`fn foo(bar: &[*const u8])` or /// `some_argument.get_raw_ptr()`). /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // Bad /// pub fn foo(x: *const u8) { @@ -89,17 +90,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for a [`#[must_use]`] attribute on + /// ### What it does + /// Checks for a [`#[must_use]`] attribute on /// unit-returning functions and methods. /// /// [`#[must_use]`]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute /// - /// **Why is this bad?** Unit values are useless. The attribute is likely + /// ### Why is this bad? + /// Unit values are useless. The attribute is likely /// a remnant of a refactoring that removed the return type. /// - /// **Known problems:** None. - /// - /// **Examples:** + /// ### Examples /// ```rust /// #[must_use] /// fn useless() { } @@ -110,19 +111,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for a [`#[must_use]`] attribute without + /// ### What it does + /// Checks for a [`#[must_use]`] attribute without /// further information on functions and methods that return a type already /// marked as `#[must_use]`. /// /// [`#[must_use]`]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute /// - /// **Why is this bad?** The attribute isn't needed. Not using the result + /// ### Why is this bad? + /// The attribute isn't needed. Not using the result /// will already be reported. Alternatively, one can add some text to the /// attribute to improve the lint message. /// - /// **Known problems:** None. - /// - /// **Examples:** + /// ### Examples /// ```rust /// #[must_use] /// fn double_must_use() -> Result<(), ()> { @@ -135,16 +136,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for public functions that have no + /// ### What it does + /// Checks for public functions that have no /// [`#[must_use]`] attribute, but return something not already marked /// must-use, have no mutable arg and mutate no statics. /// /// [`#[must_use]`]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute /// - /// **Why is this bad?** Not bad at all, this lint just shows places where + /// ### Why is this bad? + /// Not bad at all, this lint just shows places where /// you could add the attribute. /// - /// **Known problems:** The lint only checks the arguments for mutable + /// ### Known problems + /// The lint only checks the arguments for mutable /// types without looking if they are actually changed. On the other hand, /// it also ignores a broad range of potentially interesting side effects, /// because we cannot decide whether the programmer intends the function to @@ -152,7 +156,7 @@ declare_clippy_lint! { /// positives. At least we don't lint if the result type is unit or already /// `#[must_use]`. /// - /// **Examples:** + /// ### Examples /// ```rust /// // this could be annotated with `#[must_use]`. /// fn id(t: T) -> T { t } @@ -163,20 +167,23 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for public functions that return a `Result` + /// ### What it does + /// Checks for public functions that return a `Result` /// with an `Err` type of `()`. It suggests using a custom type that /// implements `std::error::Error`. /// - /// **Why is this bad?** Unit does not implement `Error` and carries no + /// ### Why is this bad? + /// Unit does not implement `Error` and carries no /// further information about what went wrong. /// - /// **Known problems:** Of course, this lint assumes that `Result` is used + /// ### Known problems + /// Of course, this lint assumes that `Result` is used /// for a fallible operation (which is after all the intended use). However /// code may opt to (mis)use it as a basic two-variant-enum. In that case, /// the suggestion is misguided, and the code should use a custom enum /// instead. /// - /// **Examples:** + /// ### Examples /// ```rust /// pub fn read_u8() -> Result { Err(()) } /// ``` diff --git a/clippy_lints/src/future_not_send.rs b/clippy_lints/src/future_not_send.rs index 515b8887453..0be03969bcb 100644 --- a/clippy_lints/src/future_not_send.rs +++ b/clippy_lints/src/future_not_send.rs @@ -12,12 +12,14 @@ use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt; use rustc_trait_selection::traits::{self, FulfillmentError, TraitEngine}; declare_clippy_lint! { - /// **What it does:** This lint requires Future implementations returned from + /// ### What it does + /// This lint requires Future implementations returned from /// functions and methods to implement the `Send` marker trait. It is mostly /// used by library authors (public and internal) that target an audience where /// multithreaded executors are likely to be used for running these Futures. /// - /// **Why is this bad?** A Future implementation captures some state that it + /// ### Why is this bad? + /// A Future implementation captures some state that it /// needs to eventually produce its final value. When targeting a multithreaded /// executor (which is the norm on non-embedded devices) this means that this /// state may need to be transported to other threads, in other words the @@ -31,10 +33,7 @@ declare_clippy_lint! { /// modifying the library where the offending Future implementation is /// produced. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// async fn not_send(bytes: std::rc::Rc<[u8]>) {} /// ``` diff --git a/clippy_lints/src/get_last_with_len.rs b/clippy_lints/src/get_last_with_len.rs index 8e45fdfecc4..ced35030de8 100644 --- a/clippy_lints/src/get_last_with_len.rs +++ b/clippy_lints/src/get_last_with_len.rs @@ -14,10 +14,12 @@ use rustc_span::source_map::Spanned; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for using `x.get(x.len() - 1)` instead of + /// ### What it does + /// Checks for using `x.get(x.len() - 1)` instead of /// `x.last()`. /// - /// **Why is this bad?** Using `x.last()` is easier to read and has the same + /// ### Why is this bad? + /// Using `x.last()` is easier to read and has the same /// result. /// /// Note that using `x[x.len() - 1]` is semantically different from @@ -27,10 +29,7 @@ declare_clippy_lint! { /// There is another lint (get_unwrap) that covers the case of using /// `x.get(index).unwrap()` instead of `x[index]`. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Bad /// let x = vec![2, 3, 5]; diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index 99c461930e4..5feb0ce8dec 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -11,14 +11,14 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::{clip, unsext}; declare_clippy_lint! { - /// **What it does:** Checks for identity operations, e.g., `x + 0`. + /// ### What it does + /// Checks for identity operations, e.g., `x + 0`. /// - /// **Why is this bad?** This code can be removed without changing the + /// ### Why is this bad? + /// This code can be removed without changing the /// meaning. So it just obscures what's going on. Delete it mercilessly. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let x = 1; /// x / 1 + 0 * 1 - 0 | 0; diff --git a/clippy_lints/src/if_let_mutex.rs b/clippy_lints/src/if_let_mutex.rs index 5403d76ea30..d3ddeda9fd1 100644 --- a/clippy_lints/src/if_let_mutex.rs +++ b/clippy_lints/src/if_let_mutex.rs @@ -9,16 +9,15 @@ use rustc_middle::hir::map::Map; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for `Mutex::lock` calls in `if let` expression + /// ### What it does + /// Checks for `Mutex::lock` calls in `if let` expression /// with lock calls in any of the else blocks. /// - /// **Why is this bad?** The Mutex lock remains held for the whole + /// ### Why is this bad? + /// The Mutex lock remains held for the whole /// `if let ... else` block and deadlocks. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust,ignore /// if let Ok(thing) = mutex.lock() { /// do_thing(); diff --git a/clippy_lints/src/if_let_some_result.rs b/clippy_lints/src/if_let_some_result.rs index 611da3744ee..587307811a1 100644 --- a/clippy_lints/src/if_let_some_result.rs +++ b/clippy_lints/src/if_let_some_result.rs @@ -10,14 +10,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:*** Checks for unnecessary `ok()` in if let. + /// ### What it does + ///* Checks for unnecessary `ok()` in if let. /// - /// **Why is this bad?** Calling `ok()` in if let is unnecessary, instead match + /// ### Why is this bad? + /// Calling `ok()` in if let is unnecessary, instead match /// on `Ok(pat)` /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// for i in iter { /// if let Some(value) = i.parse().ok() { diff --git a/clippy_lints/src/if_not_else.rs b/clippy_lints/src/if_not_else.rs index c56f67df061..28db7233d70 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -8,14 +8,14 @@ use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for usage of `!` or `!=` in an if condition with an + /// ### What it does + /// Checks for usage of `!` or `!=` in an if condition with an /// else branch. /// - /// **Why is this bad?** Negations reduce the readability of statements. + /// ### Why is this bad? + /// Negations reduce the readability of statements. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let v: Vec = vec![]; /// # fn a() {} diff --git a/clippy_lints/src/if_then_some_else_none.rs b/clippy_lints/src/if_then_some_else_none.rs index eadcd0867a8..17b9a2f888e 100644 --- a/clippy_lints/src/if_then_some_else_none.rs +++ b/clippy_lints/src/if_then_some_else_none.rs @@ -10,14 +10,13 @@ use rustc_semver::RustcVersion; use rustc_session::{declare_tool_lint, impl_lint_pass}; declare_clippy_lint! { - /// **What it does:** Checks for if-else that could be written to `bool::then`. + /// ### What it does + /// Checks for if-else that could be written to `bool::then`. /// - /// **Why is this bad?** Looks a little redundant. Using `bool::then` helps it have less lines of code. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Looks a little redundant. Using `bool::then` helps it have less lines of code. /// + /// ### Example /// ```rust /// # let v = vec![0]; /// let a = if v.is_empty() { diff --git a/clippy_lints/src/implicit_hasher.rs b/clippy_lints/src/implicit_hasher.rs index 879d6a75bbe..aae44f64e66 100644 --- a/clippy_lints/src/implicit_hasher.rs +++ b/clippy_lints/src/implicit_hasher.rs @@ -22,18 +22,21 @@ use clippy_utils::source::{snippet, snippet_opt}; use clippy_utils::ty::is_type_diagnostic_item; declare_clippy_lint! { - /// **What it does:** Checks for public `impl` or `fn` missing generalization + /// ### What it does + /// Checks for public `impl` or `fn` missing generalization /// over different hashers and implicitly defaulting to the default hashing /// algorithm (`SipHash`). /// - /// **Why is this bad?** `HashMap` or `HashSet` with custom hashers cannot be + /// ### Why is this bad? + /// `HashMap` or `HashSet` with custom hashers cannot be /// used with them. /// - /// **Known problems:** Suggestions for replacing constructors can contain + /// ### Known problems + /// Suggestions for replacing constructors can contain /// false-positives. Also applying suggestions can require modification of other /// pieces of code, possibly including external crates. /// - /// **Example:** + /// ### Example /// ```rust /// # use std::collections::HashMap; /// # use std::hash::{Hash, BuildHasher}; diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index f2f830ca5c0..fa7b5302cb1 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -13,17 +13,17 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{Span, SyntaxContext}; declare_clippy_lint! { - /// **What it does:** Checks for missing return statements at the end of a block. + /// ### What it does + /// Checks for missing return statements at the end of a block. /// - /// **Why is this bad?** Actually omitting the return keyword is idiomatic Rust code. Programmers + /// ### Why is this bad? + /// Actually omitting the return keyword is idiomatic Rust code. Programmers /// coming from other languages might prefer the expressiveness of `return`. It's possible to miss /// the last returning statement because the only difference is a missing `;`. Especially in bigger /// code with multiple return paths having a `return` keyword makes it easier to find the /// corresponding statements. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn foo(x: usize) -> usize { /// x diff --git a/clippy_lints/src/implicit_saturating_sub.rs b/clippy_lints/src/implicit_saturating_sub.rs index 4069a685ea0..0a7d31dce2f 100644 --- a/clippy_lints/src/implicit_saturating_sub.rs +++ b/clippy_lints/src/implicit_saturating_sub.rs @@ -8,14 +8,13 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for implicit saturating subtraction. + /// ### What it does + /// Checks for implicit saturating subtraction. /// - /// **Why is this bad?** Simplicity and readability. Instead we can easily use an builtin function. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Simplicity and readability. Instead we can easily use an builtin function. /// + /// ### Example /// ```rust /// let end: u32 = 10; /// let start: u32 = 5; diff --git a/clippy_lints/src/inconsistent_struct_constructor.rs b/clippy_lints/src/inconsistent_struct_constructor.rs index 3b635071f28..1f8240a1f63 100644 --- a/clippy_lints/src/inconsistent_struct_constructor.rs +++ b/clippy_lints/src/inconsistent_struct_constructor.rs @@ -10,11 +10,13 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::Symbol; declare_clippy_lint! { - /// **What it does:** Checks for struct constructors where all fields are shorthand and + /// ### What it does + /// Checks for struct constructors where all fields are shorthand and /// the order of the field init shorthand in the constructor is inconsistent /// with the order in the struct definition. /// - /// **Why is this bad?** Since the order of fields in a constructor doesn't affect the + /// ### Why is this bad? + /// Since the order of fields in a constructor doesn't affect the /// resulted instance as the below example indicates, /// /// ```rust @@ -32,10 +34,7 @@ declare_clippy_lint! { /// /// inconsistent order can be confusing and decreases readability and consistency. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// struct Foo { /// x: i32, diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index bfa284f333a..8c1f1073309 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -10,14 +10,17 @@ use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for out of bounds array indexing with a constant + /// ### What it does + /// Checks for out of bounds array indexing with a constant /// index. /// - /// **Why is this bad?** This will always panic at runtime. + /// ### Why is this bad? + /// This will always panic at runtime. /// - /// **Known problems:** Hopefully none. + /// ### Known problems + /// Hopefully none. /// - /// **Example:** + /// ### Example /// ```no_run /// # #![allow(const_err)] /// let x = [1, 2, 3, 4]; @@ -36,16 +39,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of indexing or slicing. Arrays are special cases, this lint + /// ### What it does + /// Checks for usage of indexing or slicing. Arrays are special cases, this lint /// does report on arrays if we can tell that slicing operations are in bounds and does not /// lint on constant `usize` indexing on arrays because that is handled by rustc's `const_err` lint. /// - /// **Why is this bad?** Indexing and slicing can panic at runtime and there are + /// ### Why is this bad? + /// Indexing and slicing can panic at runtime and there are /// safe alternatives. /// - /// **Known problems:** Hopefully none. + /// ### Known problems + /// Hopefully none. /// - /// **Example:** + /// ### Example /// ```rust,no_run /// // Vector /// let x = vec![0; 5]; diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index 295a4e1fccb..2411a3175b9 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -7,14 +7,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::{sym, Symbol}; declare_clippy_lint! { - /// **What it does:** Checks for iteration that is guaranteed to be infinite. + /// ### What it does + /// Checks for iteration that is guaranteed to be infinite. /// - /// **Why is this bad?** While there may be places where this is acceptable + /// ### Why is this bad? + /// While there may be places where this is acceptable /// (e.g., in event streams), in most cases this is simply an error. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```no_run /// use std::iter; /// @@ -26,15 +26,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for iteration that may be infinite. + /// ### What it does + /// Checks for iteration that may be infinite. /// - /// **Why is this bad?** While there may be places where this is acceptable + /// ### Why is this bad? + /// While there may be places where this is acceptable /// (e.g., in event streams), in most cases this is simply an error. /// - /// **Known problems:** The code may have a condition to stop iteration, but + /// ### Known problems + /// The code may have a condition to stop iteration, but /// this lint is not clever enough to analyze it. /// - /// **Example:** + /// ### Example /// ```rust /// let infinite_iter = 0..; /// [0..].iter().zip(infinite_iter.take_while(|x| *x > 5)); diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index 9641784eb9a..d87055c842c 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -10,13 +10,13 @@ use rustc_span::Span; use std::collections::hash_map::Entry; declare_clippy_lint! { - /// **What it does:** Checks for multiple inherent implementations of a struct + /// ### What it does + /// Checks for multiple inherent implementations of a struct /// - /// **Why is this bad?** Splitting the implementation of a type makes the code harder to navigate. + /// ### Why is this bad? + /// Splitting the implementation of a type makes the code harder to navigate. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// struct X; /// impl X { diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index b023e13e846..b62fad4bd39 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -8,14 +8,16 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`. + /// ### What it does + /// Checks for the definition of inherent methods with a signature of `to_string(&self) -> String`. /// - /// **Why is this bad?** This method is also implicitly defined if a type implements the `Display` trait. As the functionality of `Display` is much more versatile, it should be preferred. + /// ### Why is this bad? + /// This method is also implicitly defined if a type implements the `Display` trait. As the functionality of `Display` is much more versatile, it should be preferred. /// - /// **Known problems:** None - /// - /// ** Example:** + /// ### Known problems + /// None /// + /// ### Example /// ```rust /// // Bad /// pub struct A; @@ -45,14 +47,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the definition of inherent methods with a signature of `to_string(&self) -> String` and if the type implementing this method also implements the `Display` trait. - /// - /// **Why is this bad?** This method is also implicitly defined if a type implements the `Display` trait. The less versatile inherent method will then shadow the implementation introduced by `Display`. + /// ### What it does + /// Checks for the definition of inherent methods with a signature of `to_string(&self) -> String` and if the type implementing this method also implements the `Display` trait. /// - /// **Known problems:** None + /// ### Why is this bad? + /// This method is also implicitly defined if a type implements the `Display` trait. The less versatile inherent method will then shadow the implementation introduced by `Display`. /// - /// ** Example:** + /// ### Known problems + /// None /// + /// ### Example /// ```rust /// // Bad /// use std::fmt; diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index 20f00bd51ba..3e3df903f17 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -10,14 +10,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{sym, Symbol}; declare_clippy_lint! { - /// **What it does:** Checks for `#[inline]` on trait methods without bodies + /// ### What it does + /// Checks for `#[inline]` on trait methods without bodies /// - /// **Why is this bad?** Only implementations of trait methods may be inlined. + /// ### Why is this bad? + /// Only implementations of trait methods may be inlined. /// The inline attribute is ignored for trait methods without bodies. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// trait Animal { /// #[inline] diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index c4a1222b51f..49b69dd072a 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -8,13 +8,13 @@ use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for usage of `x >= y + 1` or `x - 1 >= y` (and `<=`) in a block + /// ### What it does + /// Checks for usage of `x >= y + 1` or `x - 1 >= y` (and `<=`) in a block /// - /// **Why is this bad?** Readability -- better to use `> y` instead of `>= y + 1`. + /// ### Why is this bad? + /// Readability -- better to use `> y` instead of `>= y + 1`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let x = 1; /// # let y = 1; diff --git a/clippy_lints/src/integer_division.rs b/clippy_lints/src/integer_division.rs index e5482f675e7..a0e6f12b812 100644 --- a/clippy_lints/src/integer_division.rs +++ b/clippy_lints/src/integer_division.rs @@ -5,15 +5,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for division of integers + /// ### What it does + /// Checks for division of integers /// - /// **Why is this bad?** When outside of some very specific algorithms, + /// ### Why is this bad? + /// When outside of some very specific algorithms, /// integer division is very often a mistake because it discards the /// remainder. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// let x = 3 / 2; diff --git a/clippy_lints/src/invalid_upcast_comparisons.rs b/clippy_lints/src/invalid_upcast_comparisons.rs index 37011f5578d..3b28b121204 100644 --- a/clippy_lints/src/invalid_upcast_comparisons.rs +++ b/clippy_lints/src/invalid_upcast_comparisons.rs @@ -14,18 +14,20 @@ use clippy_utils::source::snippet; use clippy_utils::{comparisons, sext}; declare_clippy_lint! { - /// **What it does:** Checks for comparisons where the relation is always either + /// ### What it does + /// Checks for comparisons where the relation is always either /// true or false, but where one side has been upcast so that the comparison is /// necessary. Only integer types are checked. /// - /// **Why is this bad?** An expression like `let x : u8 = ...; (x as u32) > 300` + /// ### Why is this bad? + /// An expression like `let x : u8 = ...; (x as u32) > 300` /// will mistakenly imply that it is possible for `x` to be outside the range of /// `u8`. /// - /// **Known problems:** + /// ### Known problems /// https://github.com/rust-lang/rust-clippy/issues/886 /// - /// **Example:** + /// ### Example /// ```rust /// let x: u8 = 1; /// (x as u32) > 300; diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index c69571f32a2..429c6ed7d2d 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -7,15 +7,15 @@ use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for items declared after some statement in a block. + /// ### What it does + /// Checks for items declared after some statement in a block. /// - /// **Why is this bad?** Items live for the entire scope they are declared + /// ### Why is this bad? + /// Items live for the entire scope they are declared /// in. But statements are processed in order. This might cause confusion as /// it's hard to figure out which item is meant in a statement. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// fn foo() { diff --git a/clippy_lints/src/large_const_arrays.rs b/clippy_lints/src/large_const_arrays.rs index 48dc5fefe99..5d4e06c2af0 100644 --- a/clippy_lints/src/large_const_arrays.rs +++ b/clippy_lints/src/large_const_arrays.rs @@ -11,15 +11,15 @@ use rustc_span::{BytePos, Pos, Span}; use rustc_typeck::hir_ty_to_ty; declare_clippy_lint! { - /// **What it does:** Checks for large `const` arrays that should + /// ### What it does + /// Checks for large `const` arrays that should /// be defined as `static` instead. /// - /// **Why is this bad?** Performance: const variables are inlined upon use. + /// ### Why is this bad? + /// Performance: const variables are inlined upon use. /// Static items result in only one instance and has a fixed location in memory. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // Bad /// pub const a = [0u32; 1_000_000]; diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index f166748d86b..cde2336b690 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -10,20 +10,22 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_target::abi::LayoutOf; declare_clippy_lint! { - /// **What it does:** Checks for large size differences between variants on + /// ### What it does + /// Checks for large size differences between variants on /// `enum`s. /// - /// **Why is this bad?** Enum size is bounded by the largest variant. Having a + /// ### Why is this bad? + /// Enum size is bounded by the largest variant. Having a /// large variant can penalize the memory layout of that enum. /// - /// **Known problems:** This lint obviously cannot take the distribution of + /// ### Known problems + /// This lint obviously cannot take the distribution of /// variants in your running program into account. It is possible that the /// smaller variants make up less than 1% of all instances, in which case /// the overhead is negligible and the boxing is counter-productive. Always /// measure the change this lint suggests. /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Bad /// enum Test { diff --git a/clippy_lints/src/large_stack_arrays.rs b/clippy_lints/src/large_stack_arrays.rs index c46b98022c6..7088630bfdb 100644 --- a/clippy_lints/src/large_stack_arrays.rs +++ b/clippy_lints/src/large_stack_arrays.rs @@ -10,13 +10,13 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use crate::rustc_target::abi::LayoutOf; declare_clippy_lint! { - /// **What it does:** Checks for local arrays that may be too large. + /// ### What it does + /// Checks for local arrays that may be too large. /// - /// **Why is this bad?** Large local arrays may cause stack overflow. + /// ### Why is this bad? + /// Large local arrays may cause stack overflow. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// let a = [0u32; 1_000_000]; /// ``` diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 892b3af0b32..b66d7a9f729 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -18,17 +18,17 @@ use rustc_span::{ }; declare_clippy_lint! { - /// **What it does:** Checks for getting the length of something via `.len()` + /// ### What it does + /// Checks for getting the length of something via `.len()` /// just to compare to zero, and suggests using `.is_empty()` where applicable. /// - /// **Why is this bad?** Some structures can answer `.is_empty()` much faster + /// ### Why is this bad? + /// Some structures can answer `.is_empty()` much faster /// than calculating their length. So it is good to get into the habit of using /// `.is_empty()`, and having it is cheap. /// Besides, it makes the intent clearer than a manual comparison in some contexts. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// if x.len() == 0 { /// .. @@ -52,18 +52,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for items that implement `.len()` but not + /// ### What it does + /// Checks for items that implement `.len()` but not /// `.is_empty()`. /// - /// **Why is this bad?** It is good custom to have both methods, because for + /// ### Why is this bad? + /// It is good custom to have both methods, because for /// some data structures, asking about the length will be a costly operation, /// whereas `.is_empty()` can usually answer in constant time. Also it used to /// lead to false positives on the [`len_zero`](#len_zero) lint – currently that /// lint will ignore such entities. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// impl X { /// pub fn len(&self) -> usize { @@ -77,17 +77,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for comparing to an empty slice such as `""` or `[]`, + /// ### What it does + /// Checks for comparing to an empty slice such as `""` or `[]`, /// and suggests using `.is_empty()` where applicable. /// - /// **Why is this bad?** Some structures can answer `.is_empty()` much faster + /// ### Why is this bad? + /// Some structures can answer `.is_empty()` much faster /// than checking for equality. So it is good to get into the habit of using /// `.is_empty()`, and having it is cheap. /// Besides, it makes the intent clearer than a manual comparison in some contexts. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// /// ```ignore /// if s == "" { diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 67eae4d87bb..13f0d43cf8d 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -9,14 +9,14 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for variable declarations immediately followed by a + /// ### What it does + /// Checks for variable declarations immediately followed by a /// conditional affectation. /// - /// **Why is this bad?** This is not idiomatic Rust. + /// ### Why is this bad? + /// This is not idiomatic Rust. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// let foo; /// diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index e627b1385bc..8992d25932c 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -9,15 +9,15 @@ use rustc_middle::ty::subst::GenericArgKind; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for `let _ = ` + /// ### What it does + /// Checks for `let _ = ` /// where expr is #[must_use] /// - /// **Why is this bad?** It's better to explicitly + /// ### Why is this bad? + /// It's better to explicitly /// handle the value of a #[must_use] expr /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn f() -> Result { /// Ok(0) @@ -33,17 +33,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `let _ = sync_lock` + /// ### What it does + /// Checks for `let _ = sync_lock` /// - /// **Why is this bad?** This statement immediately drops the lock instead of + /// ### Why is this bad? + /// This statement immediately drops the lock instead of /// extending its lifetime to the end of the scope, which is often not intended. /// To extend lock lifetime to the end of the scope, use an underscore-prefixed /// name instead (i.e. _lock). If you want to explicitly drop the lock, /// `std::mem::drop` conveys your intention better and is less error-prone. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// /// Bad: /// ```rust,ignore @@ -60,19 +60,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `let _ = ` + /// ### What it does + /// Checks for `let _ = ` /// where expr has a type that implements `Drop` /// - /// **Why is this bad?** This statement immediately drops the initializer + /// ### Why is this bad? + /// This statement immediately drops the initializer /// expression instead of extending its lifetime to the end of the scope, which /// is often not intended. To extend the expression's lifetime to the end of the /// scope, use an underscore-prefixed name instead (i.e. _var). If you want to /// explicitly drop the expression, `std::mem::drop` conveys your intention /// better and is less error-prone. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// /// Bad: /// ```rust,ignore diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index aa763b5c5e6..3cffb507f70 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -73,14 +73,13 @@ use rustc_session::Session; /// use clippy_lints::declare_clippy_lint; /// /// declare_clippy_lint! { -/// /// **What it does:** Checks for ... (describe what the lint matches). +/// /// ### What it does +/// /// Checks for ... (describe what the lint matches). /// /// -/// /// **Why is this bad?** Supply the reason for linting the code. -/// /// -/// /// **Known problems:** None. (Or describe where it could go wrong.) -/// /// -/// /// **Example:** +/// /// ### Why is this bad? +/// /// Supply the reason for linting the code. /// /// +/// /// ### Example /// /// ```rust /// /// // Bad /// /// Insert a short example of code that triggers the lint diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 5ae68ba5b2f..e5e6f8d25cc 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -18,20 +18,22 @@ use rustc_span::source_map::Span; use rustc_span::symbol::{kw, Symbol}; declare_clippy_lint! { - /// **What it does:** Checks for lifetime annotations which can be removed by + /// ### What it does + /// Checks for lifetime annotations which can be removed by /// relying on lifetime elision. /// - /// **Why is this bad?** The additional lifetimes make the code look more + /// ### Why is this bad? + /// The additional lifetimes make the code look more /// complicated, while there is nothing out of the ordinary going on. Removing /// them leads to more readable code. /// - /// **Known problems:** + /// ### Known problems /// - We bail out if the function has a `where` clause where lifetimes /// are mentioned due to potenial false positives. /// - Lifetime bounds such as `impl Foo + 'a` and `T: 'a` must be elided with the /// placeholder notation `'_` because the fully elided notation leaves the type bound to `'static`. /// - /// **Example:** + /// ### Example /// ```rust /// // Bad: unnecessary lifetime annotations /// fn in_and_out<'a>(x: &'a u8, y: u8) -> &'a u8 { @@ -50,16 +52,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for lifetimes in generics that are never used + /// ### What it does + /// Checks for lifetimes in generics that are never used /// anywhere else. /// - /// **Why is this bad?** The additional lifetimes make the code look more + /// ### Why is this bad? + /// The additional lifetimes make the code look more /// complicated, while there is nothing out of the ordinary going on. Removing /// them leads to more readable code. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Bad: unnecessary lifetimes /// fn unused_lifetime<'a>(x: u8) { diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index e0c5578bd60..699ddce0cff 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -16,15 +16,14 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use std::iter; declare_clippy_lint! { - /// **What it does:** Warns if a long integral or floating-point constant does + /// ### What it does + /// Warns if a long integral or floating-point constant does /// not contain underscores. /// - /// **Why is this bad?** Reading long numbers is difficult without separators. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Reading long numbers is difficult without separators. /// + /// ### Example /// ```rust /// // Bad /// let x: u64 = 61864918973511; @@ -38,17 +37,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns for mistyped suffix in literals + /// ### What it does + /// Warns for mistyped suffix in literals /// - /// **Why is this bad?** This is most probably a typo + /// ### Why is this bad? + /// This is most probably a typo /// - /// **Known problems:** + /// ### Known problems /// - Recommends a signed suffix, even though the number might be too big and an unsigned /// suffix is required /// - Does not match on `_127` since that is a valid grouping for decimal and octal numbers /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Probably mistyped /// 2_32; @@ -62,16 +62,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns if an integral or floating-point constant is + /// ### What it does + /// Warns if an integral or floating-point constant is /// grouped inconsistently with underscores. /// - /// **Why is this bad?** Readers may incorrectly interpret inconsistently + /// ### Why is this bad? + /// Readers may incorrectly interpret inconsistently /// grouped digits. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Bad /// let x: u64 = 618_64_9189_73_511; @@ -85,15 +84,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns if hexadecimal or binary literals are not grouped + /// ### What it does + /// Warns if hexadecimal or binary literals are not grouped /// by nibble or byte. /// - /// **Why is this bad?** Negatively impacts readability. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Negatively impacts readability. /// + /// ### Example /// ```rust /// let x: u32 = 0xFFF_FFF; /// let y: u8 = 0b01_011_101; @@ -104,16 +102,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns if the digits of an integral or floating-point + /// ### What it does + /// Warns if the digits of an integral or floating-point /// constant are grouped into groups that /// are too large. /// - /// **Why is this bad?** Negatively impacts readability. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Negatively impacts readability. /// + /// ### Example /// ```rust /// let x: u64 = 6186491_8973511; /// ``` @@ -123,15 +120,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns if there is a better representation for a numeric literal. + /// ### What it does + /// Warns if there is a better representation for a numeric literal. /// - /// **Why is this bad?** Especially for big powers of 2 a hexadecimal representation is more + /// ### Why is this bad? + /// Especially for big powers of 2 a hexadecimal representation is more /// readable than a decimal representation. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// `255` => `0xFF` /// `65_535` => `0xFFFF` /// `4_042_322_160` => `0xF0F0_F0F0` diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 56a123b69c6..7ca54d53972 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -26,14 +26,14 @@ use rustc_span::source_map::Span; use utils::{get_span_of_entire_for_loop, make_iterator_snippet, IncrementVisitor, InitializeVisitor}; declare_clippy_lint! { - /// **What it does:** Checks for for-loops that manually copy items between + /// ### What it does + /// Checks for for-loops that manually copy items between /// slices that could be optimized by having a memcpy. /// - /// **Why is this bad?** It is not as fast as a memcpy. + /// ### Why is this bad? + /// It is not as fast as a memcpy. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let src = vec![1]; /// # let mut dst = vec![0; 65]; @@ -53,15 +53,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for looping over the range of `0..len` of some + /// ### What it does + /// Checks for looping over the range of `0..len` of some /// collection just to get the values by index. /// - /// **Why is this bad?** Just iterating the collection itself makes the intent + /// ### Why is this bad? + /// Just iterating the collection itself makes the intent /// more clear and is probably faster. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let vec = vec!['a', 'b', 'c']; /// for i in 0..vec.len() { @@ -81,15 +81,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for loops on `x.iter()` where `&x` will do, and + /// ### What it does + /// Checks for loops on `x.iter()` where `&x` will do, and /// suggests the latter. /// - /// **Why is this bad?** Readability. + /// ### Why is this bad? + /// Readability. /// - /// **Known problems:** False negatives. We currently only warn on some known + /// ### Known problems + /// False negatives. We currently only warn on some known /// types. /// - /// **Example:** + /// ### Example /// ```rust /// // with `y` a `Vec` or slice: /// # let y = vec![1]; @@ -110,14 +113,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for loops on `y.into_iter()` where `y` will do, and + /// ### What it does + /// Checks for loops on `y.into_iter()` where `y` will do, and /// suggests the latter. /// - /// **Why is this bad?** Readability. + /// ### Why is this bad? + /// Readability. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// # let y = vec![1]; /// // with `y` a `Vec` or slice: @@ -138,18 +141,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for loops on `x.next()`. + /// ### What it does + /// Checks for loops on `x.next()`. /// - /// **Why is this bad?** `next()` returns either `Some(value)` if there was a + /// ### Why is this bad? + /// `next()` returns either `Some(value)` if there was a /// value, or `None` otherwise. The insidious thing is that `Option<_>` /// implements `IntoIterator`, so that possibly one value will be iterated, /// leading to some hard to find bugs. No one will want to write such code /// [except to win an Underhanded Rust /// Contest](https://www.reddit.com/r/rust/comments/3hb0wm/underhanded_rust_contest/cu5yuhr). /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// for x in y.next() { /// .. @@ -161,14 +164,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `for` loops over `Option` or `Result` values. + /// ### What it does + /// Checks for `for` loops over `Option` or `Result` values. /// - /// **Why is this bad?** Readability. This is more clearly expressed as an `if + /// ### Why is this bad? + /// Readability. This is more clearly expressed as an `if /// let`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let opt = Some(1); /// @@ -204,15 +207,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Detects `loop + match` combinations that are easier + /// ### What it does + /// Detects `loop + match` combinations that are easier /// written as a `while let` loop. /// - /// **Why is this bad?** The `while let` loop is usually shorter and more + /// ### Why is this bad? + /// The `while let` loop is usually shorter and more /// readable. /// - /// **Known problems:** Sometimes the wrong binding is displayed ([#383](https://github.com/rust-lang/rust-clippy/issues/383)). + /// ### Known problems + /// Sometimes the wrong binding is displayed ([#383](https://github.com/rust-lang/rust-clippy/issues/383)). /// - /// **Example:** + /// ### Example /// ```rust,no_run /// # let y = Some(1); /// loop { @@ -233,16 +239,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for functions collecting an iterator when collect + /// ### What it does + /// Checks for functions collecting an iterator when collect /// is not needed. /// - /// **Why is this bad?** `collect` causes the allocation of a new data structure, + /// ### Why is this bad? + /// `collect` causes the allocation of a new data structure, /// when this allocation may not be needed. /// - /// **Known problems:** - /// None - /// - /// **Example:** + /// ### Example /// ```rust /// # let iterator = vec![1].into_iter(); /// let len = iterator.clone().collect::>().len(); @@ -255,15 +260,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks `for` loops over slices with an explicit counter + /// ### What it does + /// Checks `for` loops over slices with an explicit counter /// and suggests the use of `.enumerate()`. /// - /// **Why is it bad?** Using `.enumerate()` makes the intent more clear, + /// ### Why is this bad? + /// Using `.enumerate()` makes the intent more clear, /// declutters the code and may be faster in some instances. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let v = vec![1]; /// # fn bar(bar: usize, baz: usize) {} @@ -285,9 +290,11 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for empty `loop` expressions. + /// ### What it does + /// Checks for empty `loop` expressions. /// - /// **Why is this bad?** These busy loops burn CPU cycles without doing + /// ### Why is this bad? + /// These busy loops burn CPU cycles without doing /// anything. It is _almost always_ a better idea to `panic!` than to have /// a busy loop. /// @@ -306,9 +313,7 @@ declare_clippy_lint! { /// - [`x86_64::instructions::hlt`](https://docs.rs/x86_64/0.12.2/x86_64/instructions/fn.hlt.html) /// - [`cortex_m::asm::wfi`](https://docs.rs/cortex-m/0.6.3/cortex_m/asm/fn.wfi.html) /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```no_run /// loop {} /// ``` @@ -318,14 +323,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `while let` expressions on iterators. + /// ### What it does + /// Checks for `while let` expressions on iterators. /// - /// **Why is this bad?** Readability. A simple `for` loop is shorter and conveys + /// ### Why is this bad? + /// Readability. A simple `for` loop is shorter and conveys /// the intent better. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// while let Some(val) = iter() { /// .. @@ -337,15 +342,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for iterating a map (`HashMap` or `BTreeMap`) and + /// ### What it does + /// Checks for iterating a map (`HashMap` or `BTreeMap`) and /// ignoring either the keys or values. /// - /// **Why is this bad?** Readability. There are `keys` and `values` methods that + /// ### Why is this bad? + /// Readability. There are `keys` and `values` methods that /// can be used to express that don't need the values or keys. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// for (k, _) in &map { /// .. @@ -365,15 +370,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for loops that will always `break`, `return` or + /// ### What it does + /// Checks for loops that will always `break`, `return` or /// `continue` an outer loop. /// - /// **Why is this bad?** This loop never loops, all it does is obfuscating the + /// ### Why is this bad? + /// This loop never loops, all it does is obfuscating the /// code. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// loop { /// ..; @@ -386,13 +391,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for loops which have a range bound that is a mutable variable - /// - /// **Why is this bad?** One might think that modifying the mutable variable changes the loop bounds + /// ### What it does + /// Checks for loops which have a range bound that is a mutable variable /// - /// **Known problems:** None + /// ### Why is this bad? + /// One might think that modifying the mutable variable changes the loop bounds /// - /// **Example:** + /// ### Example /// ```rust /// let mut foo = 42; /// for i in 0..foo { @@ -406,17 +411,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks whether variables used within while loop condition + /// ### What it does + /// Checks whether variables used within while loop condition /// can be (and are) mutated in the body. /// - /// **Why is this bad?** If the condition is unchanged, entering the body of the loop + /// ### Why is this bad? + /// If the condition is unchanged, entering the body of the loop /// will lead to an infinite loop. /// - /// **Known problems:** If the `while`-loop is in a closure, the check for mutation of the + /// ### Known problems + /// If the `while`-loop is in a closure, the check for mutation of the /// condition variables in the body can cause false negatives. For example when only `Upvar` `a` is /// in the condition and only `Upvar` `b` gets mutated in the body, the lint will not trigger. /// - /// **Example:** + /// ### Example /// ```rust /// let i = 0; /// while i > 10 { @@ -429,15 +437,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks whether a for loop is being used to push a constant + /// ### What it does + /// Checks whether a for loop is being used to push a constant /// value into a Vec. /// - /// **Why is this bad?** This kind of operation can be expressed more succinctly with + /// ### Why is this bad? + /// This kind of operation can be expressed more succinctly with /// `vec![item;SIZE]` or `vec.resize(NEW_SIZE, item)` and using these alternatives may also /// have better performance. - /// **Known problems:** None /// - /// **Example:** + /// ### Example /// ```rust /// let item1 = 2; /// let item2 = 3; @@ -462,13 +471,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks whether a for loop has a single element. + /// ### What it does + /// Checks whether a for loop has a single element. /// - /// **Why is this bad?** There is no reason to have a loop of a + /// ### Why is this bad? + /// There is no reason to have a loop of a /// single element. - /// **Known problems:** None /// - /// **Example:** + /// ### Example /// ```rust /// let item1 = 2; /// for item in &[item1] { @@ -487,15 +497,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Check for unnecessary `if let` usage in a for loop + /// ### What it does + /// Check for unnecessary `if let` usage in a for loop /// where only the `Some` or `Ok` variant of the iterator element is used. /// - /// **Why is this bad?** It is verbose and can be simplified + /// ### Why is this bad? + /// It is verbose and can be simplified /// by first calling the `flatten` method on the `Iterator`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// /// ```rust /// let x = vec![Some(1), Some(2), Some(3)]; diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs index 66479ae264e..a371f8bbd3c 100644 --- a/clippy_lints/src/macro_use.rs +++ b/clippy_lints/src/macro_use.rs @@ -12,14 +12,14 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::{edition::Edition, sym, Span}; declare_clippy_lint! { - /// **What it does:** Checks for `#[macro_use] use...`. + /// ### What it does + /// Checks for `#[macro_use] use...`. /// - /// **Why is this bad?** Since the Rust 2018 edition you can import + /// ### Why is this bad? + /// Since the Rust 2018 edition you can import /// macro's directly, this is considered idiomatic. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// #[macro_use] /// use some_macro; diff --git a/clippy_lints/src/main_recursion.rs b/clippy_lints/src/main_recursion.rs index 07d8a440aea..776e4b3fe76 100644 --- a/clippy_lints/src/main_recursion.rs +++ b/clippy_lints/src/main_recursion.rs @@ -7,14 +7,14 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; declare_clippy_lint! { - /// **What it does:** Checks for recursion using the entrypoint. + /// ### What it does + /// Checks for recursion using the entrypoint. /// - /// **Why is this bad?** Apart from special setups (which we could detect following attributes like #![no_std]), + /// ### Why is this bad? + /// Apart from special setups (which we could detect following attributes like #![no_std]), /// recursing into main() seems like an unintuitive antipattern we should be able to detect. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```no_run /// fn main() { /// main(); diff --git a/clippy_lints/src/manual_async_fn.rs b/clippy_lints/src/manual_async_fn.rs index 5d88ff3b99f..8e1385fb83a 100644 --- a/clippy_lints/src/manual_async_fn.rs +++ b/clippy_lints/src/manual_async_fn.rs @@ -14,14 +14,13 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{sym, Span}; declare_clippy_lint! { - /// **What it does:** It checks for manual implementations of `async` functions. + /// ### What it does + /// It checks for manual implementations of `async` functions. /// - /// **Why is this bad?** It's more idiomatic to use the dedicated syntax. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// It's more idiomatic to use the dedicated syntax. /// + /// ### Example /// ```rust /// use std::future::Future; /// diff --git a/clippy_lints/src/manual_map.rs b/clippy_lints/src/manual_map.rs index 563d5cdb5fb..7dec1595e0d 100644 --- a/clippy_lints/src/manual_map.rs +++ b/clippy_lints/src/manual_map.rs @@ -16,14 +16,13 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{sym, SyntaxContext}; declare_clippy_lint! { - /// **What it does:** Checks for usages of `match` which could be implemented using `map` + /// ### What it does + /// Checks for usages of `match` which could be implemented using `map` /// - /// **Why is this bad?** Using the `map` method is clearer and more concise. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Using the `map` method is clearer and more concise. /// + /// ### Example /// ```rust /// match Some(0) { /// Some(x) => Some(x + 1), diff --git a/clippy_lints/src/manual_non_exhaustive.rs b/clippy_lints/src/manual_non_exhaustive.rs index 54f714b54b6..335ea001ee4 100644 --- a/clippy_lints/src/manual_non_exhaustive.rs +++ b/clippy_lints/src/manual_non_exhaustive.rs @@ -11,15 +11,14 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::{sym, Span}; declare_clippy_lint! { - /// **What it does:** Checks for manual implementations of the non-exhaustive pattern. + /// ### What it does + /// Checks for manual implementations of the non-exhaustive pattern. /// - /// **Why is this bad?** Using the #[non_exhaustive] attribute expresses better the intent + /// ### Why is this bad? + /// Using the #[non_exhaustive] attribute expresses better the intent /// and allows possible optimizations when applied to enums. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// struct S { /// pub a: i32, diff --git a/clippy_lints/src/manual_ok_or.rs b/clippy_lints/src/manual_ok_or.rs index 847c8c648b0..b2f287af697 100644 --- a/clippy_lints/src/manual_ok_or.rs +++ b/clippy_lints/src/manual_ok_or.rs @@ -13,15 +13,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; declare_clippy_lint! { - /// **What it does:** + /// ### What it does + /// /// Finds patterns that reimplement `Option::ok_or`. /// - /// **Why is this bad?** - /// Concise code helps focusing on behavior instead of boilerplate. + /// ### Why is this bad? /// - /// **Known problems:** None. + /// Concise code helps focusing on behavior instead of boilerplate. /// - /// **Examples:** + /// ### Examples /// ```rust /// let foo: Option = None; /// foo.map_or(Err("error"), |v| Ok(v)); diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index 61b5fe81fa9..db12c377488 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -18,21 +18,17 @@ use rustc_span::source_map::Spanned; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Suggests using `strip_{prefix,suffix}` over `str::{starts,ends}_with` and slicing using /// the pattern's length. /// - /// **Why is this bad?** + /// ### Why is this bad? /// Using `str:strip_{prefix,suffix}` is safer and may have better performance as there is no /// slicing which may panic and the compiler does not need to insert this panic code. It is /// also sometimes more readable as it removes the need for duplicating or storing the pattern /// used by `str::{starts,ends}_with` and in the slicing. /// - /// **Known problems:** - /// None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let s = "hello, world!"; /// if s.starts_with("hello, ") { diff --git a/clippy_lints/src/manual_unwrap_or.rs b/clippy_lints/src/manual_unwrap_or.rs index 9d8d77cf8f0..426789742d5 100644 --- a/clippy_lints/src/manual_unwrap_or.rs +++ b/clippy_lints/src/manual_unwrap_or.rs @@ -15,15 +15,13 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Finds patterns that reimplement `Option::unwrap_or` or `Result::unwrap_or`. /// - /// **Why is this bad?** + /// ### Why is this bad? /// Concise code helps focusing on behavior instead of boilerplate. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let foo: Option = None; /// match foo { diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index e1f80ab025c..394606200bb 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -15,16 +15,15 @@ use rustc_span::symbol::Ident; use rustc_span::{sym, Span}; declare_clippy_lint! { - /// **What it does:** Checks for usage of `map(|x| x.clone())` or + /// ### What it does + /// Checks for usage of `map(|x| x.clone())` or /// dereferencing closures for `Copy` types, on `Iterator` or `Option`, /// and suggests `cloned()` or `copied()` instead /// - /// **Why is this bad?** Readability, this can be written more concisely - /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Why is this bad? + /// Readability, this can be written more concisely /// + /// ### Example /// ```rust /// let x = vec![42, 43]; /// let y = x.iter(); diff --git a/clippy_lints/src/map_err_ignore.rs b/clippy_lints/src/map_err_ignore.rs index 425a9734e5f..82d3732326e 100644 --- a/clippy_lints/src/map_err_ignore.rs +++ b/clippy_lints/src/map_err_ignore.rs @@ -4,13 +4,13 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for instances of `map_err(|_| Some::Enum)` + /// ### What it does + /// Checks for instances of `map_err(|_| Some::Enum)` /// - /// **Why is this bad?** This `map_err` throws away the original error rather than allowing the enum to contain and report the cause of the error + /// ### Why is this bad? + /// This `map_err` throws away the original error rather than allowing the enum to contain and report the cause of the error /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// Before: /// ```rust /// use std::fmt; diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 57cd907e77e..fd40590d077 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -12,16 +12,15 @@ use rustc_span::source_map::Span; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for usage of `option.map(f)` where f is a function + /// ### What it does + /// Checks for usage of `option.map(f)` where f is a function /// or closure that returns the unit type `()`. /// - /// **Why is this bad?** Readability, this can be written more clearly with + /// ### Why is this bad? + /// Readability, this can be written more clearly with /// an if let statement /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// # fn do_stuff() -> Option { Some(String::new()) } /// # fn log_err_msg(foo: String) -> Option { Some(foo) } @@ -54,16 +53,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `result.map(f)` where f is a function + /// ### What it does + /// Checks for usage of `result.map(f)` where f is a function /// or closure that returns the unit type `()`. /// - /// **Why is this bad?** Readability, this can be written more clearly with + /// ### Why is this bad? + /// Readability, this can be written more clearly with /// an if let statement /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// # fn do_stuff() -> Result { Ok(String::new()) } /// # fn log_err_msg(foo: String) -> Result { Ok(foo) } diff --git a/clippy_lints/src/match_on_vec_items.rs b/clippy_lints/src/match_on_vec_items.rs index ca6fb0831fe..e66a35452f0 100644 --- a/clippy_lints/src/match_on_vec_items.rs +++ b/clippy_lints/src/match_on_vec_items.rs @@ -10,13 +10,13 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for `match vec[idx]` or `match vec[n..m]`. + /// ### What it does + /// Checks for `match vec[idx]` or `match vec[n..m]`. /// - /// **Why is this bad?** This can panic at runtime. + /// ### Why is this bad? + /// This can panic at runtime. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust, no_run /// let arr = vec![0, 1, 2, 3]; /// let idx = 1; diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index d7f600b3ab2..5360c02f905 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -35,14 +35,14 @@ use std::iter; use std::ops::Bound; declare_clippy_lint! { - /// **What it does:** Checks for matches with a single arm where an `if let` + /// ### What it does + /// Checks for matches with a single arm where an `if let` /// will usually suffice. /// - /// **Why is this bad?** Just readability – `if let` nests less than a `match`. + /// ### Why is this bad? + /// Just readability – `if let` nests less than a `match`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # fn bar(stool: &str) {} /// # let x = Some("abc"); @@ -63,15 +63,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for matches with two arms where an `if let else` will + /// ### What it does + /// Checks for matches with two arms where an `if let else` will /// usually suffice. /// - /// **Why is this bad?** Just readability – `if let` nests less than a `match`. - /// - /// **Known problems:** Personal style preferences may differ. + /// ### Why is this bad? + /// Just readability – `if let` nests less than a `match`. /// - /// **Example:** + /// ### Known problems + /// Personal style preferences may differ. /// + /// ### Example /// Using `match`: /// /// ```rust @@ -102,16 +104,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for matches where all arms match a reference, + /// ### What it does + /// Checks for matches where all arms match a reference, /// suggesting to remove the reference and deref the matched expression /// instead. It also checks for `if let &foo = bar` blocks. /// - /// **Why is this bad?** It just makes the code less readable. That reference + /// ### Why is this bad? + /// It just makes the code less readable. That reference /// destructuring adds nothing to the code. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // Bad /// match x { @@ -133,14 +135,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for matches where match expression is a `bool`. It + /// ### What it does + /// Checks for matches where match expression is a `bool`. It /// suggests to replace the expression with an `if...else` block. /// - /// **Why is this bad?** It makes the code less readable. + /// ### Why is this bad? + /// It makes the code less readable. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # fn foo() {} /// # fn bar() {} @@ -167,14 +169,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for overlapping match arms. + /// ### What it does + /// Checks for overlapping match arms. /// - /// **Why is this bad?** It is likely to be an error and if not, makes the code + /// ### Why is this bad? + /// It is likely to be an error and if not, makes the code /// less obvious. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x = 5; /// match x { @@ -189,15 +191,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for arm which matches all errors with `Err(_)` + /// ### What it does + /// Checks for arm which matches all errors with `Err(_)` /// and take drastic actions like `panic!`. /// - /// **Why is this bad?** It is generally a bad practice, similar to + /// ### Why is this bad? + /// It is generally a bad practice, similar to /// catching all exceptions in java with `catch(Exception)` /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x: Result = Ok(3); /// match x { @@ -211,14 +213,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for match which is used to add a reference to an + /// ### What it does + /// Checks for match which is used to add a reference to an /// `Option` value. /// - /// **Why is this bad?** Using `as_ref()` or `as_mut()` instead is shorter. + /// ### Why is this bad? + /// Using `as_ref()` or `as_mut()` instead is shorter. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x: Option<()> = None; /// @@ -237,14 +239,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for wildcard enum matches using `_`. + /// ### What it does + /// Checks for wildcard enum matches using `_`. /// - /// **Why is this bad?** New enum variants added by library updates can be missed. + /// ### Why is this bad? + /// New enum variants added by library updates can be missed. /// - /// **Known problems:** Suggested replacements may be incorrect if guards exhaustively cover some + /// ### Known problems + /// Suggested replacements may be incorrect if guards exhaustively cover some /// variants, and also may not use correct path to enum if it's not present in the current scope. /// - /// **Example:** + /// ### Example /// ```rust /// # enum Foo { A(usize), B(usize) } /// # let x = Foo::B(1); @@ -266,15 +271,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for wildcard enum matches for a single variant. + /// ### What it does + /// Checks for wildcard enum matches for a single variant. /// - /// **Why is this bad?** New enum variants added by library updates can be missed. + /// ### Why is this bad? + /// New enum variants added by library updates can be missed. /// - /// **Known problems:** Suggested replacements may not use correct path to enum + /// ### Known problems + /// Suggested replacements may not use correct path to enum /// if it's not present in the current scope. /// - /// **Example:** - /// + /// ### Example /// ```rust /// # enum Foo { A, B, C } /// # let x = Foo::B; @@ -298,14 +305,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for wildcard pattern used with others patterns in same match arm. + /// ### What it does + /// Checks for wildcard pattern used with others patterns in same match arm. /// - /// **Why is this bad?** Wildcard pattern already covers any other pattern as it will match anyway. + /// ### Why is this bad? + /// Wildcard pattern already covers any other pattern as it will match anyway. /// It makes the code less readable, especially to spot wildcard pattern use in match arm. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// match "foo" { @@ -325,14 +332,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for matches being used to destructure a single-variant enum + /// ### What it does + /// Checks for matches being used to destructure a single-variant enum /// or tuple struct where a `let` will suffice. /// - /// **Why is this bad?** Just readability – `let` doesn't nest, whereas a `match` does. + /// ### Why is this bad? + /// Just readability – `let` doesn't nest, whereas a `match` does. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// enum Wrapper { /// Data(i32), @@ -360,14 +367,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for useless match that binds to only one value. + /// ### What it does + /// Checks for useless match that binds to only one value. /// - /// **Why is this bad?** Readability and needless complexity. + /// ### Why is this bad? + /// Readability and needless complexity. /// - /// **Known problems:** Suggested replacements may be incorrect when `match` + /// ### Known problems + /// Suggested replacements may be incorrect when `match` /// is actually binding temporary value, bringing a 'dropped while borrowed' error. /// - /// **Example:** + /// ### Example /// ```rust /// # let a = 1; /// # let b = 2; @@ -388,14 +398,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for unnecessary '..' pattern binding on struct when all fields are explicitly matched. + /// ### What it does + /// Checks for unnecessary '..' pattern binding on struct when all fields are explicitly matched. /// - /// **Why is this bad?** Correctness and readability. It's like having a wildcard pattern after + /// ### Why is this bad? + /// Correctness and readability. It's like having a wildcard pattern after /// matching all enum variants explicitly. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # struct A { a: i32 } /// let a = A { a: 5 }; @@ -418,21 +428,23 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Lint for redundant pattern matching over `Result`, `Option`, + /// ### What it does + /// Lint for redundant pattern matching over `Result`, `Option`, /// `std::task::Poll` or `std::net::IpAddr` /// - /// **Why is this bad?** It's more concise and clear to just use the proper + /// ### Why is this bad? + /// It's more concise and clear to just use the proper /// utility function /// - /// **Known problems:** This will change the drop order for the matched type. Both `if let` and + /// ### Known problems + /// This will change the drop order for the matched type. Both `if let` and /// `while let` will drop the value at the end of the block, both `if` and `while` will drop the /// value before entering the block. For most types this change will not matter, but for a few /// types this will not be an acceptable change (e.g. locks). See the /// [reference](https://doc.rust-lang.org/reference/destructors.html#drop-scopes) for more about /// drop order. /// - /// **Example:** - /// + /// ### Example /// ```rust /// # use std::task::Poll; /// # use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; @@ -471,15 +483,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `match` or `if let` expressions producing a + /// ### What it does + /// Checks for `match` or `if let` expressions producing a /// `bool` that could be written using `matches!` /// - /// **Why is this bad?** Readability and needless complexity. + /// ### Why is this bad? + /// Readability and needless complexity. /// - /// **Known problems:** This lint falsely triggers, if there are arms with + /// ### Known problems + /// This lint falsely triggers, if there are arms with /// `cfg` attributes that remove an arm evaluating to `false`. /// - /// **Example:** + /// ### Example /// ```rust /// let x = Some(5); /// @@ -504,17 +519,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `match` with identical arm bodies. + /// ### What it does + /// Checks for `match` with identical arm bodies. /// - /// **Why is this bad?** This is probably a copy & paste error. If arm bodies + /// ### Why is this bad? + /// This is probably a copy & paste error. If arm bodies /// are the same on purpose, you can factor them /// [using `|`](https://doc.rust-lang.org/book/patterns.html#multiple-patterns). /// - /// **Known problems:** False positive possible with order dependent `match` + /// ### Known problems + /// False positive possible with order dependent `match` /// (see issue /// [#860](https://github.com/rust-lang/rust-clippy/issues/860)). /// - /// **Example:** + /// ### Example /// ```rust,ignore /// match foo { /// Bar => bar(), diff --git a/clippy_lints/src/mem_discriminant.rs b/clippy_lints/src/mem_discriminant.rs index aca96e06ef2..59176c4b846 100644 --- a/clippy_lints/src/mem_discriminant.rs +++ b/clippy_lints/src/mem_discriminant.rs @@ -9,14 +9,14 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for calls of `mem::discriminant()` on a non-enum type. + /// ### What it does + /// Checks for calls of `mem::discriminant()` on a non-enum type. /// - /// **Why is this bad?** The value of `mem::discriminant()` on non-enum types + /// ### Why is this bad? + /// The value of `mem::discriminant()` on non-enum types /// is unspecified. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// use std::mem; /// diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index a28cb5f32fe..07202a59c4b 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -5,15 +5,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for usage of `std::mem::forget(t)` where `t` is + /// ### What it does + /// Checks for usage of `std::mem::forget(t)` where `t` is /// `Drop`. /// - /// **Why is this bad?** `std::mem::forget(t)` prevents `t` from running its + /// ### Why is this bad? + /// `std::mem::forget(t)` prevents `t` from running its /// destructor, possibly causing leaks. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # use std::mem; /// # use std::rc::Rc; diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index 183daee3617..3d071c9081b 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -14,16 +14,16 @@ use rustc_span::source_map::Span; use rustc_span::symbol::sym; declare_clippy_lint! { - /// **What it does:** Checks for `mem::replace()` on an `Option` with + /// ### What it does + /// Checks for `mem::replace()` on an `Option` with /// `None`. /// - /// **Why is this bad?** `Option` already has the method `take()` for + /// ### Why is this bad? + /// `Option` already has the method `take()` for /// taking its current value (Some(..) or None) and replacing it with /// `None`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// use std::mem; /// @@ -41,17 +41,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `mem::replace(&mut _, mem::uninitialized())` + /// ### What it does + /// Checks for `mem::replace(&mut _, mem::uninitialized())` /// and `mem::replace(&mut _, mem::zeroed())`. /// - /// **Why is this bad?** This will lead to undefined behavior even if the + /// ### Why is this bad? + /// This will lead to undefined behavior even if the /// value is overwritten later, because the uninitialized value may be /// observed in the case of a panic. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ``` /// use std::mem; ///# fn may_panic(v: Vec) -> Vec { v } @@ -73,15 +72,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `std::mem::replace` on a value of type + /// ### What it does + /// Checks for `std::mem::replace` on a value of type /// `T` with `T::default()`. /// - /// **Why is this bad?** `std::mem` module already has the method `take` to + /// ### Why is this bad? + /// `std::mem` module already has the method `take` to /// take the current value and replace it with the default value of that type. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let mut text = String::from("foo"); /// let replaced = std::mem::replace(&mut text, String::default()); diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 283fcf281df..d3e12023814 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -80,16 +80,15 @@ use rustc_span::{sym, Span}; use rustc_typeck::hir_ty_to_ty; declare_clippy_lint! { - /// **What it does:** Checks for usages of `cloned()` on an `Iterator` or `Option` where + /// ### What it does + /// Checks for usages of `cloned()` on an `Iterator` or `Option` where /// `copied()` could be used instead. /// - /// **Why is this bad?** `copied()` is better because it guarantees that the type being cloned + /// ### Why is this bad? + /// `copied()` is better because it guarantees that the type being cloned /// implements `Copy`. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// [1, 2, 3].iter().cloned(); /// ``` @@ -103,16 +102,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usages of `Iterator::flat_map()` where `filter_map()` could be + /// ### What it does + /// Checks for usages of `Iterator::flat_map()` where `filter_map()` could be /// used instead. /// - /// **Why is this bad?** When applicable, `filter_map()` is more clear since it shows that + /// ### Why is this bad? + /// When applicable, `filter_map()` is more clear since it shows that /// `Option` is used to produce 0 or 1 items. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let nums: Vec = ["1", "2", "whee!"].iter().flat_map(|x| x.parse().ok()).collect(); /// ``` @@ -126,9 +124,11 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `.unwrap()` calls on `Option`s and on `Result`s. + /// ### What it does + /// Checks for `.unwrap()` calls on `Option`s and on `Result`s. /// - /// **Why is this bad?** It is better to handle the `None` or `Err` case, + /// ### Why is this bad? + /// It is better to handle the `None` or `Err` case, /// or at least call `.expect(_)` with a more helpful message. Still, for a lot of /// quick-and-dirty code, `unwrap` is a good choice, which is why this lint is /// `Allow` by default. @@ -141,9 +141,7 @@ declare_clippy_lint! { /// messages on display. Therefore, it may be beneficial to look at the places /// where they may get displayed. Activate this lint to do just that. /// - /// **Known problems:** None. - /// - /// **Examples:** + /// ### Examples /// ```rust /// # let opt = Some(1); /// @@ -171,9 +169,11 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `.expect()` calls on `Option`s and `Result`s. + /// ### What it does + /// Checks for `.expect()` calls on `Option`s and `Result`s. /// - /// **Why is this bad?** Usually it is better to handle the `None` or `Err` case. + /// ### Why is this bad? + /// Usually it is better to handle the `None` or `Err` case. /// Still, for a lot of quick-and-dirty code, `expect` is a good choice, which is why /// this lint is `Allow` by default. /// @@ -181,9 +181,7 @@ declare_clippy_lint! { /// values. Normally, you want to implement more sophisticated error handling, /// and propagate errors upwards with `?` operator. /// - /// **Known problems:** None. - /// - /// **Examples:** + /// ### Examples /// ```rust,ignore /// # let opt = Some(1); /// @@ -213,20 +211,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for methods that should live in a trait + /// ### What it does + /// Checks for methods that should live in a trait /// implementation of a `std` trait (see [llogiq's blog /// post](http://llogiq.github.io/2015/07/30/traits.html) for further /// information) instead of an inherent implementation. /// - /// **Why is this bad?** Implementing the traits improve ergonomics for users of + /// ### Why is this bad? + /// Implementing the traits improve ergonomics for users of /// the code, often with very little cost. Also people seeing a `mul(...)` /// method /// may expect `*` to work equally, so you should have good reason to disappoint /// them. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// struct X; /// impl X { @@ -242,7 +240,8 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for methods with certain name prefixes and which + /// ### What it does + /// Checks for methods with certain name prefixes and which /// doesn't match how self is taken. The actual rules are: /// /// |Prefix |Postfix |`self` taken | `self` type | @@ -265,13 +264,12 @@ declare_clippy_lint! { /// Please find more info here: /// https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv /// - /// **Why is this bad?** Consistency breeds readability. If you follow the + /// ### Why is this bad? + /// Consistency breeds readability. If you follow the /// conventions, your users won't be surprised that they, e.g., need to supply a /// mutable reference to a `as_..` function. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # struct X; /// impl X { @@ -287,14 +285,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `ok().expect(..)`. + /// ### What it does + /// Checks for usage of `ok().expect(..)`. /// - /// **Why is this bad?** Because you usually call `expect()` on the `Result` + /// ### Why is this bad? + /// Because you usually call `expect()` on the `Result` /// directly to get a better error message. /// - /// **Known problems:** The error type needs to implement `Debug` + /// ### Known problems + /// The error type needs to implement `Debug` /// - /// **Example:** + /// ### Example /// ```rust /// # let x = Ok::<_, ()>(()); /// @@ -310,15 +311,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `option.map(_).unwrap_or(_)` or `option.map(_).unwrap_or_else(_)` or + /// ### What it does + /// Checks for usage of `option.map(_).unwrap_or(_)` or `option.map(_).unwrap_or_else(_)` or /// `result.map(_).unwrap_or_else(_)`. /// - /// **Why is this bad?** Readability, these can be written more concisely (resp.) as + /// ### Why is this bad? + /// Readability, these can be written more concisely (resp.) as /// `option.map_or(_, _)`, `option.map_or_else(_, _)` and `result.map_or_else(_, _)`. /// - /// **Known problems:** The order of the arguments is not in execution order + /// ### Known problems + /// The order of the arguments is not in execution order /// - /// **Examples:** + /// ### Examples /// ```rust /// # let x = Some(1); /// @@ -347,14 +351,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.map_or(None, _)`. + /// ### What it does + /// Checks for usage of `_.map_or(None, _)`. /// - /// **Why is this bad?** Readability, this can be written more concisely as + /// ### Why is this bad? + /// Readability, this can be written more concisely as /// `_.and_then(_)`. /// - /// **Known problems:** The order of the arguments is not in execution order. + /// ### Known problems + /// The order of the arguments is not in execution order. /// - /// **Example:** + /// ### Example /// ```rust /// # let opt = Some(1); /// @@ -370,15 +377,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.map_or(None, Some)`. + /// ### What it does + /// Checks for usage of `_.map_or(None, Some)`. /// - /// **Why is this bad?** Readability, this can be written more concisely as + /// ### Why is this bad? + /// Readability, this can be written more concisely as /// `_.ok()`. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// Bad: /// ```rust /// # let r: Result = Ok(1); @@ -396,16 +402,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.and_then(|x| Some(y))`, `_.and_then(|x| Ok(y))` or + /// ### What it does + /// Checks for usage of `_.and_then(|x| Some(y))`, `_.and_then(|x| Ok(y))` or /// `_.or_else(|x| Err(y))`. /// - /// **Why is this bad?** Readability, this can be written more concisely as + /// ### Why is this bad? + /// Readability, this can be written more concisely as /// `_.map(|x| y)` or `_.map_err(|x| y)`. /// - /// **Known problems:** None - /// - /// **Example:** - /// + /// ### Example /// ```rust /// # fn opt() -> Option<&'static str> { Some("42") } /// # fn res() -> Result<&'static str, &'static str> { Ok("42") } @@ -429,14 +434,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.filter(_).next()`. + /// ### What it does + /// Checks for usage of `_.filter(_).next()`. /// - /// **Why is this bad?** Readability, this can be written more concisely as + /// ### Why is this bad? + /// Readability, this can be written more concisely as /// `_.find(_)`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let vec = vec![1]; /// vec.iter().filter(|x| **x == 0).next(); @@ -452,14 +457,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.skip_while(condition).next()`. + /// ### What it does + /// Checks for usage of `_.skip_while(condition).next()`. /// - /// **Why is this bad?** Readability, this can be written more concisely as + /// ### Why is this bad? + /// Readability, this can be written more concisely as /// `_.find(!condition)`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let vec = vec![1]; /// vec.iter().skip_while(|x| **x == 0).next(); @@ -475,14 +480,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.map(_).flatten(_)` on `Iterator` and `Option` + /// ### What it does + /// Checks for usage of `_.map(_).flatten(_)` on `Iterator` and `Option` /// - /// **Why is this bad?** Readability, this can be written more concisely as + /// ### Why is this bad? + /// Readability, this can be written more concisely as /// `_.flat_map(_)` /// - /// **Known problems:** - /// - /// **Example:** + /// ### Example /// ```rust /// let vec = vec![vec![1]]; /// @@ -498,15 +503,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.filter(_).map(_)` that can be written more simply + /// ### What it does + /// Checks for usage of `_.filter(_).map(_)` that can be written more simply /// as `filter_map(_)`. /// - /// **Why is this bad?** Redundant code in the `filter` and `map` operations is poor style and + /// ### Why is this bad? + /// Redundant code in the `filter` and `map` operations is poor style and /// less performant. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// Bad: /// ```rust /// (0_i32..10) @@ -524,15 +529,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.find(_).map(_)` that can be written more simply + /// ### What it does + /// Checks for usage of `_.find(_).map(_)` that can be written more simply /// as `find_map(_)`. /// - /// **Why is this bad?** Redundant code in the `find` and `map` operations is poor style and + /// ### Why is this bad? + /// Redundant code in the `find` and `map` operations is poor style and /// less performant. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// Bad: /// ```rust /// (0_i32..10) @@ -550,14 +555,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.filter_map(_).next()`. + /// ### What it does + /// Checks for usage of `_.filter_map(_).next()`. /// - /// **Why is this bad?** Readability, this can be written more concisely as + /// ### Why is this bad? + /// Readability, this can be written more concisely as /// `_.find_map(_)`. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// (0..3).filter_map(|x| if x == 2 { Some(x) } else { None }).next(); /// ``` @@ -572,13 +577,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `flat_map(|x| x)`. + /// ### What it does + /// Checks for usage of `flat_map(|x| x)`. /// - /// **Why is this bad?** Readability, this can be written more concisely by using `flatten`. + /// ### Why is this bad? + /// Readability, this can be written more concisely by using `flatten`. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// # let iter = vec![vec![0]].into_iter(); /// iter.flat_map(|x| x); @@ -594,16 +599,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for an iterator or string search (such as `find()`, + /// ### What it does + /// Checks for an iterator or string search (such as `find()`, /// `position()`, or `rposition()`) followed by a call to `is_some()` or `is_none()`. /// - /// **Why is this bad?** Readability, this can be written more concisely as: + /// ### Why is this bad? + /// Readability, this can be written more concisely as: /// * `_.any(_)`, or `_.contains(_)` for `is_some()`, /// * `!_.any(_)`, or `!_.contains(_)` for `is_none()`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let vec = vec![1]; /// vec.iter().find(|x| **x == 0).is_some(); @@ -623,15 +628,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `.chars().next()` on a `str` to check + /// ### What it does + /// Checks for usage of `.chars().next()` on a `str` to check /// if it starts with a given char. /// - /// **Why is this bad?** Readability, this can be written more concisely as + /// ### Why is this bad? + /// Readability, this can be written more concisely as /// `_.starts_with(_)`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let name = "foo"; /// if name.chars().next() == Some('_') {}; @@ -647,17 +652,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to `.or(foo(..))`, `.unwrap_or(foo(..))`, + /// ### What it does + /// Checks for calls to `.or(foo(..))`, `.unwrap_or(foo(..))`, /// etc., and suggests to use `or_else`, `unwrap_or_else`, etc., or /// `unwrap_or_default` instead. /// - /// **Why is this bad?** The function will always be called and potentially + /// ### Why is this bad? + /// The function will always be called and potentially /// allocate an object acting as the default. /// - /// **Known problems:** If the function has side-effects, not calling it will + /// ### Known problems + /// If the function has side-effects, not calling it will /// change the semantic of the program, but you shouldn't rely on that anyway. /// - /// **Example:** + /// ### Example /// ```rust /// # let foo = Some(String::new()); /// foo.unwrap_or(String::new()); @@ -678,15 +686,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to `.expect(&format!(...))`, `.expect(foo(..))`, + /// ### What it does + /// Checks for calls to `.expect(&format!(...))`, `.expect(foo(..))`, /// etc., and suggests to use `unwrap_or_else` instead /// - /// **Why is this bad?** The function will always be called. + /// ### Why is this bad? + /// The function will always be called. /// - /// **Known problems:** If the function has side-effects, not calling it will + /// ### Known problems + /// If the function has side-effects, not calling it will /// change the semantics of the program, but you shouldn't rely on that anyway. /// - /// **Example:** + /// ### Example /// ```rust /// # let foo = Some(String::new()); /// # let err_code = "418"; @@ -713,14 +724,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `.clone()` on a `Copy` type. + /// ### What it does + /// Checks for usage of `.clone()` on a `Copy` type. /// - /// **Why is this bad?** The only reason `Copy` types implement `Clone` is for + /// ### Why is this bad? + /// The only reason `Copy` types implement `Clone` is for /// generics, not for using the `clone` method on a concrete type. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// 42u64.clone(); /// ``` @@ -730,15 +741,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `.clone()` on a ref-counted pointer, + /// ### What it does + /// Checks for usage of `.clone()` on a ref-counted pointer, /// (`Rc`, `Arc`, `rc::Weak`, or `sync::Weak`), and suggests calling Clone via unified /// function syntax instead (e.g., `Rc::clone(foo)`). /// - /// **Why is this bad?** Calling '.clone()' on an Rc, Arc, or Weak + /// ### Why is this bad? + /// Calling '.clone()' on an Rc, Arc, or Weak /// can obscure the fact that only the pointer is being cloned, not the underlying /// data. /// - /// **Example:** + /// ### Example /// ```rust /// # use std::rc::Rc; /// let x = Rc::new(1); @@ -755,14 +768,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `.clone()` on an `&&T`. + /// ### What it does + /// Checks for usage of `.clone()` on an `&&T`. /// - /// **Why is this bad?** Cloning an `&&T` copies the inner `&T`, instead of + /// ### Why is this bad? + /// Cloning an `&&T` copies the inner `&T`, instead of /// cloning the underlying `T`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn main() { /// let x = vec![1]; @@ -777,16 +790,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `.to_string()` on an `&&T` where + /// ### What it does + /// Checks for usage of `.to_string()` on an `&&T` where /// `T` implements `ToString` directly (like `&&str` or `&&String`). /// - /// **Why is this bad?** This bypasses the specialized implementation of + /// ### Why is this bad? + /// This bypasses the specialized implementation of /// `ToString` and instead goes through the more expensive string formatting /// facilities. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Generic implementation for `T: Display` is used (slow) /// ["foo", "bar"].iter().map(|s| s.to_string()); @@ -800,14 +813,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `new` not returning a type that contains `Self`. + /// ### What it does + /// Checks for `new` not returning a type that contains `Self`. /// - /// **Why is this bad?** As a convention, `new` methods are used to make a new + /// ### Why is this bad? + /// As a convention, `new` methods are used to make a new /// instance of a type. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// In an impl block: /// ```rust /// # struct Foo; @@ -861,15 +874,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for string methods that receive a single-character + /// ### What it does + /// Checks for string methods that receive a single-character /// `str` as an argument, e.g., `_.split("x")`. /// - /// **Why is this bad?** Performing these methods using a `char` is faster than + /// ### Why is this bad? + /// Performing these methods using a `char` is faster than /// using a `str`. /// - /// **Known problems:** Does not catch multi-byte unicode characters. + /// ### Known problems + /// Does not catch multi-byte unicode characters. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // Bad /// _.split("x"); @@ -882,14 +898,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calling `.step_by(0)` on iterators which panics. + /// ### What it does + /// Checks for calling `.step_by(0)` on iterators which panics. /// - /// **Why is this bad?** This very much looks like an oversight. Use `panic!()` instead if you + /// ### Why is this bad? + /// This very much looks like an oversight. Use `panic!()` instead if you /// actually intend to panic. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,should_panic /// for x in (0..100).step_by(0) { /// //.. @@ -901,15 +917,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for indirect collection of populated `Option` + /// ### What it does + /// Checks for indirect collection of populated `Option` /// - /// **Why is this bad?** `Option` is like a collection of 0-1 things, so `flatten` + /// ### Why is this bad? + /// `Option` is like a collection of 0-1 things, so `flatten` /// automatically does this without suspicious-looking `unwrap` calls. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let _ = std::iter::empty::>().filter(Option::is_some).map(Option::unwrap); /// ``` @@ -923,16 +938,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the use of `iter.nth(0)`. + /// ### What it does + /// Checks for the use of `iter.nth(0)`. /// - /// **Why is this bad?** `iter.next()` is equivalent to + /// ### Why is this bad? + /// `iter.next()` is equivalent to /// `iter.nth(0)`, as they both consume the next element, /// but is more readable. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// # use std::collections::HashSet; /// // Bad @@ -951,15 +965,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for use of `.iter().nth()` (and the related + /// ### What it does + /// Checks for use of `.iter().nth()` (and the related /// `.iter_mut().nth()`) on standard library types with O(1) element access. /// - /// **Why is this bad?** `.get()` and `.get_mut()` are more efficient and more + /// ### Why is this bad? + /// `.get()` and `.get_mut()` are more efficient and more /// readable. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let some_vec = vec![0, 1, 2, 3]; /// let bad_vec = some_vec.iter().nth(3); @@ -977,13 +991,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for use of `.skip(x).next()` on iterators. - /// - /// **Why is this bad?** `.nth(x)` is cleaner + /// ### What it does + /// Checks for use of `.skip(x).next()` on iterators. /// - /// **Known problems:** None. + /// ### Why is this bad? + /// `.nth(x)` is cleaner /// - /// **Example:** + /// ### Example /// ```rust /// let some_vec = vec![0, 1, 2, 3]; /// let bad_vec = some_vec.iter().skip(3).next(); @@ -1001,13 +1015,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for use of `.get().unwrap()` (or + /// ### What it does + /// Checks for use of `.get().unwrap()` (or /// `.get_mut().unwrap`) on a standard library type which implements `Index` /// - /// **Why is this bad?** Using the Index trait (`[]`) is more clear and more + /// ### Why is this bad? + /// Using the Index trait (`[]`) is more clear and more /// concise. /// - /// **Known problems:** Not a replacement for error handling: Using either + /// ### Known problems + /// Not a replacement for error handling: Using either /// `.unwrap()` or the Index trait (`[]`) carries the risk of causing a `panic` /// if the value being accessed is `None`. If the use of `.get().unwrap()` is a /// temporary placeholder for dealing with the `Option` type, then this does @@ -1016,7 +1033,7 @@ declare_clippy_lint! { /// is handled in a future refactor instead of using `.unwrap()` or the Index /// trait. /// - /// **Example:** + /// ### Example /// ```rust /// let mut some_vec = vec![0, 1, 2, 3]; /// let last = some_vec.get(3).unwrap(); @@ -1034,14 +1051,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for occurrences where one vector gets extended instead of append + /// ### What it does + /// Checks for occurrences where one vector gets extended instead of append /// - /// **Why is this bad?** Using `append` instead of `extend` is more concise and faster - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Using `append` instead of `extend` is more concise and faster /// + /// ### Example /// ```rust /// let mut a = vec![1, 2, 3]; /// let mut b = vec![4, 5, 6]; @@ -1058,14 +1074,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the use of `.extend(s.chars())` where s is a + /// ### What it does + /// Checks for the use of `.extend(s.chars())` where s is a /// `&str` or `String`. /// - /// **Why is this bad?** `.push_str(s)` is clearer + /// ### Why is this bad? + /// `.push_str(s)` is clearer /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let abc = "abc"; /// let def = String::from("def"); @@ -1087,14 +1103,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the use of `.cloned().collect()` on slice to + /// ### What it does + /// Checks for the use of `.cloned().collect()` on slice to /// create a `Vec`. /// - /// **Why is this bad?** `.to_vec()` is clearer - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// `.to_vec()` is clearer /// - /// **Example:** + /// ### Example /// ```rust /// let s = [1, 2, 3, 4, 5]; /// let s2: Vec = s[..].iter().cloned().collect(); @@ -1110,15 +1126,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.chars().last()` or + /// ### What it does + /// Checks for usage of `_.chars().last()` or /// `_.chars().next_back()` on a `str` to check if it ends with a given char. /// - /// **Why is this bad?** Readability, this can be written more concisely as + /// ### Why is this bad? + /// Readability, this can be written more concisely as /// `_.ends_with(_)`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let name = "_"; /// @@ -1134,14 +1150,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `.as_ref()` or `.as_mut()` where the + /// ### What it does + /// Checks for usage of `.as_ref()` or `.as_mut()` where the /// types before and after the call are the same. /// - /// **Why is this bad?** The call is unnecessary. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// The call is unnecessary. /// - /// **Example:** + /// ### Example /// ```rust /// # fn do_stuff(x: &[i32]) {} /// let x: &[i32] = &[1, 2, 3, 4, 5]; @@ -1159,15 +1175,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for using `fold` when a more succinct alternative exists. + /// ### What it does + /// Checks for using `fold` when a more succinct alternative exists. /// Specifically, this checks for `fold`s which could be replaced by `any`, `all`, /// `sum` or `product`. /// - /// **Why is this bad?** Readability. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// Readability. /// - /// **Example:** + /// ### Example /// ```rust /// let _ = (0..3).fold(false, |acc, x| acc || x > 2); /// ``` @@ -1181,16 +1197,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `filter_map` calls which could be replaced by `filter` or `map`. + /// ### What it does + /// Checks for `filter_map` calls which could be replaced by `filter` or `map`. /// More specifically it checks if the closure provided is only performing one of the /// filter or map operations and suggests the appropriate option. /// - /// **Why is this bad?** Complexity. The intent is also clearer if only a single + /// ### Why is this bad? + /// Complexity. The intent is also clearer if only a single /// operation is being performed. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// let _ = (0..3).filter_map(|x| if x > 2 { Some(x) } else { None }); /// @@ -1210,17 +1226,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `into_iter` calls on references which should be replaced by `iter` + /// ### What it does + /// Checks for `into_iter` calls on references which should be replaced by `iter` /// or `iter_mut`. /// - /// **Why is this bad?** Readability. Calling `into_iter` on a reference will not move out its + /// ### Why is this bad? + /// Readability. Calling `into_iter` on a reference will not move out its /// content into the resulting iterator, which is confusing. It is better just call `iter` or /// `iter_mut` directly. /// - /// **Known problems:** None - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Bad /// let _ = (&vec![3, 4, 5]).into_iter(); @@ -1234,16 +1249,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to `map` followed by a `count`. + /// ### What it does + /// Checks for calls to `map` followed by a `count`. /// - /// **Why is this bad?** It looks suspicious. Maybe `map` was confused with `filter`. + /// ### Why is this bad? + /// It looks suspicious. Maybe `map` was confused with `filter`. /// If the `map` call is intentional, this should be rewritten. Or, if you intend to /// drive the iterator to completion, you can just use `for_each` instead. /// - /// **Known problems:** None - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let _ = (0..3).map(|x| x + 2).count(); /// ``` @@ -1253,16 +1267,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `MaybeUninit::uninit().assume_init()`. + /// ### What it does + /// Checks for `MaybeUninit::uninit().assume_init()`. /// - /// **Why is this bad?** For most types, this is undefined behavior. + /// ### Why is this bad? + /// For most types, this is undefined behavior. /// - /// **Known problems:** For now, we accept empty tuples and tuples / arrays + /// ### Known problems + /// For now, we accept empty tuples and tuples / arrays /// of `MaybeUninit`. There may be other types that allow uninitialized /// data, but those are not yet rigorously defined. /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Beware the UB /// use std::mem::MaybeUninit; @@ -1285,12 +1301,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `.checked_add/sub(x).unwrap_or(MAX/MIN)`. + /// ### What it does + /// Checks for `.checked_add/sub(x).unwrap_or(MAX/MIN)`. /// - /// **Why is this bad?** These can be written simply with `saturating_add/sub` methods. - /// - /// **Example:** + /// ### Why is this bad? + /// These can be written simply with `saturating_add/sub` methods. /// + /// ### Example /// ```rust /// # let y: u32 = 0; /// # let x: u32 = 100; @@ -1312,14 +1329,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `offset(_)`, `wrapping_`{`add`, `sub`}, etc. on raw pointers to + /// ### What it does + /// Checks for `offset(_)`, `wrapping_`{`add`, `sub`}, etc. on raw pointers to /// zero-sized types /// - /// **Why is this bad?** This is a no-op, and likely unintended - /// - /// **Known problems:** None + /// ### Why is this bad? + /// This is a no-op, and likely unintended /// - /// **Example:** + /// ### Example /// ```rust /// unsafe { (&() as *const ()).offset(1) }; /// ``` @@ -1329,15 +1346,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `FileType::is_file()`. + /// ### What it does + /// Checks for `FileType::is_file()`. /// - /// **Why is this bad?** When people testing a file type with `FileType::is_file` + /// ### Why is this bad? + /// When people testing a file type with `FileType::is_file` /// they are testing whether a path is something they can get bytes from. But /// `is_file` doesn't cover special file types in unix-like systems, and doesn't cover /// symlink in windows. Using `!FileType::is_dir()` is a better way to that intention. /// - /// **Example:** - /// + /// ### Example /// ```rust /// # || { /// let metadata = std::fs::metadata("foo.txt")?; @@ -1369,14 +1387,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.as_ref().map(Deref::deref)` or it's aliases (such as String::as_str). + /// ### What it does + /// Checks for usage of `_.as_ref().map(Deref::deref)` or it's aliases (such as String::as_str). /// - /// **Why is this bad?** Readability, this can be written more concisely as + /// ### Why is this bad? + /// Readability, this can be written more concisely as /// `_.as_deref()`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let opt = Some("".to_string()); /// opt.as_ref().map(String::as_str) @@ -1394,13 +1412,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `iter().next()` on a Slice or an Array - /// - /// **Why is this bad?** These can be shortened into `.get()` + /// ### What it does + /// Checks for usage of `iter().next()` on a Slice or an Array /// - /// **Known problems:** None. + /// ### Why is this bad? + /// These can be shortened into `.get()` /// - /// **Example:** + /// ### Example /// ```rust /// # let a = [1, 2, 3]; /// # let b = vec![1, 2, 3]; @@ -1420,14 +1438,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns when using `push_str`/`insert_str` with a single-character string literal + /// ### What it does + /// Warns when using `push_str`/`insert_str` with a single-character string literal /// where `push`/`insert` with a `char` would work fine. /// - /// **Why is this bad?** It's less clear that we are pushing a single character. + /// ### Why is this bad? + /// It's less clear that we are pushing a single character. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// let mut string = String::new(); /// string.insert_str(0, "R"); @@ -1445,7 +1463,8 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** As the counterpart to `or_fun_call`, this lint looks for unnecessary + /// ### What it does + /// As the counterpart to `or_fun_call`, this lint looks for unnecessary /// lazily evaluated closures on `Option` and `Result`. /// /// This lint suggests changing the following functions, when eager evaluation results in @@ -1456,13 +1475,14 @@ declare_clippy_lint! { /// - `get_or_insert_with` to `get_or_insert` /// - `ok_or_else` to `ok_or` /// - /// **Why is this bad?** Using eager evaluation is shorter and simpler in some cases. + /// ### Why is this bad? + /// Using eager evaluation is shorter and simpler in some cases. /// - /// **Known problems:** It is possible, but not recommended for `Deref` and `Index` to have + /// ### Known problems + /// It is possible, but not recommended for `Deref` and `Index` to have /// side effects. Eagerly evaluating them can change the semantics of the program. /// - /// **Example:** - /// + /// ### Example /// ```rust /// // example code where clippy issues a warning /// let opt: Option = None; @@ -1481,14 +1501,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `_.map(_).collect::()`. - /// - /// **Why is this bad?** Using `try_for_each` instead is more readable and idiomatic. - /// - /// **Known problems:** None + /// ### What it does + /// Checks for usage of `_.map(_).collect::()`. /// - /// **Example:** + /// ### Why is this bad? + /// Using `try_for_each` instead is more readable and idiomatic. /// + /// ### Example /// ```rust /// (0..3).map(|t| Err(t)).collect::>(); /// ``` @@ -1502,16 +1521,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `from_iter()` function calls on types that implement the `FromIterator` + /// ### What it does + /// Checks for `from_iter()` function calls on types that implement the `FromIterator` /// trait. /// - /// **Why is this bad?** It is recommended style to use collect. See + /// ### Why is this bad? + /// It is recommended style to use collect. See /// [FromIterator documentation](https://doc.rust-lang.org/std/iter/trait.FromIterator.html) /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// use std::iter::FromIterator; /// @@ -1535,15 +1553,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `inspect().for_each()`. + /// ### What it does + /// Checks for usage of `inspect().for_each()`. /// - /// **Why is this bad?** It is the same as performing the computation + /// ### Why is this bad? + /// It is the same as performing the computation /// inside `inspect` at the beginning of the closure in `for_each`. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// [1,2,3,4,5].iter() /// .inspect(|&x| println!("inspect the number: {}", x)) @@ -1565,14 +1582,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `filter_map(|x| x)`. - /// - /// **Why is this bad?** Readability, this can be written more concisely by using `flatten`. + /// ### What it does + /// Checks for usage of `filter_map(|x| x)`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Readability, this can be written more concisely by using `flatten`. /// + /// ### Example /// ```rust /// # let iter = vec![Some(1)].into_iter(); /// iter.filter_map(|x| x); @@ -1588,14 +1604,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for instances of `map(f)` where `f` is the identity function. - /// - /// **Why is this bad?** It can be written more concisely without the call to `map`. + /// ### What it does + /// Checks for instances of `map(f)` where `f` is the identity function. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// It can be written more concisely without the call to `map`. /// + /// ### Example /// ```rust /// let x = [1, 2, 3]; /// let y: Vec<_> = x.iter().map(|x| x).map(|x| 2*x).collect(); @@ -1611,15 +1626,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the use of `.bytes().nth()`. + /// ### What it does + /// Checks for the use of `.bytes().nth()`. /// - /// **Why is this bad?** `.as_bytes().get()` is more efficient and more + /// ### Why is this bad? + /// `.as_bytes().get()` is more efficient and more /// readable. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Bad /// let _ = "Hello".bytes().nth(3); @@ -1633,15 +1647,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the usage of `_.to_owned()`, `vec.to_vec()`, or similar when calling `_.clone()` would be clearer. + /// ### What it does + /// Checks for the usage of `_.to_owned()`, `vec.to_vec()`, or similar when calling `_.clone()` would be clearer. /// - /// **Why is this bad?** These methods do the same thing as `_.clone()` but may be confusing as + /// ### Why is this bad? + /// These methods do the same thing as `_.clone()` but may be confusing as /// to why we are calling `to_vec` on something that is already a `Vec` or calling `to_owned` on something that is already owned. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let a = vec![1, 2, 3]; /// let b = a.to_vec(); @@ -1659,15 +1672,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the use of `.iter().count()`. + /// ### What it does + /// Checks for the use of `.iter().count()`. /// - /// **Why is this bad?** `.len()` is more efficient and more + /// ### Why is this bad? + /// `.len()` is more efficient and more /// readable. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Bad /// let some_vec = vec![0, 1, 2, 3]; @@ -1685,17 +1697,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to [`splitn`] + /// ### What it does + /// Checks for calls to [`splitn`] /// (https://doc.rust-lang.org/std/primitive.str.html#method.splitn) and /// related functions with either zero or one splits. /// - /// **Why is this bad?** These calls don't actually split the value and are + /// ### Why is this bad? + /// These calls don't actually split the value and are /// likely to be intended as a different number. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Bad /// let s = ""; @@ -1715,14 +1726,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for manual implementations of `str::repeat` - /// - /// **Why is this bad?** These are both harder to read, as well as less performant. - /// - /// **Known problems:** None. + /// ### What it does + /// Checks for manual implementations of `str::repeat` /// - /// **Example:** + /// ### Why is this bad? + /// These are both harder to read, as well as less performant. /// + /// ### Example /// ```rust /// // Bad /// let x: String = std::iter::repeat('x').take(10).collect(); diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index ff3473b744e..dc2dd45e4ed 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -8,15 +8,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use std::cmp::Ordering; declare_clippy_lint! { - /// **What it does:** Checks for expressions where `std::cmp::min` and `max` are + /// ### What it does + /// Checks for expressions where `std::cmp::min` and `max` are /// used to clamp values, but switched so that the result is constant. /// - /// **Why is this bad?** This is in all probability not the intended outcome. At + /// ### Why is this bad? + /// This is in all probability not the intended outcome. At /// the least it hurts readability of the code. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```ignore /// min(0, max(100, x)) /// ``` diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 7cfce2e61cc..c796abe9815 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -25,10 +25,12 @@ use clippy_utils::{ }; declare_clippy_lint! { - /// **What it does:** Checks for function arguments and let bindings denoted as + /// ### What it does + /// Checks for function arguments and let bindings denoted as /// `ref`. /// - /// **Why is this bad?** The `ref` declaration makes the function take an owned + /// ### Why is this bad? + /// The `ref` declaration makes the function take an owned /// value, but turns the argument into a reference (which means that the value /// is destroyed when exiting the function). This adds not much value: either /// take a reference type, or take an owned value and create references in the @@ -37,11 +39,12 @@ declare_clippy_lint! { /// For let bindings, `let x = &foo;` is preferred over `let ref x = foo`. The /// type of `x` is more obvious with the former. /// - /// **Known problems:** If the argument is dereferenced within the function, + /// ### Known problems + /// If the argument is dereferenced within the function, /// removing the `ref` will lead to errors. This can be fixed by removing the /// dereferences, e.g., changing `*x` to `x` within the function. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // Bad /// fn foo(ref x: u8) -> bool { @@ -59,14 +62,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for comparisons to NaN. + /// ### What it does + /// Checks for comparisons to NaN. /// - /// **Why is this bad?** NaN does not compare meaningfully to anything – not + /// ### Why is this bad? + /// NaN does not compare meaningfully to anything – not /// even itself – so those comparisons are simply wrong. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let x = 1.0; /// @@ -82,18 +85,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for (in-)equality comparisons on floating-point + /// ### What it does + /// Checks for (in-)equality comparisons on floating-point /// values (apart from zero), except in functions called `*eq*` (which probably /// implement equality for a type involving floats). /// - /// **Why is this bad?** Floating point calculations are usually imprecise, so + /// ### Why is this bad? + /// Floating point calculations are usually imprecise, so /// asking if two values are *exactly* equal is asking for trouble. For a good /// guide on what to do, see [the floating point /// guide](http://www.floating-point-gui.de/errors/comparison). /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x = 1.2331f64; /// let y = 1.2332f64; @@ -115,16 +118,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for conversions to owned values just for the sake + /// ### What it does + /// Checks for conversions to owned values just for the sake /// of a comparison. /// - /// **Why is this bad?** The comparison can operate on a reference, so creating + /// ### Why is this bad? + /// The comparison can operate on a reference, so creating /// an owned value effectively throws it away directly afterwards, which is /// needlessly consuming code and heap space. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let x = "foo"; /// # let y = String::from("foo"); @@ -142,18 +145,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for getting the remainder of a division by one or minus + /// ### What it does + /// Checks for getting the remainder of a division by one or minus /// one. /// - /// **Why is this bad?** The result for a divisor of one can only ever be zero; for + /// ### Why is this bad? + /// The result for a divisor of one can only ever be zero; for /// minus one it can cause panic/overflow (if the left operand is the minimal value of /// the respective integer type) or results in zero. No one will write such code /// deliberately, unless trying to win an Underhanded Rust Contest. Even for that /// contest, it's probably a bad idea. Use something more underhanded. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let x = 1; /// let a = x % 1; @@ -165,17 +168,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the use of bindings with a single leading + /// ### What it does + /// Checks for the use of bindings with a single leading /// underscore. /// - /// **Why is this bad?** A single leading underscore is usually used to indicate + /// ### Why is this bad? + /// A single leading underscore is usually used to indicate /// that a binding will not be used. Using such a binding breaks this /// expectation. /// - /// **Known problems:** The lint does not work properly with desugaring and + /// ### Known problems + /// The lint does not work properly with desugaring and /// macro, it has been allowed in the mean time. /// - /// **Example:** + /// ### Example /// ```rust /// let _x = 0; /// let y = _x + 1; // Here we are using `_x`, even though it has a leading @@ -187,17 +193,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the use of short circuit boolean conditions as + /// ### What it does + /// Checks for the use of short circuit boolean conditions as /// a /// statement. /// - /// **Why is this bad?** Using a short circuit boolean condition as a statement + /// ### Why is this bad? + /// Using a short circuit boolean condition as a statement /// may hide the fact that the second part is executed or not depending on the /// outcome of the first part. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// f() && g(); // We should write `if f() { g(); }`. /// ``` @@ -207,15 +213,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Catch casts from `0` to some pointer type + /// ### What it does + /// Catch casts from `0` to some pointer type /// - /// **Why is this bad?** This generally means `null` and is better expressed as + /// ### Why is this bad? + /// This generally means `null` and is better expressed as /// {`std`, `core`}`::ptr::`{`null`, `null_mut`}. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Bad /// let a = 0 as *const u32; @@ -229,18 +234,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for (in-)equality comparisons on floating-point + /// ### What it does + /// Checks for (in-)equality comparisons on floating-point /// value and constant, except in functions called `*eq*` (which probably /// implement equality for a type involving floats). /// - /// **Why is this bad?** Floating point calculations are usually imprecise, so + /// ### Why is this bad? + /// Floating point calculations are usually imprecise, so /// asking if two values are *exactly* equal is asking for trouble. For a good /// guide on what to do, see [the floating point /// guide](http://www.floating-point-gui.de/errors/comparison). /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x: f64 = 1.0; /// const ONE: f64 = 1.00; diff --git a/clippy_lints/src/misc_early/mod.rs b/clippy_lints/src/misc_early/mod.rs index 050b6805b7c..06fe967dafc 100644 --- a/clippy_lints/src/misc_early/mod.rs +++ b/clippy_lints/src/misc_early/mod.rs @@ -18,14 +18,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; declare_clippy_lint! { - /// **What it does:** Checks for structure field patterns bound to wildcards. + /// ### What it does + /// Checks for structure field patterns bound to wildcards. /// - /// **Why is this bad?** Using `..` instead is shorter and leaves the focus on + /// ### Why is this bad? + /// Using `..` instead is shorter and leaves the focus on /// the fields that are actually bound. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # struct Foo { /// # a: i32, @@ -52,14 +52,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for function arguments having the similar names + /// ### What it does + /// Checks for function arguments having the similar names /// differing by an underscore. /// - /// **Why is this bad?** It affects code readability. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// It affects code readability. /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// fn foo(a: i32, _a: i32) {} @@ -73,14 +73,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Detects expressions of the form `--x`. + /// ### What it does + /// Detects expressions of the form `--x`. /// - /// **Why is this bad?** It can mislead C/C++ programmers to think `x` was + /// ### Why is this bad? + /// It can mislead C/C++ programmers to think `x` was /// decremented. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let mut x = 3; /// --x; @@ -91,14 +91,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns on hexadecimal literals with mixed-case letter + /// ### What it does + /// Warns on hexadecimal literals with mixed-case letter /// digits. /// - /// **Why is this bad?** It looks confusing. + /// ### Why is this bad? + /// It looks confusing. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// let y = 0x1a9BAcD; @@ -112,14 +112,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns if literal suffixes are not separated by an + /// ### What it does + /// Warns if literal suffixes are not separated by an /// underscore. /// - /// **Why is this bad?** It is much less readable. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// It is much less readable. /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// let y = 123832i32; @@ -133,17 +133,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns if an integral constant literal starts with `0`. + /// ### What it does + /// Warns if an integral constant literal starts with `0`. /// - /// **Why is this bad?** In some languages (including the infamous C language + /// ### Why is this bad? + /// In some languages (including the infamous C language /// and most of its /// family), this marks an octal constant. In Rust however, this is a decimal /// constant. This could /// be confusing for both the writer and a reader of the constant. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// /// In Rust: /// ```rust @@ -171,13 +171,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Warns if a generic shadows a built-in type. - /// - /// **Why is this bad?** This gives surprising type errors. + /// ### What it does + /// Warns if a generic shadows a built-in type. /// - /// **Known problems:** None. + /// ### Why is this bad? + /// This gives surprising type errors. /// - /// **Example:** + /// ### Example /// /// ```ignore /// impl Foo { @@ -192,14 +192,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for patterns in the form `name @ _`. + /// ### What it does + /// Checks for patterns in the form `name @ _`. /// - /// **Why is this bad?** It's almost always more readable to just use direct + /// ### Why is this bad? + /// It's almost always more readable to just use direct /// bindings. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let v = Some("abc"); /// @@ -221,19 +221,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for tuple patterns with a wildcard + /// ### What it does + /// Checks for tuple patterns with a wildcard /// pattern (`_`) is next to a rest pattern (`..`). /// /// _NOTE_: While `_, ..` means there is at least one element left, `..` /// means there are 0 or more elements left. This can make a difference /// when refactoring, but shouldn't result in errors in the refactored code, /// since the wildcard pattern isn't used anyway. - /// **Why is this bad?** The wildcard pattern is unneeded as the rest pattern + /// ### Why is this bad? + /// The wildcard pattern is unneeded as the rest pattern /// can match that element as well. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # struct TupleStruct(u32, u32, u32); /// # let t = TupleStruct(1, 2, 3); diff --git a/clippy_lints/src/missing_const_for_fn.rs b/clippy_lints/src/missing_const_for_fn.rs index 59cbc481ed4..5b2584d43a1 100644 --- a/clippy_lints/src/missing_const_for_fn.rs +++ b/clippy_lints/src/missing_const_for_fn.rs @@ -13,16 +13,13 @@ use rustc_span::Span; use rustc_typeck::hir_ty_to_ty; declare_clippy_lint! { - /// **What it does:** - /// + /// ### What it does /// Suggests the use of `const` in functions and methods where possible. /// - /// **Why is this bad?** - /// + /// ### Why is this bad? /// Not having the function const prevents callers of the function from being const as well. /// - /// **Known problems:** - /// + /// ### Known problems /// Const functions are currently still being worked on, with some features only being available /// on nightly. This lint does not consider all edge cases currently and the suggestions may be /// incorrect if you are using this lint on stable. @@ -42,8 +39,7 @@ declare_clippy_lint! { /// can't be const as it calls a non-const function. Making `a` const and running Clippy again, /// will suggest to make `b` const, too. /// - /// **Example:** - /// + /// ### Example /// ```rust /// # struct Foo { /// # random_number: usize, diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index ec1572c26c2..aeed8268902 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -17,15 +17,15 @@ use rustc_span::source_map::Span; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Warns if there is missing doc for any documentable item + /// ### What it does + /// Warns if there is missing doc for any documentable item /// (public or private). /// - /// **Why is this bad?** Doc is good. *rustc* has a `MISSING_DOCS` + /// ### Why is this bad? + /// Doc is good. *rustc* has a `MISSING_DOCS` /// allowed-by-default lint for /// public members, but has no way to enforce documentation of private items. /// This lint fixes that. - /// - /// **Known problems:** None. pub MISSING_DOCS_IN_PRIVATE_ITEMS, restriction, "detects missing documentation for public and private members" diff --git a/clippy_lints/src/missing_enforced_import_rename.rs b/clippy_lints/src/missing_enforced_import_rename.rs index 59565350f72..9d27870321c 100644 --- a/clippy_lints/src/missing_enforced_import_rename.rs +++ b/clippy_lints/src/missing_enforced_import_rename.rs @@ -10,17 +10,16 @@ use rustc_span::Symbol; use crate::utils::conf::Rename; declare_clippy_lint! { - /// **What it does:** Checks for imports that do not rename the item as specified + /// ### What it does + /// Checks for imports that do not rename the item as specified /// in the `enforce-import-renames` config option. /// - /// **Why is this bad?** Consistency is important, if a project has defined import + /// ### Why is this bad? + /// Consistency is important, if a project has defined import /// renames they should be followed. More practically, some item names are too /// vague outside of their defining scope this can enforce a more meaningful naming. /// - /// **Known problems:** None - /// - /// **Example:** - /// + /// ### Example /// An example clippy.toml configuration: /// ```toml /// # clippy.toml diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 041fe64a1a9..be5b4b4006f 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -7,10 +7,12 @@ use rustc_span::source_map::Span; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** it lints if an exported function, method, trait method with default impl, + /// ### What it does + /// it lints if an exported function, method, trait method with default impl, /// or trait method impl is not `#[inline]`. /// - /// **Why is this bad?** In general, it is not. Functions can be inlined across + /// ### Why is this bad? + /// In general, it is not. Functions can be inlined across /// crates when that's profitable as long as any form of LTO is used. When LTO is disabled, /// functions that are not `#[inline]` cannot be inlined across crates. Certain types of crates /// might intend for most of the methods in their public API to be able to be inlined across @@ -18,9 +20,7 @@ declare_clippy_lint! { /// sense. It allows the crate to require all exported methods to be `#[inline]` by default, and /// then opt out for specific methods where this might not make sense. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// pub fn foo() {} // missing #[inline] /// fn ok() {} // ok diff --git a/clippy_lints/src/modulo_arithmetic.rs b/clippy_lints/src/modulo_arithmetic.rs index 1414fdc1b11..2d14943b56c 100644 --- a/clippy_lints/src/modulo_arithmetic.rs +++ b/clippy_lints/src/modulo_arithmetic.rs @@ -9,18 +9,18 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use std::fmt::Display; declare_clippy_lint! { - /// **What it does:** Checks for modulo arithmetic. + /// ### What it does + /// Checks for modulo arithmetic. /// - /// **Why is this bad?** The results of modulo (%) operation might differ + /// ### Why is this bad? + /// The results of modulo (%) operation might differ /// depending on the language, when negative numbers are involved. /// If you interop with different languages it might be beneficial /// to double check all places that use modulo arithmetic. /// /// For example, in Rust `17 % -3 = 2`, but in Python `17 % -3 = -1`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x = -17 % 3; /// ``` diff --git a/clippy_lints/src/multiple_crate_versions.rs b/clippy_lints/src/multiple_crate_versions.rs index f5ce3e32551..1c61970fdc8 100644 --- a/clippy_lints/src/multiple_crate_versions.rs +++ b/clippy_lints/src/multiple_crate_versions.rs @@ -13,17 +13,20 @@ use if_chain::if_chain; use itertools::Itertools; declare_clippy_lint! { - /// **What it does:** Checks to see if multiple versions of a crate are being + /// ### What it does + /// Checks to see if multiple versions of a crate are being /// used. /// - /// **Why is this bad?** This bloats the size of targets, and can lead to + /// ### Why is this bad? + /// This bloats the size of targets, and can lead to /// confusing error messages when structs or traits are used interchangeably /// between different versions of a crate. /// - /// **Known problems:** Because this can be caused purely by the dependencies + /// ### Known problems + /// Because this can be caused purely by the dependencies /// themselves, it's not always possible to fix this issue. /// - /// **Example:** + /// ### Example /// ```toml /// # This will pull in both winapi v0.3.x and v0.2.x, triggering a warning. /// [dependencies] diff --git a/clippy_lints/src/mut_key.rs b/clippy_lints/src/mut_key.rs index 68f7cdf6ea0..2c7681c45a4 100644 --- a/clippy_lints/src/mut_key.rs +++ b/clippy_lints/src/mut_key.rs @@ -10,18 +10,21 @@ use rustc_span::symbol::sym; use std::iter; declare_clippy_lint! { - /// **What it does:** Checks for sets/maps with mutable key types. + /// ### What it does + /// Checks for sets/maps with mutable key types. /// - /// **Why is this bad?** All of `HashMap`, `HashSet`, `BTreeMap` and + /// ### Why is this bad? + /// All of `HashMap`, `HashSet`, `BTreeMap` and /// `BtreeSet` rely on either the hash or the order of keys be unchanging, /// so having types with interior mutability is a bad idea. /// - /// **Known problems:** It's correct to use a struct, that contains interior mutability + /// ### Known problems + /// It's correct to use a struct, that contains interior mutability /// as a key, when its `Hash` implementation doesn't access any of the interior mutable types. /// However, this lint is unable to recognize this, so it causes a false positive in theses cases. /// The `bytes` crate is a great example of this. /// - /// **Example:** + /// ### Example /// ```rust /// use std::cmp::{PartialEq, Eq}; /// use std::collections::HashSet; diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index 4b9c51d0c16..d5032c5ba7f 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -9,15 +9,15 @@ use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for instances of `mut mut` references. + /// ### What it does + /// Checks for instances of `mut mut` references. /// - /// **Why is this bad?** Multiple `mut`s don't add anything meaningful to the + /// ### Why is this bad? + /// Multiple `mut`s don't add anything meaningful to the /// source. This is either a copy'n'paste error, or it shows a fundamental /// misunderstanding of references. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let mut y = 1; /// let x = &mut &mut y; diff --git a/clippy_lints/src/mut_mutex_lock.rs b/clippy_lints/src/mut_mutex_lock.rs index b9ba74c7d02..85e870632a5 100644 --- a/clippy_lints/src/mut_mutex_lock.rs +++ b/clippy_lints/src/mut_mutex_lock.rs @@ -8,17 +8,16 @@ use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for `&mut Mutex::lock` calls + /// ### What it does + /// Checks for `&mut Mutex::lock` calls /// - /// **Why is this bad?** `Mutex::lock` is less efficient than + /// ### Why is this bad? + /// `Mutex::lock` is less efficient than /// calling `Mutex::get_mut`. In addition you also have a statically /// guarantee that the mutex isn't locked, instead of just a runtime /// guarantee. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// use std::sync::{Arc, Mutex}; /// diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 6efe8ffcde0..8d5d7951fc5 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -7,15 +7,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use std::iter; declare_clippy_lint! { - /// **What it does:** Detects passing a mutable reference to a function that only + /// ### What it does + /// Detects passing a mutable reference to a function that only /// requires an immutable reference. /// - /// **Why is this bad?** The mutable reference rules out all other references to + /// ### Why is this bad? + /// The mutable reference rules out all other references to /// the value. Also the code misleads about the intent of the call site. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// // Bad /// my_vec.push(&mut value) diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 81bf853300f..ee50891cc31 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -9,17 +9,17 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** Checks for function/method calls with a mutable + /// ### What it does + /// Checks for function/method calls with a mutable /// parameter in `debug_assert!`, `debug_assert_eq!` and `debug_assert_ne!` macros. /// - /// **Why is this bad?** In release builds `debug_assert!` macros are optimized out by the + /// ### Why is this bad? + /// In release builds `debug_assert!` macros are optimized out by the /// compiler. /// Therefore mutating something in a `debug_assert!` macro results in different behaviour /// between a release and debug build. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// debug_assert_eq!(vec![3].pop(), Some(3)); /// // or diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index 354e2c3fb74..436ceec6cfa 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -10,17 +10,20 @@ use rustc_middle::ty::{self, Ty}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for usages of `Mutex` where an atomic will do. + /// ### What it does + /// Checks for usages of `Mutex` where an atomic will do. /// - /// **Why is this bad?** Using a mutex just to make access to a plain bool or + /// ### Why is this bad? + /// Using a mutex just to make access to a plain bool or /// reference sequential is shooting flies with cannons. /// `std::sync::atomic::AtomicBool` and `std::sync::atomic::AtomicPtr` are leaner and /// faster. /// - /// **Known problems:** This lint cannot detect if the mutex is actually used + /// ### Known problems + /// This lint cannot detect if the mutex is actually used /// for waiting before a critical section. /// - /// **Example:** + /// ### Example /// ```rust /// # let y = true; /// @@ -38,17 +41,20 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usages of `Mutex` where `X` is an integral + /// ### What it does + /// Checks for usages of `Mutex` where `X` is an integral /// type. /// - /// **Why is this bad?** Using a mutex just to make access to a plain integer + /// ### Why is this bad? + /// Using a mutex just to make access to a plain integer /// sequential is /// shooting flies with cannons. `std::sync::atomic::AtomicUsize` is leaner and faster. /// - /// **Known problems:** This lint cannot detect if the mutex is actually used + /// ### Known problems + /// This lint cannot detect if the mutex is actually used /// for waiting before a critical section. /// - /// **Example:** + /// ### Example /// ```rust /// # use std::sync::Mutex; /// let x = Mutex::new(0usize); diff --git a/clippy_lints/src/needless_arbitrary_self_type.rs b/clippy_lints/src/needless_arbitrary_self_type.rs index fe3c4455be5..9a3d9383cd9 100644 --- a/clippy_lints/src/needless_arbitrary_self_type.rs +++ b/clippy_lints/src/needless_arbitrary_self_type.rs @@ -9,13 +9,13 @@ use rustc_span::symbol::kw; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** The lint checks for `self` in fn parameters that + /// ### What it does + /// The lint checks for `self` in fn parameters that /// specify the `Self`-type explicitly - /// **Why is this bad?** Increases the amount and decreases the readability of code + /// ### Why is this bad? + /// Increases the amount and decreases the readability of code /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// enum ValType { /// I32, diff --git a/clippy_lints/src/needless_bitwise_bool.rs b/clippy_lints/src/needless_bitwise_bool.rs index b30bfbd4294..203da29cb91 100644 --- a/clippy_lints/src/needless_bitwise_bool.rs +++ b/clippy_lints/src/needless_bitwise_bool.rs @@ -9,20 +9,19 @@ use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Checks for uses of bitwise and/or operators between booleans, where performance may be improved by using /// a lazy and. /// - /// **Why is this bad?** + /// ### Why is this bad? /// The bitwise operators do not support short-circuiting, so it may hinder code performance. /// Additionally, boolean logic "masked" as bitwise logic is not caught by lints like `unnecessary_fold` /// - /// **Known problems:** + /// ### Known problems /// This lint evaluates only when the right side is determined to have no side effects. At this time, that /// determination is quite conservative. /// - /// **Example:** - /// + /// ### Example /// ```rust /// let (x,y) = (true, false); /// if x & !y {} // where both x and y are booleans diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 780690548e5..36f2829a5b9 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -15,17 +15,20 @@ use rustc_span::source_map::Spanned; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** Checks for expressions of the form `if c { true } else { + /// ### What it does + /// Checks for expressions of the form `if c { true } else { /// false }` (or vice versa) and suggests using the condition directly. /// - /// **Why is this bad?** Redundant code. + /// ### Why is this bad? + /// Redundant code. /// - /// **Known problems:** Maybe false positives: Sometimes, the two branches are + /// ### Known problems + /// Maybe false positives: Sometimes, the two branches are /// painstakingly documented (which we, of course, do not detect), so they *may* /// have some value. Even then, the documentation can be rewritten to match the /// shorter code. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// if x { /// false @@ -43,15 +46,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for expressions of the form `x == true`, + /// ### What it does + /// Checks for expressions of the form `x == true`, /// `x != true` and order comparisons such as `x < true` (or vice versa) and /// suggest using the variable directly. /// - /// **Why is this bad?** Unnecessary code. + /// ### Why is this bad? + /// Unnecessary code. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// if x == true {} /// if y == false {} diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index dd1dfa2bdfb..3f0b23ee4d3 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -17,15 +17,15 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** Checks for address of operations (`&`) that are going to + /// ### What it does + /// Checks for address of operations (`&`) that are going to /// be dereferenced immediately by the compiler. /// - /// **Why is this bad?** Suggests that the receiver of the expression borrows + /// ### Why is this bad? + /// Suggests that the receiver of the expression borrows /// the expression. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// let x: &i32 = &&&&&&5; @@ -39,13 +39,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `ref` bindings which create a reference to a reference. - /// - /// **Why is this bad?** The address-of operator at the use site is clearer about the need for a reference. + /// ### What it does + /// Checks for `ref` bindings which create a reference to a reference. /// - /// **Known problems:** None. + /// ### Why is this bad? + /// The address-of operator at the use site is clearer about the need for a reference. /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// let x = Some(""); diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index 0e976b130eb..36879eda7c0 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -7,12 +7,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for bindings that destructure a reference and borrow the inner + /// ### What it does + /// Checks for bindings that destructure a reference and borrow the inner /// value with `&ref`. /// - /// **Why is this bad?** This pattern has no effect in almost all cases. + /// ### Why is this bad? + /// This pattern has no effect in almost all cases. /// - /// **Known problems:** In some cases, `&ref` is needed to avoid a lifetime mismatch error. + /// ### Known problems + /// In some cases, `&ref` is needed to avoid a lifetime mismatch error. /// Example: /// ```rust /// fn foo(a: &Option, b: &Option) { @@ -23,7 +26,7 @@ declare_clippy_lint! { /// } /// ``` /// - /// **Example:** + /// ### Example /// Bad: /// ```rust /// let mut v = Vec::::new(); diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index 1d19413e0d0..5088b8bb0d3 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -42,20 +42,20 @@ use rustc_span::source_map::{original_sp, DUMMY_SP}; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** The lint checks for `if`-statements appearing in loops + /// ### What it does + /// The lint checks for `if`-statements appearing in loops /// that contain a `continue` statement in either their main blocks or their /// `else`-blocks, when omitting the `else`-block possibly with some /// rearrangement of code can make the code easier to understand. /// - /// **Why is this bad?** Having explicit `else` blocks for `if` statements + /// ### Why is this bad? + /// Having explicit `else` blocks for `if` statements /// containing `continue` in their THEN branch adds unnecessary branching and /// nesting to the code. Having an else block containing just `continue` can /// also be better written by grouping the statements following the whole `if` /// statement within the THEN block and omitting the else block completely. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// # fn condition() -> bool { false } /// # fn update_condition() {} diff --git a/clippy_lints/src/needless_for_each.rs b/clippy_lints/src/needless_for_each.rs index a723a472a25..d9aa42fe8ee 100644 --- a/clippy_lints/src/needless_for_each.rs +++ b/clippy_lints/src/needless_for_each.rs @@ -16,18 +16,17 @@ use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::has_iter_method; declare_clippy_lint! { - /// **What it does:** Checks for usage of `for_each` that would be more simply written as a + /// ### What it does + /// Checks for usage of `for_each` that would be more simply written as a /// `for` loop. /// - /// **Why is this bad?** `for_each` may be used after applying iterator transformers like + /// ### Why is this bad? + /// `for_each` may be used after applying iterator transformers like /// `filter` for better readability and performance. It may also be used to fit a simple /// operation on one line. /// But when none of these apply, a simple `for` loop is more idiomatic. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let v = vec![0, 1, 2]; /// v.iter().for_each(|elem| { diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 283b1847b6c..03eeb54d8d1 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -24,20 +24,22 @@ use rustc_typeck::expr_use_visitor as euv; use std::borrow::Cow; declare_clippy_lint! { - /// **What it does:** Checks for functions taking arguments by value, but not + /// ### What it does + /// Checks for functions taking arguments by value, but not /// consuming them in its /// body. /// - /// **Why is this bad?** Taking arguments by reference is more flexible and can + /// ### Why is this bad? + /// Taking arguments by reference is more flexible and can /// sometimes avoid /// unnecessary allocations. /// - /// **Known problems:** + /// ### Known problems /// * This lint suggests taking an argument by reference, /// however sometimes it is better to let users decide the argument type /// (by using `Borrow` trait, for example), depending on how the function is used. /// - /// **Example:** + /// ### Example /// ```rust /// fn foo(v: Vec) { /// assert_eq!(v.len(), 42); diff --git a/clippy_lints/src/needless_question_mark.rs b/clippy_lints/src/needless_question_mark.rs index c64491c63e2..42e48336e15 100644 --- a/clippy_lints/src/needless_question_mark.rs +++ b/clippy_lints/src/needless_question_mark.rs @@ -10,15 +10,13 @@ use rustc_middle::ty::TyS; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Suggests alternatives for useless applications of `?` in terminating expressions /// - /// **Why is this bad?** There's no reason to use `?` to short-circuit when execution of the body will end there anyway. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// There's no reason to use `?` to short-circuit when execution of the body will end there anyway. /// + /// ### Example /// ```rust /// struct TO { /// magic: Option, diff --git a/clippy_lints/src/needless_update.rs b/clippy_lints/src/needless_update.rs index 8f325404deb..2a33b7392ca 100644 --- a/clippy_lints/src/needless_update.rs +++ b/clippy_lints/src/needless_update.rs @@ -5,18 +5,18 @@ use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for needlessly including a base struct on update + /// ### What it does + /// Checks for needlessly including a base struct on update /// when all fields are changed anyway. /// /// This lint is not applied to structs marked with /// [non_exhaustive](https://doc.rust-lang.org/reference/attributes/type_system.html). /// - /// **Why is this bad?** This will cost resources (because the base has to be + /// ### Why is this bad? + /// This will cost resources (because the base has to be /// somewhere), and make the code less readable. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # struct Point { /// # x: i32, 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 c824f6f54b5..6ad49b70605 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -8,19 +8,16 @@ use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Checks for the usage of negated comparison operators on types which only implement /// `PartialOrd` (e.g., `f64`). /// - /// **Why is this bad?** + /// ### Why is this bad? /// These operators make it easy to forget that the underlying types actually allow not only three /// potential Orderings (Less, Equal, Greater) but also a fourth one (Uncomparable). This is /// especially easy to miss if the operator based comparison result is negated. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// use std::cmp::Ordering; /// diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index d5e1ea6d242..fa36d8fb1b3 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -7,13 +7,16 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Span; declare_clippy_lint! { - /// **What it does:** Checks for multiplication by -1 as a form of negation. + /// ### What it does + /// Checks for multiplication by -1 as a form of negation. /// - /// **Why is this bad?** It's more readable to just negate. + /// ### Why is this bad? + /// It's more readable to just negate. /// - /// **Known problems:** This only catches integers (for now). + /// ### Known problems + /// This only catches integers (for now). /// - /// **Example:** + /// ### Example /// ```ignore /// x * -1 /// ``` diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index bc409dd6efb..5c63d245bf1 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -13,18 +13,17 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for types with a `fn new() -> Self` method and no + /// ### What it does + /// Checks for types with a `fn new() -> Self` method and no /// implementation of /// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html). /// - /// **Why is this bad?** The user might expect to be able to use + /// ### Why is this bad? + /// The user might expect to be able to use /// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html) as the /// type can be constructed without arguments. /// - /// **Known problems:** Hopefully none. - /// - /// **Example:** - /// + /// ### Example /// ```ignore /// struct Foo(Bar); /// diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 910b0536092..e07518b2586 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -9,15 +9,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use std::ops::Deref; declare_clippy_lint! { - /// **What it does:** Checks for statements which have no effect. + /// ### What it does + /// Checks for statements which have no effect. /// - /// **Why is this bad?** Similar to dead code, these statements are actually + /// ### Why is this bad? + /// Similar to dead code, these statements are actually /// executed. However, as they have no effect, all they do is make the code less /// readable. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// 0; /// ``` @@ -27,15 +27,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for expression statements that can be reduced to a + /// ### What it does + /// Checks for expression statements that can be reduced to a /// sub-expression. /// - /// **Why is this bad?** Expressions by themselves often have no side-effects. + /// ### Why is this bad? + /// Expressions by themselves often have no side-effects. /// Having such expressions reduces readability. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// compute_array()[0]; /// ``` diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index d775cd7c7f7..aa3067876eb 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -24,10 +24,12 @@ use rustc_typeck::hir_ty_to_ty; // FIXME: this is a correctness problem but there's no suitable // warn-by-default category. declare_clippy_lint! { - /// **What it does:** Checks for declaration of `const` items which is interior + /// ### What it does + /// Checks for declaration of `const` items which is interior /// mutable (e.g., contains a `Cell`, `Mutex`, `AtomicXxxx`, etc.). /// - /// **Why is this bad?** Consts are copied everywhere they are referenced, i.e., + /// ### Why is this bad? + /// Consts are copied everywhere they are referenced, i.e., /// every time you refer to the const a fresh instance of the `Cell` or `Mutex` /// or `AtomicXxxx` will be created, which defeats the whole purpose of using /// these types in the first place. @@ -35,7 +37,8 @@ declare_clippy_lint! { /// The `const` should better be replaced by a `static` item if a global /// variable is wanted, or replaced by a `const fn` if a constructor is wanted. /// - /// **Known problems:** A "non-constant" const item is a legacy way to supply an + /// ### Known problems + /// A "non-constant" const item is a legacy way to supply an /// initialized value to downstream `static` items (e.g., the /// `std::sync::ONCE_INIT` constant). In this case the use of `const` is legit, /// and this lint should be suppressed. @@ -52,7 +55,7 @@ declare_clippy_lint! { /// the interior mutable field is used or not. See issues /// [#5812](https://github.com/rust-lang/rust-clippy/issues/5812) and /// - /// **Example:** + /// ### Example /// ```rust /// use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; /// @@ -74,17 +77,20 @@ declare_clippy_lint! { // FIXME: this is a correctness problem but there's no suitable // warn-by-default category. declare_clippy_lint! { - /// **What it does:** Checks if `const` items which is interior mutable (e.g., + /// ### What it does + /// Checks if `const` items which is interior mutable (e.g., /// contains a `Cell`, `Mutex`, `AtomicXxxx`, etc.) has been borrowed directly. /// - /// **Why is this bad?** Consts are copied everywhere they are referenced, i.e., + /// ### Why is this bad? + /// Consts are copied everywhere they are referenced, i.e., /// every time you refer to the const a fresh instance of the `Cell` or `Mutex` /// or `AtomicXxxx` will be created, which defeats the whole purpose of using /// these types in the first place. /// /// The `const` value should be stored inside a `static` item. /// - /// **Known problems:** When an enum has variants with interior mutability, use of its non + /// ### Known problems + /// When an enum has variants with interior mutability, use of its non /// interior mutable variants can generate false positives. See issue /// [#3962](https://github.com/rust-lang/rust-clippy/issues/3962) /// @@ -93,7 +99,7 @@ declare_clippy_lint! { /// [#5812](https://github.com/rust-lang/rust-clippy/issues/5812) and /// [#3825](https://github.com/rust-lang/rust-clippy/issues/3825) /// - /// **Example:** + /// ### Example /// ```rust /// use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; /// const CONST_ATOM: AtomicUsize = AtomicUsize::new(12); diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 7183a7c3858..dc55b103eb6 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -12,14 +12,14 @@ use rustc_span::symbol::{Ident, Symbol}; use std::cmp::Ordering; declare_clippy_lint! { - /// **What it does:** Checks for names that are very similar and thus confusing. + /// ### What it does + /// Checks for names that are very similar and thus confusing. /// - /// **Why is this bad?** It's hard to distinguish between names that differ only + /// ### Why is this bad? + /// It's hard to distinguish between names that differ only /// by a single character. /// - /// **Known problems:** None? - /// - /// **Example:** + /// ### Example /// ```ignore /// let checked_exp = something; /// let checked_expr = something_else; @@ -30,15 +30,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for too many variables whose name consists of a + /// ### What it does + /// Checks for too many variables whose name consists of a /// single character. /// - /// **Why is this bad?** It's hard to memorize what a variable means without a + /// ### Why is this bad? + /// It's hard to memorize what a variable means without a /// descriptive name. /// - /// **Known problems:** None? - /// - /// **Example:** + /// ### Example /// ```ignore /// let (a, b, c, d, e, f, g) = (...); /// ``` @@ -48,15 +48,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks if you have variables whose name consists of just + /// ### What it does + /// Checks if you have variables whose name consists of just /// underscores and digits. /// - /// **Why is this bad?** It's hard to memorize what a variable means without a + /// ### Why is this bad? + /// It's hard to memorize what a variable means without a /// descriptive name. /// - /// **Known problems:** None? - /// - /// **Example:** + /// ### Example /// ```rust /// let _1 = 1; /// let ___1 = 1; diff --git a/clippy_lints/src/non_octal_unix_permissions.rs b/clippy_lints/src/non_octal_unix_permissions.rs index a83daea97bf..3b74f69d375 100644 --- a/clippy_lints/src/non_octal_unix_permissions.rs +++ b/clippy_lints/src/non_octal_unix_permissions.rs @@ -9,15 +9,14 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for non-octal values used to set Unix file permissions. + /// ### What it does + /// Checks for non-octal values used to set Unix file permissions. /// - /// **Why is this bad?** They will be converted into octal, creating potentially + /// ### Why is this bad? + /// They will be converted into octal, creating potentially /// unintended file permissions. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust,ignore /// use std::fs::OpenOptions; /// use std::os::unix::fs::OpenOptionsExt; diff --git a/clippy_lints/src/nonstandard_macro_braces.rs b/clippy_lints/src/nonstandard_macro_braces.rs index 043e7fa30d6..dbe9cbe0ded 100644 --- a/clippy_lints/src/nonstandard_macro_braces.rs +++ b/clippy_lints/src/nonstandard_macro_braces.rs @@ -13,16 +13,14 @@ use rustc_span::Span; use serde::{de, Deserialize}; declare_clippy_lint! { - /// **What it does:** Checks that common macros are used with consistent bracing. + /// ### What it does + /// Checks that common macros are used with consistent bracing. /// - /// **Why is this bad?** This is mostly a consistency lint although using () or [] + /// ### Why is this bad? + /// This is mostly a consistency lint although using () or [] /// doesn't give you a semicolon in item position, which can be unexpected. /// - /// **Known problems:** - /// None - /// - /// **Example:** - /// + /// ### Example /// ```rust /// vec!{1, 2, 3}; /// ``` diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index fded48038e3..4064d94da2a 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -8,15 +8,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::{Span, Spanned}; declare_clippy_lint! { - /// **What it does:** Checks for duplicate open options as well as combinations + /// ### What it does + /// Checks for duplicate open options as well as combinations /// that make no sense. /// - /// **Why is this bad?** In the best case, the code will be harder to read than + /// ### Why is this bad? + /// In the best case, the code will be harder to read than /// necessary. I don't know the worst case. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// use std::fs::OpenOptions; /// diff --git a/clippy_lints/src/option_env_unwrap.rs b/clippy_lints/src/option_env_unwrap.rs index b6f518661bd..d7306628030 100644 --- a/clippy_lints/src/option_env_unwrap.rs +++ b/clippy_lints/src/option_env_unwrap.rs @@ -7,17 +7,16 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for usage of `option_env!(...).unwrap()` and + /// ### What it does + /// Checks for usage of `option_env!(...).unwrap()` and /// suggests usage of the `env!` macro. /// - /// **Why is this bad?** Unwrapping the result of `option_env!` will panic + /// ### Why is this bad? + /// Unwrapping the result of `option_env!` will panic /// at run-time if the environment variable doesn't exist, whereas `env!` /// catches it at compile-time. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust,no_run /// let _ = option_env!("HOME").unwrap(); /// ``` diff --git a/clippy_lints/src/option_if_let_else.rs b/clippy_lints/src/option_if_let_else.rs index b2be35bdddb..7aef3a5f34c 100644 --- a/clippy_lints/src/option_if_let_else.rs +++ b/clippy_lints/src/option_if_let_else.rs @@ -12,24 +12,23 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Lints usage of `if let Some(v) = ... { y } else { x }` which is more /// idiomatically done with `Option::map_or` (if the else bit is a pure /// expression) or `Option::map_or_else` (if the else bit is an impure /// expression). /// - /// **Why is this bad?** + /// ### Why is this bad? /// Using the dedicated functions of the Option type is clearer and /// more concise than an `if let` expression. /// - /// **Known problems:** + /// ### Known problems /// This lint uses a deliberately conservative metric for checking /// if the inside of either body contains breaks or continues which will /// cause it to not suggest a fix if either block contains a loop with /// continues or breaks contained within the loop. /// - /// **Example:** - /// + /// ### Example /// ```rust /// # let optional: Option = Some(0); /// # fn do_complicated_function() -> u32 { 5 }; diff --git a/clippy_lints/src/overflow_check_conditional.rs b/clippy_lints/src/overflow_check_conditional.rs index e222782c2cc..34755afdb72 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -6,14 +6,14 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Detects classic underflow/overflow checks. + /// ### What it does + /// Detects classic underflow/overflow checks. /// - /// **Why is this bad?** Most classic C underflow/overflow checks will fail in + /// ### Why is this bad? + /// Most classic C underflow/overflow checks will fail in /// Rust. Users can use functions like `overflowing_*` and `wrapping_*` instead. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let a = 1; /// # let b = 2; diff --git a/clippy_lints/src/panic_in_result_fn.rs b/clippy_lints/src/panic_in_result_fn.rs index cef74d87e7c..e2b6ba8e2d2 100644 --- a/clippy_lints/src/panic_in_result_fn.rs +++ b/clippy_lints/src/panic_in_result_fn.rs @@ -8,14 +8,16 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{sym, Span}; declare_clippy_lint! { - /// **What it does:** Checks for usage of `panic!`, `unimplemented!`, `todo!`, `unreachable!` or assertions in a function of type result. + /// ### What it does + /// Checks for usage of `panic!`, `unimplemented!`, `todo!`, `unreachable!` or assertions in a function of type result. /// - /// **Why is this bad?** For some codebases, it is desirable for functions of type result to return an error instead of crashing. Hence panicking macros should be avoided. + /// ### Why is this bad? + /// For some codebases, it is desirable for functions of type result to return an error instead of crashing. Hence panicking macros should be avoided. /// - /// **Known problems:** Functions called from a function returning a `Result` may invoke a panicking macro. This is not checked. - /// - /// **Example:** + /// ### Known problems + /// Functions called from a function returning a `Result` may invoke a panicking macro. This is not checked. /// + /// ### Example /// ```rust /// fn result_with_panic() -> Result /// { diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index dc28874c16e..d8d9081d6f1 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -7,13 +7,13 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** Checks for usage of `panic!`. + /// ### What it does + /// Checks for usage of `panic!`. /// - /// **Why is this bad?** `panic!` will stop the execution of the executable + /// ### Why is this bad? + /// `panic!` will stop the execution of the executable /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```no_run /// panic!("even with a good reason"); /// ``` @@ -23,13 +23,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `unimplemented!`. - /// - /// **Why is this bad?** This macro should not be present in production code + /// ### What it does + /// Checks for usage of `unimplemented!`. /// - /// **Known problems:** None. + /// ### Why is this bad? + /// This macro should not be present in production code /// - /// **Example:** + /// ### Example /// ```no_run /// unimplemented!(); /// ``` @@ -39,13 +39,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `todo!`. + /// ### What it does + /// Checks for usage of `todo!`. /// - /// **Why is this bad?** This macro should not be present in production code + /// ### Why is this bad? + /// This macro should not be present in production code /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```no_run /// todo!(); /// ``` @@ -55,13 +55,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `unreachable!`. - /// - /// **Why is this bad?** This macro can cause code to panic + /// ### What it does + /// Checks for usage of `unreachable!`. /// - /// **Known problems:** None. + /// ### Why is this bad? + /// This macro can cause code to panic /// - /// **Example:** + /// ### Example /// ```no_run /// unreachable!(); /// ``` diff --git a/clippy_lints/src/partialeq_ne_impl.rs b/clippy_lints/src/partialeq_ne_impl.rs index 1251ddd9a02..4ec493e5f45 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -7,16 +7,16 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for manual re-implementations of `PartialEq::ne`. + /// ### What it does + /// Checks for manual re-implementations of `PartialEq::ne`. /// - /// **Why is this bad?** `PartialEq::ne` is required to always return the + /// ### Why is this bad? + /// `PartialEq::ne` is required to always return the /// negated result of `PartialEq::eq`, which is exactly what the default /// implementation does. Therefore, there should never be any need to /// re-implement it. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// struct Foo; /// diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index f6a70478559..f738ac25417 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -20,15 +20,18 @@ use rustc_target::spec::abi::Abi; use rustc_target::spec::Target; declare_clippy_lint! { - /// **What it does:** Checks for functions taking arguments by reference, where + /// ### What it does + /// Checks for functions taking arguments by reference, where /// the argument type is `Copy` and small enough to be more efficient to always /// pass by value. /// - /// **Why is this bad?** In many calling conventions instances of structs will + /// ### Why is this bad? + /// In many calling conventions instances of structs will /// be passed through registers if they fit into two or less general purpose /// registers. /// - /// **Known problems:** This lint is target register size dependent, it is + /// ### Known problems + /// This lint is target register size dependent, it is /// limited to 32-bit to try and reduce portability problems between 32 and /// 64-bit, but if you are compiling for 8 or 16-bit targets then the limit /// will be different. @@ -50,7 +53,7 @@ declare_clippy_lint! { /// that explains a real case in which this false positive /// led to an **undefined behaviour** introduced with unsafe code. /// - /// **Example:** + /// ### Example /// /// ```rust /// // Bad @@ -67,18 +70,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for functions taking arguments by value, where + /// ### What it does + /// Checks for functions taking arguments by value, where /// the argument type is `Copy` and large enough to be worth considering /// passing by reference. Does not trigger if the function is being exported, /// because that might induce API breakage, if the parameter is declared as mutable, /// or if the argument is a `self`. /// - /// **Why is this bad?** Arguments passed by value might result in an unnecessary + /// ### Why is this bad? + /// Arguments passed by value might result in an unnecessary /// shallow copy, taking up more space in the stack and requiring a call to /// `memcpy`, which can be expensive. /// - /// **Example:** - /// + /// ### Example /// ```rust /// #[derive(Clone, Copy)] /// struct TooLarge([u8; 2048]); diff --git a/clippy_lints/src/path_buf_push_overwrite.rs b/clippy_lints/src/path_buf_push_overwrite.rs index 00245926381..3df7a72d295 100644 --- a/clippy_lints/src/path_buf_push_overwrite.rs +++ b/clippy_lints/src/path_buf_push_overwrite.rs @@ -10,15 +10,15 @@ use rustc_span::symbol::sym; use std::path::{Component, Path}; declare_clippy_lint! { - /// **What it does:*** Checks for [push](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.push) + /// ### What it does + ///* Checks for [push](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.push) /// calls on `PathBuf` that can cause overwrites. /// - /// **Why is this bad?** Calling `push` with a root path at the start can overwrite the + /// ### Why is this bad? + /// Calling `push` with a root path at the start can overwrite the /// previous defined path. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// use std::path::PathBuf; /// diff --git a/clippy_lints/src/pattern_type_mismatch.rs b/clippy_lints/src/pattern_type_mismatch.rs index ea4065d371b..4534f6e2516 100644 --- a/clippy_lints/src/pattern_type_mismatch.rs +++ b/clippy_lints/src/pattern_type_mismatch.rs @@ -13,7 +13,8 @@ use rustc_span::source_map::Span; use std::iter; declare_clippy_lint! { - /// **What it does:** Checks for patterns that aren't exact representations of the types + /// ### What it does + /// Checks for patterns that aren't exact representations of the types /// they are applied to. /// /// To satisfy this lint, you will have to adjust either the expression that is matched @@ -32,14 +33,12 @@ declare_clippy_lint! { /// this lint can still be used to highlight areas of interest and ensure a good understanding /// of ownership semantics. /// - /// **Why is this bad?** It isn't bad in general. But in some contexts it can be desirable + /// ### Why is this bad? + /// It isn't bad in general. But in some contexts it can be desirable /// because it increases ownership hints in the code, and will guard against some changes /// in ownership. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// This example shows the basic adjustments necessary to satisfy the lint. Note how /// the matched expression is explicitly dereferenced with `*` and the `inner` variable /// is bound to a shared borrow via `ref inner`. diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index 9cf00c953b9..1a8da00d9d6 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -25,7 +25,8 @@ const ALLOWED_ODD_FUNCTIONS: [&str; 14] = [ ]; declare_clippy_lint! { - /// **What it does:** Checks for operations where precedence may be unclear + /// ### What it does + /// Checks for operations where precedence may be unclear /// and suggests to add parentheses. Currently it catches the following: /// * mixed usage of arithmetic and bit shifting/combining operators without /// parentheses @@ -33,13 +34,12 @@ declare_clippy_lint! { /// numeric literal) /// followed by a method call /// - /// **Why is this bad?** Not everyone knows the precedence of those operators by + /// ### Why is this bad? + /// Not everyone knows the precedence of those operators by /// heart, so expressions like these may trip others trying to reason about the /// code. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// * `1 << 2 + 3` equals 32, while `(1 << 2) + 3` equals 7 /// * `-1i32.abs()` equals -1, while `(-1i32).abs()` equals 1 pub PRECEDENCE, diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index b15447622a8..c0d1f1eb6e6 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -20,16 +20,19 @@ use rustc_span::{sym, MultiSpan}; use std::borrow::Cow; declare_clippy_lint! { - /// **What it does:** This lint checks for function arguments of type `&String` + /// ### What it does + /// This lint checks for function arguments of type `&String` /// or `&Vec` unless the references are mutable. It will also suggest you /// replace `.clone()` calls with the appropriate `.to_owned()`/`to_string()` /// calls. /// - /// **Why is this bad?** Requiring the argument to be of the specific size + /// ### Why is this bad? + /// Requiring the argument to be of the specific size /// makes the function less useful for no benefit; slices in the form of `&[T]` /// or `&str` usually suffice and can be obtained from other types, too. /// - /// **Known problems:** The lint does not follow data. So if you have an + /// ### Known problems + /// The lint does not follow data. So if you have an /// argument `x` and write `let y = x; y.clone()` the lint will not suggest /// changing that `.clone()` to `.to_owned()`. /// @@ -59,7 +62,7 @@ declare_clippy_lint! { /// other crates referencing it, of which you may not be aware. Carefully /// deprecate the function before applying the lint suggestions in this case. /// - /// **Example:** + /// ### Example /// ```ignore /// // Bad /// fn foo(&Vec) { .. } @@ -73,15 +76,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** This lint checks for equality comparisons with `ptr::null` + /// ### What it does + /// This lint checks for equality comparisons with `ptr::null` /// - /// **Why is this bad?** It's easier and more readable to use the inherent + /// ### Why is this bad? + /// It's easier and more readable to use the inherent /// `.is_null()` /// method instead /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// // Bad /// if x == ptr::null { @@ -99,19 +102,22 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** This lint checks for functions that take immutable + /// ### What it does + /// This lint checks for functions that take immutable /// references and return mutable ones. /// - /// **Why is this bad?** This is trivially unsound, as one can create two + /// ### Why is this bad? + /// This is trivially unsound, as one can create two /// mutable references from the same (immutable!) source. /// This [error](https://github.com/rust-lang/rust/issues/39465) /// actually lead to an interim Rust release 1.15.1. /// - /// **Known problems:** To be on the conservative side, if there's at least one + /// ### Known problems + /// To be on the conservative side, if there's at least one /// mutable reference with the output lifetime, this lint will not trigger. /// In practice, this case is unlikely anyway. /// - /// **Example:** + /// ### Example /// ```ignore /// fn foo(&Foo) -> &mut Bar { .. } /// ``` @@ -121,13 +127,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** This lint checks for invalid usages of `ptr::null`. - /// - /// **Why is this bad?** This causes undefined behavior. + /// ### What it does + /// This lint checks for invalid usages of `ptr::null`. /// - /// **Known problems:** None. + /// ### Why is this bad? + /// This causes undefined behavior. /// - /// **Example:** + /// ### Example /// ```ignore /// // Bad. Undefined behavior /// unsafe { std::slice::from_raw_parts(ptr::null(), 0); } diff --git a/clippy_lints/src/ptr_eq.rs b/clippy_lints/src/ptr_eq.rs index 77cfa3f6b17..d6d7049fb61 100644 --- a/clippy_lints/src/ptr_eq.rs +++ b/clippy_lints/src/ptr_eq.rs @@ -8,16 +8,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Use `std::ptr::eq` when applicable + /// ### What it does + /// Use `std::ptr::eq` when applicable /// - /// **Why is this bad?** `ptr::eq` can be used to compare `&T` references + /// ### Why is this bad? + /// `ptr::eq` can be used to compare `&T` references /// (which coerce to `*const T` implicitly) by their address rather than /// comparing the values they point to. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let a = &[1, 2, 3]; /// let b = &[1, 2, 3]; diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index afb198f4955..f1975056ddc 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -8,15 +8,15 @@ use rustc_span::sym; use std::fmt; declare_clippy_lint! { - /// **What it does:** Checks for usage of the `offset` pointer method with a `usize` casted to an + /// ### 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 + /// ### 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:** + /// ### Example /// ```rust /// let vec = vec![b'a', b'b', b'c']; /// let ptr = vec.as_ptr(); diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index d66bac52243..0e682c692c7 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -13,13 +13,13 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for expressions that could be replaced by the question mark operator. + /// ### What it does + /// Checks for expressions that could be replaced by the question mark operator. /// - /// **Why is this bad?** Question mark usage is more idiomatic. + /// ### Why is this bad? + /// Question mark usage is more idiomatic. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```ignore /// if option.is_none() { /// return None; diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index b41c478c266..0179bd48ee3 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -18,14 +18,14 @@ use rustc_span::symbol::Ident; use std::cmp::Ordering; declare_clippy_lint! { - /// **What it does:** Checks for zipping a collection with the range of + /// ### What it does + /// Checks for zipping a collection with the range of /// `0.._.len()`. /// - /// **Why is this bad?** The code is better expressed with `.enumerate()`. + /// ### Why is this bad? + /// The code is better expressed with `.enumerate()`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let x = vec![1]; /// x.iter().zip(0..x.len()); @@ -41,13 +41,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for exclusive ranges where 1 is added to the + /// ### What it does + /// Checks for exclusive ranges where 1 is added to the /// upper bound, e.g., `x..(y+1)`. /// - /// **Why is this bad?** The code is more readable with an inclusive range + /// ### Why is this bad? + /// The code is more readable with an inclusive range /// like `x..=y`. /// - /// **Known problems:** Will add unnecessary pair of parentheses when the + /// ### Known problems + /// Will add unnecessary pair of parentheses when the /// expression is not wrapped in a pair but starts with a opening parenthesis /// and ends with a closing one. /// I.e., `let _ = (f()+1)..(f()+1)` results in `let _ = ((f()+1)..=f())`. @@ -61,7 +64,7 @@ declare_clippy_lint! { /// `RangeBounds` trait /// ([#3307](https://github.com/rust-lang/rust-clippy/issues/3307)). /// - /// **Example:** + /// ### Example /// ```rust,ignore /// for x..(y+1) { .. } /// ``` @@ -75,18 +78,21 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for inclusive ranges where 1 is subtracted from + /// ### What it does + /// Checks for inclusive ranges where 1 is subtracted from /// the upper bound, e.g., `x..=(y-1)`. /// - /// **Why is this bad?** The code is more readable with an exclusive range + /// ### Why is this bad? + /// The code is more readable with an exclusive range /// like `x..y`. /// - /// **Known problems:** This will cause a warning that cannot be fixed if + /// ### Known problems + /// This will cause a warning that cannot be fixed if /// the consumer of the range only accepts a specific range type, instead of /// the generic `RangeBounds` trait /// ([#3307](https://github.com/rust-lang/rust-clippy/issues/3307)). /// - /// **Example:** + /// ### Example /// ```rust,ignore /// for x..=(y-1) { .. } /// ``` @@ -100,16 +106,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for range expressions `x..y` where both `x` and `y` + /// ### What it does + /// Checks for range expressions `x..y` where both `x` and `y` /// are constant and `x` is greater or equal to `y`. /// - /// **Why is this bad?** Empty ranges yield no values so iterating them is a no-op. + /// ### Why is this bad? + /// Empty ranges yield no values so iterating them is a no-op. /// Moreover, trying to use a reversed range to index a slice will panic at run-time. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust,no_run /// fn main() { /// (10..=0).for_each(|x| println!("{}", x)); @@ -133,16 +138,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for expressions like `x >= 3 && x < 8` that could + /// ### What it does + /// Checks for expressions like `x >= 3 && x < 8` that could /// be more readably expressed as `(3..8).contains(x)`. /// - /// **Why is this bad?** `contains` expresses the intent better and has less + /// ### Why is this bad? + /// `contains` expresses the intent better and has less /// failure modes (such as fencepost errors or using `||` instead of `&&`). /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // given /// let x = 6; diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 56ef95a88c8..530b3396abe 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -32,17 +32,18 @@ macro_rules! unwrap_or_continue { } declare_clippy_lint! { - /// **What it does:** Checks for a redundant `clone()` (and its relatives) which clones an owned + /// ### What it does + /// Checks for a redundant `clone()` (and its relatives) which clones an owned /// value that is going to be dropped without further use. /// - /// **Why is this bad?** It is not always possible for the compiler to eliminate useless + /// ### Why is this bad? + /// It is not always possible for the compiler to eliminate useless /// allocations and deallocations generated by redundant `clone()`s. /// - /// **Known problems:** - /// + /// ### Known problems /// False-negatives: analysis performed by this lint is conservative and limited. /// - /// **Example:** + /// ### Example /// ```rust /// # use std::path::Path; /// # #[derive(Clone)] diff --git a/clippy_lints/src/redundant_closure_call.rs b/clippy_lints/src/redundant_closure_call.rs index 8f56a21ac5b..a79b2fe76e2 100644 --- a/clippy_lints/src/redundant_closure_call.rs +++ b/clippy_lints/src/redundant_closure_call.rs @@ -14,15 +14,15 @@ use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Detects closures called in the same expression where they + /// ### What it does + /// Detects closures called in the same expression where they /// are defined. /// - /// **Why is this bad?** It is unnecessarily adding to the expression's + /// ### Why is this bad? + /// It is unnecessarily adding to the expression's /// complexity. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // Bad /// let a = (|| 42)() diff --git a/clippy_lints/src/redundant_else.rs b/clippy_lints/src/redundant_else.rs index 061526c6f09..68b256d2944 100644 --- a/clippy_lints/src/redundant_else.rs +++ b/clippy_lints/src/redundant_else.rs @@ -6,14 +6,16 @@ use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for `else` blocks that can be removed without changing semantics. + /// ### What it does + /// Checks for `else` blocks that can be removed without changing semantics. /// - /// **Why is this bad?** The `else` block adds unnecessary indentation and verbosity. + /// ### Why is this bad? + /// The `else` block adds unnecessary indentation and verbosity. /// - /// **Known problems:** Some may prefer to keep the `else` block for clarity. - /// - /// **Example:** + /// ### Known problems + /// Some may prefer to keep the `else` block for clarity. /// + /// ### Example /// ```rust /// fn my_func(count: u32) { /// if count == 0 { diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index d5ee8d3468d..47df4917510 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -8,15 +8,15 @@ use rustc_semver::RustcVersion; use rustc_session::{declare_tool_lint, impl_lint_pass}; declare_clippy_lint! { - /// **What it does:** Checks for fields in struct literals where shorthands + /// ### What it does + /// Checks for fields in struct literals where shorthands /// could be used. /// - /// **Why is this bad?** If the field and variable names are the same, + /// ### Why is this bad? + /// If the field and variable names are the same, /// the field name is redundant. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let bar: u8 = 123; /// diff --git a/clippy_lints/src/redundant_pub_crate.rs b/clippy_lints/src/redundant_pub_crate.rs index 05f9e01acb4..59a55b9dffa 100644 --- a/clippy_lints/src/redundant_pub_crate.rs +++ b/clippy_lints/src/redundant_pub_crate.rs @@ -5,16 +5,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; declare_clippy_lint! { - /// **What it does:** Checks for items declared `pub(crate)` that are not crate visible because they + /// ### What it does + /// Checks for items declared `pub(crate)` that are not crate visible because they /// are inside a private module. /// - /// **Why is this bad?** Writing `pub(crate)` is misleading when it's redundant due to the parent + /// ### Why is this bad? + /// Writing `pub(crate)` is misleading when it's redundant due to the parent /// module's visibility. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// mod internal { /// pub(crate) fn internal_fn() { } diff --git a/clippy_lints/src/redundant_slicing.rs b/clippy_lints/src/redundant_slicing.rs index 9c6cd7b4fa6..290348c4509 100644 --- a/clippy_lints/src/redundant_slicing.rs +++ b/clippy_lints/src/redundant_slicing.rs @@ -10,17 +10,19 @@ use rustc_middle::ty::TyS; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for redundant slicing expressions which use the full range, and + /// ### What it does + /// Checks for redundant slicing expressions which use the full range, and /// do not change the type. /// - /// **Why is this bad?** It unnecessarily adds complexity to the expression. + /// ### Why is this bad? + /// It unnecessarily adds complexity to the expression. /// - /// **Known problems:** If the type being sliced has an implementation of `Index` + /// ### Known problems + /// If the type being sliced has an implementation of `Index` /// that actually changes anything then it can't be removed. However, this would be surprising /// to people reading the code and should have a note with it. /// - /// **Example:** - /// + /// ### Example /// ```ignore /// fn get_slice(x: &[u32]) -> &[u32] { /// &x[..] diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index 48107d9c037..d5a1a61da6b 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -8,14 +8,14 @@ use rustc_semver::RustcVersion; use rustc_session::{declare_tool_lint, impl_lint_pass}; declare_clippy_lint! { - /// **What it does:** Checks for constants and statics with an explicit `'static` lifetime. + /// ### What it does + /// Checks for constants and statics with an explicit `'static` lifetime. /// - /// **Why is this bad?** Adding `'static` to every reference can create very + /// ### Why is this bad? + /// Adding `'static` to every reference can create very /// complicated types. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// const FOO: &'static [(&'static str, &'static str, fn(&Bar) -> bool)] = /// &[...] diff --git a/clippy_lints/src/ref_option_ref.rs b/clippy_lints/src/ref_option_ref.rs index 0cf4e0ce7fe..65ab6cac442 100644 --- a/clippy_lints/src/ref_option_ref.rs +++ b/clippy_lints/src/ref_option_ref.rs @@ -9,16 +9,18 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; declare_clippy_lint! { - /// **What it does:** Checks for usage of `&Option<&T>`. + /// ### What it does + /// Checks for usage of `&Option<&T>`. /// - /// **Why is this bad?** Since `&` is Copy, it's useless to have a + /// ### Why is this bad? + /// Since `&` is Copy, it's useless to have a /// reference on `Option<&T>`. /// - /// **Known problems:** It may be irrelevant to use this lint on + /// ### Known problems + /// It may be irrelevant to use this lint on /// public API code as it will make a breaking change to apply it. /// - /// **Example:** - /// + /// ### Example /// ```rust,ignore /// let x: &Option<&u32> = &Some(&0u32); /// ``` diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs index d6336389b0a..e0930d69ab9 100644 --- a/clippy_lints/src/reference.rs +++ b/clippy_lints/src/reference.rs @@ -10,15 +10,18 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::BytePos; declare_clippy_lint! { - /// **What it does:** Checks for usage of `*&` and `*&mut` in expressions. + /// ### What it does + /// Checks for usage of `*&` and `*&mut` in expressions. /// - /// **Why is this bad?** Immediately dereferencing a reference is no-op and + /// ### Why is this bad? + /// Immediately dereferencing a reference is no-op and /// makes the code less clear. /// - /// **Known problems:** Multiple dereference/addrof pairs are not handled so + /// ### Known problems + /// Multiple dereference/addrof pairs are not handled so /// the suggested fix for `x = **&&y` is `x = *&y`, which is still incorrect. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // Bad /// let a = f(*&mut b); @@ -101,13 +104,15 @@ impl EarlyLintPass for DerefAddrOf { } declare_clippy_lint! { - /// **What it does:** Checks for references in expressions that use + /// ### What it does + /// Checks for references in expressions that use /// auto dereference. /// - /// **Why is this bad?** The reference is a no-op and is automatically + /// ### Why is this bad? + /// The reference is a no-op and is automatically /// dereferenced by the compiler and makes the code less clear. /// - /// **Example:** + /// ### Example /// ```rust /// struct Point(u32, u32); /// let point = Point(30, 20); diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 75151167454..eab09733730 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -11,15 +11,15 @@ use rustc_span::source_map::{BytePos, Span}; use std::convert::TryFrom; declare_clippy_lint! { - /// **What it does:** Checks [regex](https://crates.io/crates/regex) creation + /// ### What it does + /// Checks [regex](https://crates.io/crates/regex) creation /// (with `Regex::new`, `RegexBuilder::new`, or `RegexSet::new`) for correct /// regex syntax. /// - /// **Why is this bad?** This will lead to a runtime panic. + /// ### Why is this bad? + /// This will lead to a runtime panic. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// Regex::new("|") /// ``` @@ -29,18 +29,21 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for trivial [regex](https://crates.io/crates/regex) + /// ### What it does + /// Checks for trivial [regex](https://crates.io/crates/regex) /// creation (with `Regex::new`, `RegexBuilder::new`, or `RegexSet::new`). /// - /// **Why is this bad?** Matching the regex can likely be replaced by `==` or + /// ### Why is this bad? + /// Matching the regex can likely be replaced by `==` or /// `str::starts_with`, `str::ends_with` or `std::contains` or other `str` /// methods. /// - /// **Known problems:** If the same regex is going to be applied to multiple + /// ### Known problems + /// If the same regex is going to be applied to multiple /// inputs, the precomputations done by `Regex` construction can give /// significantly better performance than any of the `str`-based methods. /// - /// **Example:** + /// ### Example /// ```ignore /// Regex::new("^foobar") /// ``` diff --git a/clippy_lints/src/repeat_once.rs b/clippy_lints/src/repeat_once.rs index 17cb96bc4eb..54b9c8b3275 100644 --- a/clippy_lints/src/repeat_once.rs +++ b/clippy_lints/src/repeat_once.rs @@ -11,7 +11,8 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for usage of `.repeat(1)` and suggest the following method for each types. + /// ### What it does + /// Checks for usage of `.repeat(1)` and suggest the following method for each types. /// - `.to_string()` for `str` /// - `.clone()` for `String` /// - `.to_vec()` for `slice` @@ -19,13 +20,11 @@ declare_clippy_lint! { /// The lint will evaluate constant expressions and values as arguments of `.repeat(..)` and emit a message if /// they are equivalent to `1`. (Related discussion in [rust-clippy#7306](https://github.com/rust-lang/rust-clippy/issues/7306)) /// - /// **Why is this bad?** For example, `String.repeat(1)` is equivalent to `.clone()`. If cloning + /// ### Why is this bad? + /// For example, `String.repeat(1)` is equivalent to `.clone()`. If cloning /// the string is the intention behind this, `clone()` should be used. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// fn main() { /// let x = String::from("hello world").repeat(1); diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 251d527c265..db4b1002ce1 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -15,15 +15,15 @@ use rustc_span::source_map::Span; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for `let`-bindings, which are subsequently + /// ### What it does + /// Checks for `let`-bindings, which are subsequently /// returned. /// - /// **Why is this bad?** It is just extraneous code. Remove it to make your code + /// ### Why is this bad? + /// It is just extraneous code. Remove it to make your code /// more rusty. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn foo() -> String { /// let x = String::new(); @@ -42,14 +42,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for return statements at the end of a block. + /// ### What it does + /// Checks for return statements at the end of a block. /// - /// **Why is this bad?** Removing the `return` and semicolon will make the code + /// ### Why is this bad? + /// Removing the `return` and semicolon will make the code /// more rusty. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn foo(x: usize) -> usize { /// return x; diff --git a/clippy_lints/src/self_assignment.rs b/clippy_lints/src/self_assignment.rs index e7925c4fbde..fbd65fef7d1 100644 --- a/clippy_lints/src/self_assignment.rs +++ b/clippy_lints/src/self_assignment.rs @@ -6,16 +6,18 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for explicit self-assignments. + /// ### What it does + /// Checks for explicit self-assignments. /// - /// **Why is this bad?** Self-assignments are redundant and unlikely to be + /// ### Why is this bad? + /// Self-assignments are redundant and unlikely to be /// intentional. /// - /// **Known problems:** If expression contains any deref coercions or + /// ### Known problems + /// If expression contains any deref coercions or /// indexing operations they are assumed not to have any side effects. /// - /// **Example:** - /// + /// ### Example /// ```rust /// struct Event { /// id: usize, diff --git a/clippy_lints/src/self_named_constructor.rs b/clippy_lints/src/self_named_constructor.rs index da991e1d90c..2123a14cc1b 100644 --- a/clippy_lints/src/self_named_constructor.rs +++ b/clippy_lints/src/self_named_constructor.rs @@ -6,14 +6,13 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Warns when constructors have the same name as their types. + /// ### What it does + /// Warns when constructors have the same name as their types. /// - /// **Why is this bad?** Repeating the name of the type is redundant. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Repeating the name of the type is redundant. /// + /// ### Example /// ```rust,ignore /// struct Foo {} /// diff --git a/clippy_lints/src/semicolon_if_nothing_returned.rs b/clippy_lints/src/semicolon_if_nothing_returned.rs index da3e30af35c..6966230156c 100644 --- a/clippy_lints/src/semicolon_if_nothing_returned.rs +++ b/clippy_lints/src/semicolon_if_nothing_returned.rs @@ -9,16 +9,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Looks for blocks of expressions and fires if the last expression returns + /// ### What it does + /// Looks for blocks of expressions and fires if the last expression returns /// `()` but is not followed by a semicolon. /// - /// **Why is this bad?** The semicolon might be optional but when extending the block with new + /// ### Why is this bad? + /// The semicolon might be optional but when extending the block with new /// code, it doesn't require a change in previous last line. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// fn main() { /// println!("Hello world") diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs index 169f7d26285..2cd0f85999c 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -5,14 +5,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for mis-uses of the serde API. + /// ### What it does + /// Checks for mis-uses of the serde API. /// - /// **Why is this bad?** Serde is very finnicky about how its API should be + /// ### Why is this bad? + /// Serde is very finnicky about how its API should be /// used, but the type system can't be used to enforce it (yet?). /// - /// **Known problems:** None. - /// - /// **Example:** Implementing `Visitor::visit_string` but not + /// ### Example + /// Implementing `Visitor::visit_string` but not /// `Visitor::visit_str`. pub SERDE_API_MISUSE, correctness, diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index ac3f7ebd14b..b28a37cabd4 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -14,17 +14,20 @@ use rustc_span::source_map::Span; use rustc_span::symbol::Symbol; declare_clippy_lint! { - /// **What it does:** Checks for bindings that shadow other bindings already in + /// ### What it does + /// Checks for bindings that shadow other bindings already in /// scope, while just changing reference level or mutability. /// - /// **Why is this bad?** Not much, in fact it's a very common pattern in Rust + /// ### Why is this bad? + /// Not much, in fact it's a very common pattern in Rust /// code. Still, some may opt to avoid it in their code base, they can set this /// lint to `Warn`. /// - /// **Known problems:** This lint, as the other shadowing related lints, + /// ### Known problems + /// This lint, as the other shadowing related lints, /// currently only catches very simple patterns. /// - /// **Example:** + /// ### Example /// ```rust /// # let x = 1; /// // Bad @@ -39,18 +42,21 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for bindings that shadow other bindings already in + /// ### What it does + /// Checks for bindings that shadow other bindings already in /// scope, while reusing the original value. /// - /// **Why is this bad?** Not too much, in fact it's a common pattern in Rust + /// ### Why is this bad? + /// Not too much, in fact it's a common pattern in Rust /// code. Still, some argue that name shadowing like this hurts readability, /// because a value may be bound to different things depending on position in /// the code. /// - /// **Known problems:** This lint, as the other shadowing related lints, + /// ### Known problems + /// This lint, as the other shadowing related lints, /// currently only catches very simple patterns. /// - /// **Example:** + /// ### Example /// ```rust /// let x = 2; /// let x = x + 1; @@ -66,21 +72,24 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for bindings that shadow other bindings already in + /// ### What it does + /// Checks for bindings that shadow other bindings already in /// scope, either without a initialization or with one that does not even use /// the original value. /// - /// **Why is this bad?** Name shadowing can hurt readability, especially in + /// ### Why is this bad? + /// Name shadowing can hurt readability, especially in /// large code bases, because it is easy to lose track of the active binding at /// any place in the code. This can be alleviated by either giving more specific /// names to bindings or introducing more scopes to contain the bindings. /// - /// **Known problems:** This lint, as the other shadowing related lints, + /// ### Known problems + /// This lint, as the other shadowing related lints, /// currently only catches very simple patterns. Note that /// `allow`/`warn`/`deny`/`forbid` attributes only work on the function level /// for this lint. /// - /// **Example:** + /// ### Example /// ```rust /// # let y = 1; /// # let z = 2; diff --git a/clippy_lints/src/single_component_path_imports.rs b/clippy_lints/src/single_component_path_imports.rs index 1eaad438237..f6487b8c46b 100644 --- a/clippy_lints/src/single_component_path_imports.rs +++ b/clippy_lints/src/single_component_path_imports.rs @@ -7,15 +7,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{edition::Edition, symbol::kw, Span, Symbol}; declare_clippy_lint! { - /// **What it does:** Checking for imports with single component use path. + /// ### What it does + /// Checking for imports with single component use path. /// - /// **Why is this bad?** Import with single component use path such as `use cratename;` + /// ### Why is this bad? + /// Import with single component use path such as `use cratename;` /// is not necessary, and thus should be removed. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust,ignore /// use regex; /// diff --git a/clippy_lints/src/size_of_in_element_count.rs b/clippy_lints/src/size_of_in_element_count.rs index b1965cfd601..3e4e4a8d0c0 100644 --- a/clippy_lints/src/size_of_in_element_count.rs +++ b/clippy_lints/src/size_of_in_element_count.rs @@ -11,16 +11,16 @@ use rustc_middle::ty::{self, Ty, TyS, TypeAndMut}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Detects expressions where + /// ### What it does + /// Detects expressions where /// `size_of::` or `size_of_val::` is used as a /// count of elements of type `T` /// - /// **Why is this bad?** These functions expect a count + /// ### Why is this bad? + /// These functions expect a count /// of `T` and not a number of bytes /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,no_run /// # use std::ptr::copy_nonoverlapping; /// # use std::mem::size_of; diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index e5c58d70b60..3d039e13065 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -13,14 +13,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; declare_clippy_lint! { - /// **What it does:** Checks slow zero-filled vector initialization + /// ### What it does + /// Checks slow zero-filled vector initialization /// - /// **Why is this bad?** These structures are non-idiomatic and less efficient than simply using + /// ### Why is this bad? + /// These structures are non-idiomatic and less efficient than simply using /// `vec![0; len]`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # use core::iter::repeat; /// # let len = 4; diff --git a/clippy_lints/src/stable_sort_primitive.rs b/clippy_lints/src/stable_sort_primitive.rs index 65790375c73..4ea1293d504 100644 --- a/clippy_lints/src/stable_sort_primitive.rs +++ b/clippy_lints/src/stable_sort_primitive.rs @@ -7,22 +7,18 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// When sorting primitive values (integers, bools, chars, as well /// as arrays, slices, and tuples of such items), it is better to /// use an unstable sort than a stable sort. /// - /// **Why is this bad?** + /// ### Why is this bad? /// Using a stable sort consumes more memory and cpu cycles. Because /// values which compare equal are identical, preserving their /// relative order (the guarantee that a stable sort provides) means /// nothing, while the extra costs still apply. /// - /// **Known problems:** - /// None - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let mut vec = vec![2, 1, 3]; /// vec.sort(); diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 958e462125e..1a78a4968e5 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -14,16 +14,15 @@ use rustc_span::source_map::Spanned; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for string appends of the form `x = x + y` (without + /// ### What it does + /// Checks for string appends of the form `x = x + y` (without /// `let`!). /// - /// **Why is this bad?** It's not really bad, but some people think that the + /// ### Why is this bad? + /// It's not really bad, but some people think that the /// `.push_str(_)` method is more readable. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let mut x = "Hello".to_owned(); /// x = x + ", World"; @@ -38,11 +37,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for all instances of `x + _` where `x` is of type + /// ### What it does + /// Checks for all instances of `x + _` where `x` is of type /// `String`, but only if [`string_add_assign`](#string_add_assign) does *not* /// match. /// - /// **Why is this bad?** It's not bad in and of itself. However, this particular + /// ### Why is this bad? + /// It's not bad in and of itself. However, this particular /// `Add` implementation is asymmetric (the other operand need not be `String`, /// but `x` does), while addition as mathematically defined is symmetric, also /// the `String::push_str(_)` function is a perfectly good replacement. @@ -52,10 +53,7 @@ declare_clippy_lint! { /// in other languages is actually fine, which is why we decided to make this /// particular lint `allow` by default. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let x = "Hello".to_owned(); /// x + ", World"; @@ -66,13 +64,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for the `as_bytes` method called on string literals + /// ### What it does + /// Checks for the `as_bytes` method called on string literals /// that contain only ASCII characters. /// - /// **Why is this bad?** Byte string literals (e.g., `b"foo"`) can be used + /// ### Why is this bad? + /// Byte string literals (e.g., `b"foo"`) can be used /// instead. They are shorter but less discoverable than `as_bytes()`. /// - /// **Known Problems:** + /// ### Known problems /// `"str".as_bytes()` and the suggested replacement of `b"str"` are not /// equivalent because they have different types. The former is `&[u8]` /// while the latter is `&[u8; 3]`. That means in general they will have a @@ -94,7 +94,7 @@ declare_clippy_lint! { /// `b"str"` but `&b"str"[..]`, which is a great deal of punctuation and not /// more readable than a function call. /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// let bs = "a byte string".as_bytes(); @@ -177,13 +177,13 @@ fn is_add(cx: &LateContext<'_>, src: &Expr<'_>, target: &Expr<'_>) -> bool { } declare_clippy_lint! { - /// **What it does:** Check if the string is transformed to byte array and casted back to string. + /// ### What it does + /// Check if the string is transformed to byte array and casted back to string. /// - /// **Why is this bad?** It's unnecessary, the string can be used directly. + /// ### Why is this bad? + /// It's unnecessary, the string can be used directly. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// let _ = std::str::from_utf8(&"Hello World!".as_bytes()[6..11]).unwrap(); /// ``` @@ -317,16 +317,15 @@ impl<'tcx> LateLintPass<'tcx> for StringLitAsBytes { } declare_clippy_lint! { - /// **What it does:** This lint checks for `.to_string()` method calls on values of type `&str`. + /// ### What it does + /// This lint checks for `.to_string()` method calls on values of type `&str`. /// - /// **Why is this bad?** The `to_string` method is also used on other types to convert them to a string. + /// ### Why is this bad? + /// The `to_string` method is also used on other types to convert them to a string. /// When called on a `&str` it turns the `&str` into the owned variant `String`, which can be better /// expressed with `.to_owned()`. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // example code where clippy issues a warning /// let _ = "str".to_string(); @@ -366,14 +365,14 @@ impl LateLintPass<'_> for StrToString { } declare_clippy_lint! { - /// **What it does:** This lint checks for `.to_string()` method calls on values of type `String`. + /// ### What it does + /// This lint checks for `.to_string()` method calls on values of type `String`. /// - /// **Why is this bad?** The `to_string` method is also used on other types to convert them to a string. + /// ### Why is this bad? + /// The `to_string` method is also used on other types to convert them to a string. /// When called on a `String` it only clones the `String`, which can be better expressed with `.clone()`. - /// **Known problems:** None. - /// - /// **Example:** /// + /// ### Example /// ```rust /// // example code where clippy issues a warning /// let msg = String::from("Hello World"); diff --git a/clippy_lints/src/strlen_on_c_strings.rs b/clippy_lints/src/strlen_on_c_strings.rs index 2ccf3a3796d..516fa3d95b4 100644 --- a/clippy_lints/src/strlen_on_c_strings.rs +++ b/clippy_lints/src/strlen_on_c_strings.rs @@ -11,16 +11,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::{sym, Symbol}; declare_clippy_lint! { - /// **What it does:** Checks for usage of `libc::strlen` on a `CString` or `CStr` value, + /// ### What it does + /// Checks for usage of `libc::strlen` on a `CString` or `CStr` value, /// and suggest calling `as_bytes().len()` or `to_bytes().len()` respectively instead. /// - /// **Why is this bad?** This avoids calling an unsafe `libc` function. + /// ### Why is this bad? + /// This avoids calling an unsafe `libc` function. /// Currently, it also avoids calculating the length. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust, ignore /// use std::ffi::CString; /// let cstring = CString::new("foo").expect("CString::new failed"); diff --git a/clippy_lints/src/suspicious_operation_groupings.rs b/clippy_lints/src/suspicious_operation_groupings.rs index bb707f78fcc..a8e962d1af3 100644 --- a/clippy_lints/src/suspicious_operation_groupings.rs +++ b/clippy_lints/src/suspicious_operation_groupings.rs @@ -13,20 +13,21 @@ use rustc_span::symbol::Ident; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Checks for unlikely usages of binary operators that are almost /// certainly typos and/or copy/paste errors, given the other usages /// of binary operators nearby. - /// **Why is this bad?** + /// + /// ### Why is this bad? /// They are probably bugs and if they aren't then they look like bugs /// and you should add a comment explaining why you are doing such an /// odd set of operations. - /// **Known problems:** + /// + /// ### Known problems /// There may be some false positives if you are trying to do something /// unusual that happens to look like a typo. /// - /// **Example:** - /// + /// ### Example /// ```rust /// struct Vec3 { /// x: f64, diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index f2bffd55321..682fad00a13 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -8,14 +8,14 @@ use rustc_middle::hir::map::Map; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Lints for suspicious operations in impls of arithmetic operators, e.g. + /// ### What it does + /// Lints for suspicious operations in impls of arithmetic operators, e.g. /// subtracting elements in an Add impl. /// - /// **Why this is bad?** This is probably a typo or copy-and-paste error and not intended. + /// ### Why is this bad? + /// This is probably a typo or copy-and-paste error and not intended. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```ignore /// impl Add for Foo { /// type Output = Foo; @@ -31,14 +31,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Lints for suspicious operations in impls of OpAssign, e.g. + /// ### What it does + /// Lints for suspicious operations in impls of OpAssign, e.g. /// subtracting elements in an AddAssign impl. /// - /// **Why this is bad?** This is probably a typo or copy-and-paste error and not intended. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// This is probably a typo or copy-and-paste error and not intended. /// - /// **Example:** + /// ### Example /// ```ignore /// impl AddAssign for Foo { /// fn add_assign(&mut self, other: Foo) { diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 19967e2c970..4fa8e77a67b 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -12,14 +12,14 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for manual swapping. + /// ### What it does + /// Checks for manual swapping. /// - /// **Why is this bad?** The `std::mem::swap` function exposes the intent better + /// ### Why is this bad? + /// The `std::mem::swap` function exposes the intent better /// without deinitializing or copying either variable. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let mut a = 42; /// let mut b = 1337; @@ -40,13 +40,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `foo = bar; bar = foo` sequences. - /// - /// **Why is this bad?** This looks like a failed attempt to swap. + /// ### What it does + /// Checks for `foo = bar; bar = foo` sequences. /// - /// **Known problems:** None. + /// ### Why is this bad? + /// This looks like a failed attempt to swap. /// - /// **Example:** + /// ### Example /// ```rust /// # let mut a = 1; /// # let mut b = 2; diff --git a/clippy_lints/src/tabs_in_doc_comments.rs b/clippy_lints/src/tabs_in_doc_comments.rs index e2c144709f5..6a73b94d87e 100644 --- a/clippy_lints/src/tabs_in_doc_comments.rs +++ b/clippy_lints/src/tabs_in_doc_comments.rs @@ -7,16 +7,16 @@ use rustc_span::source_map::{BytePos, Span}; use std::convert::TryFrom; declare_clippy_lint! { - /// **What it does:** Checks doc comments for usage of tab characters. + /// ### What it does + /// Checks doc comments for usage of tab characters. /// - /// **Why is this bad?** The rust style-guide promotes spaces instead of tabs for indentation. + /// ### Why is this bad? + /// The rust style-guide promotes spaces instead of tabs for indentation. /// To keep a consistent view on the source, also doc comments should not have tabs. /// Also, explaining ascii-diagrams containing tabs can get displayed incorrectly when the /// display settings of the author and reader differ. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// /// /// /// Struct to hold two strings: diff --git a/clippy_lints/src/temporary_assignment.rs b/clippy_lints/src/temporary_assignment.rs index 8ef25dc816c..a9da690339c 100644 --- a/clippy_lints/src/temporary_assignment.rs +++ b/clippy_lints/src/temporary_assignment.rs @@ -5,15 +5,15 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for construction of a structure or tuple just to + /// ### What it does + /// Checks for construction of a structure or tuple just to /// assign a value in it. /// - /// **Why is this bad?** Readability. If the structure is only created to be + /// ### Why is this bad? + /// Readability. If the structure is only created to be /// updated, why not write the structure you want in the first place? /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// (0, 0).0 = 1 /// ``` diff --git a/clippy_lints/src/to_digit_is_some.rs b/clippy_lints/src/to_digit_is_some.rs index c66a596c784..1c14a919995 100644 --- a/clippy_lints/src/to_digit_is_some.rs +++ b/clippy_lints/src/to_digit_is_some.rs @@ -9,12 +9,14 @@ use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for `.to_digit(..).is_some()` on `char`s. + /// ### What it does + /// Checks for `.to_digit(..).is_some()` on `char`s. /// - /// **Why is this bad?** This is a convoluted way of checking if a `char` is a digit. It's + /// ### Why is this bad? + /// This is a convoluted way of checking if a `char` is a digit. It's /// more straight forward to use the dedicated `is_digit` method. /// - /// **Example:** + /// ### Example /// ```rust /// # let c = 'c'; /// # let radix = 10; diff --git a/clippy_lints/src/to_string_in_display.rs b/clippy_lints/src/to_string_in_display.rs index 4fb297ac6c6..b036ed9a3d2 100644 --- a/clippy_lints/src/to_string_in_display.rs +++ b/clippy_lints/src/to_string_in_display.rs @@ -7,15 +7,15 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::symbol::sym; declare_clippy_lint! { - /// **What it does:** Checks for uses of `to_string()` in `Display` traits. + /// ### What it does + /// Checks for uses of `to_string()` in `Display` traits. /// - /// **Why is this bad?** Usually `to_string` is implemented indirectly + /// ### Why is this bad? + /// Usually `to_string` is implemented indirectly /// via `Display`. Hence using it while implementing `Display` would /// lead to infinite recursion. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// /// ```rust /// use std::fmt; diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index 74a94db1800..79367c4230c 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -11,14 +11,14 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** This lint warns about unnecessary type repetitions in trait bounds + /// ### What it does + /// This lint warns about unnecessary type repetitions in trait bounds /// - /// **Why is this bad?** Repeating the type for every bound makes the code + /// ### Why is this bad? + /// Repeating the type for every bound makes the code /// less readable than combining the bounds /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// pub fn foo(t: T) where T: Copy, T: Clone {} /// ``` @@ -34,15 +34,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for cases where generics are being used and multiple + /// ### What it does + /// Checks for cases where generics are being used and multiple /// syntax specifications for trait bounds are used simultaneously. /// - /// **Why is this bad?** Duplicate bounds makes the code + /// ### Why is this bad? + /// Duplicate bounds makes the code /// less readable than specifing them only once. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn func(arg: T) where T: Clone + Default {} /// ``` diff --git a/clippy_lints/src/transmute/mod.rs b/clippy_lints/src/transmute/mod.rs index 89fd5faa165..33ec9c331ce 100644 --- a/clippy_lints/src/transmute/mod.rs +++ b/clippy_lints/src/transmute/mod.rs @@ -20,15 +20,18 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; declare_clippy_lint! { - /// **What it does:** Checks for transmutes that can't ever be correct on any + /// ### What it does + /// Checks for transmutes that can't ever be correct on any /// architecture. /// - /// **Why is this bad?** It's basically guaranteed to be undefined behaviour. + /// ### Why is this bad? + /// It's basically guaranteed to be undefined behaviour. /// - /// **Known problems:** When accessing C, users might want to store pointer + /// ### Known problems + /// When accessing C, users might want to store pointer /// sized objects in `extradata` arguments to save an allocation. /// - /// **Example:** + /// ### Example /// ```ignore /// let ptr: *const T = core::intrinsics::transmute('x') /// ``` @@ -39,15 +42,15 @@ declare_clippy_lint! { // FIXME: Move this to `complexity` again, after #5343 is fixed declare_clippy_lint! { - /// **What it does:** Checks for transmutes to the original type of the object + /// ### What it does + /// Checks for transmutes to the original type of the object /// and transmutes that could be a cast. /// - /// **Why is this bad?** Readability. The code tricks people into thinking that + /// ### Why is this bad? + /// Readability. The code tricks people into thinking that /// something complex is going on. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// core::intrinsics::transmute(t); // where the result type is the same as `t`'s /// ``` @@ -58,14 +61,14 @@ declare_clippy_lint! { // FIXME: Merge this lint with USELESS_TRANSMUTE once that is out of the nursery. declare_clippy_lint! { - /// **What it does:**Checks for transmutes that could be a pointer cast. + /// ### What it does + ///Checks for transmutes that could be a pointer cast. /// - /// **Why is this bad?** Readability. The code tricks people into thinking that + /// ### Why is this bad? + /// Readability. The code tricks people into thinking that /// something complex is going on. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// /// ```rust /// # let p: *const [i32] = &[]; @@ -82,14 +85,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for transmutes between a type `T` and `*T`. + /// ### What it does + /// Checks for transmutes between a type `T` and `*T`. /// - /// **Why is this bad?** It's easy to mistakenly transmute between a type and a + /// ### Why is this bad? + /// It's easy to mistakenly transmute between a type and a /// pointer to that type. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// core::intrinsics::transmute(t) // where the result type is the same as /// // `*t` or `&t`'s @@ -100,17 +103,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for transmutes from a pointer to a reference. + /// ### What it does + /// Checks for transmutes from a pointer to a reference. /// - /// **Why is this bad?** This can always be rewritten with `&` and `*`. + /// ### Why is this bad? + /// This can always be rewritten with `&` and `*`. /// - /// **Known problems:** + /// ### Known problems /// - `mem::transmute` in statics and constants is stable from Rust 1.46.0, /// while dereferencing raw pointer is not stable yet. /// If you need to do this in those places, /// you would have to use `transmute` instead. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// unsafe { /// let _: &T = std::mem::transmute(p); // where p: *const T @@ -125,11 +130,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for transmutes from an integer to a `char`. + /// ### What it does + /// Checks for transmutes from an integer to a `char`. /// - /// **Why is this bad?** Not every integer is a Unicode scalar value. + /// ### Why is this bad? + /// Not every integer is a Unicode scalar value. /// - /// **Known problems:** + /// ### Known problems /// - [`from_u32`] which this lint suggests using is slower than `transmute` /// as it needs to validate the input. /// If you are certain that the input is always a valid Unicode scalar value, @@ -140,7 +147,7 @@ declare_clippy_lint! { /// [`from_u32`]: https://doc.rust-lang.org/std/char/fn.from_u32.html /// [`from_u32_unchecked`]: https://doc.rust-lang.org/std/char/fn.from_u32_unchecked.html /// - /// **Example:** + /// ### Example /// ```rust /// let x = 1_u32; /// unsafe { @@ -156,11 +163,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for transmutes from a `&[u8]` to a `&str`. + /// ### What it does + /// Checks for transmutes from a `&[u8]` to a `&str`. /// - /// **Why is this bad?** Not every byte slice is a valid UTF-8 string. + /// ### Why is this bad? + /// Not every byte slice is a valid UTF-8 string. /// - /// **Known problems:** + /// ### Known problems /// - [`from_utf8`] which this lint suggests using is slower than `transmute` /// as it needs to validate the input. /// If you are certain that the input is always a valid UTF-8, @@ -171,7 +180,7 @@ declare_clippy_lint! { /// [`from_utf8`]: https://doc.rust-lang.org/std/str/fn.from_utf8.html /// [`from_utf8_unchecked`]: https://doc.rust-lang.org/std/str/fn.from_utf8_unchecked.html /// - /// **Example:** + /// ### Example /// ```rust /// let b: &[u8] = &[1_u8, 2_u8]; /// unsafe { @@ -187,13 +196,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for transmutes from an integer to a `bool`. - /// - /// **Why is this bad?** This might result in an invalid in-memory representation of a `bool`. + /// ### What it does + /// Checks for transmutes from an integer to a `bool`. /// - /// **Known problems:** None. + /// ### Why is this bad? + /// This might result in an invalid in-memory representation of a `bool`. /// - /// **Example:** + /// ### Example /// ```rust /// let x = 1_u8; /// unsafe { @@ -209,14 +218,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for transmutes from an integer to a float. + /// ### What it does + /// Checks for transmutes from an integer to a float. /// - /// **Why is this bad?** Transmutes are dangerous and error-prone, whereas `from_bits` is intuitive + /// ### Why is this bad? + /// Transmutes are dangerous and error-prone, whereas `from_bits` is intuitive /// and safe. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// unsafe { /// let _: f32 = std::mem::transmute(1_u32); // where x: u32 @@ -231,14 +240,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for transmutes from a float to an integer. + /// ### What it does + /// Checks for transmutes from a float to an integer. /// - /// **Why is this bad?** Transmutes are dangerous and error-prone, whereas `to_bits` is intuitive + /// ### Why is this bad? + /// Transmutes are dangerous and error-prone, whereas `to_bits` is intuitive /// and safe. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// unsafe { /// let _: u32 = std::mem::transmute(1f32); @@ -253,15 +262,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for transmutes from a pointer to a pointer, or + /// ### What it does + /// Checks for transmutes from a pointer to a pointer, or /// from a reference to a reference. /// - /// **Why is this bad?** Transmutes are dangerous, and these can instead be + /// ### Why is this bad? + /// Transmutes are dangerous, and these can instead be /// written as casts. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let ptr = &1u32 as *const u32; /// unsafe { @@ -280,15 +289,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for transmutes between collections whose + /// ### What it does + /// Checks for transmutes between collections whose /// types have different ABI, size or alignment. /// - /// **Why is this bad?** This is undefined behavior. + /// ### Why is this bad? + /// This is undefined behavior. /// - /// **Known problems:** Currently, we cannot know whether a type is a + /// ### Known problems + /// Currently, we cannot know whether a type is a /// collection, so we just lint the ones that come with `std`. /// - /// **Example:** + /// ### Example /// ```rust /// // different size, therefore likely out-of-bounds memory access /// // You absolutely do not want this in your code! diff --git a/clippy_lints/src/transmuting_null.rs b/clippy_lints/src/transmuting_null.rs index 0c39d4d8cf4..a67fa792205 100644 --- a/clippy_lints/src/transmuting_null.rs +++ b/clippy_lints/src/transmuting_null.rs @@ -10,15 +10,18 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; declare_clippy_lint! { - /// **What it does:** Checks for transmute calls which would receive a null pointer. + /// ### What it does + /// Checks for transmute calls which would receive a null pointer. /// - /// **Why is this bad?** Transmuting a null pointer is undefined behavior. + /// ### Why is this bad? + /// Transmuting a null pointer is undefined behavior. /// - /// **Known problems:** Not all cases can be detected at the moment of this writing. + /// ### Known problems + /// Not all cases can be detected at the moment of this writing. /// For example, variables which hold a null pointer and are then fed to a `transmute` /// call, aren't detectable yet. /// - /// **Example:** + /// ### Example /// ```rust /// let null_ref: &u64 = unsafe { std::mem::transmute(0 as *const u64) }; /// ``` diff --git a/clippy_lints/src/try_err.rs b/clippy_lints/src/try_err.rs index f2ba2b2ecf6..1196271d5dd 100644 --- a/clippy_lints/src/try_err.rs +++ b/clippy_lints/src/try_err.rs @@ -13,16 +13,16 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for usages of `Err(x)?`. + /// ### What it does + /// Checks for usages of `Err(x)?`. /// - /// **Why is this bad?** The `?` operator is designed to allow calls that + /// ### Why is this bad? + /// The `?` operator is designed to allow calls that /// can fail to be easily chained. For example, `foo()?.bar()` or /// `foo(bar()?)`. Because `Err(x)?` can't be used that way (it will /// always return), it is more clear to write `return Err(x)`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn foo(fail: bool) -> Result { /// if fail { diff --git a/clippy_lints/src/types/mod.rs b/clippy_lints/src/types/mod.rs index 7d629b5455b..ad7409fe3a9 100644 --- a/clippy_lints/src/types/mod.rs +++ b/clippy_lints/src/types/mod.rs @@ -20,16 +20,16 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::source_map::Span; declare_clippy_lint! { - /// **What it does:** Checks for use of `Box>` anywhere in the code. + /// ### What it does + /// Checks for use of `Box>` anywhere in the code. /// Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information. /// - /// **Why is this bad?** `Vec` already keeps its contents in a separate area on + /// ### Why is this bad? + /// `Vec` already keeps its contents in a separate area on /// the heap. So if you `Box` it, you just add another level of indirection /// without any benefit whatsoever. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// struct X { /// values: Box>, @@ -49,16 +49,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for use of `Vec>` where T: Sized anywhere in the code. + /// ### What it does + /// Checks for use of `Vec>` where T: Sized anywhere in the code. /// Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information. /// - /// **Why is this bad?** `Vec` already keeps its contents in a separate area on + /// ### Why is this bad? + /// `Vec` already keeps its contents in a separate area on /// the heap. So if you `Box` its contents, you just add another level of indirection. /// - /// **Known problems:** Vec> makes sense if T is a large type (see [#3530](https://github.com/rust-lang/rust-clippy/issues/3530), + /// ### Known problems + /// Vec> makes sense if T is a large type (see [#3530](https://github.com/rust-lang/rust-clippy/issues/3530), /// 1st comment). /// - /// **Example:** + /// ### Example /// ```rust /// struct X { /// values: Vec>, @@ -78,19 +81,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for use of `Option>` in function signatures and type + /// ### What it does + /// Checks for use of `Option>` in function signatures and type /// definitions /// - /// **Why is this bad?** `Option<_>` represents an optional value. `Option>` + /// ### Why is this bad? + /// `Option<_>` represents an optional value. `Option>` /// represents an optional optional value which is logically the same thing as an optional /// value but has an unneeded extra level of wrapping. /// /// If you have a case where `Some(Some(_))`, `Some(None)` and `None` are distinct cases, /// consider a custom `enum` instead, with clear names for each case. /// - /// **Known problems:** None. - /// - /// **Example** + /// ### Example /// ```rust /// fn get_data() -> Option> { /// None @@ -116,10 +119,12 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usage of any `LinkedList`, suggesting to use a + /// ### What it does + /// Checks for usage of any `LinkedList`, suggesting to use a /// `Vec` or a `VecDeque` (formerly called `RingBuf`). /// - /// **Why is this bad?** Gankro says: + /// ### Why is this bad? + /// Gankro says: /// /// > The TL;DR of `LinkedList` is that it's built on a massive amount of /// pointers and indirection. @@ -138,10 +143,11 @@ declare_clippy_lint! { /// can still be better /// > because of how expensive it is to seek to the middle of a `LinkedList`. /// - /// **Known problems:** False positives – the instances where using a + /// ### Known problems + /// False positives – the instances where using a /// `LinkedList` makes sense are few and far between, but they can still happen. /// - /// **Example:** + /// ### Example /// ```rust /// # use std::collections::LinkedList; /// let x: LinkedList = LinkedList::new(); @@ -152,15 +158,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for use of `&Box` anywhere in the code. + /// ### What it does + /// Checks for use of `&Box` anywhere in the code. /// Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information. /// - /// **Why is this bad?** Any `&Box` can also be a `&T`, which is more + /// ### Why is this bad? + /// Any `&Box` can also be a `&T`, which is more /// general. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// fn foo(bar: &Box) { ... } /// ``` @@ -176,14 +182,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for use of redundant allocations anywhere in the code. + /// ### What it does + /// Checks for use of redundant allocations anywhere in the code. /// - /// **Why is this bad?** Expressions such as `Rc<&T>`, `Rc>`, `Rc>`, `Rc>`, Arc<&T>`, `Arc>`, + /// ### Why is this bad? + /// Expressions such as `Rc<&T>`, `Rc>`, `Rc>`, `Rc>`, Arc<&T>`, `Arc>`, /// `Arc>`, `Arc>`, `Box<&T>`, `Box>`, `Box>`, `Box>`, add an unnecessary level of indirection. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # use std::rc::Rc; /// fn foo(bar: Rc<&usize>) {} @@ -200,9 +206,11 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `Rc` and `Arc` when `T` is a mutable buffer type such as `String` or `Vec`. + /// ### What it does + /// Checks for `Rc` and `Arc` when `T` is a mutable buffer type such as `String` or `Vec`. /// - /// **Why is this bad?** Expressions such as `Rc` usually have no advantage over `Rc`, since + /// ### Why is this bad? + /// Expressions such as `Rc` usually have no advantage over `Rc`, since /// it is larger and involves an extra level of indirection, and doesn't implement `Borrow`. /// /// While mutating a buffer type would still be possible with `Rc::get_mut()`, it only @@ -211,10 +219,11 @@ declare_clippy_lint! { /// type with an interior mutable container (such as `RefCell` or `Mutex`) would normally /// be used. /// - /// **Known problems:** This pattern can be desirable to avoid the overhead of a `RefCell` or `Mutex` for + /// ### Known problems + /// This pattern can be desirable to avoid the overhead of a `RefCell` or `Mutex` for /// cases where mutation only happens before there are any additional references. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// # use std::rc::Rc; /// fn foo(interned: Rc) { ... } @@ -231,15 +240,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for types used in structs, parameters and `let` + /// ### What it does + /// Checks for types used in structs, parameters and `let` /// declarations above a certain complexity threshold. /// - /// **Why is this bad?** Too complex types make the code less readable. Consider + /// ### Why is this bad? + /// Too complex types make the code less readable. Consider /// using a `type` definition to simplify them. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # use std::rc::Rc; /// struct Foo { @@ -252,16 +261,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for `Rc>`. + /// ### What it does + /// Checks for `Rc>`. /// - /// **Why is this bad?** `Rc` is used in single thread and `Mutex` is used in multi thread. + /// ### Why is this bad? + /// `Rc` is used in single thread and `Mutex` is used in multi thread. /// Consider using `Rc>` in single thread or `Arc>` in multi thread. /// - /// **Known problems:** Sometimes combining generic types can lead to the requirement that a + /// ### Known problems + /// Sometimes combining generic types can lead to the requirement that a /// type use Rc in conjunction with Mutex. We must consider those cases false positives, but /// alas they are quite hard to rule out. Luckily they are also rare. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// use std::rc::Rc; /// use std::sync::Mutex; diff --git a/clippy_lints/src/undropped_manually_drops.rs b/clippy_lints/src/undropped_manually_drops.rs index f4f5e1233e3..47571e608c7 100644 --- a/clippy_lints/src/undropped_manually_drops.rs +++ b/clippy_lints/src/undropped_manually_drops.rs @@ -6,15 +6,17 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Prevents the safe `std::mem::drop` function from being called on `std::mem::ManuallyDrop`. + /// ### What it does + /// Prevents the safe `std::mem::drop` function from being called on `std::mem::ManuallyDrop`. /// - /// **Why is this bad?** The safe `drop` function does not drop the inner value of a `ManuallyDrop`. + /// ### Why is this bad? + /// The safe `drop` function does not drop the inner value of a `ManuallyDrop`. /// - /// **Known problems:** Does not catch cases if the user binds `std::mem::drop` + /// ### Known problems + /// Does not catch cases if the user binds `std::mem::drop` /// to a different name and calls it that way. /// - /// **Example:** - /// + /// ### Example /// ```rust /// struct S; /// drop(std::mem::ManuallyDrop::new(S)); diff --git a/clippy_lints/src/unicode.rs b/clippy_lints/src/unicode.rs index 2f0a61898ba..f337dec8f2b 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -10,14 +10,15 @@ use rustc_span::source_map::Span; use unicode_normalization::UnicodeNormalization; declare_clippy_lint! { - /// **What it does:** Checks for invisible Unicode characters in the code. + /// ### What it does + /// Checks for invisible Unicode characters in the code. /// - /// **Why is this bad?** Having an invisible character in the code makes for all + /// ### Why is this bad? + /// Having an invisible character in the code makes for all /// sorts of April fools, but otherwise is very much frowned upon. /// - /// **Known problems:** None. - /// - /// **Example:** You don't see it, but there may be a zero-width space or soft hyphen + /// ### Example + /// You don't see it, but there may be a zero-width space or soft hyphen /// some­where in this text. pub INVISIBLE_CHARACTERS, correctness, @@ -25,17 +26,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for non-ASCII characters in string literals. + /// ### What it does + /// Checks for non-ASCII characters in string literals. /// - /// **Why is this bad?** Yeah, we know, the 90's called and wanted their charset + /// ### Why is this bad? + /// Yeah, we know, the 90's called and wanted their charset /// back. Even so, there still are editors and other programs out there that /// don't work well with Unicode. So if the code is meant to be used /// internationally, on multiple operating systems, or has other portability /// requirements, activating this lint could be useful. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x = String::from("€"); /// ``` @@ -49,16 +50,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for string literals that contain Unicode in a form + /// ### What it does + /// Checks for string literals that contain Unicode in a form /// that is not equal to its /// [NFC-recomposition](http://www.unicode.org/reports/tr15/#Norm_Forms). /// - /// **Why is this bad?** If such a string is compared to another, the results + /// ### Why is this bad? + /// If such a string is compared to another, the results /// may be surprising. /// - /// **Known problems** None. - /// - /// **Example:** You may not see it, but "à"" and "à"" aren't the same string. The + /// ### Example + /// You may not see it, but "à"" and "à"" aren't the same string. The /// former when escaped is actually `"a\u{300}"` while the latter is `"\u{e0}"`. pub UNICODE_NOT_NFC, pedantic, diff --git a/clippy_lints/src/unit_return_expecting_ord.rs b/clippy_lints/src/unit_return_expecting_ord.rs index 1c420a50427..900d4531760 100644 --- a/clippy_lints/src/unit_return_expecting_ord.rs +++ b/clippy_lints/src/unit_return_expecting_ord.rs @@ -10,20 +10,22 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{BytePos, Span}; declare_clippy_lint! { - /// **What it does:** Checks for functions that expect closures of type + /// ### What it does + /// Checks for functions that expect closures of type /// Fn(...) -> Ord where the implemented closure returns the unit type. /// The lint also suggests to remove the semi-colon at the end of the statement if present. /// - /// **Why is this bad?** Likely, returning the unit type is unintentional, and + /// ### Why is this bad? + /// Likely, returning the unit type is unintentional, and /// could simply be caused by an extra semi-colon. Since () implements Ord /// it doesn't cause a compilation error. /// This is the same reasoning behind the unit_cmp lint. /// - /// **Known problems:** If returning unit is intentional, then there is no + /// ### Known problems + /// If returning unit is intentional, then there is no /// way of specifying this without triggering needless_return lint /// - /// **Example:** - /// + /// ### Example /// ```rust /// let mut twins = vec!((1, 1), (2, 2)); /// twins.sort_by_key(|x| { x.1; }); diff --git a/clippy_lints/src/unit_types/mod.rs b/clippy_lints/src/unit_types/mod.rs index 64420a03933..66b1abbe50b 100644 --- a/clippy_lints/src/unit_types/mod.rs +++ b/clippy_lints/src/unit_types/mod.rs @@ -8,14 +8,14 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for binding a unit value. + /// ### What it does + /// Checks for binding a unit value. /// - /// **Why is this bad?** A unit value cannot usefully be used anywhere. So + /// ### Why is this bad? + /// A unit value cannot usefully be used anywhere. So /// binding one is kind of pointless. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// let x = { /// 1; @@ -27,16 +27,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for comparisons to unit. This includes all binary + /// ### What it does + /// Checks for comparisons to unit. This includes all binary /// comparisons (like `==` and `<`) and asserts. /// - /// **Why is this bad?** Unit is always equal to itself, and thus is just a + /// ### Why is this bad? + /// Unit is always equal to itself, and thus is just a /// clumsily written constant. Mostly this happens when someone accidentally /// adds semicolons at the end of the operands. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # fn foo() {}; /// # fn bar() {}; @@ -74,14 +74,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for passing a unit value as an argument to a function without using a + /// ### What it does + /// Checks for passing a unit value as an argument to a function without using a /// unit literal (`()`). /// - /// **Why is this bad?** This is likely the result of an accidental semicolon. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// This is likely the result of an accidental semicolon. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// foo({ /// let a = bar(); diff --git a/clippy_lints/src/unnamed_address.rs b/clippy_lints/src/unnamed_address.rs index 9cca05b1f1a..1eafdee0352 100644 --- a/clippy_lints/src/unnamed_address.rs +++ b/clippy_lints/src/unnamed_address.rs @@ -7,16 +7,15 @@ use rustc_middle::ty; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for comparisons with an address of a function item. + /// ### What it does + /// Checks for comparisons with an address of a function item. /// - /// **Why is this bad?** Function item address is not guaranteed to be unique and could vary + /// ### Why is this bad? + /// Function item address is not guaranteed to be unique and could vary /// between different code generation units. Furthermore different function items could have /// the same address after being merged together. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// type F = fn(); /// fn a() {} @@ -31,17 +30,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for comparisons with an address of a trait vtable. + /// ### What it does + /// Checks for comparisons with an address of a trait vtable. /// - /// **Why is this bad?** Comparing trait objects pointers compares an vtable addresses which + /// ### Why is this bad? + /// Comparing trait objects pointers compares an vtable addresses which /// are not guaranteed to be unique and could vary between different code generation units. /// Furthermore vtables for different types could have the same address after being merged /// together. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust,ignore /// let a: Rc = ... /// let b: Rc = ... diff --git a/clippy_lints/src/unnecessary_self_imports.rs b/clippy_lints/src/unnecessary_self_imports.rs index 48c54d79cf1..4cfd2df551f 100644 --- a/clippy_lints/src/unnecessary_self_imports.rs +++ b/clippy_lints/src/unnecessary_self_imports.rs @@ -7,16 +7,18 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::kw; declare_clippy_lint! { - /// **What it does:** Checks for imports ending in `::{self}`. + /// ### What it does + /// Checks for imports ending in `::{self}`. /// - /// **Why is this bad?** In most cases, this can be written much more cleanly by omitting `::{self}`. + /// ### Why is this bad? + /// In most cases, this can be written much more cleanly by omitting `::{self}`. /// - /// **Known problems:** Removing `::{self}` will cause any non-module items at the same path to also be imported. + /// ### Known problems + /// Removing `::{self}` will cause any non-module items at the same path to also be imported. /// This might cause a naming conflict (https://github.com/rust-lang/rustfmt/issues/3568). This lint makes no attempt /// to detect this scenario and that is why it is a restriction lint. /// - /// **Example:** - /// + /// ### Example /// ```rust /// use std::io::{self}; /// ``` diff --git a/clippy_lints/src/unnecessary_sort_by.rs b/clippy_lints/src/unnecessary_sort_by.rs index 347d858b640..6fc5707a4ee 100644 --- a/clippy_lints/src/unnecessary_sort_by.rs +++ b/clippy_lints/src/unnecessary_sort_by.rs @@ -12,21 +12,20 @@ use rustc_span::symbol::Ident; use std::iter; declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Detects uses of `Vec::sort_by` passing in a closure /// which compares the two arguments, either directly or indirectly. /// - /// **Why is this bad?** + /// ### Why is this bad? /// It is more clear to use `Vec::sort_by_key` (or `Vec::sort` if /// possible) than to use `Vec::sort_by` and a more complicated /// closure. /// - /// **Known problems:** + /// ### Known problems /// If the suggested `Vec::sort_by_key` uses Reverse and it isn't already /// imported by a use statement, then it will need to be added manually. /// - /// **Example:** - /// + /// ### Example /// ```rust /// # struct A; /// # impl A { fn foo(&self) {} } diff --git a/clippy_lints/src/unnecessary_wraps.rs b/clippy_lints/src/unnecessary_wraps.rs index a85ffa6aa95..7a62b21937f 100644 --- a/clippy_lints/src/unnecessary_wraps.rs +++ b/clippy_lints/src/unnecessary_wraps.rs @@ -13,15 +13,17 @@ use rustc_span::symbol::sym; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** Checks for private functions that only return `Ok` or `Some`. + /// ### What it does + /// Checks for private functions that only return `Ok` or `Some`. /// - /// **Why is this bad?** It is not meaningful to wrap values when no `None` or `Err` is returned. + /// ### Why is this bad? + /// It is not meaningful to wrap values when no `None` or `Err` is returned. /// - /// **Known problems:** There can be false positives if the function signature is designed to + /// ### Known problems + /// There can be false positives if the function signature is designed to /// fit some external requirement. /// - /// **Example:** - /// + /// ### Example /// ```rust /// fn get_cool_number(a: bool, b: bool) -> Option { /// if a && b { diff --git a/clippy_lints/src/unnested_or_patterns.rs b/clippy_lints/src/unnested_or_patterns.rs index 07a4e294049..9acfbc994b3 100644 --- a/clippy_lints/src/unnested_or_patterns.rs +++ b/clippy_lints/src/unnested_or_patterns.rs @@ -17,22 +17,17 @@ use std::cell::Cell; use std::mem; declare_clippy_lint! { - /// **What it does:** - /// + /// ### What it does /// Checks for unnested or-patterns, e.g., `Some(0) | Some(2)` and /// suggests replacing the pattern with a nested one, `Some(0 | 2)`. /// /// Another way to think of this is that it rewrites patterns in /// *disjunctive normal form (DNF)* into *conjunctive normal form (CNF)*. /// - /// **Why is this bad?** - /// + /// ### Why is this bad? /// In the example above, `Some` is repeated, which unncessarily complicates the pattern. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// fn main() { /// if let Some(0) | Some(2) = Some(0) {} diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index 16ad9d2dfd3..3c694af2b9d 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -6,15 +6,15 @@ use rustc_span::source_map::Span; use rustc_span::symbol::Ident; declare_clippy_lint! { - /// **What it does:** Checks for imports that remove "unsafe" from an item's + /// ### What it does + /// Checks for imports that remove "unsafe" from an item's /// name. /// - /// **Why is this bad?** Renaming makes it less clear which traits and + /// ### Why is this bad? + /// Renaming makes it less clear which traits and /// structures are unsafe. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// use std::cell::{UnsafeCell as TotallySafeCell}; /// diff --git a/clippy_lints/src/unused_async.rs b/clippy_lints/src/unused_async.rs index 18ee07d3a95..3a6a07c5226 100644 --- a/clippy_lints/src/unused_async.rs +++ b/clippy_lints/src/unused_async.rs @@ -7,16 +7,15 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::Span; declare_clippy_lint! { - /// **What it does:** Checks for functions that are declared `async` but have no `.await`s inside of them. + /// ### What it does + /// Checks for functions that are declared `async` but have no `.await`s inside of them. /// - /// **Why is this bad?** Async functions with no async code create overhead, both mentally and computationally. + /// ### Why is this bad? + /// Async functions with no async code create overhead, both mentally and computationally. /// Callers of async methods either need to be calling from an async function themselves or run it on an executor, both of which /// causes runtime overhead and hassle for the caller. /// - /// **Known problems:** None - /// - /// **Example:** - /// + /// ### Example /// ```rust /// // Bad /// async fn get_random_number() -> i64 { diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index ee082d30d93..82bc4a6d153 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -5,9 +5,11 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for unused written/read amount. + /// ### What it does + /// Checks for unused written/read amount. /// - /// **Why is this bad?** `io::Write::write(_vectored)` and + /// ### Why is this bad? + /// `io::Write::write(_vectored)` and /// `io::Read::read(_vectored)` are not guaranteed to /// process the entire buffer. They return how many bytes were processed, which /// might be smaller @@ -15,9 +17,10 @@ declare_clippy_lint! { /// partial-write/read, use /// `write_all`/`read_exact` instead. /// - /// **Known problems:** Detects only common patterns. + /// ### Known problems + /// Detects only common patterns. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// use std::io; /// fn foo(w: &mut W) -> io::Result<()> { diff --git a/clippy_lints/src/unused_self.rs b/clippy_lints/src/unused_self.rs index 15343cf90f2..658ac81f6ea 100644 --- a/clippy_lints/src/unused_self.rs +++ b/clippy_lints/src/unused_self.rs @@ -6,14 +6,14 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks methods that contain a `self` argument but don't use it + /// ### What it does + /// Checks methods that contain a `self` argument but don't use it /// - /// **Why is this bad?** It may be clearer to define the method as an associated function instead + /// ### Why is this bad? + /// It may be clearer to define the method as an associated function instead /// of an instance method if it doesn't require `self`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust,ignore /// struct A; /// impl A { diff --git a/clippy_lints/src/unused_unit.rs b/clippy_lints/src/unused_unit.rs index ab0cdf75ffe..9ed5e585f84 100644 --- a/clippy_lints/src/unused_unit.rs +++ b/clippy_lints/src/unused_unit.rs @@ -10,15 +10,15 @@ use rustc_span::source_map::Span; use rustc_span::BytePos; declare_clippy_lint! { - /// **What it does:** Checks for unit (`()`) expressions that can be removed. + /// ### What it does + /// Checks for unit (`()`) expressions that can be removed. /// - /// **Why is this bad?** Such expressions add no value, but can make the code + /// ### Why is this bad? + /// Such expressions add no value, but can make the code /// less readable. Depending on formatting they can make a `break` or `return` /// statement look like a function call. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// fn return_unit() -> () { /// () diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index d4efee56eff..c5b8acb9982 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -13,13 +13,13 @@ use rustc_span::source_map::Span; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for calls of `unwrap[_err]()` that cannot fail. + /// ### What it does + /// Checks for calls of `unwrap[_err]()` that cannot fail. /// - /// **Why is this bad?** Using `if let` or `match` is more idiomatic. + /// ### Why is this bad? + /// Using `if let` or `match` is more idiomatic. /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// ```rust /// # let option = Some(0); /// # fn do_something_with(_x: usize) {} @@ -43,14 +43,17 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls of `unwrap[_err]()` that will always fail. + /// ### What it does + /// Checks for calls of `unwrap[_err]()` that will always fail. /// - /// **Why is this bad?** If panicking is desired, an explicit `panic!()` should be used. + /// ### Why is this bad? + /// If panicking is desired, an explicit `panic!()` should be used. /// - /// **Known problems:** This lint only checks `if` conditions not assignments. + /// ### Known problems + /// This lint only checks `if` conditions not assignments. /// So something like `let x: Option<()> = None; x.unwrap();` will not be recognized. /// - /// **Example:** + /// ### Example /// ```rust /// # let option = Some(0); /// # fn do_something_with(_x: usize) {} diff --git a/clippy_lints/src/unwrap_in_result.rs b/clippy_lints/src/unwrap_in_result.rs index d17aa6d8424..6eadd1fc1c9 100644 --- a/clippy_lints/src/unwrap_in_result.rs +++ b/clippy_lints/src/unwrap_in_result.rs @@ -12,13 +12,16 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{sym, Span}; declare_clippy_lint! { - /// **What it does:** Checks for functions of type Result that contain `expect()` or `unwrap()` + /// ### What it does + /// Checks for functions of type Result that contain `expect()` or `unwrap()` /// - /// **Why is this bad?** These functions promote recoverable errors to non-recoverable errors which may be undesirable in code bases which wish to avoid panics. + /// ### Why is this bad? + /// These functions promote recoverable errors to non-recoverable errors which may be undesirable in code bases which wish to avoid panics. /// - /// **Known problems:** This can cause false positives in functions that handle both recoverable and non recoverable errors. + /// ### Known problems + /// This can cause false positives in functions that handle both recoverable and non recoverable errors. /// - /// **Example:** + /// ### Example /// Before: /// ```rust /// fn divisible_by_3(i_str: String) -> Result<(), String> { diff --git a/clippy_lints/src/upper_case_acronyms.rs b/clippy_lints/src/upper_case_acronyms.rs index 0b58c6c0917..7fa0e23ee73 100644 --- a/clippy_lints/src/upper_case_acronyms.rs +++ b/clippy_lints/src/upper_case_acronyms.rs @@ -8,9 +8,11 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::symbol::Ident; declare_clippy_lint! { - /// **What it does:** Checks for fully capitalized names and optionally names containing a capitalized acronym. + /// ### What it does + /// Checks for fully capitalized names and optionally names containing a capitalized acronym. /// - /// **Why is this bad?** In CamelCase, acronyms count as one word. + /// ### Why is this bad? + /// In CamelCase, acronyms count as one word. /// See [naming conventions](https://rust-lang.github.io/api-guidelines/naming.html#casing-conforms-to-rfc-430-c-case) /// for more. /// @@ -18,12 +20,12 @@ declare_clippy_lint! { /// You can use the `upper-case-acronyms-aggressive: true` config option to enable linting /// on all camel case names /// - /// **Known problems:** When two acronyms are contiguous, the lint can't tell where + /// ### Known problems + /// When two acronyms are contiguous, the lint can't tell where /// the first acronym ends and the second starts, so it suggests to lowercase all of /// the letters in the second acronym. /// - /// **Example:** - /// + /// ### Example /// ```rust /// struct HTTPResponse; /// ``` diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index 71117e967e3..fbd552186df 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -20,19 +20,20 @@ use rustc_span::Span; use rustc_typeck::hir_ty_to_ty; declare_clippy_lint! { - /// **What it does:** Checks for unnecessary repetition of structure name when a + /// ### What it does + /// Checks for unnecessary repetition of structure name when a /// replacement with `Self` is applicable. /// - /// **Why is this bad?** Unnecessary repetition. Mixed use of `Self` and struct + /// ### Why is this bad? + /// Unnecessary repetition. Mixed use of `Self` and struct /// name /// feels inconsistent. /// - /// **Known problems:** + /// ### Known problems /// - Unaddressed false negative in fn bodies of trait implementations /// - False positive with assotiated types in traits (#4140) /// - /// **Example:** - /// + /// ### Example /// ```rust /// struct Foo {} /// impl Foo { diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index 25a959d3e41..2861b432919 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -12,15 +12,14 @@ use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::sym; declare_clippy_lint! { - /// **What it does:** Checks for `Into`, `TryInto`, `From`, `TryFrom`, or `IntoIter` calls + /// ### What it does + /// Checks for `Into`, `TryInto`, `From`, `TryFrom`, or `IntoIter` calls /// which uselessly convert to the same type. /// - /// **Why is this bad?** Redundant code. - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? + /// Redundant code. /// + /// ### Example /// ```rust /// // Bad /// // format!() returns a `String` diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index c1e7fd7fe95..61fd375a989 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -13,9 +13,10 @@ use rustc_middle::hir::map::Map; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Generates clippy code that detects the offending pattern + /// ### What it does + /// Generates clippy code that detects the offending pattern /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // ./tests/ui/my_lint.rs /// fn foo() { diff --git a/clippy_lints/src/utils/inspector.rs b/clippy_lints/src/utils/inspector.rs index 4665eeeff7b..f7ddee12dcf 100644 --- a/clippy_lints/src/utils/inspector.rs +++ b/clippy_lints/src/utils/inspector.rs @@ -8,10 +8,11 @@ use rustc_session::Session; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Dumps every ast/hir node which has the `#[clippy::dump]` + /// ### What it does + /// Dumps every ast/hir node which has the `#[clippy::dump]` /// attribute /// - /// **Example:** + /// ### Example /// ```rust,ignore /// #[clippy::dump] /// extern crate foo; diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index 668807f499f..d660008e7d1 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -36,29 +36,33 @@ use std::borrow::{Borrow, Cow}; pub mod metadata_collector; declare_clippy_lint! { - /// **What it does:** Checks for various things we like to keep tidy in clippy. + /// ### What it does + /// Checks for various things we like to keep tidy in clippy. /// - /// **Why is this bad?** We like to pretend we're an example of tidy code. + /// ### Why is this bad? + /// We like to pretend we're an example of tidy code. /// - /// **Known problems:** None. - /// - /// **Example:** Wrong ordering of the util::paths constants. + /// ### Example + /// Wrong ordering of the util::paths constants. pub CLIPPY_LINTS_INTERNAL, internal, "various things that will negatively affect your clippy experience" } declare_clippy_lint! { - /// **What it does:** Ensures every lint is associated to a `LintPass`. + /// ### What it does + /// Ensures every lint is associated to a `LintPass`. /// - /// **Why is this bad?** The compiler only knows lints via a `LintPass`. Without + /// ### Why is this bad? + /// The compiler only knows lints via a `LintPass`. Without /// putting a lint to a `LintPass::get_lints()`'s return, the compiler will not /// know the name of the lint. /// - /// **Known problems:** Only checks for lints associated using the + /// ### Known problems + /// Only checks for lints associated using the /// `declare_lint_pass!`, `impl_lint_pass!`, and `lint_array!` macros. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// declare_lint! { pub LINT_1, ... } /// declare_lint! { pub LINT_2, ... } @@ -73,15 +77,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to `cx.span_lint*` and suggests to use the `utils::*` + /// ### What it does + /// Checks for calls to `cx.span_lint*` and suggests to use the `utils::*` /// variant of the function. /// - /// **Why is this bad?** The `utils::*` variants also add a link to the Clippy documentation to the + /// ### Why is this bad? + /// The `utils::*` variants also add a link to the Clippy documentation to the /// warning/error messages. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// Bad: /// ```rust,ignore /// cx.span_lint(LINT_NAME, "message"); @@ -97,14 +101,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to `cx.outer().expn_data()` and suggests to use + /// ### What it does + /// Checks for calls to `cx.outer().expn_data()` and suggests to use /// the `cx.outer_expn_data()` /// - /// **Why is this bad?** `cx.outer_expn_data()` is faster and more concise. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// `cx.outer_expn_data()` is faster and more concise. /// - /// **Example:** + /// ### Example /// Bad: /// ```rust,ignore /// expr.span.ctxt().outer().expn_data() @@ -120,14 +124,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Not an actual lint. This lint is only meant for testing our customized internal compiler + /// ### What it does + /// Not an actual lint. This lint is only meant for testing our customized internal compiler /// error message by calling `panic`. /// - /// **Why is this bad?** ICE in large quantities can damage your teeth + /// ### Why is this bad? + /// ICE in large quantities can damage your teeth /// - /// **Known problems:** None - /// - /// **Example:** + /// ### Example /// Bad: /// ```rust,ignore /// 🍦🍦🍦🍦🍦 @@ -138,14 +142,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for cases of an auto-generated lint without an updated description, + /// ### What it does + /// Checks for cases of an auto-generated lint without an updated description, /// i.e. `default lint description`. /// - /// **Why is this bad?** Indicates that the lint is not finished. - /// - /// **Known problems:** None + /// ### Why is this bad? + /// Indicates that the lint is not finished. /// - /// **Example:** + /// ### Example /// Bad: /// ```rust,ignore /// declare_lint! { pub COOL_LINT, nursery, "default lint description" } @@ -161,7 +165,8 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Lints `span_lint_and_then` function calls, where the + /// ### What it does + /// Lints `span_lint_and_then` function calls, where the /// closure argument has only one statement and that statement is a method /// call to `span_suggestion`, `span_help`, `span_note` (using the same /// span), `help` or `note`. @@ -170,12 +175,11 @@ declare_clippy_lint! { /// wrapper functions `span_lint_and_sugg`, span_lint_and_help`, or /// `span_lint_and_note`. /// - /// **Why is this bad?** Using the wrapper `span_lint_and_*` functions, is more + /// ### Why is this bad? + /// Using the wrapper `span_lint_and_*` functions, is more /// convenient, readable and less error prone. /// - /// **Known problems:** None - /// - /// *Example:** + /// ### Example /// Bad: /// ```rust,ignore /// span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |diag| { @@ -222,14 +226,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for calls to `utils::match_type()` on a type diagnostic item + /// ### What it does + /// Checks for calls to `utils::match_type()` on a type diagnostic item /// and suggests to use `utils::is_type_diagnostic_item()` instead. /// - /// **Why is this bad?** `utils::is_type_diagnostic_item()` does not require hardcoded paths. - /// - /// **Known problems:** None. + /// ### Why is this bad? + /// `utils::is_type_diagnostic_item()` does not require hardcoded paths. /// - /// **Example:** + /// ### Example /// Bad: /// ```rust,ignore /// utils::match_type(cx, ty, &paths::VEC) @@ -245,30 +249,27 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Checks the paths module for invalid paths. /// - /// **Why is this bad?** + /// ### Why is this bad? /// It indicates a bug in the code. /// - /// **Known problems:** None. - /// - /// **Example:** None. + /// ### Example + /// None. pub INVALID_PATHS, internal, "invalid path" } declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// Checks for interning symbols that have already been pre-interned and defined as constants. /// - /// **Why is this bad?** + /// ### Why is this bad? /// It's faster and easier to use the symbol constant. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// Bad: /// ```rust,ignore /// let _ = sym!(f32); @@ -284,13 +285,13 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for unnecessary conversion from Symbol to a string. - /// - /// **Why is this bad?** It's faster use symbols directly intead of strings. + /// ### What it does + /// Checks for unnecessary conversion from Symbol to a string. /// - /// **Known problems:** None. + /// ### Why is this bad? + /// It's faster use symbols directly intead of strings. /// - /// **Example:** + /// ### Example /// Bad: /// ```rust,ignore /// symbol.as_str() == "clippy"; diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index 3eccc89cdeb..3244677b301 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -68,7 +68,7 @@ const CLIPPY_LINT_GROUP_PREFIX: &str = "clippy::"; macro_rules! CONFIGURATION_SECTION_TEMPLATE { () => { r#" -**Configuration** +### Configuration This lint has the following configuration variables: {configurations} @@ -116,18 +116,21 @@ const DEPRECATED_LINT_TYPE: [&str; 3] = ["clippy_lints", "deprecated_lints", "Cl const APPLICABILITY_NAME_INDEX: usize = 2; declare_clippy_lint! { - /// **What it does:** Collects metadata about clippy lints for the website. + /// ### What it does + /// Collects metadata about clippy lints for the website. /// /// This lint will be used to report problems of syntax parsing. You should hopefully never /// see this but never say never I guess ^^ /// - /// **Why is this bad?** This is not a bad thing but definitely a hacky way to do it. See + /// ### Why is this bad? + /// This is not a bad thing but definitely a hacky way to do it. See /// issue [#4310](https://github.com/rust-lang/rust-clippy/issues/4310) for a discussion /// about the implementation. /// - /// **Known problems:** Hopefully none. It would be pretty uncool to have a problem here :) + /// ### Known problems + /// Hopefully none. It would be pretty uncool to have a problem here :) /// - /// **Example output:** + /// ### Example output /// ```json,ignore /// { /// "id": "internal_metadata_collector", @@ -374,7 +377,8 @@ impl<'hir> LateLintPass<'hir> for MetadataCollector { /// Collecting lint declarations like: /// ```rust, ignore /// declare_clippy_lint! { - /// /// **What it does:** Something IDK. + /// /// ### What it does + /// /// Something IDK. /// pub SOME_LINT, /// internal, /// "Who am I?" diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index 1d5b7c98d31..32fa46f042c 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -19,14 +19,14 @@ pub struct UselessVec { } declare_clippy_lint! { - /// **What it does:** Checks for usage of `&vec![..]` when using `&[..]` would + /// ### What it does + /// Checks for usage of `&vec![..]` when using `&[..]` would /// be possible. /// - /// **Why is this bad?** This is less efficient. + /// ### Why is this bad? + /// This is less efficient. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # fn foo(my_vec: &[u8]) {} /// diff --git a/clippy_lints/src/vec_init_then_push.rs b/clippy_lints/src/vec_init_then_push.rs index c7190e2f979..0413c02b230 100644 --- a/clippy_lints/src/vec_init_then_push.rs +++ b/clippy_lints/src/vec_init_then_push.rs @@ -13,15 +13,14 @@ use rustc_span::{symbol::sym, Span}; use std::convert::TryInto; declare_clippy_lint! { - /// **What it does:** Checks for calls to `push` immediately after creating a new `Vec`. + /// ### What it does + /// Checks for calls to `push` immediately after creating a new `Vec`. /// - /// **Why is this bad?** The `vec![]` macro is both more performant and easier to read than + /// ### Why is this bad? + /// The `vec![]` macro is both more performant and easier to read than /// multiple `push` calls. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust /// let mut v = Vec::new(); /// v.push(0); diff --git a/clippy_lints/src/vec_resize_to_zero.rs b/clippy_lints/src/vec_resize_to_zero.rs index 5540e87405f..5c0429db6b8 100644 --- a/clippy_lints/src/vec_resize_to_zero.rs +++ b/clippy_lints/src/vec_resize_to_zero.rs @@ -10,13 +10,13 @@ use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::Spanned; declare_clippy_lint! { - /// **What it does:** Finds occurrences of `Vec::resize(0, an_int)` + /// ### What it does + /// Finds occurrences of `Vec::resize(0, an_int)` /// - /// **Why is this bad?** This is probably an argument inversion mistake. + /// ### Why is this bad? + /// This is probably an argument inversion mistake. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// vec!(1, 2, 3, 4, 5).resize(0, 5) /// ``` diff --git a/clippy_lints/src/verbose_file_reads.rs b/clippy_lints/src/verbose_file_reads.rs index 3ab68df2b6d..e07c12f4f16 100644 --- a/clippy_lints/src/verbose_file_reads.rs +++ b/clippy_lints/src/verbose_file_reads.rs @@ -7,15 +7,14 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for use of File::read_to_end and File::read_to_string. + /// ### What it does + /// Checks for use of File::read_to_end and File::read_to_string. /// - /// **Why is this bad?** `fs::{read, read_to_string}` provide the same functionality when `buf` is empty with fewer imports and no intermediate values. + /// ### Why is this bad? + /// `fs::{read, read_to_string}` provide the same functionality when `buf` is empty with fewer imports and no intermediate values. /// See also: [fs::read docs](https://doc.rust-lang.org/std/fs/fn.read.html), [fs::read_to_string docs](https://doc.rust-lang.org/std/fs/fn.read_to_string.html) /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```rust,no_run /// # use std::io::Read; /// # use std::fs::File; diff --git a/clippy_lints/src/wildcard_dependencies.rs b/clippy_lints/src/wildcard_dependencies.rs index 1ca1117a41e..fd3872bacbe 100644 --- a/clippy_lints/src/wildcard_dependencies.rs +++ b/clippy_lints/src/wildcard_dependencies.rs @@ -7,16 +7,15 @@ use rustc_span::source_map::DUMMY_SP; use if_chain::if_chain; declare_clippy_lint! { - /// **What it does:** Checks for wildcard dependencies in the `Cargo.toml`. + /// ### What it does + /// Checks for wildcard dependencies in the `Cargo.toml`. /// - /// **Why is this bad?** [As the edition guide says](https://rust-lang-nursery.github.io/edition-guide/rust-2018/cargo-and-crates-io/crates-io-disallows-wildcard-dependencies.html), + /// ### Why is this bad? + /// [As the edition guide says](https://rust-lang-nursery.github.io/edition-guide/rust-2018/cargo-and-crates-io/crates-io-disallows-wildcard-dependencies.html), /// it is highly unlikely that you work with any possible version of your dependency, /// and wildcard dependencies would cause unnecessary breakage in the ecosystem. /// - /// **Known problems:** None. - /// - /// **Example:** - /// + /// ### Example /// ```toml /// [dependencies] /// regex = "*" diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index 520586b3a1f..bafb9d3e3b1 100644 --- a/clippy_lints/src/wildcard_imports.rs +++ b/clippy_lints/src/wildcard_imports.rs @@ -13,15 +13,18 @@ use rustc_span::symbol::kw; use rustc_span::{sym, BytePos}; declare_clippy_lint! { - /// **What it does:** Checks for `use Enum::*`. + /// ### What it does + /// Checks for `use Enum::*`. /// - /// **Why is this bad?** It is usually better style to use the prefixed name of + /// ### Why is this bad? + /// It is usually better style to use the prefixed name of /// an enumeration variant, rather than importing variants. /// - /// **Known problems:** Old-style enumerations that prefix the variants are + /// ### Known problems + /// Old-style enumerations that prefix the variants are /// still around. /// - /// **Example:** + /// ### Example /// ```rust,ignore /// // Bad /// use std::cmp::Ordering::*; @@ -37,9 +40,11 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for wildcard imports `use _::*`. + /// ### What it does + /// Checks for wildcard imports `use _::*`. /// - /// **Why is this bad?** wildcard imports can pollute the namespace. This is especially bad if + /// ### Why is this bad? + /// wildcard imports can pollute the namespace. This is especially bad if /// you try to import something through a wildcard, that already has been imported by name from /// a different source: /// @@ -52,8 +57,7 @@ declare_clippy_lint! { /// /// This can lead to confusing error messages at best and to unexpected behavior at worst. /// - /// **Exceptions:** - /// + /// ### Exceptions /// Wildcard imports are allowed from modules named `prelude`. Many crates (including the standard library) /// provide modules named "prelude" specifically designed for wildcard import. /// @@ -61,14 +65,14 @@ declare_clippy_lint! { /// /// These exceptions can be disabled using the `warn-on-all-wildcard-imports` configuration flag. /// - /// **Known problems:** If macros are imported through the wildcard, this macro is not included + /// ### Known problems + /// If macros are imported through the wildcard, this macro is not included /// by the suggestion and has to be added by hand. /// /// Applying the suggestion when explicit imports of the things imported with a glob import /// exist, may result in `unused_imports` warnings. /// - /// **Example:** - /// + /// ### Example /// ```rust,ignore /// // Bad /// use crate1::*; diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 5229a705865..4553ac704a2 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -16,14 +16,14 @@ use rustc_span::symbol::{kw, Symbol}; use rustc_span::{sym, BytePos, Span, DUMMY_SP}; declare_clippy_lint! { - /// **What it does:** This lint warns when you use `println!("")` to + /// ### What it does + /// This lint warns when you use `println!("")` to /// print a newline. /// - /// **Why is this bad?** You should use `println!()`, which is simpler. + /// ### Why is this bad? + /// You should use `println!()`, which is simpler. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// println!(""); @@ -37,15 +37,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** This lint warns when you use `print!()` with a format + /// ### What it does + /// This lint warns when you use `print!()` with a format /// string that ends in a newline. /// - /// **Why is this bad?** You should use `println!()` instead, which appends the + /// ### Why is this bad? + /// You should use `println!()` instead, which appends the /// newline. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # let name = "World"; /// print!("Hello {}!\n", name); @@ -61,15 +61,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for printing on *stdout*. The purpose of this lint + /// ### What it does + /// Checks for printing on *stdout*. The purpose of this lint /// is to catch debugging remnants. /// - /// **Why is this bad?** People often print on *stdout* while debugging an + /// ### Why is this bad? + /// People often print on *stdout* while debugging an /// application and might forget to remove those prints afterward. /// - /// **Known problems:** Only catches `print!` and `println!` calls. + /// ### Known problems + /// Only catches `print!` and `println!` calls. /// - /// **Example:** + /// ### Example /// ```rust /// println!("Hello world!"); /// ``` @@ -79,15 +82,18 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for printing on *stderr*. The purpose of this lint + /// ### What it does + /// Checks for printing on *stderr*. The purpose of this lint /// is to catch debugging remnants. /// - /// **Why is this bad?** People often print on *stderr* while debugging an + /// ### Why is this bad? + /// People often print on *stderr* while debugging an /// application and might forget to remove those prints afterward. /// - /// **Known problems:** Only catches `eprint!` and `eprintln!` calls. + /// ### Known problems + /// Only catches `eprint!` and `eprintln!` calls. /// - /// **Example:** + /// ### Example /// ```rust /// eprintln!("Hello world!"); /// ``` @@ -97,13 +103,15 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for use of `Debug` formatting. The purpose of this + /// ### What it does + /// Checks for use of `Debug` formatting. The purpose of this /// lint is to catch debugging remnants. /// - /// **Why is this bad?** The purpose of the `Debug` trait is to facilitate + /// ### Why is this bad? + /// The purpose of the `Debug` trait is to facilitate /// debugging Rust code. It should not be used in user-facing output. /// - /// **Example:** + /// ### Example /// ```rust /// # let foo = "bar"; /// println!("{:?}", foo); @@ -114,16 +122,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** This lint warns about the use of literals as `print!`/`println!` args. + /// ### What it does + /// This lint warns about the use of literals as `print!`/`println!` args. /// - /// **Why is this bad?** Using literals as `println!` args is inefficient + /// ### Why is this bad? + /// Using literals as `println!` args is inefficient /// (c.f., https://github.com/matthiaskrgr/rust-str-bench) and unnecessary /// (i.e., just put the literal in the format string) /// - /// **Known problems:** Will also warn with macro calls as arguments that expand to literals + /// ### Known problems + /// Will also warn with macro calls as arguments that expand to literals /// -- e.g., `println!("{}", env!("FOO"))`. /// - /// **Example:** + /// ### Example /// ```rust /// println!("{}", "foo"); /// ``` @@ -137,14 +148,14 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** This lint warns when you use `writeln!(buf, "")` to + /// ### What it does + /// This lint warns when you use `writeln!(buf, "")` to /// print a newline. /// - /// **Why is this bad?** You should use `writeln!(buf)`, which is simpler. + /// ### Why is this bad? + /// You should use `writeln!(buf)`, which is simpler. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # use std::fmt::Write; /// # let mut buf = String::new(); @@ -160,16 +171,16 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** This lint warns when you use `write!()` with a format + /// ### What it does + /// This lint warns when you use `write!()` with a format /// string that /// ends in a newline. /// - /// **Why is this bad?** You should use `writeln!()` instead, which appends the + /// ### Why is this bad? + /// You should use `writeln!()` instead, which appends the /// newline. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// # use std::fmt::Write; /// # let mut buf = String::new(); @@ -186,16 +197,19 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** This lint warns about the use of literals as `write!`/`writeln!` args. + /// ### What it does + /// This lint warns about the use of literals as `write!`/`writeln!` args. /// - /// **Why is this bad?** Using literals as `writeln!` args is inefficient + /// ### Why is this bad? + /// Using literals as `writeln!` args is inefficient /// (c.f., https://github.com/matthiaskrgr/rust-str-bench) and unnecessary /// (i.e., just put the literal in the format string) /// - /// **Known problems:** Will also warn with macro calls as arguments that expand to literals + /// ### Known problems + /// Will also warn with macro calls as arguments that expand to literals /// -- e.g., `writeln!(buf, "{}", env!("FOO"))`. /// - /// **Example:** + /// ### Example /// ```rust /// # use std::fmt::Write; /// # let mut buf = String::new(); diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index a1ea743ba80..b29ced28ac4 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -6,13 +6,13 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy_lint! { - /// **What it does:** Checks for `0.0 / 0.0`. + /// ### What it does + /// Checks for `0.0 / 0.0`. /// - /// **Why is this bad?** It's less readable than `f32::NAN` or `f64::NAN`. + /// ### Why is this bad? + /// It's less readable than `f32::NAN` or `f64::NAN`. /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Example /// ```rust /// // Bad /// let nan = 0.0f32 / 0.0; diff --git a/clippy_lints/src/zero_sized_map_values.rs b/clippy_lints/src/zero_sized_map_values.rs index d6a8112218f..2fbe27f9479 100644 --- a/clippy_lints/src/zero_sized_map_values.rs +++ b/clippy_lints/src/zero_sized_map_values.rs @@ -10,18 +10,19 @@ use rustc_target::abi::LayoutOf as _; use rustc_typeck::hir_ty_to_ty; declare_clippy_lint! { - /// **What it does:** Checks for maps with zero-sized value types anywhere in the code. + /// ### What it does + /// Checks for maps with zero-sized value types anywhere in the code. /// - /// **Why is this bad?** Since there is only a single value for a zero-sized type, a map + /// ### Why is this bad? + /// Since there is only a single value for a zero-sized type, a map /// containing zero sized values is effectively a set. Using a set in that case improves /// readability and communicates intent more clearly. /// - /// **Known problems:** + /// ### Known problems /// * A zero-sized type cannot be recovered later if it contains private fields. /// * This lints the signature of public items /// - /// **Example:** - /// + /// ### Example /// ```rust /// # use std::collections::HashMap; /// fn unique_words(text: &str) -> HashMap<&str, ()> { diff --git a/doc/adding_lints.md b/doc/adding_lints.md index 5a06afedbf4..f2260c3d1a2 100644 --- a/doc/adding_lints.md +++ b/doc/adding_lints.md @@ -11,6 +11,7 @@ because that's clearly a non-descriptive name. - [Setup](#setup) - [Getting Started](#getting-started) - [Testing](#testing) + - [Cargo lints](#cargo-lints) - [Rustfix tests](#rustfix-tests) - [Edition 2018 tests](#edition-2018-tests) - [Testing manually](#testing-manually) @@ -179,14 +180,11 @@ the auto-generated lint declaration to have a real description, something like t ```rust declare_clippy_lint! { - /// **What it does:** + /// ### What it does /// - /// **Why is this bad?** - /// - /// **Known problems:** None. - /// - /// **Example:** + /// ### Why is this bad? /// + /// ### Example /// ```rust /// // example code /// ``` @@ -487,13 +485,13 @@ Please document your lint with a doc comment akin to the following: ```rust declare_clippy_lint! { - /// **What it does:** Checks for ... (describe what the lint matches). - /// - /// **Why is this bad?** Supply the reason for linting the code. + /// ### What it does + /// Checks for ... (describe what the lint matches). /// - /// **Known problems:** None. (Or describe where it could go wrong.) + /// ### Why is this bad? + /// Supply the reason for linting the code. /// - /// **Example:** + /// ### Example /// /// ```rust,ignore /// // Bad -- cgit 1.4.1-3-g733a5 From d647696c1f167802c9bb9ffe2c98459b152d563c Mon Sep 17 00:00:00 2001 From: xFrednet Date: Thu, 21 Oct 2021 21:06:26 +0200 Subject: Added `clippy::version` attribute to all normal lints So, some context for this, well, more a story. I'm not used to scripting, I've never really scripted anything, even if it's a valuable skill. I just never really needed it. Now, `@flip1995` correctly suggested using a script for this in `rust-clippy#7813`... And I decided to write a script using nushell because why not? This was a mistake... I spend way more time on this than I would like to admit. It has definitely been more than 4 hours. It shouldn't take that long, but me being new to scripting and nushell just wasn't a good mixture... Anyway, here is the script that creates another script which adds the versions. Fun... Just execute this on the `gh-pages` branch and the resulting `replacer.sh` in `clippy_lints` and it should all work. ```nu mv v0.0.212 rust-1.00.0; mv beta rust-1.57.0; mv master rust-1.58.0; let paths = (open ./rust-1.58.0/lints.json | select id id_span | flatten | select id path); let versions = ( ls | where name =~ "rust-" | select name | format {name}/lints.json | each { open $it | select id | insert version $it | str substring "5,11" version} | group-by id | rotate counter-clockwise id version | update version {get version | first 1} | flatten | select id version); $paths | each { |row| let version = ($versions | where id == ($row.id) | format {version}) let idu = ($row.id | str upcase) $"sed -i '0,/($idu),/{s/pub ($idu),/#[clippy::version = "($version)"]\n pub ($idu),/}' ($row.path)" } | str collect ";" | str find-replace --all '1.00.0' 'pre 1.29.0' | save "replacer.sh"; ``` And this still has some problems, but at this point I just want to be done -.- --- clippy_lints/src/absurd_extreme_comparisons.rs | 1 + clippy_lints/src/approx_const.rs | 1 + clippy_lints/src/arithmetic.rs | 2 + clippy_lints/src/as_conversions.rs | 1 + clippy_lints/src/asm_syntax.rs | 2 + clippy_lints/src/assertions_on_constants.rs | 1 + clippy_lints/src/assign_ops.rs | 2 + clippy_lints/src/async_yields_async.rs | 1 + clippy_lints/src/attrs.rs | 7 +++ clippy_lints/src/await_holding_invalid.rs | 2 + clippy_lints/src/bit_mask.rs | 3 ++ clippy_lints/src/blacklisted_name.rs | 1 + clippy_lints/src/blocks_in_if_conditions.rs | 1 + clippy_lints/src/bool_assert_comparison.rs | 1 + clippy_lints/src/booleans.rs | 2 + clippy_lints/src/bytecount.rs | 1 + clippy_lints/src/cargo_common_metadata.rs | 1 + .../case_sensitive_file_extension_comparisons.rs | 1 + clippy_lints/src/casts/mod.rs | 13 +++++ clippy_lints/src/checked_conversions.rs | 1 + clippy_lints/src/cognitive_complexity.rs | 1 + clippy_lints/src/collapsible_if.rs | 2 + clippy_lints/src/collapsible_match.rs | 1 + clippy_lints/src/comparison_chain.rs | 1 + clippy_lints/src/copies.rs | 4 ++ clippy_lints/src/copy_iterator.rs | 1 + clippy_lints/src/create_dir.rs | 1 + clippy_lints/src/dbg_macro.rs | 1 + clippy_lints/src/default.rs | 2 + clippy_lints/src/default_numeric_fallback.rs | 1 + clippy_lints/src/dereference.rs | 1 + clippy_lints/src/derivable_impls.rs | 1 + clippy_lints/src/derive.rs | 4 ++ clippy_lints/src/disallowed_method.rs | 1 + clippy_lints/src/disallowed_script_idents.rs | 1 + clippy_lints/src/disallowed_type.rs | 1 + clippy_lints/src/doc.rs | 5 ++ clippy_lints/src/double_comparison.rs | 1 + clippy_lints/src/double_parens.rs | 1 + clippy_lints/src/drop_forget_ref.rs | 4 ++ clippy_lints/src/duration_subsec.rs | 1 + clippy_lints/src/else_if_without_else.rs | 1 + clippy_lints/src/empty_enum.rs | 1 + clippy_lints/src/entry.rs | 1 + clippy_lints/src/enum_clike.rs | 1 + clippy_lints/src/enum_variants.rs | 3 ++ clippy_lints/src/eq_op.rs | 2 + clippy_lints/src/equatable_if_let.rs | 1 + clippy_lints/src/erasing_op.rs | 1 + clippy_lints/src/escape.rs | 1 + clippy_lints/src/eta_reduction.rs | 2 + clippy_lints/src/eval_order_dependence.rs | 2 + clippy_lints/src/excessive_bools.rs | 2 + clippy_lints/src/exhaustive_items.rs | 2 + clippy_lints/src/exit.rs | 1 + clippy_lints/src/explicit_write.rs | 1 + clippy_lints/src/fallible_impl_from.rs | 1 + clippy_lints/src/feature_name.rs | 2 + clippy_lints/src/float_equality_without_abs.rs | 1 + clippy_lints/src/float_literal.rs | 2 + clippy_lints/src/floating_point_arithmetic.rs | 2 + clippy_lints/src/format.rs | 1 + clippy_lints/src/format_args.rs | 2 + clippy_lints/src/formatting.rs | 4 ++ clippy_lints/src/from_over_into.rs | 1 + clippy_lints/src/from_str_radix_10.rs | 1 + clippy_lints/src/functions/mod.rs | 7 +++ clippy_lints/src/future_not_send.rs | 1 + clippy_lints/src/get_last_with_len.rs | 1 + clippy_lints/src/identity_op.rs | 1 + clippy_lints/src/if_let_mutex.rs | 1 + clippy_lints/src/if_not_else.rs | 1 + clippy_lints/src/if_then_some_else_none.rs | 1 + clippy_lints/src/implicit_hasher.rs | 1 + clippy_lints/src/implicit_return.rs | 1 + clippy_lints/src/implicit_saturating_sub.rs | 1 + .../src/inconsistent_struct_constructor.rs | 1 + clippy_lints/src/indexing_slicing.rs | 2 + clippy_lints/src/infinite_iter.rs | 2 + clippy_lints/src/inherent_impl.rs | 1 + clippy_lints/src/inherent_to_string.rs | 2 + clippy_lints/src/inline_fn_without_body.rs | 1 + clippy_lints/src/int_plus_one.rs | 1 + clippy_lints/src/integer_division.rs | 1 + clippy_lints/src/invalid_upcast_comparisons.rs | 1 + clippy_lints/src/items_after_statements.rs | 1 + clippy_lints/src/iter_not_returning_iterator.rs | 1 + clippy_lints/src/large_const_arrays.rs | 1 + clippy_lints/src/large_enum_variant.rs | 1 + clippy_lints/src/large_stack_arrays.rs | 1 + clippy_lints/src/len_zero.rs | 3 ++ clippy_lints/src/let_if_seq.rs | 1 + clippy_lints/src/let_underscore.rs | 3 ++ clippy_lints/src/lifetimes.rs | 2 + clippy_lints/src/literal_representation.rs | 6 +++ clippy_lints/src/loops/mod.rs | 18 +++++++ clippy_lints/src/macro_use.rs | 1 + clippy_lints/src/main_recursion.rs | 1 + clippy_lints/src/manual_assert.rs | 1 + clippy_lints/src/manual_async_fn.rs | 1 + clippy_lints/src/manual_map.rs | 1 + clippy_lints/src/manual_non_exhaustive.rs | 1 + clippy_lints/src/manual_ok_or.rs | 1 + clippy_lints/src/manual_strip.rs | 1 + clippy_lints/src/manual_unwrap_or.rs | 1 + clippy_lints/src/map_clone.rs | 1 + clippy_lints/src/map_err_ignore.rs | 1 + clippy_lints/src/map_unit_fn.rs | 2 + clippy_lints/src/match_on_vec_items.rs | 1 + clippy_lints/src/match_result_ok.rs | 1 + clippy_lints/src/match_str_case_mismatch.rs | 1 + clippy_lints/src/matches.rs | 16 ++++++ clippy_lints/src/mem_forget.rs | 1 + clippy_lints/src/mem_replace.rs | 3 ++ clippy_lints/src/methods/mod.rs | 63 ++++++++++++++++++++++ clippy_lints/src/minmax.rs | 1 + clippy_lints/src/misc.rs | 9 ++++ clippy_lints/src/misc_early/mod.rs | 9 ++++ clippy_lints/src/missing_const_for_fn.rs | 1 + clippy_lints/src/missing_doc.rs | 1 + clippy_lints/src/missing_enforced_import_rename.rs | 1 + clippy_lints/src/missing_inline.rs | 1 + clippy_lints/src/module_style.rs | 2 + clippy_lints/src/modulo_arithmetic.rs | 1 + clippy_lints/src/multiple_crate_versions.rs | 1 + clippy_lints/src/mut_key.rs | 1 + clippy_lints/src/mut_mut.rs | 1 + clippy_lints/src/mut_mutex_lock.rs | 1 + clippy_lints/src/mut_reference.rs | 1 + clippy_lints/src/mutable_debug_assertion.rs | 1 + clippy_lints/src/mutex_atomic.rs | 2 + clippy_lints/src/needless_arbitrary_self_type.rs | 1 + clippy_lints/src/needless_bitwise_bool.rs | 1 + clippy_lints/src/needless_bool.rs | 2 + clippy_lints/src/needless_borrow.rs | 2 + clippy_lints/src/needless_borrowed_ref.rs | 1 + clippy_lints/src/needless_continue.rs | 1 + clippy_lints/src/needless_for_each.rs | 1 + clippy_lints/src/needless_option_as_deref.rs | 1 + clippy_lints/src/needless_pass_by_value.rs | 1 + clippy_lints/src/needless_question_mark.rs | 1 + clippy_lints/src/needless_update.rs | 1 + clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 1 + clippy_lints/src/neg_multiply.rs | 1 + clippy_lints/src/new_without_default.rs | 1 + clippy_lints/src/no_effect.rs | 3 ++ clippy_lints/src/non_copy_const.rs | 2 + clippy_lints/src/non_expressive_names.rs | 3 ++ clippy_lints/src/non_octal_unix_permissions.rs | 1 + clippy_lints/src/non_send_fields_in_send_ty.rs | 1 + clippy_lints/src/nonstandard_macro_braces.rs | 1 + clippy_lints/src/open_options.rs | 1 + clippy_lints/src/option_env_unwrap.rs | 1 + clippy_lints/src/option_if_let_else.rs | 1 + clippy_lints/src/overflow_check_conditional.rs | 1 + clippy_lints/src/panic_in_result_fn.rs | 1 + clippy_lints/src/panic_unimplemented.rs | 4 ++ clippy_lints/src/partialeq_ne_impl.rs | 1 + clippy_lints/src/pass_by_ref_or_value.rs | 2 + clippy_lints/src/path_buf_push_overwrite.rs | 1 + clippy_lints/src/pattern_type_mismatch.rs | 1 + clippy_lints/src/precedence.rs | 1 + clippy_lints/src/ptr.rs | 4 ++ clippy_lints/src/ptr_eq.rs | 1 + clippy_lints/src/ptr_offset_with_cast.rs | 1 + clippy_lints/src/question_mark.rs | 1 + clippy_lints/src/ranges.rs | 5 ++ clippy_lints/src/redundant_clone.rs | 1 + clippy_lints/src/redundant_closure_call.rs | 1 + clippy_lints/src/redundant_else.rs | 1 + clippy_lints/src/redundant_field_names.rs | 1 + clippy_lints/src/redundant_pub_crate.rs | 1 + clippy_lints/src/redundant_slicing.rs | 1 + clippy_lints/src/redundant_static_lifetimes.rs | 1 + clippy_lints/src/ref_option_ref.rs | 1 + clippy_lints/src/reference.rs | 2 + clippy_lints/src/regex.rs | 2 + clippy_lints/src/repeat_once.rs | 1 + clippy_lints/src/returns.rs | 2 + clippy_lints/src/same_name_method.rs | 1 + clippy_lints/src/self_assignment.rs | 1 + clippy_lints/src/self_named_constructors.rs | 1 + clippy_lints/src/semicolon_if_nothing_returned.rs | 1 + clippy_lints/src/serde_api.rs | 1 + clippy_lints/src/shadow.rs | 3 ++ clippy_lints/src/single_component_path_imports.rs | 1 + clippy_lints/src/size_of_in_element_count.rs | 1 + clippy_lints/src/slow_vector_initialization.rs | 1 + clippy_lints/src/stable_sort_primitive.rs | 1 + clippy_lints/src/strings.rs | 7 +++ clippy_lints/src/strlen_on_c_strings.rs | 1 + clippy_lints/src/suspicious_operation_groupings.rs | 1 + clippy_lints/src/suspicious_trait_impl.rs | 2 + clippy_lints/src/swap.rs | 2 + clippy_lints/src/tabs_in_doc_comments.rs | 1 + clippy_lints/src/temporary_assignment.rs | 1 + clippy_lints/src/to_digit_is_some.rs | 1 + clippy_lints/src/to_string_in_display.rs | 1 + clippy_lints/src/trailing_empty_array.rs | 1 + clippy_lints/src/trait_bounds.rs | 2 + clippy_lints/src/transmute/mod.rs | 13 +++++ clippy_lints/src/transmuting_null.rs | 1 + clippy_lints/src/try_err.rs | 1 + clippy_lints/src/types/mod.rs | 9 ++++ clippy_lints/src/undocumented_unsafe_blocks.rs | 1 + clippy_lints/src/undropped_manually_drops.rs | 1 + clippy_lints/src/unicode.rs | 3 ++ clippy_lints/src/uninit_vec.rs | 1 + clippy_lints/src/unit_hash.rs | 1 + clippy_lints/src/unit_return_expecting_ord.rs | 1 + clippy_lints/src/unit_types/mod.rs | 3 ++ clippy_lints/src/unnamed_address.rs | 2 + clippy_lints/src/unnecessary_self_imports.rs | 1 + clippy_lints/src/unnecessary_sort_by.rs | 1 + clippy_lints/src/unnecessary_wraps.rs | 1 + clippy_lints/src/unnested_or_patterns.rs | 1 + clippy_lints/src/unsafe_removed_from_name.rs | 1 + clippy_lints/src/unused_async.rs | 1 + clippy_lints/src/unused_io_amount.rs | 1 + clippy_lints/src/unused_self.rs | 1 + clippy_lints/src/unused_unit.rs | 1 + clippy_lints/src/unwrap.rs | 2 + clippy_lints/src/unwrap_in_result.rs | 1 + clippy_lints/src/upper_case_acronyms.rs | 1 + clippy_lints/src/use_self.rs | 1 + clippy_lints/src/useless_conversion.rs | 1 + clippy_lints/src/vec.rs | 1 + clippy_lints/src/vec_init_then_push.rs | 1 + clippy_lints/src/vec_resize_to_zero.rs | 1 + clippy_lints/src/verbose_file_reads.rs | 1 + clippy_lints/src/wildcard_dependencies.rs | 1 + clippy_lints/src/wildcard_imports.rs | 2 + clippy_lints/src/write.rs | 9 ++++ clippy_lints/src/zero_div_zero.rs | 1 + clippy_lints/src/zero_sized_map_values.rs | 1 + 235 files changed, 490 insertions(+) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/absurd_extreme_comparisons.rs b/clippy_lints/src/absurd_extreme_comparisons.rs index 1483f3f9185..7665aa8380b 100644 --- a/clippy_lints/src/absurd_extreme_comparisons.rs +++ b/clippy_lints/src/absurd_extreme_comparisons.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// if vec.len() <= 0 {} /// if 100 > i32::MAX {} /// ``` + #[clippy::version = "pre 1.29.0"] pub ABSURD_EXTREME_COMPARISONS, correctness, "a comparison with a maximum or minimum value that is always true or false" diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index fb54ac1ec51..12435eefbc4 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -33,6 +33,7 @@ declare_clippy_lint! { /// let x = std::f32::consts::PI; /// let y = std::f64::consts::FRAC_1_PI; /// ``` + #[clippy::version = "pre 1.29.0"] pub APPROX_CONSTANT, correctness, "the approximate of a known float constant (in `std::fXX::consts`)" diff --git a/clippy_lints/src/arithmetic.rs b/clippy_lints/src/arithmetic.rs index 36fe7b7a867..e0c1d6ab6e1 100644 --- a/clippy_lints/src/arithmetic.rs +++ b/clippy_lints/src/arithmetic.rs @@ -25,6 +25,7 @@ declare_clippy_lint! { /// # let a = 0; /// a + 1; /// ``` + #[clippy::version = "pre 1.29.0"] pub INTEGER_ARITHMETIC, restriction, "any integer arithmetic expression which could overflow or panic" @@ -43,6 +44,7 @@ declare_clippy_lint! { /// # let a = 0.0; /// a + 1.0; /// ``` + #[clippy::version = "pre 1.29.0"] pub FLOAT_ARITHMETIC, restriction, "any floating-point arithmetic statement" diff --git a/clippy_lints/src/as_conversions.rs b/clippy_lints/src/as_conversions.rs index 0be460d67a7..53704da1046 100644 --- a/clippy_lints/src/as_conversions.rs +++ b/clippy_lints/src/as_conversions.rs @@ -38,6 +38,7 @@ declare_clippy_lint! { /// f(a.try_into().expect("Unexpected u16 overflow in f")); /// ``` /// + #[clippy::version = "1.41.0"] pub AS_CONVERSIONS, restriction, "using a potentially dangerous silent `as` conversion" diff --git a/clippy_lints/src/asm_syntax.rs b/clippy_lints/src/asm_syntax.rs index 825832eb79d..0322698f029 100644 --- a/clippy_lints/src/asm_syntax.rs +++ b/clippy_lints/src/asm_syntax.rs @@ -75,6 +75,7 @@ declare_clippy_lint! { /// asm!("lea ({}), {}", in(reg) ptr, lateout(reg) _, options(att_syntax)); /// # } /// ``` + #[clippy::version = "1.49.0"] pub INLINE_ASM_X86_INTEL_SYNTAX, restriction, "prefer AT&T x86 assembly syntax" @@ -111,6 +112,7 @@ declare_clippy_lint! { /// asm!("lea {}, [{}]", lateout(reg) _, in(reg) ptr); /// # } /// ``` + #[clippy::version = "1.49.0"] pub INLINE_ASM_X86_ATT_SYNTAX, restriction, "prefer Intel x86 assembly syntax" diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index d834a1d317a..521fc84ee9c 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -26,6 +26,7 @@ declare_clippy_lint! { /// const B: bool = false; /// assert!(B) /// ``` + #[clippy::version = "1.34.0"] pub ASSERTIONS_ON_CONSTANTS, style, "`assert!(true)` / `assert!(false)` will be optimized out by the compiler, and should probably be replaced by a `panic!()` or `unreachable!()`" diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 2097a1feff9..e16f4369da9 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -34,6 +34,7 @@ declare_clippy_lint! { /// // Good /// a += b; /// ``` + #[clippy::version = "pre 1.29.0"] pub ASSIGN_OP_PATTERN, style, "assigning the result of an operation on a variable to that same variable" @@ -60,6 +61,7 @@ declare_clippy_lint! { /// // ... /// a += a + b; /// ``` + #[clippy::version = "pre 1.29.0"] pub MISREFACTORED_ASSIGN_OP, suspicious, "having a variable on both sides of an assign op" diff --git a/clippy_lints/src/async_yields_async.rs b/clippy_lints/src/async_yields_async.rs index 182736a5a20..0619490e73c 100644 --- a/clippy_lints/src/async_yields_async.rs +++ b/clippy_lints/src/async_yields_async.rs @@ -34,6 +34,7 @@ declare_clippy_lint! { /// }; /// } /// ``` + #[clippy::version = "1.48.0"] pub ASYNC_YIELDS_ASYNC, correctness, "async blocks that return a type that can be awaited" diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 9c5db18336f..1edb7c950e7 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -66,6 +66,7 @@ declare_clippy_lint! { /// #[inline(always)] /// fn not_quite_hot_code(..) { ... } /// ``` + #[clippy::version = "pre 1.29.0"] pub INLINE_ALWAYS, pedantic, "use of `#[inline(always)]`" @@ -100,6 +101,7 @@ declare_clippy_lint! { /// #[macro_use] /// extern crate baz; /// ``` + #[clippy::version = "pre 1.29.0"] pub USELESS_ATTRIBUTE, correctness, "use of lint attributes on `extern crate` items" @@ -119,6 +121,7 @@ declare_clippy_lint! { /// #[deprecated(since = "forever")] /// fn something_else() { /* ... */ } /// ``` + #[clippy::version = "pre 1.29.0"] pub DEPRECATED_SEMVER, correctness, "use of `#[deprecated(since = \"x\")]` where x is not semver" @@ -156,6 +159,7 @@ declare_clippy_lint! { /// #[allow(dead_code)] /// fn this_is_fine_too() { } /// ``` + #[clippy::version = "pre 1.29.0"] pub EMPTY_LINE_AFTER_OUTER_ATTR, nursery, "empty line after outer attribute" @@ -179,6 +183,7 @@ declare_clippy_lint! { /// ```rust /// #![deny(clippy::as_conversions)] /// ``` + #[clippy::version = "1.47.0"] pub BLANKET_CLIPPY_RESTRICTION_LINTS, suspicious, "enabling the complete restriction group" @@ -210,6 +215,7 @@ declare_clippy_lint! { /// #[rustfmt::skip] /// fn main() { } /// ``` + #[clippy::version = "1.32.0"] pub DEPRECATED_CFG_ATTR, complexity, "usage of `cfg_attr(rustfmt)` instead of tool attributes" @@ -242,6 +248,7 @@ declare_clippy_lint! { /// fn conditional() { } /// ``` /// Check the [Rust Reference](https://doc.rust-lang.org/reference/conditional-compilation.html#target_os) for more details. + #[clippy::version = "1.45.0"] pub MISMATCHED_TARGET_OS, correctness, "usage of `cfg(operating_system)` instead of `cfg(target_os = \"operating_system\")`" diff --git a/clippy_lints/src/await_holding_invalid.rs b/clippy_lints/src/await_holding_invalid.rs index 28615b9217c..1cc3418d474 100644 --- a/clippy_lints/src/await_holding_invalid.rs +++ b/clippy_lints/src/await_holding_invalid.rs @@ -47,6 +47,7 @@ declare_clippy_lint! { /// bar.await; /// } /// ``` + #[clippy::version = "1.45.0"] pub AWAIT_HOLDING_LOCK, pedantic, "Inside an async function, holding a MutexGuard while calling await" @@ -88,6 +89,7 @@ declare_clippy_lint! { /// bar.await; /// } /// ``` + #[clippy::version = "1.49.0"] pub AWAIT_HOLDING_REFCELL_REF, pedantic, "Inside an async function, holding a RefCell ref while calling await" diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 11346e7c96a..0977cf22b2c 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -41,6 +41,7 @@ declare_clippy_lint! { /// # let x = 1; /// if (x & 1 == 2) { } /// ``` + #[clippy::version = "pre 1.29.0"] pub BAD_BIT_MASK, correctness, "expressions of the form `_ & mask == select` that will only ever return `true` or `false`" @@ -73,6 +74,7 @@ declare_clippy_lint! { /// # let x = 1; /// if (x | 1 > 3) { } /// ``` + #[clippy::version = "pre 1.29.0"] pub INEFFECTIVE_BIT_MASK, correctness, "expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`" @@ -95,6 +97,7 @@ declare_clippy_lint! { /// # let x = 1; /// if x & 0b1111 == 0 { } /// ``` + #[clippy::version = "pre 1.29.0"] pub VERBOSE_BIT_MASK, pedantic, "expressions where a bit mask is less readable than the corresponding method call" diff --git a/clippy_lints/src/blacklisted_name.rs b/clippy_lints/src/blacklisted_name.rs index 916c78c982a..1600fb25d89 100644 --- a/clippy_lints/src/blacklisted_name.rs +++ b/clippy_lints/src/blacklisted_name.rs @@ -17,6 +17,7 @@ declare_clippy_lint! { /// ```rust /// let foo = 3.14; /// ``` + #[clippy::version = "pre 1.29.0"] pub BLACKLISTED_NAME, style, "usage of a blacklisted/placeholder name" diff --git a/clippy_lints/src/blocks_in_if_conditions.rs b/clippy_lints/src/blocks_in_if_conditions.rs index 47e5b0d583d..b59f49357df 100644 --- a/clippy_lints/src/blocks_in_if_conditions.rs +++ b/clippy_lints/src/blocks_in_if_conditions.rs @@ -41,6 +41,7 @@ declare_clippy_lint! { /// let res = { let x = somefunc(); x }; /// if res { /* ... */ } /// ``` + #[clippy::version = "1.45.0"] pub BLOCKS_IN_IF_CONDITIONS, style, "useless or complex blocks that can be eliminated in conditions" diff --git a/clippy_lints/src/bool_assert_comparison.rs b/clippy_lints/src/bool_assert_comparison.rs index cdc192a47e4..a59abc66306 100644 --- a/clippy_lints/src/bool_assert_comparison.rs +++ b/clippy_lints/src/bool_assert_comparison.rs @@ -23,6 +23,7 @@ declare_clippy_lint! { /// // Good /// assert!(!"a".is_empty()); /// ``` + #[clippy::version = "1.53.0"] pub BOOL_ASSERT_COMPARISON, style, "Using a boolean as comparison value in an assert_* macro when there is no need" diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index a1e6b7224ff..51835ee7488 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -31,6 +31,7 @@ declare_clippy_lint! { /// if a && true // should be: if a /// if !(a == b) // should be: if a != b /// ``` + #[clippy::version = "pre 1.29.0"] pub NONMINIMAL_BOOL, complexity, "boolean expressions that can be written more concisely" @@ -52,6 +53,7 @@ declare_clippy_lint! { /// if a && b || a { ... } /// ``` /// The `b` is unnecessary, the expression is equivalent to `if a`. + #[clippy::version = "pre 1.29.0"] pub LOGIC_BUG, correctness, "boolean expressions that contain terminals which can be eliminated" diff --git a/clippy_lints/src/bytecount.rs b/clippy_lints/src/bytecount.rs index a07cd5e5f4e..a938ada9d2a 100644 --- a/clippy_lints/src/bytecount.rs +++ b/clippy_lints/src/bytecount.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// # let vec = vec![1_u8]; /// &vec.iter().filter(|x| **x == 0u8).count(); // use bytecount::count instead /// ``` + #[clippy::version = "pre 1.29.0"] pub NAIVE_BYTECOUNT, pedantic, "use of naive `.filter(|&x| x == y).count()` to count byte values" diff --git a/clippy_lints/src/cargo_common_metadata.rs b/clippy_lints/src/cargo_common_metadata.rs index ff619c59b6e..23f79fdc682 100644 --- a/clippy_lints/src/cargo_common_metadata.rs +++ b/clippy_lints/src/cargo_common_metadata.rs @@ -42,6 +42,7 @@ declare_clippy_lint! { /// keywords = ["clippy", "lint", "plugin"] /// categories = ["development-tools", "development-tools::cargo-plugins"] /// ``` + #[clippy::version = "1.32.0"] pub CARGO_COMMON_METADATA, cargo, "common metadata is defined in `Cargo.toml`" diff --git a/clippy_lints/src/case_sensitive_file_extension_comparisons.rs b/clippy_lints/src/case_sensitive_file_extension_comparisons.rs index c876553c165..3f286dd9e2f 100644 --- a/clippy_lints/src/case_sensitive_file_extension_comparisons.rs +++ b/clippy_lints/src/case_sensitive_file_extension_comparisons.rs @@ -27,6 +27,7 @@ declare_clippy_lint! { /// filename.rsplit('.').next().map(|ext| ext.eq_ignore_ascii_case("rs")) == Some(true) /// } /// ``` + #[clippy::version = "1.51.0"] pub CASE_SENSITIVE_FILE_EXTENSION_COMPARISONS, pedantic, "Checks for calls to ends_with with case-sensitive file extensions" diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index 233abd17894..c674327486c 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -40,6 +40,7 @@ declare_clippy_lint! { /// let x = u64::MAX; /// x as f64; /// ``` + #[clippy::version = "pre 1.29.0"] pub CAST_PRECISION_LOSS, pedantic, "casts that cause loss of precision, e.g., `x as f32` where `x: u64`" @@ -61,6 +62,7 @@ declare_clippy_lint! { /// let y: i8 = -1; /// y as u128; // will return 18446744073709551615 /// ``` + #[clippy::version = "pre 1.29.0"] pub CAST_SIGN_LOSS, pedantic, "casts from signed types to unsigned types, e.g., `x as u32` where `x: i32`" @@ -83,6 +85,7 @@ declare_clippy_lint! { /// x as u8 /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub CAST_POSSIBLE_TRUNCATION, pedantic, "casts that may cause truncation of the value, e.g., `x as u8` where `x: u32`, or `x as i32` where `x: f32`" @@ -106,6 +109,7 @@ declare_clippy_lint! { /// ```rust /// u32::MAX as i32; // will yield a value of `-1` /// ``` + #[clippy::version = "pre 1.29.0"] pub CAST_POSSIBLE_WRAP, pedantic, "casts that may cause wrapping around the value, e.g., `x as i32` where `x: u32` and `x > i32::MAX`" @@ -138,6 +142,7 @@ declare_clippy_lint! { /// u64::from(x) /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub CAST_LOSSLESS, pedantic, "casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`" @@ -163,6 +168,7 @@ declare_clippy_lint! { /// let _ = 2_i32; /// let _ = 0.5_f32; /// ``` + #[clippy::version = "pre 1.29.0"] pub UNNECESSARY_CAST, complexity, "cast to the same type, e.g., `x as i32` where `x: i32`" @@ -190,6 +196,7 @@ declare_clippy_lint! { /// (&1u8 as *const u8).cast::(); /// (&mut 1u8 as *mut u8).cast::(); /// ``` + #[clippy::version = "pre 1.29.0"] pub CAST_PTR_ALIGNMENT, pedantic, "cast from a pointer to a more-strictly-aligned pointer" @@ -217,6 +224,7 @@ declare_clippy_lint! { /// fn fun2() -> i32 { 1 } /// let a = fun2 as usize; /// ``` + #[clippy::version = "pre 1.29.0"] pub FN_TO_NUMERIC_CAST, style, "casting a function pointer to a numeric type other than usize" @@ -247,6 +255,7 @@ declare_clippy_lint! { /// let fn_ptr = fn2 as usize; /// let fn_ptr_truncated = fn_ptr as i32; /// ``` + #[clippy::version = "pre 1.29.0"] pub FN_TO_NUMERIC_CAST_WITH_TRUNCATION, style, "casting a function pointer to a numeric type not wide enough to store the address" @@ -283,6 +292,7 @@ declare_clippy_lint! { /// } /// let _ = fn3 as fn() -> u16; /// ``` + #[clippy::version = "1.58.0"] pub FN_TO_NUMERIC_CAST_ANY, restriction, "casting a function pointer to any integer type" @@ -317,6 +327,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.33.0"] pub CAST_REF_TO_MUT, correctness, "a cast of reference to a mutable pointer" @@ -344,6 +355,7 @@ declare_clippy_lint! { /// ```rust,ignore /// b'x' /// ``` + #[clippy::version = "pre 1.29.0"] pub CHAR_LIT_AS_U8, complexity, "casting a character literal to `u8` truncates" @@ -372,6 +384,7 @@ declare_clippy_lint! { /// let _ = ptr.cast::(); /// let _ = mut_ptr.cast::(); /// ``` + #[clippy::version = "1.51.0"] pub PTR_AS_PTR, pedantic, "casting using `as` from and to raw pointers that doesn't change its mutability, where `pointer::cast` could take the place of `as`" diff --git a/clippy_lints/src/checked_conversions.rs b/clippy_lints/src/checked_conversions.rs index 842bbf006cc..ffe6340bd77 100644 --- a/clippy_lints/src/checked_conversions.rs +++ b/clippy_lints/src/checked_conversions.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// i32::try_from(foo).is_ok() /// # ; /// ``` + #[clippy::version = "1.37.0"] pub CHECKED_CONVERSIONS, pedantic, "`try_from` could replace manual bounds checking when casting" diff --git a/clippy_lints/src/cognitive_complexity.rs b/clippy_lints/src/cognitive_complexity.rs index 1ccb8c5d880..84a2373efe1 100644 --- a/clippy_lints/src/cognitive_complexity.rs +++ b/clippy_lints/src/cognitive_complexity.rs @@ -27,6 +27,7 @@ declare_clippy_lint! { /// /// ### Example /// No. You'll see it when you get the warning. + #[clippy::version = "1.35.0"] pub COGNITIVE_COMPLEXITY, nursery, "functions that should be split up into multiple functions" diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 4aa87980715..f03f34e5a4b 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -47,6 +47,7 @@ declare_clippy_lint! { /// … /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub COLLAPSIBLE_IF, style, "nested `if`s that can be collapsed (e.g., `if x { if y { ... } }`" @@ -82,6 +83,7 @@ declare_clippy_lint! { /// … /// } /// ``` + #[clippy::version = "1.51.0"] pub COLLAPSIBLE_ELSE_IF, style, "nested `else`-`if` expressions that can be collapsed (e.g., `else { if x { ... } }`)" diff --git a/clippy_lints/src/collapsible_match.rs b/clippy_lints/src/collapsible_match.rs index a4693fa213b..626f9971f01 100644 --- a/clippy_lints/src/collapsible_match.rs +++ b/clippy_lints/src/collapsible_match.rs @@ -41,6 +41,7 @@ declare_clippy_lint! { /// }; /// } /// ``` + #[clippy::version = "1.50.0"] pub COLLAPSIBLE_MATCH, style, "Nested `match` or `if let` expressions where the patterns may be \"collapsed\" together." diff --git a/clippy_lints/src/comparison_chain.rs b/clippy_lints/src/comparison_chain.rs index 597a3c67024..399d11472b0 100644 --- a/clippy_lints/src/comparison_chain.rs +++ b/clippy_lints/src/comparison_chain.rs @@ -49,6 +49,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.40.0"] pub COMPARISON_CHAIN, style, "`if`s that can be rewritten with `match` and `cmp`" diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index f57da62da5f..d07bc23235b 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -41,6 +41,7 @@ declare_clippy_lint! { /// … /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub IFS_SAME_COND, correctness, "consecutive `if`s with the same condition" @@ -88,6 +89,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.41.0"] pub SAME_FUNCTIONS_IN_IF_CONDITION, pedantic, "consecutive `if`s with the same function call" @@ -109,6 +111,7 @@ declare_clippy_lint! { /// 42 /// }; /// ``` + #[clippy::version = "pre 1.29.0"] pub IF_SAME_THEN_ELSE, correctness, "`if` with the same `then` and `else` blocks" @@ -147,6 +150,7 @@ declare_clippy_lint! { /// 42 /// }; /// ``` + #[clippy::version = "1.53.0"] pub BRANCHES_SHARING_CODE, nursery, "`if` statement with shared code in all blocks" diff --git a/clippy_lints/src/copy_iterator.rs b/clippy_lints/src/copy_iterator.rs index c2e9e8b3ab7..026683f6006 100644 --- a/clippy_lints/src/copy_iterator.rs +++ b/clippy_lints/src/copy_iterator.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// let a: Vec<_> = my_iterator.take(1).collect(); /// let b: Vec<_> = my_iterator.collect(); /// ``` + #[clippy::version = "1.30.0"] pub COPY_ITERATOR, pedantic, "implementing `Iterator` on a `Copy` type" diff --git a/clippy_lints/src/create_dir.rs b/clippy_lints/src/create_dir.rs index e4ee2772483..6bc4054a5ab 100644 --- a/clippy_lints/src/create_dir.rs +++ b/clippy_lints/src/create_dir.rs @@ -23,6 +23,7 @@ declare_clippy_lint! { /// ```rust /// std::fs::create_dir_all("foo"); /// ``` + #[clippy::version = "1.48.0"] pub CREATE_DIR, restriction, "calling `std::fs::create_dir` instead of `std::fs::create_dir_all`" diff --git a/clippy_lints/src/dbg_macro.rs b/clippy_lints/src/dbg_macro.rs index bab4a696f83..1aae4c81c73 100644 --- a/clippy_lints/src/dbg_macro.rs +++ b/clippy_lints/src/dbg_macro.rs @@ -23,6 +23,7 @@ declare_clippy_lint! { /// // Good /// true /// ``` + #[clippy::version = "1.34.0"] pub DBG_MACRO, restriction, "`dbg!` macro is intended as a debugging tool" diff --git a/clippy_lints/src/default.rs b/clippy_lints/src/default.rs index 54647ba823e..a0b137efe22 100644 --- a/clippy_lints/src/default.rs +++ b/clippy_lints/src/default.rs @@ -29,6 +29,7 @@ declare_clippy_lint! { /// // Good /// let s = String::default(); /// ``` + #[clippy::version = "pre 1.29.0"] pub DEFAULT_TRAIT_ACCESS, pedantic, "checks for literal calls to `Default::default()`" @@ -62,6 +63,7 @@ declare_clippy_lint! { /// .. Default::default() /// }; /// ``` + #[clippy::version = "1.49.0"] pub FIELD_REASSIGN_WITH_DEFAULT, style, "binding initialized with Default should have its fields set in the initializer" diff --git a/clippy_lints/src/default_numeric_fallback.rs b/clippy_lints/src/default_numeric_fallback.rs index 3f1b7ea6214..3573ea5f026 100644 --- a/clippy_lints/src/default_numeric_fallback.rs +++ b/clippy_lints/src/default_numeric_fallback.rs @@ -46,6 +46,7 @@ declare_clippy_lint! { /// let i = 10i32; /// let f = 1.23f64; /// ``` + #[clippy::version = "1.52.0"] pub DEFAULT_NUMERIC_FALLBACK, restriction, "usage of unconstrained numeric literals which may cause default numeric fallback." diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index 975353add08..bbaae94d3dd 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -34,6 +34,7 @@ declare_clippy_lint! { /// ```rust,ignore /// let _ = d.unwrap().deref(); /// ``` + #[clippy::version = "1.44.0"] pub EXPLICIT_DEREF_METHODS, pedantic, "Explicit use of deref or deref_mut method while not in a method chain." diff --git a/clippy_lints/src/derivable_impls.rs b/clippy_lints/src/derivable_impls.rs index 01ec306e5e1..d0fab2b48fb 100644 --- a/clippy_lints/src/derivable_impls.rs +++ b/clippy_lints/src/derivable_impls.rs @@ -46,6 +46,7 @@ declare_clippy_lint! { /// has exactly equal bounds, and therefore this lint is disabled for types with /// generic parameters. /// + #[clippy::version = "1.57.0"] pub DERIVABLE_IMPLS, complexity, "manual implementation of the `Default` trait which is equal to a derive" diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 24ac5917dcb..4b232a26e5d 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -38,6 +38,7 @@ declare_clippy_lint! { /// ... /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub DERIVE_HASH_XOR_EQ, correctness, "deriving `Hash` but implementing `PartialEq` explicitly" @@ -88,6 +89,7 @@ declare_clippy_lint! { /// #[derive(Ord, PartialOrd, PartialEq, Eq)] /// struct Foo; /// ``` + #[clippy::version = "1.47.0"] pub DERIVE_ORD_XOR_PARTIAL_ORD, correctness, "deriving `Ord` but implementing `PartialOrd` explicitly" @@ -114,6 +116,7 @@ declare_clippy_lint! { /// // .. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub EXPL_IMPL_CLONE_ON_COPY, pedantic, "implementing `Clone` explicitly on `Copy` types" @@ -147,6 +150,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.45.0"] pub UNSAFE_DERIVE_DESERIALIZE, pedantic, "deriving `serde::Deserialize` on a type that has methods using `unsafe`" diff --git a/clippy_lints/src/disallowed_method.rs b/clippy_lints/src/disallowed_method.rs index 22d726cdcb7..c2217353b32 100644 --- a/clippy_lints/src/disallowed_method.rs +++ b/clippy_lints/src/disallowed_method.rs @@ -47,6 +47,7 @@ declare_clippy_lint! { /// let mut xs = Vec::new(); // Vec::new is _not_ disallowed in the config. /// xs.push(123); // Vec::push is _not_ disallowed in the config. /// ``` + #[clippy::version = "1.49.0"] pub DISALLOWED_METHOD, nursery, "use of a disallowed method call" diff --git a/clippy_lints/src/disallowed_script_idents.rs b/clippy_lints/src/disallowed_script_idents.rs index 6d38d30cd0b..3c3f3631849 100644 --- a/clippy_lints/src/disallowed_script_idents.rs +++ b/clippy_lints/src/disallowed_script_idents.rs @@ -38,6 +38,7 @@ declare_clippy_lint! { /// let zähler = 10; // OK, it's still latin. /// let カウンタ = 10; // Will spawn the lint. /// ``` + #[clippy::version = "1.55.0"] pub DISALLOWED_SCRIPT_IDENTS, restriction, "usage of non-allowed Unicode scripts" diff --git a/clippy_lints/src/disallowed_type.rs b/clippy_lints/src/disallowed_type.rs index 48f781516f4..7e784ca2244 100644 --- a/clippy_lints/src/disallowed_type.rs +++ b/clippy_lints/src/disallowed_type.rs @@ -42,6 +42,7 @@ declare_clippy_lint! { /// // A similar type that is allowed by the config /// use std::collections::HashMap; /// ``` + #[clippy::version = "1.55.0"] pub DISALLOWED_TYPE, nursery, "use of a disallowed type" diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 87ad5178ff0..249cf260309 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -67,6 +67,7 @@ declare_clippy_lint! { /// /// [SmallVec]: SmallVec /// fn main() {} /// ``` + #[clippy::version = "pre 1.29.0"] pub DOC_MARKDOWN, pedantic, "presence of `_`, `::` or camel-case outside backticks in documentation" @@ -101,6 +102,7 @@ declare_clippy_lint! { /// unimplemented!(); /// } /// ``` + #[clippy::version = "1.39.0"] pub MISSING_SAFETY_DOC, style, "`pub unsafe fn` without `# Safety` docs" @@ -129,6 +131,7 @@ declare_clippy_lint! { /// unimplemented!(); /// } /// ``` + #[clippy::version = "1.41.0"] pub MISSING_ERRORS_DOC, pedantic, "`pub fn` returns `Result` without `# Errors` in doc comment" @@ -159,6 +162,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.52.0"] pub MISSING_PANICS_DOC, pedantic, "`pub fn` may panic without `# Panics` in doc comment" @@ -187,6 +191,7 @@ declare_clippy_lint! { /// unimplemented!(); /// } /// `````` + #[clippy::version = "1.40.0"] pub NEEDLESS_DOCTEST_MAIN, style, "presence of `fn main() {` in code examples" diff --git a/clippy_lints/src/double_comparison.rs b/clippy_lints/src/double_comparison.rs index 6520bb91faf..176092e5b28 100644 --- a/clippy_lints/src/double_comparison.rs +++ b/clippy_lints/src/double_comparison.rs @@ -31,6 +31,7 @@ declare_clippy_lint! { /// # let y = 2; /// if x <= y {} /// ``` + #[clippy::version = "pre 1.29.0"] pub DOUBLE_COMPARISONS, complexity, "unnecessary double comparisons that can be simplified" diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index d0d87b6df9a..e10f740d24a 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -32,6 +32,7 @@ declare_clippy_lint! { /// // Good /// foo(0); /// ``` + #[clippy::version = "pre 1.29.0"] pub DOUBLE_PARENS, complexity, "Warn on unnecessary double parentheses" diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index 0f3dc866afb..a8f8e3d8a42 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -25,6 +25,7 @@ declare_clippy_lint! { /// // still locked /// operation_that_requires_mutex_to_be_unlocked(); /// ``` + #[clippy::version = "pre 1.29.0"] pub DROP_REF, correctness, "calls to `std::mem::drop` with a reference instead of an owned value" @@ -46,6 +47,7 @@ declare_clippy_lint! { /// let x = Box::new(1); /// std::mem::forget(&x) // Should have been forget(x), x will still be dropped /// ``` + #[clippy::version = "pre 1.29.0"] pub FORGET_REF, correctness, "calls to `std::mem::forget` with a reference instead of an owned value" @@ -67,6 +69,7 @@ declare_clippy_lint! { /// std::mem::drop(x) // A copy of x is passed to the function, leaving the /// // original unaffected /// ``` + #[clippy::version = "pre 1.29.0"] pub DROP_COPY, correctness, "calls to `std::mem::drop` with a value that implements Copy" @@ -94,6 +97,7 @@ declare_clippy_lint! { /// std::mem::forget(x) // A copy of x is passed to the function, leaving the /// // original unaffected /// ``` + #[clippy::version = "pre 1.29.0"] pub FORGET_COPY, correctness, "calls to `std::mem::forget` with a value that implements Copy" diff --git a/clippy_lints/src/duration_subsec.rs b/clippy_lints/src/duration_subsec.rs index 3774de62521..3070d105014 100644 --- a/clippy_lints/src/duration_subsec.rs +++ b/clippy_lints/src/duration_subsec.rs @@ -33,6 +33,7 @@ declare_clippy_lint! { /// let _micros = dur.subsec_micros(); /// let _millis = dur.subsec_millis(); /// ``` + #[clippy::version = "pre 1.29.0"] pub DURATION_SUBSEC, complexity, "checks for calculation of subsecond microseconds or milliseconds" diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs index b64246515f3..92c56c762aa 100644 --- a/clippy_lints/src/else_if_without_else.rs +++ b/clippy_lints/src/else_if_without_else.rs @@ -40,6 +40,7 @@ declare_clippy_lint! { /// // We don't care about zero. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub ELSE_IF_WITHOUT_ELSE, restriction, "`if` expression with an `else if`, but without a final `else` branch" diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs index 3453c2da278..af9e65e6361 100644 --- a/clippy_lints/src/empty_enum.rs +++ b/clippy_lints/src/empty_enum.rs @@ -34,6 +34,7 @@ declare_clippy_lint! { /// /// struct Test(!); /// ``` + #[clippy::version = "pre 1.29.0"] pub EMPTY_ENUM, pedantic, "enum with no variants" diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 57fd24bd4f0..3d92eb16870 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -54,6 +54,7 @@ declare_clippy_lint! { /// # let v = 1; /// map.entry(k).or_insert(v); /// ``` + #[clippy::version = "pre 1.29.0"] pub MAP_ENTRY, perf, "use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`" diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index a2c3c7a7b49..3b6661c817b 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// Y = 0, /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub ENUM_CLIKE_UNPORTABLE_VARIANT, correctness, "C-like enums that are `repr(isize/usize)` and have values that don't fit into an `i32`" diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index 404b67c8f29..fc3a35efaf8 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -34,6 +34,7 @@ declare_clippy_lint! { /// Battenberg, /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub ENUM_VARIANT_NAMES, style, "enums where all variants share a prefix/postfix" @@ -59,6 +60,7 @@ declare_clippy_lint! { /// struct BlackForest; /// } /// ``` + #[clippy::version = "1.33.0"] pub MODULE_NAME_REPETITIONS, pedantic, "type names prefixed/postfixed with their containing module's name" @@ -89,6 +91,7 @@ declare_clippy_lint! { /// ... /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub MODULE_INCEPTION, style, "modules that have the same name as their parent module" diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index c034c849b55..10123460527 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -34,6 +34,7 @@ declare_clippy_lint! { /// # let b = 4; /// assert_eq!(a, a); /// ``` + #[clippy::version = "pre 1.29.0"] pub EQ_OP, correctness, "equal operands on both sides of a comparison or bitwise combination (e.g., `x == x`)" @@ -59,6 +60,7 @@ declare_clippy_lint! { /// // Good /// x == *y /// ``` + #[clippy::version = "pre 1.29.0"] pub OP_REF, style, "taking a reference to satisfy the type constraints on `==`" diff --git a/clippy_lints/src/equatable_if_let.rs b/clippy_lints/src/equatable_if_let.rs index e8b1d6f6eda..8905cc0de45 100644 --- a/clippy_lints/src/equatable_if_let.rs +++ b/clippy_lints/src/equatable_if_let.rs @@ -32,6 +32,7 @@ declare_clippy_lint! { /// do_thing(); /// } /// ``` + #[clippy::version = "1.57.0"] pub EQUATABLE_IF_LET, nursery, "using pattern matching instead of equality" diff --git a/clippy_lints/src/erasing_op.rs b/clippy_lints/src/erasing_op.rs index d0944c37cf5..d49cec26be5 100644 --- a/clippy_lints/src/erasing_op.rs +++ b/clippy_lints/src/erasing_op.rs @@ -21,6 +21,7 @@ declare_clippy_lint! { /// 0 * x; /// x & 0; /// ``` + #[clippy::version = "pre 1.29.0"] pub ERASING_OP, correctness, "using erasing operations, e.g., `x * 0` or `y & 0`" diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 75b1c882c23..bc5d2f6278d 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -41,6 +41,7 @@ declare_clippy_lint! { /// foo(x); /// println!("{}", x); /// ``` + #[clippy::version = "pre 1.29.0"] pub BOXED_LOCAL, perf, "using `Box` where unnecessary" diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 8def6529b3b..5a4b4247104 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -39,6 +39,7 @@ declare_clippy_lint! { /// ``` /// where `foo(_)` is a plain function that takes the exact argument type of /// `x`. + #[clippy::version = "pre 1.29.0"] pub REDUNDANT_CLOSURE, style, "redundant closures, i.e., `|a| foo(a)` (which can be written as just `foo`)" @@ -60,6 +61,7 @@ declare_clippy_lint! { /// ```rust,ignore /// Some('a').map(char::to_uppercase); /// ``` + #[clippy::version = "1.35.0"] pub REDUNDANT_CLOSURE_FOR_METHOD_CALLS, pedantic, "redundant closures for method calls" diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 1b56dd4b081..cdac9f3e6e1 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -40,6 +40,7 @@ declare_clippy_lint! { /// }; /// let a = tmp + x; /// ``` + #[clippy::version = "pre 1.29.0"] pub EVAL_ORDER_DEPENDENCE, suspicious, "whether a variable read occurs before a write depends on sub-expression evaluation order" @@ -67,6 +68,7 @@ declare_clippy_lint! { /// let x = (a, b, c, panic!()); /// // can simply be replaced by `panic!()` /// ``` + #[clippy::version = "pre 1.29.0"] pub DIVERGING_SUB_EXPRESSION, complexity, "whether an expression contains a diverging sub expression" diff --git a/clippy_lints/src/excessive_bools.rs b/clippy_lints/src/excessive_bools.rs index 06171702f75..5435e15de7b 100644 --- a/clippy_lints/src/excessive_bools.rs +++ b/clippy_lints/src/excessive_bools.rs @@ -37,6 +37,7 @@ declare_clippy_lint! { /// Finished, /// } /// ``` + #[clippy::version = "1.43.0"] pub STRUCT_EXCESSIVE_BOOLS, pedantic, "using too many bools in a struct" @@ -75,6 +76,7 @@ declare_clippy_lint! { /// /// fn f(shape: Shape, temperature: Temperature) { ... } /// ``` + #[clippy::version = "1.43.0"] pub FN_PARAMS_EXCESSIVE_BOOLS, pedantic, "using too many bools in function parameters" diff --git a/clippy_lints/src/exhaustive_items.rs b/clippy_lints/src/exhaustive_items.rs index bb4684ce38b..b0f50b5c144 100644 --- a/clippy_lints/src/exhaustive_items.rs +++ b/clippy_lints/src/exhaustive_items.rs @@ -31,6 +31,7 @@ declare_clippy_lint! { /// Baz /// } /// ``` + #[clippy::version = "1.51.0"] pub EXHAUSTIVE_ENUMS, restriction, "detects exported enums that have not been marked #[non_exhaustive]" @@ -60,6 +61,7 @@ declare_clippy_lint! { /// baz: String, /// } /// ``` + #[clippy::version = "1.51.0"] pub EXHAUSTIVE_STRUCTS, restriction, "detects exported structs that have not been marked #[non_exhaustive]" diff --git a/clippy_lints/src/exit.rs b/clippy_lints/src/exit.rs index 9cd5b2d9f44..d64cc61916c 100644 --- a/clippy_lints/src/exit.rs +++ b/clippy_lints/src/exit.rs @@ -18,6 +18,7 @@ declare_clippy_lint! { /// ```ignore /// std::process::exit(0) /// ``` + #[clippy::version = "1.41.0"] pub EXIT, restriction, "`std::process::exit` is called, terminating the program" diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index 4f46ef906f4..6b327b9ce17 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -23,6 +23,7 @@ declare_clippy_lint! { /// // this would be clearer as `eprintln!("foo: {:?}", bar);` /// writeln!(&mut std::io::stderr(), "foo: {:?}", bar).unwrap(); /// ``` + #[clippy::version = "pre 1.29.0"] pub EXPLICIT_WRITE, complexity, "using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work" diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 70337f5bbeb..05d300058cf 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -44,6 +44,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub FALLIBLE_IMPL_FROM, nursery, "Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`" diff --git a/clippy_lints/src/feature_name.rs b/clippy_lints/src/feature_name.rs index f534327f7a0..dc6bef52ddd 100644 --- a/clippy_lints/src/feature_name.rs +++ b/clippy_lints/src/feature_name.rs @@ -31,6 +31,7 @@ declare_clippy_lint! { /// ghi = [] /// ``` /// + #[clippy::version = "1.57.0"] pub REDUNDANT_FEATURE_NAMES, cargo, "usage of a redundant feature name" @@ -60,6 +61,7 @@ declare_clippy_lint! { /// def = [] /// /// ``` + #[clippy::version = "1.57.0"] pub NEGATIVE_FEATURE_NAMES, cargo, "usage of a negative feature name" diff --git a/clippy_lints/src/float_equality_without_abs.rs b/clippy_lints/src/float_equality_without_abs.rs index c33d80b8e8e..ca8886228de 100644 --- a/clippy_lints/src/float_equality_without_abs.rs +++ b/clippy_lints/src/float_equality_without_abs.rs @@ -37,6 +37,7 @@ declare_clippy_lint! { /// (a - b).abs() < f32::EPSILON /// } /// ``` + #[clippy::version = "1.48.0"] pub FLOAT_EQUALITY_WITHOUT_ABS, suspicious, "float equality check without `.abs()`" diff --git a/clippy_lints/src/float_literal.rs b/clippy_lints/src/float_literal.rs index 1e8a5bd7d34..d30dede833c 100644 --- a/clippy_lints/src/float_literal.rs +++ b/clippy_lints/src/float_literal.rs @@ -27,6 +27,7 @@ declare_clippy_lint! { /// let v: f64 = 0.123_456_789_9; /// println!("{}", v); // 0.123_456_789_9 /// ``` + #[clippy::version = "pre 1.29.0"] pub EXCESSIVE_PRECISION, style, "excessive precision for float literal" @@ -50,6 +51,7 @@ declare_clippy_lint! { /// let _: f32 = 16_777_216.0; /// let _: f64 = 16_777_217.0; /// ``` + #[clippy::version = "1.43.0"] pub LOSSY_FLOAT_LITERAL, restriction, "lossy whole number float literals" diff --git a/clippy_lints/src/floating_point_arithmetic.rs b/clippy_lints/src/floating_point_arithmetic.rs index eda611117ba..914723a4802 100644 --- a/clippy_lints/src/floating_point_arithmetic.rs +++ b/clippy_lints/src/floating_point_arithmetic.rs @@ -43,6 +43,7 @@ declare_clippy_lint! { /// let _ = a.ln_1p(); /// let _ = a.exp_m1(); /// ``` + #[clippy::version = "1.43.0"] pub IMPRECISE_FLOPS, nursery, "usage of imprecise floating point operations" @@ -99,6 +100,7 @@ declare_clippy_lint! { /// let _ = a.abs(); /// let _ = -a.abs(); /// ``` + #[clippy::version = "1.43.0"] pub SUBOPTIMAL_FLOPS, nursery, "usage of sub-optimal floating point operations" diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 7169ac9ad6c..3f043e5f2f1 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -33,6 +33,7 @@ declare_clippy_lint! { /// // Good /// foo.to_owned(); /// ``` + #[clippy::version = "pre 1.29.0"] pub USELESS_FORMAT, complexity, "useless use of `format!`" diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index bb30accf145..f0e1a67dcdd 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -31,6 +31,7 @@ declare_clippy_lint! { /// # use std::panic::Location; /// println!("error: something failed at {}", Location::caller()); /// ``` + #[clippy::version = "1.58.0"] pub FORMAT_IN_FORMAT_ARGS, perf, "`format!` used in a macro that does formatting" @@ -56,6 +57,7 @@ declare_clippy_lint! { /// # use std::panic::Location; /// println!("error: something failed at {}", Location::caller()); /// ``` + #[clippy::version = "1.58.0"] pub TO_STRING_IN_FORMAT_ARGS, perf, "`to_string` applied to a type that implements `Display` in format args" diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index b4f186525c5..3e85c8a9c80 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -21,6 +21,7 @@ declare_clippy_lint! { /// ```rust,ignore /// a =- 42; // confusing, should it be `a -= 42` or `a = -42`? /// ``` + #[clippy::version = "pre 1.29.0"] pub SUSPICIOUS_ASSIGNMENT_FORMATTING, suspicious, "suspicious formatting of `*=`, `-=` or `!=`" @@ -43,6 +44,7 @@ declare_clippy_lint! { /// if foo &&! bar { // this should be `foo && !bar` but looks like a different operator /// } /// ``` + #[clippy::version = "1.40.0"] pub SUSPICIOUS_UNARY_OP_FORMATTING, suspicious, "suspicious formatting of unary `-` or `!` on the RHS of a BinOp" @@ -79,6 +81,7 @@ declare_clippy_lint! { /// if bar { // this is the `else` block of the previous `if`, but should it be? /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub SUSPICIOUS_ELSE_FORMATTING, suspicious, "suspicious formatting of `else`" @@ -99,6 +102,7 @@ declare_clippy_lint! { /// -4, -5, -6 /// ]; /// ``` + #[clippy::version = "pre 1.29.0"] pub POSSIBLE_MISSING_COMMA, correctness, "possible missing comma in array" diff --git a/clippy_lints/src/from_over_into.rs b/clippy_lints/src/from_over_into.rs index 347c6eb12cb..866ff216f84 100644 --- a/clippy_lints/src/from_over_into.rs +++ b/clippy_lints/src/from_over_into.rs @@ -34,6 +34,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.51.0"] pub FROM_OVER_INTO, style, "Warns on implementations of `Into<..>` to use `From<..>`" diff --git a/clippy_lints/src/from_str_radix_10.rs b/clippy_lints/src/from_str_radix_10.rs index 98ce3db025c..73e800073b0 100644 --- a/clippy_lints/src/from_str_radix_10.rs +++ b/clippy_lints/src/from_str_radix_10.rs @@ -35,6 +35,7 @@ declare_clippy_lint! { /// let input: &str = get_input(); /// let num: u16 = input.parse()?; /// ``` + #[clippy::version = "1.52.0"] pub FROM_STR_RADIX_10, style, "from_str_radix with radix 10" diff --git a/clippy_lints/src/functions/mod.rs b/clippy_lints/src/functions/mod.rs index d7c5ec9ba35..ad031cbc09d 100644 --- a/clippy_lints/src/functions/mod.rs +++ b/clippy_lints/src/functions/mod.rs @@ -26,6 +26,7 @@ declare_clippy_lint! { /// // .. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub TOO_MANY_ARGUMENTS, complexity, "functions with too many arguments" @@ -49,6 +50,7 @@ declare_clippy_lint! { /// println!(""); /// } /// ``` + #[clippy::version = "1.34.0"] pub TOO_MANY_LINES, pedantic, "functions with too many lines" @@ -84,6 +86,7 @@ declare_clippy_lint! { /// println!("{}", unsafe { *x }); /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub NOT_UNSAFE_PTR_ARG_DEREF, correctness, "public functions dereferencing raw pointer arguments but not marked `unsafe`" @@ -103,6 +106,7 @@ declare_clippy_lint! { /// #[must_use] /// fn useless() { } /// ``` + #[clippy::version = "1.40.0"] pub MUST_USE_UNIT, style, "`#[must_use]` attribute on a unit-returning function / method" @@ -126,6 +130,7 @@ declare_clippy_lint! { /// unimplemented!(); /// } /// ``` + #[clippy::version = "1.40.0"] pub DOUBLE_MUST_USE, style, "`#[must_use]` attribute on a `#[must_use]`-returning function / method" @@ -155,6 +160,7 @@ declare_clippy_lint! { /// // this could be annotated with `#[must_use]`. /// fn id(t: T) -> T { t } /// ``` + #[clippy::version = "1.40.0"] pub MUST_USE_CANDIDATE, pedantic, "function or method that could take a `#[must_use]` attribute" @@ -204,6 +210,7 @@ declare_clippy_lint! { /// /// Note that there are crates that simplify creating the error type, e.g. /// [`thiserror`](https://docs.rs/thiserror). + #[clippy::version = "1.49.0"] pub RESULT_UNIT_ERR, style, "public function returning `Result` with an `Err` type of `()`" diff --git a/clippy_lints/src/future_not_send.rs b/clippy_lints/src/future_not_send.rs index e18442515b8..03af498eae3 100644 --- a/clippy_lints/src/future_not_send.rs +++ b/clippy_lints/src/future_not_send.rs @@ -41,6 +41,7 @@ declare_clippy_lint! { /// ```rust /// async fn is_send(bytes: std::sync::Arc<[u8]>) {} /// ``` + #[clippy::version = "1.44.0"] pub FUTURE_NOT_SEND, nursery, "public Futures must be Send" diff --git a/clippy_lints/src/get_last_with_len.rs b/clippy_lints/src/get_last_with_len.rs index f3929b0f1e6..edca701869e 100644 --- a/clippy_lints/src/get_last_with_len.rs +++ b/clippy_lints/src/get_last_with_len.rs @@ -39,6 +39,7 @@ declare_clippy_lint! { /// let x = vec![2, 3, 5]; /// let last_element = x.last(); /// ``` + #[clippy::version = "1.37.0"] pub GET_LAST_WITH_LEN, complexity, "Using `x.get(x.len() - 1)` when `x.last()` is correct and simpler" diff --git a/clippy_lints/src/identity_op.rs b/clippy_lints/src/identity_op.rs index 414f465c494..b4e7bbc7671 100644 --- a/clippy_lints/src/identity_op.rs +++ b/clippy_lints/src/identity_op.rs @@ -22,6 +22,7 @@ declare_clippy_lint! { /// # let x = 1; /// x / 1 + 0 * 1 - 0 | 0; /// ``` + #[clippy::version = "pre 1.29.0"] pub IDENTITY_OP, complexity, "using identity operations, e.g., `x + 0` or `y / 1`" diff --git a/clippy_lints/src/if_let_mutex.rs b/clippy_lints/src/if_let_mutex.rs index a4118bf54b6..e20741d2407 100644 --- a/clippy_lints/src/if_let_mutex.rs +++ b/clippy_lints/src/if_let_mutex.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// use_locked(locked); /// } /// ``` + #[clippy::version = "1.45.0"] pub IF_LET_MUTEX, correctness, "locking a `Mutex` in an `if let` block can cause deadlocks" diff --git a/clippy_lints/src/if_not_else.rs b/clippy_lints/src/if_not_else.rs index ac938156237..3d59b783337 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -39,6 +39,7 @@ declare_clippy_lint! { /// a() /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub IF_NOT_ELSE, pedantic, "`if` branches that could be swapped so no negation operation is necessary on the condition" diff --git a/clippy_lints/src/if_then_some_else_none.rs b/clippy_lints/src/if_then_some_else_none.rs index a2dac57454f..d95f5d41071 100644 --- a/clippy_lints/src/if_then_some_else_none.rs +++ b/clippy_lints/src/if_then_some_else_none.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// 42 /// }); /// ``` + #[clippy::version = "1.53.0"] pub IF_THEN_SOME_ELSE_NONE, restriction, "Finds if-else that could be written using `bool::then`" diff --git a/clippy_lints/src/implicit_hasher.rs b/clippy_lints/src/implicit_hasher.rs index 81eb51e6f7c..6358228dd47 100644 --- a/clippy_lints/src/implicit_hasher.rs +++ b/clippy_lints/src/implicit_hasher.rs @@ -54,6 +54,7 @@ declare_clippy_lint! { /// /// pub fn foo(map: &mut HashMap) { } /// ``` + #[clippy::version = "pre 1.29.0"] pub IMPLICIT_HASHER, pedantic, "missing generalization over different hashers" diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index 6d7c71d4082..07caeada80d 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -35,6 +35,7 @@ declare_clippy_lint! { /// return x; /// } /// ``` + #[clippy::version = "1.33.0"] pub IMPLICIT_RETURN, restriction, "use a return statement like `return expr` instead of an expression" diff --git a/clippy_lints/src/implicit_saturating_sub.rs b/clippy_lints/src/implicit_saturating_sub.rs index ecbbbc5bc64..4088c54623d 100644 --- a/clippy_lints/src/implicit_saturating_sub.rs +++ b/clippy_lints/src/implicit_saturating_sub.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// // Good /// i = i.saturating_sub(1); /// ``` + #[clippy::version = "1.44.0"] pub IMPLICIT_SATURATING_SUB, pedantic, "Perform saturating subtraction instead of implicitly checking lower bound of data type" diff --git a/clippy_lints/src/inconsistent_struct_constructor.rs b/clippy_lints/src/inconsistent_struct_constructor.rs index 52c92b3b122..1debdef9d86 100644 --- a/clippy_lints/src/inconsistent_struct_constructor.rs +++ b/clippy_lints/src/inconsistent_struct_constructor.rs @@ -55,6 +55,7 @@ declare_clippy_lint! { /// # let y = 2; /// Foo { x, y }; /// ``` + #[clippy::version = "1.52.0"] pub INCONSISTENT_STRUCT_CONSTRUCTOR, pedantic, "the order of the field init shorthand is inconsistent with the order in the struct definition" diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index f52f090d387..9ead4bb27a5 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -33,6 +33,7 @@ declare_clippy_lint! { /// x[0]; /// x[3]; /// ``` + #[clippy::version = "pre 1.29.0"] pub OUT_OF_BOUNDS_INDEXING, correctness, "out of bounds constant indexing" @@ -85,6 +86,7 @@ declare_clippy_lint! { /// y.get(10..); /// y.get(..100); /// ``` + #[clippy::version = "pre 1.29.0"] pub INDEXING_SLICING, restriction, "indexing/slicing usage" diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index 68c1fa35fcc..c7db47a552b 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -20,6 +20,7 @@ declare_clippy_lint! { /// /// iter::repeat(1_u8).collect::>(); /// ``` + #[clippy::version = "pre 1.29.0"] pub INFINITE_ITER, correctness, "infinite iteration" @@ -42,6 +43,7 @@ declare_clippy_lint! { /// let infinite_iter = 0..; /// [0..].iter().zip(infinite_iter.take_while(|x| *x > 5)); /// ``` + #[clippy::version = "pre 1.29.0"] pub MAYBE_INFINITE_ITER, pedantic, "possible infinite iteration" diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index bd0b2964309..254d3f8a4d0 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// fn other() {} /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub MULTIPLE_INHERENT_IMPL, restriction, "Multiple inherent impl that could be grouped" diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index 61dd0eb4af7..60d234cd6f0 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -41,6 +41,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.38.0"] pub INHERENT_TO_STRING, style, "type implements inherent method `to_string()`, but should instead implement the `Display` trait" @@ -88,6 +89,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.38.0"] pub INHERENT_TO_STRING_SHADOW_DISPLAY, correctness, "type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait" diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index 3e3df903f17..df69d3dcc51 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -24,6 +24,7 @@ declare_clippy_lint! { /// fn name(&self) -> &'static str; /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub INLINE_FN_WITHOUT_BODY, correctness, "use of `#[inline]` on trait methods without bodies" diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index 6850e0c3476..3716d36ad88 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// # let y = 1; /// if x > y {} /// ``` + #[clippy::version = "pre 1.29.0"] pub INT_PLUS_ONE, complexity, "instead of using `x >= y + 1`, use `x > y`" diff --git a/clippy_lints/src/integer_division.rs b/clippy_lints/src/integer_division.rs index c962e814fa5..fa786205678 100644 --- a/clippy_lints/src/integer_division.rs +++ b/clippy_lints/src/integer_division.rs @@ -23,6 +23,7 @@ declare_clippy_lint! { /// let x = 3f32 / 2f32; /// println!("{}", x); /// ``` + #[clippy::version = "1.37.0"] pub INTEGER_DIVISION, restriction, "integer division may cause loss of precision" diff --git a/clippy_lints/src/invalid_upcast_comparisons.rs b/clippy_lints/src/invalid_upcast_comparisons.rs index 82438d85c7a..36e03e50a8e 100644 --- a/clippy_lints/src/invalid_upcast_comparisons.rs +++ b/clippy_lints/src/invalid_upcast_comparisons.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// let x: u8 = 1; /// (x as u32) > 300; /// ``` + #[clippy::version = "pre 1.29.0"] pub INVALID_UPCAST_COMPARISONS, pedantic, "a comparison involving an upcast which is always true or false" diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index 3736d237642..b118d3c8b87 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -45,6 +45,7 @@ declare_clippy_lint! { /// foo(); // prints "foo" /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub ITEMS_AFTER_STATEMENTS, pedantic, "blocks where an item comes after a statement" diff --git a/clippy_lints/src/iter_not_returning_iterator.rs b/clippy_lints/src/iter_not_returning_iterator.rs index 6c779348ca2..968bbc524b2 100644 --- a/clippy_lints/src/iter_not_returning_iterator.rs +++ b/clippy_lints/src/iter_not_returning_iterator.rs @@ -32,6 +32,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.57.0"] pub ITER_NOT_RETURNING_ITERATOR, pedantic, "methods named `iter` or `iter_mut` that do not return an `Iterator`" diff --git a/clippy_lints/src/large_const_arrays.rs b/clippy_lints/src/large_const_arrays.rs index fe6814e35d0..80260e4cd83 100644 --- a/clippy_lints/src/large_const_arrays.rs +++ b/clippy_lints/src/large_const_arrays.rs @@ -27,6 +27,7 @@ declare_clippy_lint! { /// // Good /// pub static a = [0u32; 1_000_000]; /// ``` + #[clippy::version = "1.44.0"] pub LARGE_CONST_ARRAYS, perf, "large non-scalar const array may cause performance overhead" diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index 392166237be..0191713f60d 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -40,6 +40,7 @@ declare_clippy_lint! { /// B(Box<[i32; 8000]>), /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub LARGE_ENUM_VARIANT, perf, "large size difference between variants on an enum" diff --git a/clippy_lints/src/large_stack_arrays.rs b/clippy_lints/src/large_stack_arrays.rs index bbb6c1f902c..1cc2c28c04a 100644 --- a/clippy_lints/src/large_stack_arrays.rs +++ b/clippy_lints/src/large_stack_arrays.rs @@ -19,6 +19,7 @@ declare_clippy_lint! { /// ```rust,ignore /// let a = [0u32; 1_000_000]; /// ``` + #[clippy::version = "1.41.0"] pub LARGE_STACK_ARRAYS, pedantic, "allocating large arrays on stack may cause stack overflow" diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index f336fb9d42f..09cd0d22d8b 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -46,6 +46,7 @@ declare_clippy_lint! { /// .. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub LEN_ZERO, style, "checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead" @@ -71,6 +72,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub LEN_WITHOUT_IS_EMPTY, style, "traits or impls with a public `len` method but no corresponding `is_empty` method" @@ -108,6 +110,7 @@ declare_clippy_lint! { /// .. /// } /// ``` + #[clippy::version = "1.49.0"] pub COMPARISON_TO_EMPTY, style, "checking `x == \"\"` or `x == []` (or similar) when `.is_empty()` could be used instead" diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 7f2c7b707f0..db09d00d730 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -48,6 +48,7 @@ declare_clippy_lint! { /// None /// }; /// ``` + #[clippy::version = "pre 1.29.0"] pub USELESS_LET_IF_SEQ, nursery, "unidiomatic `let mut` declaration followed by initialization in `if`" diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index 9efd7aba7e8..557051fb8d2 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -26,6 +26,7 @@ declare_clippy_lint! { /// // is_ok() is marked #[must_use] /// let _ = f().is_ok(); /// ``` + #[clippy::version = "1.42.0"] pub LET_UNDERSCORE_MUST_USE, restriction, "non-binding let on a `#[must_use]` expression" @@ -53,6 +54,7 @@ declare_clippy_lint! { /// ```rust,ignore /// let _lock = mutex.lock(); /// ``` + #[clippy::version = "1.43.0"] pub LET_UNDERSCORE_LOCK, correctness, "non-binding let on a synchronization lock" @@ -94,6 +96,7 @@ declare_clippy_lint! { /// // dropped at end of scope /// } /// ``` + #[clippy::version = "1.50.0"] pub LET_UNDERSCORE_DROP, pedantic, "non-binding let on a type that implements `Drop`" diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 6565d5a6d70..fad3343d128 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -45,6 +45,7 @@ declare_clippy_lint! { /// x /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub NEEDLESS_LIFETIMES, complexity, "using explicit lifetimes for references in function arguments when elision rules \ @@ -73,6 +74,7 @@ declare_clippy_lint! { /// // ... /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub EXTRA_UNUSED_LIFETIMES, complexity, "unused lifetimes in function definitions" diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index 0e36ab085a3..130543bbbee 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// // Good /// let x: u64 = 61_864_918_973_511; /// ``` + #[clippy::version = "pre 1.29.0"] pub UNREADABLE_LITERAL, pedantic, "long literal without underscores" @@ -53,6 +54,7 @@ declare_clippy_lint! { /// // Good /// 2_i32; /// ``` + #[clippy::version = "1.30.0"] pub MISTYPED_LITERAL_SUFFIXES, correctness, "mistyped literal suffix" @@ -75,6 +77,7 @@ declare_clippy_lint! { /// // Good /// let x: u64 = 61_864_918_973_511; /// ``` + #[clippy::version = "pre 1.29.0"] pub INCONSISTENT_DIGIT_GROUPING, style, "integer literals with digits grouped inconsistently" @@ -93,6 +96,7 @@ declare_clippy_lint! { /// let x: u32 = 0xFFF_FFF; /// let y: u8 = 0b01_011_101; /// ``` + #[clippy::version = "1.49.0"] pub UNUSUAL_BYTE_GROUPINGS, style, "binary or hex literals that aren't grouped by four" @@ -111,6 +115,7 @@ declare_clippy_lint! { /// ```rust /// let x: u64 = 6186491_8973511; /// ``` + #[clippy::version = "pre 1.29.0"] pub LARGE_DIGIT_GROUPS, pedantic, "grouping digits into groups that are too large" @@ -128,6 +133,7 @@ declare_clippy_lint! { /// `255` => `0xFF` /// `65_535` => `0xFFFF` /// `4_042_322_160` => `0xF0F0_F0F0` + #[clippy::version = "pre 1.29.0"] pub DECIMAL_LITERAL_REPRESENTATION, restriction, "using decimal representation when hexadecimal would be better" diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 5df1b796401..ccec648fa78 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -47,6 +47,7 @@ declare_clippy_lint! { /// # let mut dst = vec![0; 65]; /// dst[64..(src.len() + 64)].clone_from_slice(&src[..]); /// ``` + #[clippy::version = "pre 1.29.0"] pub MANUAL_MEMCPY, perf, "manually copying items between slices" @@ -75,6 +76,7 @@ declare_clippy_lint! { /// println!("{}", i); /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub NEEDLESS_RANGE_LOOP, style, "for-looping over a range of indices where an iterator over items would do" @@ -107,6 +109,7 @@ declare_clippy_lint! { /// // .. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub EXPLICIT_ITER_LOOP, pedantic, "for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do" @@ -135,6 +138,7 @@ declare_clippy_lint! { /// // .. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub EXPLICIT_INTO_ITER_LOOP, pedantic, "for-looping over `_.into_iter()` when `_` would do" @@ -158,6 +162,7 @@ declare_clippy_lint! { /// .. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub ITER_NEXT_LOOP, correctness, "for-looping over `_.next()` which is probably not intended" @@ -201,6 +206,7 @@ declare_clippy_lint! { /// // .. /// } /// ``` + #[clippy::version = "1.45.0"] pub FOR_LOOPS_OVER_FALLIBLES, suspicious, "for-looping over an `Option` or a `Result`, which is more clearly expressed as an `if let`" @@ -233,6 +239,7 @@ declare_clippy_lint! { /// // .. do something with x /// }; /// ``` + #[clippy::version = "pre 1.29.0"] pub WHILE_LET_LOOP, complexity, "`loop { if let { ... } else break }`, which can be written as a `while let` loop" @@ -254,6 +261,7 @@ declare_clippy_lint! { /// // should be /// let len = iterator.count(); /// ``` + #[clippy::version = "1.30.0"] pub NEEDLESS_COLLECT, perf, "collecting an iterator when collect is not needed" @@ -284,6 +292,7 @@ declare_clippy_lint! { /// # fn bar(bar: usize, baz: usize) {} /// for (i, item) in v.iter().enumerate() { bar(i, *item); } /// ``` + #[clippy::version = "pre 1.29.0"] pub EXPLICIT_COUNTER_LOOP, complexity, "for-looping with an explicit counter when `_.enumerate()` would do" @@ -317,6 +326,7 @@ declare_clippy_lint! { /// ```no_run /// loop {} /// ``` + #[clippy::version = "pre 1.29.0"] pub EMPTY_LOOP, suspicious, "empty `loop {}`, which should block or sleep" @@ -336,6 +346,7 @@ declare_clippy_lint! { /// .. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub WHILE_LET_ON_ITERATOR, style, "using a `while let` loop instead of a for loop on an iterator" @@ -364,6 +375,7 @@ declare_clippy_lint! { /// .. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub FOR_KV_MAP, style, "looping on a map using `iter` when `keys` or `values` would do" @@ -385,6 +397,7 @@ declare_clippy_lint! { /// break; /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub NEVER_LOOP, correctness, "any loop that will always `break` or `return`" @@ -420,6 +433,7 @@ declare_clippy_lint! { /// println!("{}", i); // prints numbers from 0 to 42, not 0 to 21 /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub MUT_RANGE_BOUND, suspicious, "for loop over a range where one of the bounds is a mutable variable" @@ -446,6 +460,7 @@ declare_clippy_lint! { /// println!("let me loop forever!"); /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub WHILE_IMMUTABLE_CONDITION, correctness, "variables used within while expression are not mutated in the body" @@ -480,6 +495,7 @@ declare_clippy_lint! { /// let mut vec: Vec = vec![item1; 20]; /// vec.resize(20 + 30, item2); /// ``` + #[clippy::version = "1.47.0"] pub SAME_ITEM_PUSH, style, "the same item is pushed inside of a for loop" @@ -506,6 +522,7 @@ declare_clippy_lint! { /// let item = &item1; /// println!("{}", item); /// ``` + #[clippy::version = "1.49.0"] pub SINGLE_ELEMENT_LOOP, complexity, "there is no reason to have a single element loop" @@ -537,6 +554,7 @@ declare_clippy_lint! { /// println!("{}", n); /// } /// ``` + #[clippy::version = "1.52.0"] pub MANUAL_FLATTEN, complexity, "for loops over `Option`s or `Result`s with a single expression can be simplified" diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs index bccdc3be5e9..262a26951c6 100644 --- a/clippy_lints/src/macro_use.rs +++ b/clippy_lints/src/macro_use.rs @@ -24,6 +24,7 @@ declare_clippy_lint! { /// #[macro_use] /// use some_macro; /// ``` + #[clippy::version = "1.44.0"] pub MACRO_USE_IMPORTS, pedantic, "#[macro_use] is no longer needed" diff --git a/clippy_lints/src/main_recursion.rs b/clippy_lints/src/main_recursion.rs index 23b3ba2296e..fad8fa467d4 100644 --- a/clippy_lints/src/main_recursion.rs +++ b/clippy_lints/src/main_recursion.rs @@ -20,6 +20,7 @@ declare_clippy_lint! { /// main(); /// } /// ``` + #[clippy::version = "1.38.0"] pub MAIN_RECURSION, style, "recursion using the entrypoint" diff --git a/clippy_lints/src/manual_assert.rs b/clippy_lints/src/manual_assert.rs index e55aa3f1850..ed3166086f7 100644 --- a/clippy_lints/src/manual_assert.rs +++ b/clippy_lints/src/manual_assert.rs @@ -26,6 +26,7 @@ declare_clippy_lint! { /// let sad_people: Vec<&str> = vec![]; /// assert!(sad_people.is_empty(), "there are sad people: {:?}", sad_people); /// ``` + #[clippy::version = "1.57.0"] pub MANUAL_ASSERT, pedantic, "`panic!` and only a `panic!` in `if`-then statement" diff --git a/clippy_lints/src/manual_async_fn.rs b/clippy_lints/src/manual_async_fn.rs index b632af455f8..86819752f90 100644 --- a/clippy_lints/src/manual_async_fn.rs +++ b/clippy_lints/src/manual_async_fn.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// ```rust /// async fn foo() -> i32 { 42 } /// ``` + #[clippy::version = "1.45.0"] pub MANUAL_ASYNC_FN, style, "manual implementations of `async` functions can be simplified using the dedicated syntax" diff --git a/clippy_lints/src/manual_map.rs b/clippy_lints/src/manual_map.rs index 96df3d0a490..cf5dabd9462 100644 --- a/clippy_lints/src/manual_map.rs +++ b/clippy_lints/src/manual_map.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// ```rust /// Some(0).map(|x| x + 1); /// ``` + #[clippy::version = "1.52.0"] pub MANUAL_MAP, style, "reimplementation of `map`" diff --git a/clippy_lints/src/manual_non_exhaustive.rs b/clippy_lints/src/manual_non_exhaustive.rs index 335ea001ee4..63a72d4fdde 100644 --- a/clippy_lints/src/manual_non_exhaustive.rs +++ b/clippy_lints/src/manual_non_exhaustive.rs @@ -52,6 +52,7 @@ declare_clippy_lint! { /// #[non_exhaustive] /// struct T(pub i32, pub i32); /// ``` + #[clippy::version = "1.45.0"] pub MANUAL_NON_EXHAUSTIVE, style, "manual implementations of the non-exhaustive pattern can be simplified using #[non_exhaustive]" diff --git a/clippy_lints/src/manual_ok_or.rs b/clippy_lints/src/manual_ok_or.rs index cf641d0ce86..b60e2dc366b 100644 --- a/clippy_lints/src/manual_ok_or.rs +++ b/clippy_lints/src/manual_ok_or.rs @@ -32,6 +32,7 @@ declare_clippy_lint! { /// let foo: Option = None; /// foo.ok_or("error"); /// ``` + #[clippy::version = "1.49.0"] pub MANUAL_OK_OR, pedantic, "finds patterns that can be encoded more concisely with `Option::ok_or`" diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index 4e040508b6b..f8e28f1671f 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -42,6 +42,7 @@ declare_clippy_lint! { /// assert_eq!(end.to_uppercase(), "WORLD!"); /// } /// ``` + #[clippy::version = "1.48.0"] pub MANUAL_STRIP, complexity, "suggests using `strip_{prefix,suffix}` over `str::{starts,ends}_with` and slicing" diff --git a/clippy_lints/src/manual_unwrap_or.rs b/clippy_lints/src/manual_unwrap_or.rs index 42478e3416e..aac3c6e0de2 100644 --- a/clippy_lints/src/manual_unwrap_or.rs +++ b/clippy_lints/src/manual_unwrap_or.rs @@ -35,6 +35,7 @@ declare_clippy_lint! { /// let foo: Option = None; /// foo.unwrap_or(1); /// ``` + #[clippy::version = "1.49.0"] pub MANUAL_UNWRAP_OR, complexity, "finds patterns that can be encoded more concisely with `Option::unwrap_or` or `Result::unwrap_or`" diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index 7db5c7e52ea..c2b78e21861 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -37,6 +37,7 @@ declare_clippy_lint! { /// let y = x.iter(); /// let z = y.cloned(); /// ``` + #[clippy::version = "pre 1.29.0"] pub MAP_CLONE, style, "using `iterator.map(|x| x.clone())`, or dereferencing closures for `Copy` types" diff --git a/clippy_lints/src/map_err_ignore.rs b/clippy_lints/src/map_err_ignore.rs index 82d3732326e..61f21d532c5 100644 --- a/clippy_lints/src/map_err_ignore.rs +++ b/clippy_lints/src/map_err_ignore.rs @@ -97,6 +97,7 @@ declare_clippy_lint! { /// }) /// } /// ``` + #[clippy::version = "1.48.0"] pub MAP_ERR_IGNORE, restriction, "`map_err` should not ignore the original error" diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 40de9ffcd4e..a84de3e079b 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -47,6 +47,7 @@ declare_clippy_lint! { /// log_err_msg(format_msg(msg)); /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub OPTION_MAP_UNIT_FN, complexity, "using `option.map(f)`, where `f` is a function or closure that returns `()`" @@ -87,6 +88,7 @@ declare_clippy_lint! { /// log_err_msg(format_msg(msg)); /// }; /// ``` + #[clippy::version = "pre 1.29.0"] pub RESULT_MAP_UNIT_FN, complexity, "using `result.map(f)`, where `f` is a function or closure that returns `()`" diff --git a/clippy_lints/src/match_on_vec_items.rs b/clippy_lints/src/match_on_vec_items.rs index 552c9a58897..583b577ffe2 100644 --- a/clippy_lints/src/match_on_vec_items.rs +++ b/clippy_lints/src/match_on_vec_items.rs @@ -40,6 +40,7 @@ declare_clippy_lint! { /// _ => {}, /// } /// ``` + #[clippy::version = "1.45.0"] pub MATCH_ON_VEC_ITEMS, pedantic, "matching on vector elements can panic" diff --git a/clippy_lints/src/match_result_ok.rs b/clippy_lints/src/match_result_ok.rs index ecf6ad316a4..b1839f00aae 100644 --- a/clippy_lints/src/match_result_ok.rs +++ b/clippy_lints/src/match_result_ok.rs @@ -38,6 +38,7 @@ declare_clippy_lint! { /// vec.push(value) /// } /// ``` + #[clippy::version = "1.57.0"] pub MATCH_RESULT_OK, style, "usage of `ok()` in `let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead" diff --git a/clippy_lints/src/match_str_case_mismatch.rs b/clippy_lints/src/match_str_case_mismatch.rs index f501593c518..3316ebf4051 100644 --- a/clippy_lints/src/match_str_case_mismatch.rs +++ b/clippy_lints/src/match_str_case_mismatch.rs @@ -39,6 +39,7 @@ declare_clippy_lint! { /// _ => {}, /// } /// ``` + #[clippy::version = "1.58.0"] pub MATCH_STR_CASE_MISMATCH, correctness, "creation of a case altering match expression with non-compliant arms" diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index e4e533fa71a..74765a1a1de 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -57,6 +57,7 @@ declare_clippy_lint! { /// bar(foo); /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub SINGLE_MATCH, style, "a `match` statement with a single nontrivial arm (i.e., where the other arm is `_ => {}`) instead of `if let`" @@ -98,6 +99,7 @@ declare_clippy_lint! { /// bar(&other_ref); /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub SINGLE_MATCH_ELSE, pedantic, "a `match` statement with two arms where the second arm's pattern is a placeholder instead of a specific match pattern" @@ -129,6 +131,7 @@ declare_clippy_lint! { /// _ => frob(x), /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub MATCH_REF_PATS, style, "a `match` or `if let` with all arms prefixed with `&` instead of deref-ing the match expression" @@ -163,6 +166,7 @@ declare_clippy_lint! { /// bar(); /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub MATCH_BOOL, pedantic, "a `match` on a boolean expression instead of an `if..else` block" @@ -185,6 +189,7 @@ declare_clippy_lint! { /// _ => (), /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub MATCH_OVERLAPPING_ARM, style, "a `match` with overlapping arms" @@ -207,6 +212,7 @@ declare_clippy_lint! { /// Err(_) => panic!("err"), /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub MATCH_WILD_ERR_ARM, pedantic, "a `match` with `Err(_)` arm and take drastic actions" @@ -233,6 +239,7 @@ declare_clippy_lint! { /// // Good /// let r: Option<&()> = x.as_ref(); /// ``` + #[clippy::version = "pre 1.29.0"] pub MATCH_AS_REF, complexity, "a `match` on an Option value instead of using `as_ref()` or `as_mut`" @@ -265,6 +272,7 @@ declare_clippy_lint! { /// Foo::B(_) => {}, /// } /// ``` + #[clippy::version = "1.34.0"] pub WILDCARD_ENUM_MATCH_ARM, restriction, "a wildcard enum match arm using `_`" @@ -299,6 +307,7 @@ declare_clippy_lint! { /// Foo::C => {}, /// } /// ``` + #[clippy::version = "1.45.0"] pub MATCH_WILDCARD_FOR_SINGLE_VARIANTS, pedantic, "a wildcard enum match for a single variant" @@ -326,6 +335,7 @@ declare_clippy_lint! { /// _ => {}, /// } /// ``` + #[clippy::version = "1.42.0"] pub WILDCARD_IN_OR_PATTERNS, complexity, "a wildcard pattern used with others patterns in same match arm" @@ -361,6 +371,7 @@ declare_clippy_lint! { /// let wrapper = Wrapper::Data(42); /// let Wrapper::Data(data) = wrapper; /// ``` + #[clippy::version = "pre 1.29.0"] pub INFALLIBLE_DESTRUCTURING_MATCH, style, "a `match` statement with a single infallible arm instead of a `let`" @@ -392,6 +403,7 @@ declare_clippy_lint! { /// // Good /// let (c, d) = (a, b); /// ``` + #[clippy::version = "1.43.0"] pub MATCH_SINGLE_BINDING, complexity, "a match with a single binding instead of using `let` statement" @@ -422,6 +434,7 @@ declare_clippy_lint! { /// _ => {}, /// } /// ``` + #[clippy::version = "1.43.0"] pub REST_PAT_IN_FULLY_BOUND_STRUCTS, restriction, "a match on a struct that binds all fields but still uses the wildcard pattern" @@ -477,6 +490,7 @@ declare_clippy_lint! { /// if IpAddr::V6(Ipv6Addr::LOCALHOST).is_ipv6() {} /// Ok::(42).is_ok(); /// ``` + #[clippy::version = "1.31.0"] pub REDUNDANT_PATTERN_MATCHING, style, "use the proper utility function avoiding an `if let`" @@ -513,6 +527,7 @@ declare_clippy_lint! { /// // Good /// let a = matches!(x, Some(0)); /// ``` + #[clippy::version = "1.47.0"] pub MATCH_LIKE_MATCHES_MACRO, style, "a match that could be written with the matches! macro" @@ -557,6 +572,7 @@ declare_clippy_lint! { /// Quz => quz(), /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub MATCH_SAME_ARMS, pedantic, "`match` with identical arm bodies" diff --git a/clippy_lints/src/mem_forget.rs b/clippy_lints/src/mem_forget.rs index eb437dc47af..5ffcfd4d264 100644 --- a/clippy_lints/src/mem_forget.rs +++ b/clippy_lints/src/mem_forget.rs @@ -19,6 +19,7 @@ declare_clippy_lint! { /// # use std::rc::Rc; /// mem::forget(Rc::new(55)) /// ``` + #[clippy::version = "pre 1.29.0"] pub MEM_FORGET, restriction, "`mem::forget` usage on `Drop` types, likely to cause memory leaks" diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index cf721fc65db..7fc39f17232 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -35,6 +35,7 @@ declare_clippy_lint! { /// let mut an_option = Some(0); /// let taken = an_option.take(); /// ``` + #[clippy::version = "1.31.0"] pub MEM_REPLACE_OPTION_WITH_NONE, style, "replacing an `Option` with `None` instead of `take()`" @@ -66,6 +67,7 @@ declare_clippy_lint! { /// The [take_mut](https://docs.rs/take_mut) crate offers a sound solution, /// at the cost of either lazily creating a replacement value or aborting /// on panic, to ensure that the uninitialized value cannot be observed. + #[clippy::version = "1.39.0"] pub MEM_REPLACE_WITH_UNINIT, correctness, "`mem::replace(&mut _, mem::uninitialized())` or `mem::replace(&mut _, mem::zeroed())`" @@ -90,6 +92,7 @@ declare_clippy_lint! { /// let mut text = String::from("foo"); /// let taken = std::mem::take(&mut text); /// ``` + #[clippy::version = "1.42.0"] pub MEM_REPLACE_WITH_DEFAULT, style, "replacing a value of type `T` with `T::default()` instead of using `std::mem::take`" diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 6c4272f9e65..5cb849a56bc 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -99,6 +99,7 @@ declare_clippy_lint! { /// ```rust /// [1, 2, 3].iter().copied(); /// ``` + #[clippy::version = "1.53.0"] pub CLONED_INSTEAD_OF_COPIED, pedantic, "used `cloned` where `copied` could be used instead" @@ -121,6 +122,7 @@ declare_clippy_lint! { /// ```rust /// let nums: Vec = ["1", "2", "whee!"].iter().filter_map(|x| x.parse().ok()).collect(); /// ``` + #[clippy::version = "1.53.0"] pub FLAT_MAP_OPTION, pedantic, "used `flat_map` where `filter_map` could be used instead" @@ -166,6 +168,7 @@ declare_clippy_lint! { /// // Good /// res.expect("more helpful message"); /// ``` + #[clippy::version = "1.45.0"] pub UNWRAP_USED, restriction, "using `.unwrap()` on `Result` or `Option`, which should at least get a better message using `expect()`" @@ -208,6 +211,7 @@ declare_clippy_lint! { /// res?; /// # Ok::<(), ()>(()) /// ``` + #[clippy::version = "1.45.0"] pub EXPECT_USED, restriction, "using `.expect()` on `Result` or `Option`, which might be better handled" @@ -237,6 +241,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub SHOULD_IMPLEMENT_TRAIT, style, "defining a method that should be implementing a std trait" @@ -284,6 +289,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub WRONG_SELF_CONVENTION, style, "defining a method named with an established prefix (like \"into_\") that takes `self` with the wrong convention" @@ -310,6 +316,7 @@ declare_clippy_lint! { /// // Good /// x.expect("why did I do this again?"); /// ``` + #[clippy::version = "pre 1.29.0"] pub OK_EXPECT, style, "using `ok().expect()`, which gives worse error messages than calling `expect` directly on the Result" @@ -335,6 +342,7 @@ declare_clippy_lint! { /// // Good /// x.unwrap_or_default(); /// ``` + #[clippy::version = "1.56.0"] pub UNWRAP_OR_ELSE_DEFAULT, style, "using `.unwrap_or_else(Default::default)`, which is more succinctly expressed as `.unwrap_or_default()`" @@ -375,6 +383,7 @@ declare_clippy_lint! { /// // Good /// x.map_or_else(some_function, |a| a + 1); /// ``` + #[clippy::version = "1.45.0"] pub MAP_UNWRAP_OR, pedantic, "using `.map(f).unwrap_or(a)` or `.map(f).unwrap_or_else(func)`, which are more succinctly expressed as `map_or(a, f)` or `map_or_else(a, f)`" @@ -401,6 +410,7 @@ declare_clippy_lint! { /// // Good /// opt.and_then(|a| Some(a + 1)); /// ``` + #[clippy::version = "pre 1.29.0"] pub OPTION_MAP_OR_NONE, style, "using `Option.map_or(None, f)`, which is more succinctly expressed as `and_then(f)`" @@ -426,6 +436,7 @@ declare_clippy_lint! { /// # let r: Result = Ok(1); /// assert_eq!(Some(1), r.ok()); /// ``` + #[clippy::version = "1.44.0"] pub RESULT_MAP_OR_INTO_OPTION, style, "using `Result.map_or(None, Some)`, which is more succinctly expressed as `ok()`" @@ -458,6 +469,7 @@ declare_clippy_lint! { /// let _ = res().map(|s| if s.len() == 42 { 10 } else { 20 }); /// let _ = res().map_err(|s| if s.len() == 42 { 10 } else { 20 }); /// ``` + #[clippy::version = "1.45.0"] pub BIND_INSTEAD_OF_MAP, complexity, "using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`" @@ -481,6 +493,7 @@ declare_clippy_lint! { /// # let vec = vec![1]; /// vec.iter().find(|x| **x == 0); /// ``` + #[clippy::version = "pre 1.29.0"] pub FILTER_NEXT, complexity, "using `filter(p).next()`, which is more succinctly expressed as `.find(p)`" @@ -504,6 +517,7 @@ declare_clippy_lint! { /// # let vec = vec![1]; /// vec.iter().find(|x| **x != 0); /// ``` + #[clippy::version = "1.42.0"] pub SKIP_WHILE_NEXT, complexity, "using `skip_while(p).next()`, which is more succinctly expressed as `.find(!p)`" @@ -527,6 +541,7 @@ declare_clippy_lint! { /// // Good /// vec.iter().flat_map(|x| x.iter()); /// ``` + #[clippy::version = "1.31.0"] pub MAP_FLATTEN, pedantic, "using combinations of `flatten` and `map` which can usually be written as a single method call" @@ -553,6 +568,7 @@ declare_clippy_lint! { /// ```rust /// (0_i32..10).filter_map(|n| n.checked_add(1)); /// ``` + #[clippy::version = "1.51.0"] pub MANUAL_FILTER_MAP, complexity, "using `_.filter(_).map(_)` in a way that can be written more simply as `filter_map(_)`" @@ -579,6 +595,7 @@ declare_clippy_lint! { /// ```rust /// (0_i32..10).find_map(|n| n.checked_add(1)); /// ``` + #[clippy::version = "1.51.0"] pub MANUAL_FIND_MAP, complexity, "using `_.find(_).map(_)` in a way that can be written more simply as `find_map(_)`" @@ -601,6 +618,7 @@ declare_clippy_lint! { /// ```rust /// (0..3).find_map(|x| if x == 2 { Some(x) } else { None }); /// ``` + #[clippy::version = "1.36.0"] pub FILTER_MAP_NEXT, pedantic, "using combination of `filter_map` and `next` which can usually be written as a single method call" @@ -623,6 +641,7 @@ declare_clippy_lint! { /// # let iter = vec![vec![0]].into_iter(); /// iter.flatten(); /// ``` + #[clippy::version = "1.39.0"] pub FLAT_MAP_IDENTITY, complexity, "call to `flat_map` where `flatten` is sufficient" @@ -652,6 +671,7 @@ declare_clippy_lint! { /// /// let _ = !"hello world".contains("world"); /// ``` + #[clippy::version = "pre 1.29.0"] pub SEARCH_IS_SOME, complexity, "using an iterator or string search followed by `is_some()` or `is_none()`, which is more succinctly expressed as a call to `any()` or `contains()` (with negation in case of `is_none()`)" @@ -676,6 +696,7 @@ declare_clippy_lint! { /// let name = "foo"; /// if name.starts_with('_') {}; /// ``` + #[clippy::version = "pre 1.29.0"] pub CHARS_NEXT_CMP, style, "using `.chars().next()` to check if a string starts with a char" @@ -710,6 +731,7 @@ declare_clippy_lint! { /// # let foo = Some(String::new()); /// foo.unwrap_or_default(); /// ``` + #[clippy::version = "pre 1.29.0"] pub OR_FUN_CALL, perf, "using any `*or` method with a function call, which suggests `*or_else`" @@ -748,6 +770,7 @@ declare_clippy_lint! { /// # let err_msg = "I'm a teapot"; /// foo.unwrap_or_else(|| panic!("Err {}: {}", err_code, err_msg)); /// ``` + #[clippy::version = "pre 1.29.0"] pub EXPECT_FUN_CALL, perf, "using any `expect` method with a function call" @@ -765,6 +788,7 @@ declare_clippy_lint! { /// ```rust /// 42u64.clone(); /// ``` + #[clippy::version = "pre 1.29.0"] pub CLONE_ON_COPY, complexity, "using `clone` on a `Copy` type" @@ -792,6 +816,7 @@ declare_clippy_lint! { /// // Good /// Rc::clone(&x); /// ``` + #[clippy::version = "pre 1.29.0"] pub CLONE_ON_REF_PTR, restriction, "using 'clone' on a ref-counted pointer" @@ -814,6 +839,7 @@ declare_clippy_lint! { /// println!("{:p} {:p}", *y, z); // prints out the same pointer /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub CLONE_DOUBLE_REF, correctness, "using `clone` on `&&T`" @@ -837,6 +863,7 @@ declare_clippy_lint! { /// // OK, the specialized impl is used /// ["foo", "bar"].iter().map(|&s| s.to_string()); /// ``` + #[clippy::version = "1.40.0"] pub INEFFICIENT_TO_STRING, pedantic, "using `to_string` on `&&T` where `T: ToString`" @@ -898,6 +925,7 @@ declare_clippy_lint! { /// fn new() -> Self; /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub NEW_RET_NO_SELF, style, "not returning type containing `Self` in a `new` method" @@ -922,6 +950,7 @@ declare_clippy_lint! { /// /// // Good /// _.split('x'); + #[clippy::version = "pre 1.29.0"] pub SINGLE_CHAR_PATTERN, perf, "using a single-character str where a char could be used, e.g., `_.split(\"x\")`" @@ -941,6 +970,7 @@ declare_clippy_lint! { /// //.. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub ITERATOR_STEP_BY_ZERO, correctness, "using `Iterator::step_by(0)`, which will panic at runtime" @@ -962,6 +992,7 @@ declare_clippy_lint! { /// ```rust /// let _ = std::iter::empty::>().flatten(); /// ``` + #[clippy::version = "1.53.0"] pub OPTION_FILTER_MAP, complexity, "filtering `Option` for `Some` then force-unwrapping, which can be one type-safe operation" @@ -989,6 +1020,7 @@ declare_clippy_lint! { /// # s.insert(1); /// let x = s.iter().next(); /// ``` + #[clippy::version = "1.42.0"] pub ITER_NTH_ZERO, style, "replace `iter.nth(0)` with `iter.next()`" @@ -1015,6 +1047,7 @@ declare_clippy_lint! { /// let bad_vec = some_vec.get(3); /// let bad_slice = &some_vec[..].get(3); /// ``` + #[clippy::version = "pre 1.29.0"] pub ITER_NTH, perf, "using `.iter().nth()` on a standard library type with O(1) element access" @@ -1039,6 +1072,7 @@ declare_clippy_lint! { /// let bad_vec = some_vec.iter().nth(3); /// let bad_slice = &some_vec[..].iter().nth(3); /// ``` + #[clippy::version = "pre 1.29.0"] pub ITER_SKIP_NEXT, style, "using `.skip(x).next()` on an iterator" @@ -1075,6 +1109,7 @@ declare_clippy_lint! { /// let last = some_vec[3]; /// some_vec[0] = 1; /// ``` + #[clippy::version = "pre 1.29.0"] pub GET_UNWRAP, restriction, "using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead" @@ -1098,6 +1133,7 @@ declare_clippy_lint! { /// // Good /// a.append(&mut b); /// ``` + #[clippy::version = "1.55.0"] pub EXTEND_WITH_DRAIN, perf, "using vec.append(&mut vec) to move the full range of a vecor to another" @@ -1127,6 +1163,7 @@ declare_clippy_lint! { /// s.push_str(abc); /// s.push_str(&def); /// ``` + #[clippy::version = "pre 1.29.0"] pub STRING_EXTEND_CHARS, style, "using `x.extend(s.chars())` where s is a `&str` or `String`" @@ -1150,6 +1187,7 @@ declare_clippy_lint! { /// let s = [1, 2, 3, 4, 5]; /// let s2: Vec = s.to_vec(); /// ``` + #[clippy::version = "pre 1.29.0"] pub ITER_CLONED_COLLECT, style, "using `.cloned().collect()` on slice to create a `Vec`" @@ -1174,6 +1212,7 @@ declare_clippy_lint! { /// // Good /// name.ends_with('_') || name.ends_with('-'); /// ``` + #[clippy::version = "pre 1.29.0"] pub CHARS_LAST_CMP, style, "using `.chars().last()` or `.chars().next_back()` to check if a string ends with a char" @@ -1199,6 +1238,7 @@ declare_clippy_lint! { /// let x: &[i32] = &[1, 2, 3, 4, 5]; /// do_stuff(x); /// ``` + #[clippy::version = "pre 1.29.0"] pub USELESS_ASREF, complexity, "using `as_ref` where the types before and after the call are the same" @@ -1221,6 +1261,7 @@ declare_clippy_lint! { /// ```rust /// let _ = (0..3).any(|x| x > 2); /// ``` + #[clippy::version = "pre 1.29.0"] pub UNNECESSARY_FOLD, style, "using `fold` when a more succinct alternative exists" @@ -1250,6 +1291,7 @@ declare_clippy_lint! { /// // As there is no conditional check on the argument this could be written as: /// let _ = (0..4).map(|x| x + 1); /// ``` + #[clippy::version = "1.31.0"] pub UNNECESSARY_FILTER_MAP, complexity, "using `filter_map` when a more succinct alternative exists" @@ -1273,6 +1315,7 @@ declare_clippy_lint! { /// // Good /// let _ = (&vec![3, 4, 5]).iter(); /// ``` + #[clippy::version = "1.32.0"] pub INTO_ITER_ON_REF, style, "using `.into_iter()` on a reference" @@ -1292,6 +1335,7 @@ declare_clippy_lint! { /// ```rust /// let _ = (0..3).map(|x| x + 2).count(); /// ``` + #[clippy::version = "1.39.0"] pub SUSPICIOUS_MAP, suspicious, "suspicious usage of map" @@ -1326,6 +1370,7 @@ declare_clippy_lint! { /// MaybeUninit::uninit().assume_init() /// }; /// ``` + #[clippy::version = "1.39.0"] pub UNINIT_ASSUMED_INIT, correctness, "`MaybeUninit::uninit().assume_init()`" @@ -1354,6 +1399,7 @@ declare_clippy_lint! { /// let add = x.saturating_add(y); /// let sub = x.saturating_sub(y); /// ``` + #[clippy::version = "1.39.0"] pub MANUAL_SATURATING_ARITHMETIC, style, "`.chcked_add/sub(x).unwrap_or(MAX/MIN)`" @@ -1371,6 +1417,7 @@ declare_clippy_lint! { /// ```rust /// unsafe { (&() as *const ()).offset(1) }; /// ``` + #[clippy::version = "1.41.0"] pub ZST_OFFSET, correctness, "Check for offset calculations on raw pointers to zero-sized types" @@ -1412,6 +1459,7 @@ declare_clippy_lint! { /// # Ok::<_, std::io::Error>(()) /// # }; /// ``` + #[clippy::version = "1.42.0"] pub FILETYPE_IS_FILE, restriction, "`FileType::is_file` is not recommended to test for readable file type" @@ -1437,6 +1485,7 @@ declare_clippy_lint! { /// opt.as_deref() /// # ; /// ``` + #[clippy::version = "1.42.0"] pub OPTION_AS_REF_DEREF, complexity, "using `as_ref().map(Deref::deref)`, which is more succinctly expressed as `as_deref()`" @@ -1463,6 +1512,7 @@ declare_clippy_lint! { /// a.get(2); /// b.get(0); /// ``` + #[clippy::version = "1.46.0"] pub ITER_NEXT_SLICE, style, "using `.iter().next()` on a sliced array, which can be shortened to just `.get()`" @@ -1488,6 +1538,7 @@ declare_clippy_lint! { /// string.insert(0, 'R'); /// string.push('R'); /// ``` + #[clippy::version = "1.49.0"] pub SINGLE_CHAR_ADD_STR, style, "`push_str()` or `insert_str()` used with a single-character string literal as parameter" @@ -1526,6 +1577,7 @@ declare_clippy_lint! { /// /// opt.unwrap_or(42); /// ``` + #[clippy::version = "1.48.0"] pub UNNECESSARY_LAZY_EVALUATIONS, style, "using unnecessary lazy evaluation, which can be replaced with simpler eager evaluation" @@ -1546,6 +1598,7 @@ declare_clippy_lint! { /// ```rust /// (0..3).try_for_each(|t| Err(t)); /// ``` + #[clippy::version = "1.49.0"] pub MAP_COLLECT_RESULT_UNIT, style, "using `.map(_).collect::()`, which can be replaced with `try_for_each`" @@ -1578,6 +1631,7 @@ declare_clippy_lint! { /// /// assert_eq!(v, vec![5, 5, 5, 5, 5]); /// ``` + #[clippy::version = "1.49.0"] pub FROM_ITER_INSTEAD_OF_COLLECT, pedantic, "use `.collect()` instead of `::from_iter()`" @@ -1607,6 +1661,7 @@ declare_clippy_lint! { /// assert!(x >= 0); /// }); /// ``` + #[clippy::version = "1.51.0"] pub INSPECT_FOR_EACH, complexity, "using `.inspect().for_each()`, which can be replaced with `.for_each()`" @@ -1629,6 +1684,7 @@ declare_clippy_lint! { /// # let iter = vec![Some(1)].into_iter(); /// iter.flatten(); /// ``` + #[clippy::version = "1.52.0"] pub FILTER_MAP_IDENTITY, complexity, "call to `filter_map` where `flatten` is sufficient" @@ -1651,6 +1707,7 @@ declare_clippy_lint! { /// let x = [1, 2, 3]; /// let y: Vec<_> = x.iter().map(|x| 2*x).collect(); /// ``` + #[clippy::version = "1.52.0"] pub MAP_IDENTITY, complexity, "using iterator.map(|x| x)" @@ -1672,6 +1729,7 @@ declare_clippy_lint! { /// // Good /// let _ = "Hello".as_bytes().get(3); /// ``` + #[clippy::version = "1.52.0"] pub BYTES_NTH, style, "replace `.bytes().nth()` with `.as_bytes().get()`" @@ -1697,6 +1755,7 @@ declare_clippy_lint! { /// let b = a.clone(); /// let c = a.clone(); /// ``` + #[clippy::version = "1.52.0"] pub IMPLICIT_CLONE, pedantic, "implicitly cloning a value by invoking a function on its dereferenced type" @@ -1722,6 +1781,7 @@ declare_clippy_lint! { /// let _ = some_vec.len(); /// let _ = &some_vec[..].len(); /// ``` + #[clippy::version = "1.52.0"] pub ITER_COUNT, complexity, "replace `.iter().count()` with `.len()`" @@ -1751,6 +1811,7 @@ declare_clippy_lint! { /// // use x /// } /// ``` + #[clippy::version = "1.54.0"] pub SUSPICIOUS_SPLITN, correctness, "checks for `.splitn(0, ..)` and `.splitn(1, ..)`" @@ -1771,6 +1832,7 @@ declare_clippy_lint! { /// // Good /// let x: String = "x".repeat(10); /// ``` + #[clippy::version = "1.54.0"] pub MANUAL_STR_REPEAT, perf, "manual implementation of `str::repeat`" @@ -1793,6 +1855,7 @@ declare_clippy_lint! { /// let (key, value) = _.split_once('=')?; /// let value = _.split_once('=')?.1; /// ``` + #[clippy::version = "1.57.0"] pub MANUAL_SPLIT_ONCE, complexity, "replace `.splitn(2, pat)` with `.split_once(pat)`" diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index dc2dd45e4ed..a6450aec4f7 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -26,6 +26,7 @@ declare_clippy_lint! { /// ``` /// It will always be equal to `0`. Probably the author meant to clamp the value /// between 0 and 100, but has erroneously swapped `min` and `max`. + #[clippy::version = "pre 1.29.0"] pub MIN_MAX, correctness, "`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant" diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 0f32cd9164e..a93537104bf 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -56,6 +56,7 @@ declare_clippy_lint! { /// true /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub TOPLEVEL_REF_ARG, style, "an entire binding declared as `ref`, in a function argument or a `let` statement" @@ -79,6 +80,7 @@ declare_clippy_lint! { /// // Good /// if x.is_nan() { } /// ``` + #[clippy::version = "pre 1.29.0"] pub CMP_NAN, correctness, "comparisons to `NAN`, which will always return false, probably not intended" @@ -112,6 +114,7 @@ declare_clippy_lint! { /// if (y - 1.23f64).abs() < error_margin { } /// if (y - x).abs() > error_margin { } /// ``` + #[clippy::version = "pre 1.29.0"] pub FLOAT_CMP, pedantic, "using `==` or `!=` on float values instead of comparing difference with an epsilon" @@ -139,6 +142,7 @@ declare_clippy_lint! { /// # let y = String::from("foo"); /// if x == y {} /// ``` + #[clippy::version = "pre 1.29.0"] pub CMP_OWNED, perf, "creating owned instances for comparing with others, e.g., `x == \"foo\".to_string()`" @@ -162,6 +166,7 @@ declare_clippy_lint! { /// let a = x % 1; /// let a = x % -1; /// ``` + #[clippy::version = "pre 1.29.0"] pub MODULO_ONE, correctness, "taking a number modulo +/-1, which can either panic/overflow or always returns 0" @@ -187,6 +192,7 @@ declare_clippy_lint! { /// let y = _x + 1; // Here we are using `_x`, even though it has a leading /// // underscore. We should rename `_x` to `x` /// ``` + #[clippy::version = "pre 1.29.0"] pub USED_UNDERSCORE_BINDING, pedantic, "using a binding which is prefixed with an underscore" @@ -207,6 +213,7 @@ declare_clippy_lint! { /// ```rust,ignore /// f() && g(); // We should write `if f() { g(); }`. /// ``` + #[clippy::version = "pre 1.29.0"] pub SHORT_CIRCUIT_STATEMENT, complexity, "using a short circuit boolean condition as a statement" @@ -228,6 +235,7 @@ declare_clippy_lint! { /// // Good /// let a = std::ptr::null::(); /// ``` + #[clippy::version = "pre 1.29.0"] pub ZERO_PTR, style, "using `0 as *{const, mut} T`" @@ -259,6 +267,7 @@ declare_clippy_lint! { /// // let error_margin = std::f64::EPSILON; /// if (x - ONE).abs() < error_margin { } /// ``` + #[clippy::version = "pre 1.29.0"] pub FLOAT_CMP_CONST, restriction, "using `==` or `!=` on float constants instead of comparing difference with an epsilon" diff --git a/clippy_lints/src/misc_early/mod.rs b/clippy_lints/src/misc_early/mod.rs index 7c3f5f22ade..4b56eaebaea 100644 --- a/clippy_lints/src/misc_early/mod.rs +++ b/clippy_lints/src/misc_early/mod.rs @@ -46,6 +46,7 @@ declare_clippy_lint! { /// Foo { .. } => {}, /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub UNNEEDED_FIELD_PATTERN, restriction, "struct fields bound to a wildcard instead of using `..`" @@ -67,6 +68,7 @@ declare_clippy_lint! { /// // Good /// fn bar(a: i32, _b: i32) {} /// ``` + #[clippy::version = "pre 1.29.0"] pub DUPLICATE_UNDERSCORE_ARGUMENT, style, "function arguments having names which only differ by an underscore" @@ -85,6 +87,7 @@ declare_clippy_lint! { /// let mut x = 3; /// --x; /// ``` + #[clippy::version = "pre 1.29.0"] pub DOUBLE_NEG, style, "`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++" @@ -106,6 +109,7 @@ declare_clippy_lint! { /// // Good /// let y = 0x1A9BACD; /// ``` + #[clippy::version = "pre 1.29.0"] pub MIXED_CASE_HEX_LITERALS, style, "hex literals whose letter digits are not consistently upper- or lowercased" @@ -129,6 +133,7 @@ declare_clippy_lint! { /// // Good /// let y = 123832_i32; /// ``` + #[clippy::version = "pre 1.29.0"] pub UNSEPARATED_LITERAL_SUFFIX, restriction, "literals whose suffix is not separated by an underscore" @@ -189,6 +194,7 @@ declare_clippy_lint! { /// ``` /// /// prints `83` (as `83 == 0o123` while `123 == 0o173`). + #[clippy::version = "pre 1.29.0"] pub ZERO_PREFIXED_LITERAL, complexity, "integer literals starting with `0`" @@ -210,6 +216,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub BUILTIN_TYPE_SHADOW, style, "shadowing a builtin type" @@ -239,6 +246,7 @@ declare_clippy_lint! { /// y => (), /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub REDUNDANT_PATTERN, style, "using `name @ _` in a pattern" @@ -273,6 +281,7 @@ declare_clippy_lint! { /// _ => (), /// } /// ``` + #[clippy::version = "1.40.0"] pub UNNEEDED_WILDCARD_PATTERN, complexity, "tuple patterns with a wildcard pattern (`_`) is next to a rest pattern (`..`)" diff --git a/clippy_lints/src/missing_const_for_fn.rs b/clippy_lints/src/missing_const_for_fn.rs index 5b2584d43a1..a8d41050856 100644 --- a/clippy_lints/src/missing_const_for_fn.rs +++ b/clippy_lints/src/missing_const_for_fn.rs @@ -63,6 +63,7 @@ declare_clippy_lint! { /// } /// # } /// ``` + #[clippy::version = "1.34.0"] pub MISSING_CONST_FOR_FN, nursery, "Lint functions definitions that could be made `const fn`" diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 6920b4f72ea..db6aab0671b 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -27,6 +27,7 @@ declare_clippy_lint! { /// allowed-by-default lint for /// public members, but has no way to enforce documentation of private items. /// This lint fixes that. + #[clippy::version = "pre 1.29.0"] pub MISSING_DOCS_IN_PRIVATE_ITEMS, restriction, "detects missing documentation for public and private members" diff --git a/clippy_lints/src/missing_enforced_import_rename.rs b/clippy_lints/src/missing_enforced_import_rename.rs index 448bfc2fdd6..68d49e0f150 100644 --- a/clippy_lints/src/missing_enforced_import_rename.rs +++ b/clippy_lints/src/missing_enforced_import_rename.rs @@ -33,6 +33,7 @@ declare_clippy_lint! { /// ```rust,ignore /// use serde_json::Value as JsonValue; /// ``` + #[clippy::version = "1.55.0"] pub MISSING_ENFORCED_IMPORT_RENAMES, restriction, "enforce import renames" diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index b593c747498..ac2f16b49e3 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -52,6 +52,7 @@ declare_clippy_lint! { /// fn def_bar() {} // missing #[inline] /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub MISSING_INLINE_IN_PUBLIC_ITEMS, restriction, "detects missing `#[inline]` attribute for public callables (functions, trait methods, methods...)" diff --git a/clippy_lints/src/module_style.rs b/clippy_lints/src/module_style.rs index d41b5474564..3b65f80cba2 100644 --- a/clippy_lints/src/module_style.rs +++ b/clippy_lints/src/module_style.rs @@ -32,6 +32,7 @@ declare_clippy_lint! { /// stuff.rs /// lib.rs /// ``` + #[clippy::version = "1.57.0"] pub MOD_MODULE_FILES, restriction, "checks that module layout is consistent" @@ -61,6 +62,7 @@ declare_clippy_lint! { /// lib.rs /// ``` + #[clippy::version = "1.57.0"] pub SELF_NAMED_MODULE_FILES, restriction, "checks that module layout is consistent" diff --git a/clippy_lints/src/modulo_arithmetic.rs b/clippy_lints/src/modulo_arithmetic.rs index f45e68233a1..d182a7d5249 100644 --- a/clippy_lints/src/modulo_arithmetic.rs +++ b/clippy_lints/src/modulo_arithmetic.rs @@ -24,6 +24,7 @@ declare_clippy_lint! { /// ```rust /// let x = -17 % 3; /// ``` + #[clippy::version = "1.42.0"] pub MODULO_ARITHMETIC, restriction, "any modulo arithmetic statement" diff --git a/clippy_lints/src/multiple_crate_versions.rs b/clippy_lints/src/multiple_crate_versions.rs index 816b2f275fb..e45cc86d417 100644 --- a/clippy_lints/src/multiple_crate_versions.rs +++ b/clippy_lints/src/multiple_crate_versions.rs @@ -33,6 +33,7 @@ declare_clippy_lint! { /// ctrlc = "=3.1.0" /// ansi_term = "=0.11.0" /// ``` + #[clippy::version = "pre 1.29.0"] pub MULTIPLE_CRATE_VERSIONS, cargo, "multiple versions of the same crate being used" diff --git a/clippy_lints/src/mut_key.rs b/clippy_lints/src/mut_key.rs index 8476257f086..5fe887a4573 100644 --- a/clippy_lints/src/mut_key.rs +++ b/clippy_lints/src/mut_key.rs @@ -72,6 +72,7 @@ declare_clippy_lint! { /// let _: HashSet = HashSet::new(); /// } /// ``` + #[clippy::version = "1.42.0"] pub MUTABLE_KEY_TYPE, suspicious, "Check for mutable `Map`/`Set` key type" diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index 7c4cac29ba8..bcbea8f1e66 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -22,6 +22,7 @@ declare_clippy_lint! { /// # let mut y = 1; /// let x = &mut &mut y; /// ``` + #[clippy::version = "pre 1.29.0"] pub MUT_MUT, pedantic, "usage of double-mut refs, e.g., `&mut &mut ...`" diff --git a/clippy_lints/src/mut_mutex_lock.rs b/clippy_lints/src/mut_mutex_lock.rs index b96fa4774cb..b1e6308d2e1 100644 --- a/clippy_lints/src/mut_mutex_lock.rs +++ b/clippy_lints/src/mut_mutex_lock.rs @@ -38,6 +38,7 @@ declare_clippy_lint! { /// let value = value_mutex.get_mut().unwrap(); /// *value += 1; /// ``` + #[clippy::version = "1.49.0"] pub MUT_MUTEX_LOCK, style, "`&mut Mutex::lock` does unnecessary locking" diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 8d5d7951fc5..63a1cf7b7d5 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -23,6 +23,7 @@ declare_clippy_lint! { /// // Good /// my_vec.push(&value) /// ``` + #[clippy::version = "pre 1.29.0"] pub UNNECESSARY_MUT_PASSED, style, "an argument passed as a mutable reference although the callee only demands an immutable reference" diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index ee50891cc31..fa7274990db 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -26,6 +26,7 @@ declare_clippy_lint! { /// fn take_a_mut_parameter(_: &mut u32) -> bool { unimplemented!() } /// debug_assert!(take_a_mut_parameter(&mut 5)); /// ``` + #[clippy::version = "1.40.0"] pub DEBUG_ASSERT_WITH_MUT_CALL, nursery, "mutable arguments in `debug_assert{,_ne,_eq}!`" diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index 5feddcbfc61..816377fe65e 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// # use std::sync::atomic::AtomicBool; /// let x = AtomicBool::new(y); /// ``` + #[clippy::version = "pre 1.29.0"] pub MUTEX_ATOMIC, perf, "using a mutex where an atomic value could be used instead" @@ -64,6 +65,7 @@ declare_clippy_lint! { /// # use std::sync::atomic::AtomicUsize; /// let x = AtomicUsize::new(0usize); /// ``` + #[clippy::version = "pre 1.29.0"] pub MUTEX_INTEGER, nursery, "using a mutex for an integer type" diff --git a/clippy_lints/src/needless_arbitrary_self_type.rs b/clippy_lints/src/needless_arbitrary_self_type.rs index c8a8750c2ff..9838d3cad9f 100644 --- a/clippy_lints/src/needless_arbitrary_self_type.rs +++ b/clippy_lints/src/needless_arbitrary_self_type.rs @@ -52,6 +52,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.47.0"] pub NEEDLESS_ARBITRARY_SELF_TYPE, complexity, "type of `self` parameter is already by default `Self`" diff --git a/clippy_lints/src/needless_bitwise_bool.rs b/clippy_lints/src/needless_bitwise_bool.rs index ad981599473..a8a8d174a82 100644 --- a/clippy_lints/src/needless_bitwise_bool.rs +++ b/clippy_lints/src/needless_bitwise_bool.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// let (x,y) = (true, false); /// if x && !y {} /// ``` + #[clippy::version = "1.54.0"] pub NEEDLESS_BITWISE_BOOL, pedantic, "Boolean expressions that use bitwise rather than lazy operators" diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 91944653500..3709f3948c2 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -41,6 +41,7 @@ declare_clippy_lint! { /// ```rust,ignore /// !x /// ``` + #[clippy::version = "pre 1.29.0"] pub NEEDLESS_BOOL, complexity, "if-statements with plain booleans in the then- and else-clause, e.g., `if p { true } else { false }`" @@ -65,6 +66,7 @@ declare_clippy_lint! { /// if x {} /// if !y {} /// ``` + #[clippy::version = "pre 1.29.0"] pub BOOL_COMPARISON, complexity, "comparing a variable to a boolean, e.g., `if x == true` or `if x != true`" diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index 085be6650cc..6709fed91bd 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -37,6 +37,7 @@ declare_clippy_lint! { /// let x: &i32 = &5; /// fun(x); /// ``` + #[clippy::version = "pre 1.29.0"] pub NEEDLESS_BORROW, style, "taking a reference that is going to be automatically dereferenced" @@ -63,6 +64,7 @@ declare_clippy_lint! { /// // use `&x` here /// } /// ``` + #[clippy::version = "1.54.0"] pub REF_BINDING_TO_REFERENCE, pedantic, "`ref` binding to a reference" diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index 36879eda7c0..0fcc419e722 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -38,6 +38,7 @@ declare_clippy_lint! { /// let mut v = Vec::::new(); /// let _ = v.iter_mut().filter(|a| a.is_empty()); /// ``` + #[clippy::version = "pre 1.29.0"] pub NEEDLESS_BORROWED_REFERENCE, complexity, "destructuring a reference and borrowing the inner value" diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index 7aa93ed7839..98a3bce1ff3 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -110,6 +110,7 @@ declare_clippy_lint! { /// # break; /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub NEEDLESS_CONTINUE, pedantic, "`continue` statements that can be replaced by a rearrangement of code" diff --git a/clippy_lints/src/needless_for_each.rs b/clippy_lints/src/needless_for_each.rs index 9a6ddc72ce5..0c1da035173 100644 --- a/clippy_lints/src/needless_for_each.rs +++ b/clippy_lints/src/needless_for_each.rs @@ -40,6 +40,7 @@ declare_clippy_lint! { /// println!("{}", elem); /// } /// ``` + #[clippy::version = "1.53.0"] pub NEEDLESS_FOR_EACH, pedantic, "using `for_each` where a `for` loop would be simpler" diff --git a/clippy_lints/src/needless_option_as_deref.rs b/clippy_lints/src/needless_option_as_deref.rs index e88e98e6081..a28b08c33ec 100644 --- a/clippy_lints/src/needless_option_as_deref.rs +++ b/clippy_lints/src/needless_option_as_deref.rs @@ -26,6 +26,7 @@ declare_clippy_lint! { /// let a = Some(&1); /// let b = a; /// ``` + #[clippy::version = "1.57.0"] pub NEEDLESS_OPTION_AS_DEREF, complexity, "no-op use of `deref` or `deref_mut` method to `Option`." diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 352dc6f8bec..35877d51c0c 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -51,6 +51,7 @@ declare_clippy_lint! { /// assert_eq!(v.len(), 42); /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub NEEDLESS_PASS_BY_VALUE, pedantic, "functions taking arguments by value, but not consuming them in its body" diff --git a/clippy_lints/src/needless_question_mark.rs b/clippy_lints/src/needless_question_mark.rs index 42e48336e15..3ca933ea8fb 100644 --- a/clippy_lints/src/needless_question_mark.rs +++ b/clippy_lints/src/needless_question_mark.rs @@ -53,6 +53,7 @@ declare_clippy_lint! { /// tr.and_then(|t| t.magic) /// } /// ``` + #[clippy::version = "1.51.0"] pub NEEDLESS_QUESTION_MARK, complexity, "Suggest `value.inner_option` instead of `Some(value.inner_option?)`. The same goes for `Result`." diff --git a/clippy_lints/src/needless_update.rs b/clippy_lints/src/needless_update.rs index 2a33b7392ca..ed315efaa2f 100644 --- a/clippy_lints/src/needless_update.rs +++ b/clippy_lints/src/needless_update.rs @@ -40,6 +40,7 @@ declare_clippy_lint! { /// ..zero_point /// }; /// ``` + #[clippy::version = "pre 1.29.0"] pub NEEDLESS_UPDATE, complexity, "using `Foo { ..base }` when there are no missing fields" 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 6ad49b70605..efe31a15441 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// _ => false, /// }; /// ``` + #[clippy::version = "pre 1.29.0"] pub NEG_CMP_OP_ON_PARTIAL_ORD, complexity, "The use of negated comparison operators on partially ordered types may produce confusing code." diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index 1b15d29439f..cb67fab1740 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -20,6 +20,7 @@ declare_clippy_lint! { /// ```ignore /// x * -1 /// ``` + #[clippy::version = "pre 1.29.0"] pub NEG_MULTIPLY, style, "multiplying integers with `-1`" diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 0ac27f1cba2..f0c0c89ca8f 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -45,6 +45,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub NEW_WITHOUT_DEFAULT, style, "`fn new() -> Self` method without `Default` implementation" diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index 6dae8f32043..31134743d02 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -22,6 +22,7 @@ declare_clippy_lint! { /// ```rust /// 0; /// ``` + #[clippy::version = "pre 1.29.0"] pub NO_EFFECT, complexity, "statements with no effect" @@ -44,6 +45,7 @@ declare_clippy_lint! { /// ```rust,ignore /// let _i_serve_no_purpose = 1; /// ``` + #[clippy::version = "1.58.0"] pub NO_EFFECT_UNDERSCORE_BINDING, pedantic, "binding to `_` prefixed variable with no side-effect" @@ -62,6 +64,7 @@ declare_clippy_lint! { /// ```rust,ignore /// compute_array()[0]; /// ``` + #[clippy::version = "pre 1.29.0"] pub UNNECESSARY_OPERATION, complexity, "outer expressions with no effect" diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 2a85a67fa09..df82775d507 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -69,6 +69,7 @@ declare_clippy_lint! { /// STATIC_ATOM.store(9, SeqCst); /// assert_eq!(STATIC_ATOM.load(SeqCst), 9); // use a `static` item to refer to the same instance /// ``` + #[clippy::version = "pre 1.29.0"] pub DECLARE_INTERIOR_MUTABLE_CONST, style, "declaring `const` with interior mutability" @@ -113,6 +114,7 @@ declare_clippy_lint! { /// STATIC_ATOM.store(9, SeqCst); /// assert_eq!(STATIC_ATOM.load(SeqCst), 9); // use a `static` item to refer to the same instance /// ``` + #[clippy::version = "pre 1.29.0"] pub BORROW_INTERIOR_MUTABLE_CONST, style, "referencing `const` with interior mutability" diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 5b254bc8133..1a124e2d3cb 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -24,6 +24,7 @@ declare_clippy_lint! { /// let checked_exp = something; /// let checked_expr = something_else; /// ``` + #[clippy::version = "pre 1.29.0"] pub SIMILAR_NAMES, pedantic, "similarly named items and bindings" @@ -42,6 +43,7 @@ declare_clippy_lint! { /// ```ignore /// let (a, b, c, d, e, f, g) = (...); /// ``` + #[clippy::version = "pre 1.29.0"] pub MANY_SINGLE_CHAR_NAMES, pedantic, "too many single character bindings" @@ -62,6 +64,7 @@ declare_clippy_lint! { /// let ___1 = 1; /// let __1___2 = 11; /// ``` + #[clippy::version = "pre 1.29.0"] pub JUST_UNDERSCORES_AND_DIGITS, style, "unclear name" diff --git a/clippy_lints/src/non_octal_unix_permissions.rs b/clippy_lints/src/non_octal_unix_permissions.rs index 3b74f69d375..4b57dbc4c41 100644 --- a/clippy_lints/src/non_octal_unix_permissions.rs +++ b/clippy_lints/src/non_octal_unix_permissions.rs @@ -32,6 +32,7 @@ declare_clippy_lint! { /// let mut options = OpenOptions::new(); /// options.mode(0o644); /// ``` + #[clippy::version = "1.53.0"] pub NON_OCTAL_UNIX_PERMISSIONS, correctness, "use of non-octal value to set unix file permissions, which will be translated into octal" diff --git a/clippy_lints/src/non_send_fields_in_send_ty.rs b/clippy_lints/src/non_send_fields_in_send_ty.rs index 7ebf84d400f..9c07488bfe6 100644 --- a/clippy_lints/src/non_send_fields_in_send_ty.rs +++ b/clippy_lints/src/non_send_fields_in_send_ty.rs @@ -43,6 +43,7 @@ declare_clippy_lint! { /// ``` /// Use thread-safe types like [`std::sync::Arc`](https://doc.rust-lang.org/std/sync/struct.Arc.html) /// or specify correct bounds on generic type parameters (`T: Send`). + #[clippy::version = "1.57.0"] pub NON_SEND_FIELDS_IN_SEND_TY, suspicious, "there is field that does not implement `Send` in a `Send` struct" diff --git a/clippy_lints/src/nonstandard_macro_braces.rs b/clippy_lints/src/nonstandard_macro_braces.rs index bab15217d52..3dcc9e26c9e 100644 --- a/clippy_lints/src/nonstandard_macro_braces.rs +++ b/clippy_lints/src/nonstandard_macro_braces.rs @@ -31,6 +31,7 @@ declare_clippy_lint! { /// ```rust /// vec![1, 2, 3]; /// ``` + #[clippy::version = "1.55.0"] pub NONSTANDARD_MACRO_BRACES, nursery, "check consistent use of braces in macro" diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index 5752342cf62..2c77100bdcf 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -22,6 +22,7 @@ declare_clippy_lint! { /// /// OpenOptions::new().read(true).truncate(true); /// ``` + #[clippy::version = "pre 1.29.0"] pub NONSENSICAL_OPEN_OPTIONS, correctness, "nonsensical combination of options for opening a file" diff --git a/clippy_lints/src/option_env_unwrap.rs b/clippy_lints/src/option_env_unwrap.rs index d7306628030..3f5286ba097 100644 --- a/clippy_lints/src/option_env_unwrap.rs +++ b/clippy_lints/src/option_env_unwrap.rs @@ -26,6 +26,7 @@ declare_clippy_lint! { /// ```rust,no_run /// let _ = env!("HOME"); /// ``` + #[clippy::version = "1.43.0"] pub OPTION_ENV_UNWRAP, correctness, "using `option_env!(...).unwrap()` to get environment variable" diff --git a/clippy_lints/src/option_if_let_else.rs b/clippy_lints/src/option_if_let_else.rs index ed5583799fe..df72f4b0eb2 100644 --- a/clippy_lints/src/option_if_let_else.rs +++ b/clippy_lints/src/option_if_let_else.rs @@ -59,6 +59,7 @@ declare_clippy_lint! { /// y*y /// }, |foo| foo); /// ``` + #[clippy::version = "1.47.0"] pub OPTION_IF_LET_ELSE, nursery, "reimplementation of Option::map_or" diff --git a/clippy_lints/src/overflow_check_conditional.rs b/clippy_lints/src/overflow_check_conditional.rs index 0f9e5ada3a8..6dabbd48031 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -19,6 +19,7 @@ declare_clippy_lint! { /// # let b = 2; /// a + b < a; /// ``` + #[clippy::version = "pre 1.29.0"] pub OVERFLOW_CHECK_CONDITIONAL, complexity, "overflow checks inspired by C which are likely to panic" diff --git a/clippy_lints/src/panic_in_result_fn.rs b/clippy_lints/src/panic_in_result_fn.rs index 583c42b6563..8769c045214 100644 --- a/clippy_lints/src/panic_in_result_fn.rs +++ b/clippy_lints/src/panic_in_result_fn.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// Err(String::from("error")) /// } /// ``` + #[clippy::version = "1.48.0"] pub PANIC_IN_RESULT_FN, restriction, "functions of type `Result<..>` that contain `panic!()`, `todo!()`, `unreachable()`, `unimplemented()` or assertion" diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index d8d9081d6f1..edfac824ded 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -17,6 +17,7 @@ declare_clippy_lint! { /// ```no_run /// panic!("even with a good reason"); /// ``` + #[clippy::version = "1.40.0"] pub PANIC, restriction, "usage of the `panic!` macro" @@ -33,6 +34,7 @@ declare_clippy_lint! { /// ```no_run /// unimplemented!(); /// ``` + #[clippy::version = "pre 1.29.0"] pub UNIMPLEMENTED, restriction, "`unimplemented!` should not be present in production code" @@ -49,6 +51,7 @@ declare_clippy_lint! { /// ```no_run /// todo!(); /// ``` + #[clippy::version = "1.40.0"] pub TODO, restriction, "`todo!` should not be present in production code" @@ -65,6 +68,7 @@ declare_clippy_lint! { /// ```no_run /// unreachable!(); /// ``` + #[clippy::version = "1.40.0"] pub UNREACHABLE, restriction, "usage of the `unreachable!` macro" diff --git a/clippy_lints/src/partialeq_ne_impl.rs b/clippy_lints/src/partialeq_ne_impl.rs index 4ec493e5f45..e827cdaae87 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -25,6 +25,7 @@ declare_clippy_lint! { /// fn ne(&self, other: &Foo) -> bool { !(self == other) } /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub PARTIALEQ_NE_IMPL, complexity, "re-implementing `PartialEq::ne`" diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index 6229b9608b3..3092ab8392a 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -65,6 +65,7 @@ declare_clippy_lint! { /// // Better /// fn foo(v: u32) {} /// ``` + #[clippy::version = "pre 1.29.0"] pub TRIVIALLY_COPY_PASS_BY_REF, pedantic, "functions taking small copyable arguments by reference" @@ -98,6 +99,7 @@ declare_clippy_lint! { /// // Good /// fn foo(v: &TooLarge) {} /// ``` + #[clippy::version = "1.49.0"] pub LARGE_TYPES_PASSED_BY_VALUE, pedantic, "functions taking large arguments by value" diff --git a/clippy_lints/src/path_buf_push_overwrite.rs b/clippy_lints/src/path_buf_push_overwrite.rs index 3df7a72d295..8ebee9bd04d 100644 --- a/clippy_lints/src/path_buf_push_overwrite.rs +++ b/clippy_lints/src/path_buf_push_overwrite.rs @@ -35,6 +35,7 @@ declare_clippy_lint! { /// x.push("bar"); /// assert_eq!(x, PathBuf::from("/foo/bar")); /// ``` + #[clippy::version = "1.36.0"] pub PATH_BUF_PUSH_OVERWRITE, nursery, "calling `push` with file system root on `PathBuf` can overwrite it" diff --git a/clippy_lints/src/pattern_type_mismatch.rs b/clippy_lints/src/pattern_type_mismatch.rs index e7bc2446590..3e7eef4edac 100644 --- a/clippy_lints/src/pattern_type_mismatch.rs +++ b/clippy_lints/src/pattern_type_mismatch.rs @@ -77,6 +77,7 @@ declare_clippy_lint! { /// *a += b; /// } /// ``` + #[clippy::version = "1.47.0"] pub PATTERN_TYPE_MISMATCH, restriction, "type of pattern does not match the expression type" diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index 1a8da00d9d6..cc0533c9f5d 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -42,6 +42,7 @@ declare_clippy_lint! { /// ### Example /// * `1 << 2 + 3` equals 32, while `(1 << 2) + 3` equals 7 /// * `-1i32.abs()` equals -1, while `(-1i32).abs()` equals 1 + #[clippy::version = "pre 1.29.0"] pub PRECEDENCE, complexity, "operations where precedence may be unclear" diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index 8a36e20fc97..c08a19d520b 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -70,6 +70,7 @@ declare_clippy_lint! { /// // Good /// fn foo(&[u32]) { .. } /// ``` + #[clippy::version = "pre 1.29.0"] pub PTR_ARG, style, "fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` instead, respectively" @@ -96,6 +97,7 @@ declare_clippy_lint! { /// .. /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub CMP_NULL, style, "comparing a pointer to a null pointer, suggesting to use `.is_null()` instead" @@ -121,6 +123,7 @@ declare_clippy_lint! { /// ```ignore /// fn foo(&Foo) -> &mut Bar { .. } /// ``` + #[clippy::version = "pre 1.29.0"] pub MUT_FROM_REF, correctness, "fns that create mutable refs from immutable ref args" @@ -143,6 +146,7 @@ declare_clippy_lint! { /// // Good /// unsafe { std::slice::from_raw_parts(NonNull::dangling().as_ptr(), 0); } /// ``` + #[clippy::version = "1.53.0"] pub INVALID_NULL_PTR_USAGE, correctness, "invalid usage of a null pointer, suggesting `NonNull::dangling()` instead" diff --git a/clippy_lints/src/ptr_eq.rs b/clippy_lints/src/ptr_eq.rs index 2df34d6d9b9..3c126fc1ca6 100644 --- a/clippy_lints/src/ptr_eq.rs +++ b/clippy_lints/src/ptr_eq.rs @@ -29,6 +29,7 @@ declare_clippy_lint! { /// /// assert!(std::ptr::eq(a, b)); /// ``` + #[clippy::version = "1.49.0"] pub PTR_EQ, style, "use `std::ptr::eq` when comparing raw pointers" diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index cfb5287c667..964564b5794 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -38,6 +38,7 @@ declare_clippy_lint! { /// ptr.add(offset); /// } /// ``` + #[clippy::version = "1.30.0"] pub PTR_OFFSET_WITH_CAST, complexity, "unneeded pointer offset cast" diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index f63ef163bcb..a5531993ee6 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -32,6 +32,7 @@ declare_clippy_lint! { /// ```ignore /// option?; /// ``` + #[clippy::version = "pre 1.29.0"] pub QUESTION_MARK, style, "checks for expressions that could be replaced by the question mark operator" diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 87364a88ed0..09c64485bbb 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -35,6 +35,7 @@ declare_clippy_lint! { /// # let x = vec![1]; /// x.iter().enumerate(); /// ``` + #[clippy::version = "pre 1.29.0"] pub RANGE_ZIP_WITH_LEN, complexity, "zipping iterator with a range when `enumerate()` would do" @@ -72,6 +73,7 @@ declare_clippy_lint! { /// ```rust,ignore /// for x..=y { .. } /// ``` + #[clippy::version = "pre 1.29.0"] pub RANGE_PLUS_ONE, pedantic, "`x..(y+1)` reads better as `x..=y`" @@ -100,6 +102,7 @@ declare_clippy_lint! { /// ```rust,ignore /// for x..y { .. } /// ``` + #[clippy::version = "pre 1.29.0"] pub RANGE_MINUS_ONE, pedantic, "`x..=(y-1)` reads better as `x..y`" @@ -132,6 +135,7 @@ declare_clippy_lint! { /// let sub = &arr[1..3]; /// } /// ``` + #[clippy::version = "1.45.0"] pub REVERSED_EMPTY_RANGES, correctness, "reversing the limits of range expressions, resulting in empty ranges" @@ -158,6 +162,7 @@ declare_clippy_lint! { ///# let x = 6; /// assert!((3..8).contains(&x)); /// ``` + #[clippy::version = "1.49.0"] pub MANUAL_RANGE_CONTAINS, style, "manually reimplementing {`Range`, `RangeInclusive`}`::contains`" diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index f7711b6fe94..1a2c86a7686 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -62,6 +62,7 @@ declare_clippy_lint! { /// /// Path::new("/a/b").join("c").to_path_buf(); /// ``` + #[clippy::version = "1.32.0"] pub REDUNDANT_CLONE, perf, "`clone()` of an owned value that is going to be dropped immediately" diff --git a/clippy_lints/src/redundant_closure_call.rs b/clippy_lints/src/redundant_closure_call.rs index 90e3c3f4b3e..0de282542fc 100644 --- a/clippy_lints/src/redundant_closure_call.rs +++ b/clippy_lints/src/redundant_closure_call.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// // Good /// let a = 42 /// ``` + #[clippy::version = "pre 1.29.0"] pub REDUNDANT_CLOSURE_CALL, complexity, "throwaway closures called in the expression they are defined" diff --git a/clippy_lints/src/redundant_else.rs b/clippy_lints/src/redundant_else.rs index 68b256d2944..93dbe936d58 100644 --- a/clippy_lints/src/redundant_else.rs +++ b/clippy_lints/src/redundant_else.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// print!("Moving on..."); /// } /// ``` + #[clippy::version = "1.50.0"] pub REDUNDANT_ELSE, pedantic, "`else` branch that can be removed without changing semantics" diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index 47df4917510..0dea4a784b2 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// ```ignore /// let foo = Foo { bar }; /// ``` + #[clippy::version = "pre 1.29.0"] pub REDUNDANT_FIELD_NAMES, style, "checks for fields in struct literals where shorthands could be used" diff --git a/clippy_lints/src/redundant_pub_crate.rs b/clippy_lints/src/redundant_pub_crate.rs index 919d4e11e5a..2cee3c14d7f 100644 --- a/clippy_lints/src/redundant_pub_crate.rs +++ b/clippy_lints/src/redundant_pub_crate.rs @@ -26,6 +26,7 @@ declare_clippy_lint! { /// pub fn internal_fn() { } /// } /// ``` + #[clippy::version = "1.44.0"] pub REDUNDANT_PUB_CRATE, nursery, "Using `pub(crate)` visibility on items that are not crate visible due to the visibility of the module that contains them." diff --git a/clippy_lints/src/redundant_slicing.rs b/clippy_lints/src/redundant_slicing.rs index 0c460150087..b2bd0103d11 100644 --- a/clippy_lints/src/redundant_slicing.rs +++ b/clippy_lints/src/redundant_slicing.rs @@ -34,6 +34,7 @@ declare_clippy_lint! { /// x /// } /// ``` + #[clippy::version = "1.51.0"] pub REDUNDANT_SLICING, complexity, "redundant slicing of the whole range of a type" diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index d5a1a61da6b..ea5064217ab 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -27,6 +27,7 @@ declare_clippy_lint! { /// const FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...] /// static FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...] /// ``` + #[clippy::version = "1.37.0"] pub REDUNDANT_STATIC_LIFETIMES, style, "Using explicit `'static` lifetime for constants or statics when elision rules would allow omitting them." diff --git a/clippy_lints/src/ref_option_ref.rs b/clippy_lints/src/ref_option_ref.rs index d543832e314..909d6971a54 100644 --- a/clippy_lints/src/ref_option_ref.rs +++ b/clippy_lints/src/ref_option_ref.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// ```rust,ignore /// let x: Option<&u32> = Some(&0u32); /// ``` + #[clippy::version = "1.49.0"] pub REF_OPTION_REF, pedantic, "use `Option<&T>` instead of `&Option<&T>`" diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs index 70dff5ad313..22ae7a291d0 100644 --- a/clippy_lints/src/reference.rs +++ b/clippy_lints/src/reference.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// let a = f(b); /// let c = d; /// ``` + #[clippy::version = "pre 1.29.0"] pub DEREF_ADDROF, complexity, "use of `*&` or `*&mut` in an expression" @@ -124,6 +125,7 @@ declare_clippy_lint! { /// # let point = Point(30, 20); /// let x = point.0; /// ``` + #[clippy::version = "pre 1.29.0"] pub REF_IN_DEREF, complexity, "Use of reference in auto dereference expression." diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 5d08aee1e5f..8e5983b4773 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -22,6 +22,7 @@ declare_clippy_lint! { /// ```ignore /// Regex::new("|") /// ``` + #[clippy::version = "pre 1.29.0"] pub INVALID_REGEX, correctness, "invalid regular expressions" @@ -46,6 +47,7 @@ declare_clippy_lint! { /// ```ignore /// Regex::new("^foobar") /// ``` + #[clippy::version = "pre 1.29.0"] pub TRIVIAL_REGEX, nursery, "trivial regular expressions" diff --git a/clippy_lints/src/repeat_once.rs b/clippy_lints/src/repeat_once.rs index e5e55ee7505..b5dd2de6337 100644 --- a/clippy_lints/src/repeat_once.rs +++ b/clippy_lints/src/repeat_once.rs @@ -35,6 +35,7 @@ declare_clippy_lint! { /// let x = String::from("hello world").clone(); /// } /// ``` + #[clippy::version = "1.47.0"] pub REPEAT_ONCE, complexity, "using `.repeat(1)` instead of `String.clone()`, `str.to_string()` or `slice.to_vec()` " diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index e2b1a33746e..494bc7dda18 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -37,6 +37,7 @@ declare_clippy_lint! { /// String::new() /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub LET_AND_RETURN, style, "creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block" @@ -62,6 +63,7 @@ declare_clippy_lint! { /// x /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub NEEDLESS_RETURN, style, "using a return statement like `return expr;` where an expression would suffice" diff --git a/clippy_lints/src/same_name_method.rs b/clippy_lints/src/same_name_method.rs index 737ff634e44..3f38d12fb55 100644 --- a/clippy_lints/src/same_name_method.rs +++ b/clippy_lints/src/same_name_method.rs @@ -33,6 +33,7 @@ declare_clippy_lint! { /// fn foo(&self) {} /// } /// ``` + #[clippy::version = "1.57.0"] pub SAME_NAME_METHOD, restriction, "two method with same name" diff --git a/clippy_lints/src/self_assignment.rs b/clippy_lints/src/self_assignment.rs index fbd65fef7d1..b14f0518bdb 100644 --- a/clippy_lints/src/self_assignment.rs +++ b/clippy_lints/src/self_assignment.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// a.y = a.y; /// } /// ``` + #[clippy::version = "1.48.0"] pub SELF_ASSIGNMENT, correctness, "explicit self-assignment" diff --git a/clippy_lints/src/self_named_constructors.rs b/clippy_lints/src/self_named_constructors.rs index 4ba5e1a0f53..dd73dbfe09e 100644 --- a/clippy_lints/src/self_named_constructors.rs +++ b/clippy_lints/src/self_named_constructors.rs @@ -32,6 +32,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.55.0"] pub SELF_NAMED_CONSTRUCTORS, style, "method should not have the same name as the type it is implemented for" diff --git a/clippy_lints/src/semicolon_if_nothing_returned.rs b/clippy_lints/src/semicolon_if_nothing_returned.rs index d3b4929a189..0b3bbbc8155 100644 --- a/clippy_lints/src/semicolon_if_nothing_returned.rs +++ b/clippy_lints/src/semicolon_if_nothing_returned.rs @@ -29,6 +29,7 @@ declare_clippy_lint! { /// println!("Hello world"); /// } /// ``` + #[clippy::version = "1.52.0"] pub SEMICOLON_IF_NOTHING_RETURNED, pedantic, "add a semicolon if nothing is returned" diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs index 2cd0f85999c..a38b3c4ab69 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -15,6 +15,7 @@ declare_clippy_lint! { /// ### Example /// Implementing `Visitor::visit_string` but not /// `Visitor::visit_str`. + #[clippy::version = "pre 1.29.0"] pub SERDE_API_MISUSE, correctness, "various things that will negatively affect your serde experience" diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 64841f33cc3..5f82aed872c 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -29,6 +29,7 @@ declare_clippy_lint! { /// // Good /// let y = &x; // use different variable name /// ``` + #[clippy::version = "pre 1.29.0"] pub SHADOW_SAME, restriction, "rebinding a name to itself, e.g., `let mut x = &mut x`" @@ -55,6 +56,7 @@ declare_clippy_lint! { /// let x = 2; /// let y = x + 1; /// ``` + #[clippy::version = "pre 1.29.0"] pub SHADOW_REUSE, restriction, "rebinding a name to an expression that re-uses the original value, e.g., `let x = x + 1`" @@ -84,6 +86,7 @@ declare_clippy_lint! { /// // Good /// let w = z; // use different variable name /// ``` + #[clippy::version = "pre 1.29.0"] pub SHADOW_UNRELATED, restriction, "rebinding a name without even using the original value" diff --git a/clippy_lints/src/single_component_path_imports.rs b/clippy_lints/src/single_component_path_imports.rs index 87aa02b6585..28d32203da9 100644 --- a/clippy_lints/src/single_component_path_imports.rs +++ b/clippy_lints/src/single_component_path_imports.rs @@ -27,6 +27,7 @@ declare_clippy_lint! { /// regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap(); /// } /// ``` + #[clippy::version = "1.43.0"] pub SINGLE_COMPONENT_PATH_IMPORTS, style, "imports with single component path are redundant" diff --git a/clippy_lints/src/size_of_in_element_count.rs b/clippy_lints/src/size_of_in_element_count.rs index 3e4e4a8d0c0..df1e85afdd7 100644 --- a/clippy_lints/src/size_of_in_element_count.rs +++ b/clippy_lints/src/size_of_in_element_count.rs @@ -29,6 +29,7 @@ declare_clippy_lint! { /// let mut y = [2u8; SIZE]; /// unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::() * SIZE) }; /// ``` + #[clippy::version = "1.50.0"] pub SIZE_OF_IN_ELEMENT_COUNT, correctness, "using `size_of::` or `size_of_val::` where a count of elements of `T` is expected" diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index 3608fe1472d..1ae772ef70b 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// let mut vec1 = vec![0; len]; /// let mut vec2 = vec![0; len]; /// ``` + #[clippy::version = "1.32.0"] pub SLOW_VECTOR_INITIALIZATION, perf, "slow vector initialization" diff --git a/clippy_lints/src/stable_sort_primitive.rs b/clippy_lints/src/stable_sort_primitive.rs index 4ea1293d504..953d21e07a3 100644 --- a/clippy_lints/src/stable_sort_primitive.rs +++ b/clippy_lints/src/stable_sort_primitive.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// let mut vec = vec![2, 1, 3]; /// vec.sort_unstable(); /// ``` + #[clippy::version = "1.47.0"] pub STABLE_SORT_PRIMITIVE, perf, "use of sort() when sort_unstable() is equivalent" diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 6435107b8b4..368274440d5 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -31,6 +31,7 @@ declare_clippy_lint! { /// x += ", World"; /// x.push_str(", World"); /// ``` + #[clippy::version = "pre 1.29.0"] pub STRING_ADD_ASSIGN, pedantic, "using `x = x + ..` where x is a `String` instead of `push_str()`" @@ -58,6 +59,7 @@ declare_clippy_lint! { /// let x = "Hello".to_owned(); /// x + ", World"; /// ``` + #[clippy::version = "pre 1.29.0"] pub STRING_ADD, restriction, "using `x + ..` where x is a `String` instead of `push_str()`" @@ -102,6 +104,7 @@ declare_clippy_lint! { /// // Good /// let bs = b"a byte string"; /// ``` + #[clippy::version = "pre 1.29.0"] pub STRING_LIT_AS_BYTES, nursery, "calling `as_bytes` on a string literal instead of using a byte string literal" @@ -125,6 +128,7 @@ declare_clippy_lint! { /// ```rust,should_panic /// &"Ölkanne"[1..]; /// ``` + #[clippy::version = "1.58.0"] pub STRING_SLICE, restriction, "slicing a string" @@ -227,6 +231,7 @@ declare_clippy_lint! { /// ```rust /// let _ = &"Hello World!"[6..11]; /// ``` + #[clippy::version = "1.50.0"] pub STRING_FROM_UTF8_AS_BYTES, complexity, "casting string slices to byte slices and back" @@ -371,6 +376,7 @@ declare_clippy_lint! { /// // example code which does not raise clippy warning /// let _ = "str".to_owned(); /// ``` + #[clippy::version = "pre 1.29.0"] pub STR_TO_STRING, restriction, "using `to_string()` on a `&str`, which should be `to_owned()`" @@ -420,6 +426,7 @@ declare_clippy_lint! { /// let msg = String::from("Hello World"); /// let _ = msg.clone(); /// ``` + #[clippy::version = "pre 1.29.0"] pub STRING_TO_STRING, restriction, "using `to_string()` on a `String`, which should be `clone()`" diff --git a/clippy_lints/src/strlen_on_c_strings.rs b/clippy_lints/src/strlen_on_c_strings.rs index 8bf40ec5312..be7431f11aa 100644 --- a/clippy_lints/src/strlen_on_c_strings.rs +++ b/clippy_lints/src/strlen_on_c_strings.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// let cstring = CString::new("foo").expect("CString::new failed"); /// let len = cstring.as_bytes().len(); /// ``` + #[clippy::version = "1.55.0"] pub STRLEN_ON_C_STRINGS, complexity, "using `libc::strlen` on a `CString` or `CStr` value, while `as_bytes().len()` or `to_bytes().len()` respectively can be used instead" diff --git a/clippy_lints/src/suspicious_operation_groupings.rs b/clippy_lints/src/suspicious_operation_groupings.rs index 201aa067824..faf43fd9fc1 100644 --- a/clippy_lints/src/suspicious_operation_groupings.rs +++ b/clippy_lints/src/suspicious_operation_groupings.rs @@ -59,6 +59,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.50.0"] pub SUSPICIOUS_OPERATION_GROUPINGS, nursery, "groupings of binary operations that look suspiciously like typos" diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index 682fad00a13..a3195de81d1 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -25,6 +25,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub SUSPICIOUS_ARITHMETIC_IMPL, suspicious, "suspicious use of operators in impl of arithmetic trait" @@ -46,6 +47,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub SUSPICIOUS_OP_ASSIGN_IMPL, suspicious, "suspicious use of operators in impl of OpAssign trait" diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index ef26de5b6b9..a8c7ca4c916 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -35,6 +35,7 @@ declare_clippy_lint! { /// let mut b = 2; /// std::mem::swap(&mut a, &mut b); /// ``` + #[clippy::version = "pre 1.29.0"] pub MANUAL_SWAP, complexity, "manual swap of two variables" @@ -60,6 +61,7 @@ declare_clippy_lint! { /// # let mut b = 2; /// std::mem::swap(&mut a, &mut b); /// ``` + #[clippy::version = "pre 1.29.0"] pub ALMOST_SWAPPED, correctness, "`foo = bar; bar = foo` sequence" diff --git a/clippy_lints/src/tabs_in_doc_comments.rs b/clippy_lints/src/tabs_in_doc_comments.rs index 4a67cabf323..c9b4b245f4c 100644 --- a/clippy_lints/src/tabs_in_doc_comments.rs +++ b/clippy_lints/src/tabs_in_doc_comments.rs @@ -51,6 +51,7 @@ declare_clippy_lint! { /// second_string: String, ///} /// ``` + #[clippy::version = "1.41.0"] pub TABS_IN_DOC_COMMENTS, style, "using tabs in doc comments is not recommended" diff --git a/clippy_lints/src/temporary_assignment.rs b/clippy_lints/src/temporary_assignment.rs index a9da690339c..3766b8f8ed1 100644 --- a/clippy_lints/src/temporary_assignment.rs +++ b/clippy_lints/src/temporary_assignment.rs @@ -17,6 +17,7 @@ declare_clippy_lint! { /// ```rust /// (0, 0).0 = 1 /// ``` + #[clippy::version = "pre 1.29.0"] pub TEMPORARY_ASSIGNMENT, complexity, "assignments to temporaries" diff --git a/clippy_lints/src/to_digit_is_some.rs b/clippy_lints/src/to_digit_is_some.rs index 1c14a919995..5eb58b47838 100644 --- a/clippy_lints/src/to_digit_is_some.rs +++ b/clippy_lints/src/to_digit_is_some.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// # let radix = 10; /// let is_digit = c.is_digit(radix); /// ``` + #[clippy::version = "1.41.0"] pub TO_DIGIT_IS_SOME, style, "`char.is_digit()` is clearer" diff --git a/clippy_lints/src/to_string_in_display.rs b/clippy_lints/src/to_string_in_display.rs index b7414cec87c..f8b6bdcd3e1 100644 --- a/clippy_lints/src/to_string_in_display.rs +++ b/clippy_lints/src/to_string_in_display.rs @@ -39,6 +39,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.48.0"] pub TO_STRING_IN_DISPLAY, correctness, "`to_string` method used while implementing `Display` trait" diff --git a/clippy_lints/src/trailing_empty_array.rs b/clippy_lints/src/trailing_empty_array.rs index c216a1f81ea..47c0a84cd46 100644 --- a/clippy_lints/src/trailing_empty_array.rs +++ b/clippy_lints/src/trailing_empty_array.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// last: [u32; 0], /// } /// ``` + #[clippy::version = "1.58.0"] pub TRAILING_EMPTY_ARRAY, nursery, "struct with a trailing zero-sized array but without `#[repr(C)]` or another `repr` attribute" diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index 73bdcae9e39..fb4abceac25 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// ```rust /// pub fn foo(t: T) where T: Copy + Clone {} /// ``` + #[clippy::version = "1.38.0"] pub TYPE_REPETITION_IN_BOUNDS, pedantic, "Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`" @@ -57,6 +58,7 @@ declare_clippy_lint! { /// ```rust /// fn func(arg: T) where T: Clone + Default {} /// ``` + #[clippy::version = "1.47.0"] pub TRAIT_DUPLICATION_IN_BOUNDS, pedantic, "Check if the same trait bounds are specified twice during a function declaration" diff --git a/clippy_lints/src/transmute/mod.rs b/clippy_lints/src/transmute/mod.rs index e6acf1a94c9..3ad4ec74bf5 100644 --- a/clippy_lints/src/transmute/mod.rs +++ b/clippy_lints/src/transmute/mod.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// ```ignore /// let ptr: *const T = core::intrinsics::transmute('x') /// ``` + #[clippy::version = "pre 1.29.0"] pub WRONG_TRANSMUTE, correctness, "transmutes that are confusing at best, undefined behaviour at worst and always useless" @@ -55,6 +56,7 @@ declare_clippy_lint! { /// ```rust,ignore /// core::intrinsics::transmute(t); // where the result type is the same as `t`'s /// ``` + #[clippy::version = "pre 1.29.0"] pub USELESS_TRANSMUTE, nursery, "transmutes that have the same to and from types or could be a cast/coercion" @@ -80,6 +82,7 @@ declare_clippy_lint! { /// # let p: *const [i32] = &[]; /// p as *const [u16]; /// ``` + #[clippy::version = "1.47.0"] pub TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS, complexity, "transmutes that could be a pointer cast" @@ -98,6 +101,7 @@ declare_clippy_lint! { /// core::intrinsics::transmute(t) // where the result type is the same as /// // `*t` or `&t`'s /// ``` + #[clippy::version = "pre 1.29.0"] pub CROSSPOINTER_TRANSMUTE, complexity, "transmutes that have to or from types that are a pointer to the other" @@ -125,6 +129,7 @@ declare_clippy_lint! { /// // can be written: /// let _: &T = &*p; /// ``` + #[clippy::version = "pre 1.29.0"] pub TRANSMUTE_PTR_TO_REF, complexity, "transmutes from a pointer to a reference type" @@ -158,6 +163,7 @@ declare_clippy_lint! { /// // should be: /// let _ = std::char::from_u32(x).unwrap(); /// ``` + #[clippy::version = "pre 1.29.0"] pub TRANSMUTE_INT_TO_CHAR, complexity, "transmutes from an integer to a `char`" @@ -191,6 +197,7 @@ declare_clippy_lint! { /// // should be: /// let _ = std::str::from_utf8(b).unwrap(); /// ``` + #[clippy::version = "pre 1.29.0"] pub TRANSMUTE_BYTES_TO_STR, complexity, "transmutes from a `&[u8]` to a `&str`" @@ -213,6 +220,7 @@ declare_clippy_lint! { /// // should be: /// let _: bool = x != 0; /// ``` + #[clippy::version = "pre 1.29.0"] pub TRANSMUTE_INT_TO_BOOL, complexity, "transmutes from an integer to a `bool`" @@ -235,6 +243,7 @@ declare_clippy_lint! { /// // should be: /// let _: f32 = f32::from_bits(1_u32); /// ``` + #[clippy::version = "pre 1.29.0"] pub TRANSMUTE_INT_TO_FLOAT, complexity, "transmutes from an integer to a float" @@ -257,6 +266,7 @@ declare_clippy_lint! { /// // should be: /// let _: u32 = 1f32.to_bits(); /// ``` + #[clippy::version = "1.41.0"] pub TRANSMUTE_FLOAT_TO_INT, complexity, "transmutes from a float to an integer" @@ -279,6 +289,7 @@ declare_clippy_lint! { /// // should be /// let x: [u8; 8] = 0i64.to_ne_bytes(); /// ``` + #[clippy::version = "1.58.0"] pub TRANSMUTE_NUM_TO_BYTES, complexity, "transmutes from a number to an array of `u8`" @@ -306,6 +317,7 @@ declare_clippy_lint! { /// let _ = ptr as *const f32; /// let _ = unsafe{ &*(&1u32 as *const u32 as *const f32) }; /// ``` + #[clippy::version = "pre 1.29.0"] pub TRANSMUTE_PTR_TO_PTR, pedantic, "transmutes from a pointer to a pointer / a reference to a reference" @@ -337,6 +349,7 @@ declare_clippy_lint! { /// ```rust /// vec![2_u16].into_iter().map(u32::from).collect::>(); /// ``` + #[clippy::version = "1.40.0"] pub UNSOUND_COLLECTION_TRANSMUTE, correctness, "transmute between collections of layout-incompatible types" diff --git a/clippy_lints/src/transmuting_null.rs b/clippy_lints/src/transmuting_null.rs index ef80663d1da..7939dfedc3a 100644 --- a/clippy_lints/src/transmuting_null.rs +++ b/clippy_lints/src/transmuting_null.rs @@ -25,6 +25,7 @@ declare_clippy_lint! { /// ```rust /// let null_ref: &u64 = unsafe { std::mem::transmute(0 as *const u64) }; /// ``` + #[clippy::version = "1.35.0"] pub TRANSMUTING_NULL, correctness, "transmutes from a null pointer to a reference, which is undefined behavior" diff --git a/clippy_lints/src/try_err.rs b/clippy_lints/src/try_err.rs index cc450b1e599..e0e7ec9a452 100644 --- a/clippy_lints/src/try_err.rs +++ b/clippy_lints/src/try_err.rs @@ -41,6 +41,7 @@ declare_clippy_lint! { /// Ok(0) /// } /// ``` + #[clippy::version = "1.38.0"] pub TRY_ERR, style, "return errors explicitly rather than hiding them behind a `?`" diff --git a/clippy_lints/src/types/mod.rs b/clippy_lints/src/types/mod.rs index bbe07db5358..5a7ef760a30 100644 --- a/clippy_lints/src/types/mod.rs +++ b/clippy_lints/src/types/mod.rs @@ -43,6 +43,7 @@ declare_clippy_lint! { /// values: Vec, /// } /// ``` + #[clippy::version = "1.57.0"] pub BOX_COLLECTION, perf, "usage of `Box>`, vector elements are already on the heap" @@ -75,6 +76,7 @@ declare_clippy_lint! { /// values: Vec, /// } /// ``` + #[clippy::version = "1.33.0"] pub VEC_BOX, complexity, "usage of `Vec>` where T: Sized, vector elements are already on the heap" @@ -113,6 +115,7 @@ declare_clippy_lint! { /// Contents::None /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub OPTION_OPTION, pedantic, "usage of `Option>`" @@ -152,6 +155,7 @@ declare_clippy_lint! { /// # use std::collections::LinkedList; /// let x: LinkedList = LinkedList::new(); /// ``` + #[clippy::version = "pre 1.29.0"] pub LINKEDLIST, pedantic, "usage of LinkedList, usually a vector is faster, or a more specialized data structure like a `VecDeque`" @@ -176,6 +180,7 @@ declare_clippy_lint! { /// ```rust,ignore /// fn foo(bar: &T) { ... } /// ``` + #[clippy::version = "pre 1.29.0"] pub BORROWED_BOX, complexity, "a borrow of a boxed type" @@ -200,6 +205,7 @@ declare_clippy_lint! { /// ```rust /// fn foo(bar: &usize) {} /// ``` + #[clippy::version = "1.44.0"] pub REDUNDANT_ALLOCATION, perf, "redundant allocation" @@ -234,6 +240,7 @@ declare_clippy_lint! { /// ```rust,ignore /// fn foo(interned: Rc) { ... } /// ``` + #[clippy::version = "1.48.0"] pub RC_BUFFER, restriction, "shared ownership of a buffer type" @@ -255,6 +262,7 @@ declare_clippy_lint! { /// inner: Rc>>>, /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub TYPE_COMPLEXITY, complexity, "usage of very complex types that might be better factored into `type` definitions" @@ -287,6 +295,7 @@ declare_clippy_lint! { /// use std::cell::RefCell /// fn foo(interned: Rc>) { ... } /// ``` + #[clippy::version = "1.55.0"] pub RC_MUTEX, restriction, "usage of `Rc>`" diff --git a/clippy_lints/src/undocumented_unsafe_blocks.rs b/clippy_lints/src/undocumented_unsafe_blocks.rs index fbf66712261..c886faf5d28 100644 --- a/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -39,6 +39,7 @@ declare_clippy_lint! { /// // Safety: references are guaranteed to be non-null. /// let ptr = unsafe { NonNull::new_unchecked(a) }; /// ``` + #[clippy::version = "1.58.0"] pub UNDOCUMENTED_UNSAFE_BLOCKS, restriction, "creating an unsafe block without explaining why it is safe" diff --git a/clippy_lints/src/undropped_manually_drops.rs b/clippy_lints/src/undropped_manually_drops.rs index 09570616593..c58fa67a023 100644 --- a/clippy_lints/src/undropped_manually_drops.rs +++ b/clippy_lints/src/undropped_manually_drops.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// std::mem::ManuallyDrop::drop(&mut std::mem::ManuallyDrop::new(S)); /// } /// ``` + #[clippy::version = "1.49.0"] pub UNDROPPED_MANUALLY_DROPS, correctness, "use of safe `std::mem::drop` function to drop a std::mem::ManuallyDrop, which will not drop the inner value" diff --git a/clippy_lints/src/unicode.rs b/clippy_lints/src/unicode.rs index f49ce696a04..a514e8c44e2 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -20,6 +20,7 @@ declare_clippy_lint! { /// ### Example /// You don't see it, but there may be a zero-width space or soft hyphen /// some­where in this text. + #[clippy::version = "1.49.0"] pub INVISIBLE_CHARACTERS, correctness, "using an invisible character in a string literal, which is confusing" @@ -44,6 +45,7 @@ declare_clippy_lint! { /// ```rust /// let x = String::from("\u{20ac}"); /// ``` + #[clippy::version = "pre 1.29.0"] pub NON_ASCII_LITERAL, restriction, "using any literal non-ASCII chars in a string literal instead of using the `\\u` escape" @@ -62,6 +64,7 @@ declare_clippy_lint! { /// ### Example /// You may not see it, but "à"" and "à"" aren't the same string. The /// former when escaped is actually `"a\u{300}"` while the latter is `"\u{e0}"`. + #[clippy::version = "pre 1.29.0"] pub UNICODE_NOT_NFC, pedantic, "using a Unicode literal not in NFC normal form (see [Unicode tr15](http://www.unicode.org/reports/tr15/) for further information)" diff --git a/clippy_lints/src/uninit_vec.rs b/clippy_lints/src/uninit_vec.rs index f3e8b688105..46cc76b150e 100644 --- a/clippy_lints/src/uninit_vec.rs +++ b/clippy_lints/src/uninit_vec.rs @@ -52,6 +52,7 @@ declare_clippy_lint! { /// // perform initialization with `remaining` /// vec.set_len(...); // Safe to call `set_len()` on initialized part /// ``` + #[clippy::version = "1.58.0"] pub UNINIT_VEC, correctness, "Vec with uninitialized data" diff --git a/clippy_lints/src/unit_hash.rs b/clippy_lints/src/unit_hash.rs index a3a3f2d41c7..26b4e0f58a8 100644 --- a/clippy_lints/src/unit_hash.rs +++ b/clippy_lints/src/unit_hash.rs @@ -39,6 +39,7 @@ declare_clippy_lint! { /// WithValue(x) => x.hash(&mut state), /// } /// ``` + #[clippy::version = "1.58.0"] pub UNIT_HASH, correctness, "hashing a unit value, which does nothing" diff --git a/clippy_lints/src/unit_return_expecting_ord.rs b/clippy_lints/src/unit_return_expecting_ord.rs index db0f412f2a1..9fb8f236899 100644 --- a/clippy_lints/src/unit_return_expecting_ord.rs +++ b/clippy_lints/src/unit_return_expecting_ord.rs @@ -30,6 +30,7 @@ declare_clippy_lint! { /// let mut twins = vec!((1, 1), (2, 2)); /// twins.sort_by_key(|x| { x.1; }); /// ``` + #[clippy::version = "1.47.0"] pub UNIT_RETURN_EXPECTING_ORD, correctness, "fn arguments of type Fn(...) -> Ord returning the unit type ()." diff --git a/clippy_lints/src/unit_types/mod.rs b/clippy_lints/src/unit_types/mod.rs index 66b1abbe50b..d9f5b53b413 100644 --- a/clippy_lints/src/unit_types/mod.rs +++ b/clippy_lints/src/unit_types/mod.rs @@ -21,6 +21,7 @@ declare_clippy_lint! { /// 1; /// }; /// ``` + #[clippy::version = "pre 1.29.0"] pub LET_UNIT_VALUE, pedantic, "creating a `let` binding to a value of unit type, which usually can't be used afterwards" @@ -68,6 +69,7 @@ declare_clippy_lint! { /// assert_eq!({ foo(); }, { bar(); }); /// ``` /// will always succeed + #[clippy::version = "pre 1.29.0"] pub UNIT_CMP, correctness, "comparing unit values" @@ -88,6 +90,7 @@ declare_clippy_lint! { /// baz(a); /// }) /// ``` + #[clippy::version = "pre 1.29.0"] pub UNIT_ARG, complexity, "passing unit to a function" diff --git a/clippy_lints/src/unnamed_address.rs b/clippy_lints/src/unnamed_address.rs index 1eafdee0352..0bcafde658a 100644 --- a/clippy_lints/src/unnamed_address.rs +++ b/clippy_lints/src/unnamed_address.rs @@ -24,6 +24,7 @@ declare_clippy_lint! { /// // ... /// } /// ``` + #[clippy::version = "1.44.0"] pub FN_ADDRESS_COMPARISONS, correctness, "comparison with an address of a function item" @@ -47,6 +48,7 @@ declare_clippy_lint! { /// ... /// } /// ``` + #[clippy::version = "1.44.0"] pub VTABLE_ADDRESS_COMPARISONS, correctness, "comparison with an address of a trait vtable" diff --git a/clippy_lints/src/unnecessary_self_imports.rs b/clippy_lints/src/unnecessary_self_imports.rs index 4cfd2df551f..839a4bdab09 100644 --- a/clippy_lints/src/unnecessary_self_imports.rs +++ b/clippy_lints/src/unnecessary_self_imports.rs @@ -26,6 +26,7 @@ declare_clippy_lint! { /// ```rust /// use std::io; /// ``` + #[clippy::version = "1.53.0"] pub UNNECESSARY_SELF_IMPORTS, restriction, "imports ending in `::{self}`, which can be omitted" diff --git a/clippy_lints/src/unnecessary_sort_by.rs b/clippy_lints/src/unnecessary_sort_by.rs index 26b56e0f2f3..d024577f485 100644 --- a/clippy_lints/src/unnecessary_sort_by.rs +++ b/clippy_lints/src/unnecessary_sort_by.rs @@ -39,6 +39,7 @@ declare_clippy_lint! { /// # let mut vec: Vec = Vec::new(); /// vec.sort_by_key(|a| a.foo()); /// ``` + #[clippy::version = "1.46.0"] pub UNNECESSARY_SORT_BY, complexity, "Use of `Vec::sort_by` when `Vec::sort_by_key` or `Vec::sort` would be clearer" diff --git a/clippy_lints/src/unnecessary_wraps.rs b/clippy_lints/src/unnecessary_wraps.rs index fcfa8403177..1728533f18b 100644 --- a/clippy_lints/src/unnecessary_wraps.rs +++ b/clippy_lints/src/unnecessary_wraps.rs @@ -49,6 +49,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "1.50.0"] pub UNNECESSARY_WRAPS, pedantic, "functions that only return `Ok` or `Some`" diff --git a/clippy_lints/src/unnested_or_patterns.rs b/clippy_lints/src/unnested_or_patterns.rs index d6cf7190abb..0bd151fed91 100644 --- a/clippy_lints/src/unnested_or_patterns.rs +++ b/clippy_lints/src/unnested_or_patterns.rs @@ -39,6 +39,7 @@ declare_clippy_lint! { /// if let Some(0 | 2) = Some(0) {} /// } /// ``` + #[clippy::version = "1.46.0"] pub UNNESTED_OR_PATTERNS, pedantic, "unnested or-patterns, e.g., `Foo(Bar) | Foo(Baz) instead of `Foo(Bar | Baz)`" diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index 3c694af2b9d..44b1989dbc6 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -21,6 +21,7 @@ declare_clippy_lint! { /// extern crate crossbeam; /// use crossbeam::{spawn_unsafe as spawn}; /// ``` + #[clippy::version = "pre 1.29.0"] pub UNSAFE_REMOVED_FROM_NAME, style, "`unsafe` removed from API names on import" diff --git a/clippy_lints/src/unused_async.rs b/clippy_lints/src/unused_async.rs index f4808682b69..1ccb78425c2 100644 --- a/clippy_lints/src/unused_async.rs +++ b/clippy_lints/src/unused_async.rs @@ -29,6 +29,7 @@ declare_clippy_lint! { /// } /// let number_future = async { get_random_number_improved() }; /// ``` + #[clippy::version = "1.54.0"] pub UNUSED_ASYNC, pedantic, "finds async functions with no await statements" diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index 031b182bd2f..d4b5c9770a2 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -29,6 +29,7 @@ declare_clippy_lint! { /// Ok(()) /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub UNUSED_IO_AMOUNT, correctness, "unused written/read amount" diff --git a/clippy_lints/src/unused_self.rs b/clippy_lints/src/unused_self.rs index e7e249c79a2..fd9d5b52e50 100644 --- a/clippy_lints/src/unused_self.rs +++ b/clippy_lints/src/unused_self.rs @@ -29,6 +29,7 @@ declare_clippy_lint! { /// fn method() {} /// } /// ``` + #[clippy::version = "1.40.0"] pub UNUSED_SELF, pedantic, "methods that contain a `self` argument but don't use it" diff --git a/clippy_lints/src/unused_unit.rs b/clippy_lints/src/unused_unit.rs index 1164ac4938f..48c17fa2a40 100644 --- a/clippy_lints/src/unused_unit.rs +++ b/clippy_lints/src/unused_unit.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// ```rust /// fn return_unit() {} /// ``` + #[clippy::version = "1.31.0"] pub UNUSED_UNIT, style, "needless unit expression" diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index ebaa9dcbbf8..9e83cae79bc 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -39,6 +39,7 @@ declare_clippy_lint! { /// do_something_with(value) /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub UNNECESSARY_UNWRAP, complexity, "checks for calls of `unwrap[_err]()` that cannot fail" @@ -65,6 +66,7 @@ declare_clippy_lint! { /// ``` /// /// This code will always panic. The if condition should probably be inverted. + #[clippy::version = "pre 1.29.0"] pub PANICKING_UNWRAP, correctness, "checks for calls of `unwrap[_err]()` that will always fail" diff --git a/clippy_lints/src/unwrap_in_result.rs b/clippy_lints/src/unwrap_in_result.rs index 6447e3fa2ca..994df85cb8a 100644 --- a/clippy_lints/src/unwrap_in_result.rs +++ b/clippy_lints/src/unwrap_in_result.rs @@ -51,6 +51,7 @@ declare_clippy_lint! { /// Ok(()) /// } /// ``` + #[clippy::version = "1.48.0"] pub UNWRAP_IN_RESULT, restriction, "functions of type `Result<..>` or `Option`<...> that contain `expect()` or `unwrap()`" diff --git a/clippy_lints/src/upper_case_acronyms.rs b/clippy_lints/src/upper_case_acronyms.rs index dbf335a70c8..4773e350760 100644 --- a/clippy_lints/src/upper_case_acronyms.rs +++ b/clippy_lints/src/upper_case_acronyms.rs @@ -33,6 +33,7 @@ declare_clippy_lint! { /// ```rust /// struct HttpResponse; /// ``` + #[clippy::version = "1.51.0"] pub UPPER_CASE_ACRONYMS, style, "capitalized acronyms are against the naming convention" diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index 09aad296f03..059f7f647f8 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -51,6 +51,7 @@ declare_clippy_lint! { /// } /// } /// ``` + #[clippy::version = "pre 1.29.0"] pub USE_SELF, nursery, "unnecessary structure name repetition whereas `Self` is applicable" diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index 88f11542072..0e4b32541c9 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -28,6 +28,7 @@ declare_clippy_lint! { /// // Good /// let s: String = format!("hello"); /// ``` + #[clippy::version = "1.45.0"] pub USELESS_CONVERSION, complexity, "calls to `Into`, `TryInto`, `From`, `TryFrom`, or `IntoIter` which perform useless conversions to the same type" diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index d3234b5758a..79e7410c3a8 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// // Good /// foo(&[1, 2]); /// ``` + #[clippy::version = "pre 1.29.0"] pub USELESS_VEC, perf, "useless `vec!`" diff --git a/clippy_lints/src/vec_init_then_push.rs b/clippy_lints/src/vec_init_then_push.rs index b92b6ca4f43..1bc0eb6303c 100644 --- a/clippy_lints/src/vec_init_then_push.rs +++ b/clippy_lints/src/vec_init_then_push.rs @@ -27,6 +27,7 @@ declare_clippy_lint! { /// ```rust /// let v = vec![0]; /// ``` + #[clippy::version = "1.51.0"] pub VEC_INIT_THEN_PUSH, perf, "`push` immediately after `Vec` creation" diff --git a/clippy_lints/src/vec_resize_to_zero.rs b/clippy_lints/src/vec_resize_to_zero.rs index 5c0429db6b8..3441d9ccdfa 100644 --- a/clippy_lints/src/vec_resize_to_zero.rs +++ b/clippy_lints/src/vec_resize_to_zero.rs @@ -20,6 +20,7 @@ declare_clippy_lint! { /// ```rust /// vec!(1, 2, 3, 4, 5).resize(0, 5) /// ``` + #[clippy::version = "1.46.0"] pub VEC_RESIZE_TO_ZERO, correctness, "emptying a vector with `resize(0, an_int)` instead of `clear()` is probably an argument inversion mistake" diff --git a/clippy_lints/src/verbose_file_reads.rs b/clippy_lints/src/verbose_file_reads.rs index e07c12f4f16..ebdaff1e676 100644 --- a/clippy_lints/src/verbose_file_reads.rs +++ b/clippy_lints/src/verbose_file_reads.rs @@ -27,6 +27,7 @@ declare_clippy_lint! { /// # use std::fs; /// let mut bytes = fs::read("foo.txt").unwrap(); /// ``` + #[clippy::version = "1.44.0"] pub VERBOSE_FILE_READS, restriction, "use of `File::read_to_end` or `File::read_to_string`" diff --git a/clippy_lints/src/wildcard_dependencies.rs b/clippy_lints/src/wildcard_dependencies.rs index d0c98b6bd79..80d7b8a1b6d 100644 --- a/clippy_lints/src/wildcard_dependencies.rs +++ b/clippy_lints/src/wildcard_dependencies.rs @@ -20,6 +20,7 @@ declare_clippy_lint! { /// [dependencies] /// regex = "*" /// ``` + #[clippy::version = "1.32.0"] pub WILDCARD_DEPENDENCIES, cargo, "wildcard dependencies being used" diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index 2f3e525fdcf..832da66a536 100644 --- a/clippy_lints/src/wildcard_imports.rs +++ b/clippy_lints/src/wildcard_imports.rs @@ -34,6 +34,7 @@ declare_clippy_lint! { /// use std::cmp::Ordering; /// foo(Ordering::Less) /// ``` + #[clippy::version = "pre 1.29.0"] pub ENUM_GLOB_USE, pedantic, "use items that import all variants of an enum" @@ -86,6 +87,7 @@ declare_clippy_lint! { /// /// foo(); /// ``` + #[clippy::version = "1.43.0"] pub WILDCARD_IMPORTS, pedantic, "lint `use _::*` statements" diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 85d1f65c51f..1b3c15fdf23 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -31,6 +31,7 @@ declare_clippy_lint! { /// // Good /// println!(); /// ``` + #[clippy::version = "pre 1.29.0"] pub PRINTLN_EMPTY_STRING, style, "using `println!(\"\")` with an empty string" @@ -55,6 +56,7 @@ declare_clippy_lint! { /// # let name = "World"; /// println!("Hello {}!", name); /// ``` + #[clippy::version = "pre 1.29.0"] pub PRINT_WITH_NEWLINE, style, "using `print!()` with a format string that ends in a single newline" @@ -76,6 +78,7 @@ declare_clippy_lint! { /// ```rust /// println!("Hello world!"); /// ``` + #[clippy::version = "pre 1.29.0"] pub PRINT_STDOUT, restriction, "printing on stdout" @@ -97,6 +100,7 @@ declare_clippy_lint! { /// ```rust /// eprintln!("Hello world!"); /// ``` + #[clippy::version = "1.50.0"] pub PRINT_STDERR, restriction, "printing on stderr" @@ -116,6 +120,7 @@ declare_clippy_lint! { /// # let foo = "bar"; /// println!("{:?}", foo); /// ``` + #[clippy::version = "pre 1.29.0"] pub USE_DEBUG, restriction, "use of `Debug`-based formatting" @@ -142,6 +147,7 @@ declare_clippy_lint! { /// ```rust /// println!("foo"); /// ``` + #[clippy::version = "pre 1.29.0"] pub PRINT_LITERAL, style, "printing a literal with a format string" @@ -165,6 +171,7 @@ declare_clippy_lint! { /// // Good /// writeln!(buf); /// ``` + #[clippy::version = "pre 1.29.0"] pub WRITELN_EMPTY_STRING, style, "using `writeln!(buf, \"\")` with an empty string" @@ -191,6 +198,7 @@ declare_clippy_lint! { /// // Good /// writeln!(buf, "Hello {}!", name); /// ``` + #[clippy::version = "pre 1.29.0"] pub WRITE_WITH_NEWLINE, style, "using `write!()` with a format string that ends in a single newline" @@ -219,6 +227,7 @@ declare_clippy_lint! { /// // Good /// writeln!(buf, "foo"); /// ``` + #[clippy::version = "pre 1.29.0"] pub WRITE_LITERAL, style, "writing a literal with a format string" diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index e0746ce4d81..641681185a2 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -20,6 +20,7 @@ declare_clippy_lint! { /// // Good /// let nan = f32::NAN; /// ``` + #[clippy::version = "pre 1.29.0"] pub ZERO_DIVIDED_BY_ZERO, complexity, "usage of `0.0 / 0.0` to obtain NaN instead of `f32::NAN` or `f64::NAN`" diff --git a/clippy_lints/src/zero_sized_map_values.rs b/clippy_lints/src/zero_sized_map_values.rs index aa6b2614bbc..eb8436a501d 100644 --- a/clippy_lints/src/zero_sized_map_values.rs +++ b/clippy_lints/src/zero_sized_map_values.rs @@ -36,6 +36,7 @@ declare_clippy_lint! { /// todo!(); /// } /// ``` + #[clippy::version = "1.50.0"] pub ZERO_SIZED_MAP_VALUES, pedantic, "usage of map with zero-sized value type" -- cgit 1.4.1-3-g733a5 From 786f874c349b995ebed5e3d8f20db1cf65f20782 Mon Sep 17 00:00:00 2001 From: bors Date: Tue, 4 Jan 2022 22:32:02 +0000 Subject: New macro utils changelog: none Sorry, this is a big one. A lot of interrelated changes and I wanted to put the new utils to use to make sure they are somewhat battle-tested. We may want to divide some of the lint-specific refactoring commits into batches for smaller reviewing tasks. I could also split into more PRs. Introduces a bunch of new utils at `clippy_utils::macros::...`. Please read through the docs and give any feedback! I'm happy to introduce `MacroCall` and various functions to retrieve an instance. It feels like the missing puzzle piece. I'm also introducing `ExpnId` from rustc as "useful for Clippy too". `@rust-lang/clippy` Fixes #7843 by not parsing every node of macro implementations, at least the major offenders. I probably want to get rid of `is_expn_of` at some point. --- clippy_lints/src/assertions_on_constants.rs | 120 ++---- clippy_lints/src/attrs.rs | 18 +- clippy_lints/src/bool_assert_comparison.rs | 73 ++-- clippy_lints/src/doc.rs | 33 +- clippy_lints/src/eq_op.rs | 45 +-- clippy_lints/src/explicit_write.rs | 6 +- clippy_lints/src/fallible_impl_from.rs | 15 +- clippy_lints/src/format.rs | 33 +- clippy_lints/src/format_args.rs | 53 +-- clippy_lints/src/manual_assert.rs | 68 +--- clippy_lints/src/matches.rs | 24 +- clippy_lints/src/methods/expect_fun_call.rs | 21 +- clippy_lints/src/mutable_debug_assertion.rs | 42 +- clippy_lints/src/panic_in_result_fn.rs | 32 +- clippy_lints/src/panic_unimplemented.rs | 56 ++- clippy_lints/src/unit_types/unit_cmp.rs | 40 +- clippy_lints/src/utils/internal_lints.rs | 11 +- clippy_utils/Cargo.toml | 1 + clippy_utils/src/ast_utils.rs | 32 -- clippy_utils/src/higher.rs | 295 +------------- clippy_utils/src/lib.rs | 40 +- clippy_utils/src/macros.rs | 539 ++++++++++++++++++++++++++ clippy_utils/src/paths.rs | 5 - tests/ui/assertions_on_constants.rs | 1 - tests/ui/assertions_on_constants.stderr | 42 +- tests/ui/eq_op_macros.stderr | 44 +-- tests/ui/missing_panics_doc.stderr | 6 - tests/ui/panic_in_result_fn.stderr | 6 - tests/ui/panic_in_result_fn_assertions.stderr | 3 - tests/ui/panicking_macros.stderr | 21 - tests/ui/unit_cmp.stderr | 8 - 31 files changed, 868 insertions(+), 865 deletions(-) create mode 100644 clippy_utils/src/macros.rs (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index b7f414742f1..c82837746bd 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -1,12 +1,10 @@ use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::span_lint_and_help; -use clippy_utils::higher; -use clippy_utils::source::snippet_opt; -use clippy_utils::{is_direct_expn_of, is_expn_of, match_panic_call, peel_blocks}; -use if_chain::if_chain; -use rustc_hir::{Expr, ExprKind, UnOp}; +use clippy_utils::macros::{find_assert_args, root_macro_call_first_node, PanicExpn}; +use rustc_hir::Expr; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_span::sym; declare_clippy_lint! { /// ### What it does @@ -36,107 +34,39 @@ declare_lint_pass!(AssertionsOnConstants => [ASSERTIONS_ON_CONSTANTS]); impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants { fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { - let lint_true = |is_debug: bool| { - span_lint_and_help( - cx, - ASSERTIONS_ON_CONSTANTS, - e.span, - if is_debug { - "`debug_assert!(true)` will be optimized out by the compiler" - } else { - "`assert!(true)` will be optimized out by the compiler" - }, - None, - "remove it", - ); + let Some(macro_call) = root_macro_call_first_node(cx, e) else { return }; + let is_debug = match cx.tcx.get_diagnostic_name(macro_call.def_id) { + Some(sym::debug_assert_macro) => true, + Some(sym::assert_macro) => false, + _ => return, }; - let lint_false_without_message = || { + let Some((condition, panic_expn)) = find_assert_args(cx, e, macro_call.expn) else { return }; + let Some((Constant::Bool(val), _)) = constant(cx, cx.typeck_results(), condition) else { return }; + if val { span_lint_and_help( cx, ASSERTIONS_ON_CONSTANTS, - e.span, - "`assert!(false)` should probably be replaced", + macro_call.span, + &format!( + "`{}!(true)` will be optimized out by the compiler", + cx.tcx.item_name(macro_call.def_id) + ), None, - "use `panic!()` or `unreachable!()`", + "remove it", ); - }; - let lint_false_with_message = |panic_message: String| { + } else if !is_debug { + let (assert_arg, panic_arg) = match panic_expn { + PanicExpn::Empty => ("", ""), + _ => (", ..", ".."), + }; span_lint_and_help( cx, ASSERTIONS_ON_CONSTANTS, - e.span, - &format!("`assert!(false, {})` should probably be replaced", panic_message), + macro_call.span, + &format!("`assert!(false{})` should probably be replaced", assert_arg), None, - &format!("use `panic!({})` or `unreachable!({})`", panic_message, panic_message), + &format!("use `panic!({})` or `unreachable!({0})`", panic_arg), ); - }; - - if let Some(debug_assert_span) = is_expn_of(e.span, "debug_assert") { - if debug_assert_span.from_expansion() { - return; - } - if_chain! { - if let ExprKind::Unary(_, lit) = e.kind; - if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), lit); - if is_true; - then { - lint_true(true); - } - }; - } else if let Some(assert_span) = is_direct_expn_of(e.span, "assert") { - if assert_span.from_expansion() { - return; - } - if let Some(assert_match) = match_assert_with_message(cx, e) { - match assert_match { - // matched assert but not message - AssertKind::WithoutMessage(false) => lint_false_without_message(), - AssertKind::WithoutMessage(true) | AssertKind::WithMessage(_, true) => lint_true(false), - AssertKind::WithMessage(panic_message, false) => lint_false_with_message(panic_message), - }; - } - } - } -} - -/// Result of calling `match_assert_with_message`. -enum AssertKind { - WithMessage(String, bool), - WithoutMessage(bool), -} - -/// Check if the expression matches -/// -/// ```rust,ignore -/// if !c { -/// { -/// ::std::rt::begin_panic(message, _) -/// } -/// } -/// ``` -/// -/// where `message` is any expression and `c` is a constant bool. -fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option { - if_chain! { - if let Some(higher::If { cond, then, .. }) = higher::If::hir(expr); - if let ExprKind::Unary(UnOp::Not, expr) = cond.kind; - // bind the first argument of the `assert!` macro - if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), expr); - let begin_panic_call = peel_blocks(then); - // function call - if let Some(arg) = match_panic_call(cx, begin_panic_call); - // bind the second argument of the `assert!` macro if it exists - if let panic_message = snippet_opt(cx, arg.span); - // second argument of begin_panic is irrelevant - // as is the second match arm - then { - // an empty message occurs when it was generated by the macro - // (and not passed by the user) - return panic_message - .filter(|msg| !msg.is_empty()) - .map(|msg| AssertKind::WithMessage(msg, is_true)) - .or(Some(AssertKind::WithoutMessage(is_true))); } } - None } diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 0629674307b..a58d12ddd6b 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -1,9 +1,10 @@ //! checks for attributes use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; +use clippy_utils::macros::{is_panic, macro_backtrace}; use clippy_utils::msrvs; use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments}; -use clippy_utils::{extract_msrv_attr, match_panic_def_id, meets_msrv}; +use clippy_utils::{extract_msrv_attr, meets_msrv}; use if_chain::if_chain; use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem}; use rustc_errors::Applicability; @@ -443,20 +444,15 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_ } fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, expr: &Expr<'_>) -> bool { + if macro_backtrace(expr.span).last().map_or(false, |macro_call| { + is_panic(cx, macro_call.def_id) || cx.tcx.item_name(macro_call.def_id) == sym::unreachable + }) { + return false; + } match &expr.kind { ExprKind::Block(block, _) => is_relevant_block(cx, typeck_results, block), ExprKind::Ret(Some(e)) => is_relevant_expr(cx, typeck_results, e), ExprKind::Ret(None) | ExprKind::Break(_, None) => false, - ExprKind::Call(path_expr, _) => { - if let ExprKind::Path(qpath) = &path_expr.kind { - typeck_results - .qpath_res(qpath, path_expr.hir_id) - .opt_def_id() - .map_or(true, |fun_id| !match_panic_def_id(cx, fun_id)) - } else { - true - } - }, _ => true, } } diff --git a/clippy_lints/src/bool_assert_comparison.rs b/clippy_lints/src/bool_assert_comparison.rs index d0b8c52a36a..ea2cfb0bc08 100644 --- a/clippy_lints/src/bool_assert_comparison.rs +++ b/clippy_lints/src/bool_assert_comparison.rs @@ -1,4 +1,5 @@ -use clippy_utils::{diagnostics::span_lint_and_sugg, higher, is_direct_expn_of, ty::implements_trait}; +use clippy_utils::macros::{find_assert_eq_args, root_macro_call_first_node}; +use clippy_utils::{diagnostics::span_lint_and_sugg, ty::implements_trait}; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, Lit}; @@ -66,44 +67,40 @@ fn is_impl_not_trait_with_bool_out(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> impl<'tcx> LateLintPass<'tcx> for BoolAssertComparison { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { - let macros = ["assert_eq", "debug_assert_eq"]; - let inverted_macros = ["assert_ne", "debug_assert_ne"]; - - for mac in macros.iter().chain(inverted_macros.iter()) { - if let Some(span) = is_direct_expn_of(expr.span, mac) { - if let Some(args) = higher::extract_assert_macro_args(expr) { - if let [a, b, ..] = args[..] { - let nb_bool_args = usize::from(is_bool_lit(a)) + usize::from(is_bool_lit(b)); - - if nb_bool_args != 1 { - // If there are two boolean arguments, we definitely don't understand - // what's going on, so better leave things as is... - // - // Or there is simply no boolean and then we can leave things as is! - return; - } - - if !is_impl_not_trait_with_bool_out(cx, a) || !is_impl_not_trait_with_bool_out(cx, b) { - // At this point the expression which is not a boolean - // literal does not implement Not trait with a bool output, - // so we cannot suggest to rewrite our code - return; - } + let Some(macro_call) = root_macro_call_first_node(cx, expr) else { return }; + let macro_name = cx.tcx.item_name(macro_call.def_id); + if !matches!( + macro_name.as_str(), + "assert_eq" | "debug_assert_eq" | "assert_ne" | "debug_assert_ne" + ) { + return; + } + let Some ((a, b, _)) = find_assert_eq_args(cx, expr, macro_call.expn) else { return }; + if !(is_bool_lit(a) ^ is_bool_lit(b)) { + // If there are two boolean arguments, we definitely don't understand + // what's going on, so better leave things as is... + // + // Or there is simply no boolean and then we can leave things as is! + return; + } - let non_eq_mac = &mac[..mac.len() - 3]; - span_lint_and_sugg( - cx, - BOOL_ASSERT_COMPARISON, - span, - &format!("used `{}!` with a literal bool", mac), - "replace it with", - format!("{}!(..)", non_eq_mac), - Applicability::MaybeIncorrect, - ); - return; - } - } - } + if !is_impl_not_trait_with_bool_out(cx, a) || !is_impl_not_trait_with_bool_out(cx, b) { + // At this point the expression which is not a boolean + // literal does not implement Not trait with a bool output, + // so we cannot suggest to rewrite our code + return; } + + let macro_name = macro_name.as_str(); + let non_eq_mac = ¯o_name[..macro_name.len() - 3]; + span_lint_and_sugg( + cx, + BOOL_ASSERT_COMPARISON, + macro_call.span, + &format!("used `{}!` with a literal bool", macro_name), + "replace it with", + format!("{}!(..)", non_eq_mac), + Applicability::MaybeIncorrect, + ); } } diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 3650e4f91a0..9d4195e400d 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -1,8 +1,9 @@ use clippy_utils::attrs::is_doc_hidden; use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_note, span_lint_and_then}; +use clippy_utils::macros::{is_panic, root_macro_call_first_node}; use clippy_utils::source::{first_line_of_span, snippet_with_applicability}; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; -use clippy_utils::{is_entrypoint_fn, is_expn_of, match_panic_def_id, method_chain_args, return_ty}; +use clippy_utils::{is_entrypoint_fn, method_chain_args, return_ty}; use if_chain::if_chain; use itertools::Itertools; use rustc_ast::ast::{Async, AttrKind, Attribute, Fn, FnRetTy, ItemKind}; @@ -13,7 +14,7 @@ use rustc_errors::emitter::EmitterWriter; use rustc_errors::{Applicability, Handler, SuggestionStyle}; use rustc_hir as hir; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc_hir::{AnonConst, Expr, ExprKind, QPath}; +use rustc_hir::{AnonConst, Expr}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::map::Map; use rustc_middle::lint::in_external_macro; @@ -805,24 +806,17 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> { return; } - // check for `begin_panic` - if_chain! { - if let ExprKind::Call(func_expr, _) = expr.kind; - if let ExprKind::Path(QPath::Resolved(_, path)) = func_expr.kind; - if let Some(path_def_id) = path.res.opt_def_id(); - if match_panic_def_id(self.cx, path_def_id); - if is_expn_of(expr.span, "unreachable").is_none(); - if !is_expn_of_debug_assertions(expr.span); - then { - self.panic_span = Some(expr.span); + if let Some(macro_call) = root_macro_call_first_node(self.cx, expr) { + if is_panic(self.cx, macro_call.def_id) + || matches!( + self.cx.tcx.item_name(macro_call.def_id).as_str(), + "assert" | "assert_eq" | "assert_ne" | "todo" + ) + { + self.panic_span = Some(macro_call.span); } } - // check for `assert_eq` or `assert_ne` - if is_expn_of(expr.span, "assert_eq").is_some() || is_expn_of(expr.span, "assert_ne").is_some() { - self.panic_span = Some(expr.span); - } - // check for `unwrap` if let Some(arglists) = method_chain_args(expr, &["unwrap"]) { let receiver_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs(); @@ -844,8 +838,3 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> { NestedVisitorMap::OnlyBodies(self.cx.tcx.hir()) } } - -fn is_expn_of_debug_assertions(span: Span) -> bool { - const MACRO_NAMES: &[&str] = &["debug_assert", "debug_assert_eq", "debug_assert_ne"]; - MACRO_NAMES.iter().any(|name| is_expn_of(span, name).is_some()) -} diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index 10123460527..df75b815436 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -1,10 +1,11 @@ use clippy_utils::diagnostics::{multispan_sugg, span_lint, span_lint_and_then}; +use clippy_utils::macros::{find_assert_eq_args, first_node_macro_backtrace}; use clippy_utils::source::snippet; use clippy_utils::ty::{implements_trait, is_copy}; -use clippy_utils::{ast_utils::is_useless_with_eq_exprs, eq_expr_value, higher, is_expn_of, is_in_test_function}; +use clippy_utils::{ast_utils::is_useless_with_eq_exprs, eq_expr_value, is_in_test_function}; use if_chain::if_chain; use rustc_errors::Applicability; -use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, StmtKind}; +use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -68,32 +69,26 @@ declare_clippy_lint! { declare_lint_pass!(EqOp => [EQ_OP, OP_REF]); -const ASSERT_MACRO_NAMES: [&str; 4] = ["assert_eq", "assert_ne", "debug_assert_eq", "debug_assert_ne"]; - impl<'tcx> LateLintPass<'tcx> for EqOp { #[allow(clippy::similar_names, clippy::too_many_lines)] fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { - if let ExprKind::Block(block, _) = e.kind { - for stmt in block.stmts { - for amn in &ASSERT_MACRO_NAMES { - if_chain! { - if is_expn_of(stmt.span, amn).is_some(); - if let StmtKind::Semi(matchexpr) = stmt.kind; - if let Some(macro_args) = higher::extract_assert_macro_args(matchexpr); - if macro_args.len() == 2; - let (lhs, rhs) = (macro_args[0], macro_args[1]); - if eq_expr_value(cx, lhs, rhs); - if !is_in_test_function(cx.tcx, e.hir_id); - then { - span_lint( - cx, - EQ_OP, - lhs.span.to(rhs.span), - &format!("identical args used in this `{}!` macro call", amn), - ); - } - } - } + if_chain! { + if let Some((macro_call, macro_name)) = first_node_macro_backtrace(cx, e).find_map(|macro_call| { + let name = cx.tcx.item_name(macro_call.def_id); + matches!(name.as_str(), "assert_eq" | "assert_ne" | "debug_assert_eq" | "debug_assert_ne") + .then(|| (macro_call, name)) + }); + if let Some((lhs, rhs, _)) = find_assert_eq_args(cx, e, macro_call.expn); + if eq_expr_value(cx, lhs, rhs); + if macro_call.is_local(); + if !is_in_test_function(cx.tcx, e.hir_id); + then { + span_lint( + cx, + EQ_OP, + lhs.span.to(rhs.span), + &format!("identical args used in this `{}!` macro call", macro_name), + ); } } if let ExprKind::Binary(op, left, right) = e.kind { diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index 6b327b9ce17..98e5234e0aa 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; -use clippy_utils::higher::FormatArgsExpn; +use clippy_utils::macros::FormatArgsExpn; use clippy_utils::{is_expn_of, match_function_call, paths}; use if_chain::if_chain; use rustc_errors::Applicability; @@ -48,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite { } else { None }; - if let Some(format_args) = FormatArgsExpn::parse(write_arg); + if let Some(format_args) = FormatArgsExpn::parse(cx, write_arg); then { let calling_macro = // ordering is important here, since `writeln!` uses `write!` internally @@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite { ) }; let msg = format!("use of `{}.unwrap()`", used); - if let [write_output] = *format_args.format_string_symbols { + if let [write_output] = *format_args.format_string_parts { let mut write_output = write_output.to_string(); if write_output.ends_with('\n') { write_output.pop(); diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 05d300058cf..02f1baf27fa 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -1,6 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::macros::{is_panic, root_macro_call_first_node}; +use clippy_utils::method_chain_args; use clippy_utils::ty::is_type_diagnostic_item; -use clippy_utils::{is_expn_of, match_panic_def_id, method_chain_args}; use if_chain::if_chain; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; @@ -68,7 +69,7 @@ impl<'tcx> LateLintPass<'tcx> for FallibleImplFrom { fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[hir::ImplItemRef]) { use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; - use rustc_hir::{Expr, ExprKind, ImplItemKind, QPath}; + use rustc_hir::{Expr, ImplItemKind}; struct FindPanicUnwrap<'a, 'tcx> { lcx: &'a LateContext<'tcx>, @@ -80,14 +81,8 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h type Map = Map<'tcx>; fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { - // check for `begin_panic` - if_chain! { - if let ExprKind::Call(func_expr, _) = expr.kind; - if let ExprKind::Path(QPath::Resolved(_, path)) = func_expr.kind; - if let Some(path_def_id) = path.res.opt_def_id(); - if match_panic_def_id(self.lcx, path_def_id); - if is_expn_of(expr.span, "unreachable").is_none(); - then { + if let Some(macro_call) = root_macro_call_first_node(self.lcx, expr) { + if is_panic(self.lcx, macro_call.def_id) { self.result.push(expr.span); } } diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 3f043e5f2f1..688d8f8630f 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::higher::FormatExpn; +use clippy_utils::macros::{root_macro_call_first_node, FormatArgsExpn}; use clippy_utils::source::{snippet_opt, snippet_with_applicability}; use clippy_utils::sugg::Sugg; use if_chain::if_chain; @@ -43,38 +43,41 @@ declare_lint_pass!(UselessFormat => [USELESS_FORMAT]); impl<'tcx> LateLintPass<'tcx> for UselessFormat { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { - let FormatExpn { call_site, format_args } = match FormatExpn::parse(expr) { - Some(e) if !e.call_site.from_expansion() => e, - _ => return, + let (format_args, call_site) = if_chain! { + if let Some(macro_call) = root_macro_call_first_node(cx, expr); + if cx.tcx.is_diagnostic_item(sym::format_macro, macro_call.def_id); + if let Some(format_args) = FormatArgsExpn::find_nested(cx, expr, macro_call.expn); + then { + (format_args, macro_call.span) + } else { + return + } }; let mut applicability = Applicability::MachineApplicable; if format_args.value_args.is_empty() { - if format_args.format_string_parts.is_empty() { - span_useless_format_empty(cx, call_site, "String::new()".to_owned(), applicability); - } else { - if_chain! { - if let [e] = &*format_args.format_string_parts; - if let ExprKind::Lit(lit) = &e.kind; - if let Some(s_src) = snippet_opt(cx, lit.span); - then { + match *format_args.format_string_parts { + [] => span_useless_format_empty(cx, call_site, "String::new()".to_owned(), applicability), + [_] => { + if let Some(s_src) = snippet_opt(cx, format_args.format_string_span) { // Simulate macro expansion, converting {{ and }} to { and }. let s_expand = s_src.replace("{{", "{").replace("}}", "}"); let sugg = format!("{}.to_string()", s_expand); span_useless_format(cx, call_site, sugg, applicability); } - } + }, + [..] => {}, } } else if let [value] = *format_args.value_args { if_chain! { - if format_args.format_string_symbols == [kw::Empty]; + if format_args.format_string_parts == [kw::Empty]; if match cx.typeck_results().expr_ty(value).peel_refs().kind() { ty::Adt(adt, _) => cx.tcx.is_diagnostic_item(sym::String, adt.did), ty::Str => true, _ => false, }; if let Some(args) = format_args.args(); - if args.iter().all(|arg| arg.is_display() && !arg.has_string_formatting()); + if args.iter().all(|arg| arg.format_trait == sym::Display && !arg.has_string_formatting()); then { let is_new_string = match value.kind { ExprKind::Binary(..) => true, diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index f0e1a67dcdd..ae423d799d7 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; -use clippy_utils::higher::{FormatArgsArg, FormatArgsExpn, FormatExpn}; +use clippy_utils::macros::{FormatArgsArg, FormatArgsExpn}; use clippy_utils::source::snippet_opt; use clippy_utils::ty::implements_trait; use clippy_utils::{is_diag_trait_item, match_def_path, paths}; @@ -83,7 +83,7 @@ const FORMAT_MACRO_DIAG_ITEMS: &[Symbol] = &[sym::format_macro, sym::std_panic_m impl<'tcx> LateLintPass<'tcx> for FormatArgs { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { if_chain! { - if let Some(format_args) = FormatArgsExpn::parse(expr); + if let Some(format_args) = FormatArgsExpn::parse(cx, expr); let expr_expn_data = expr.span.ctxt().outer_expn_data(); let outermost_expn_data = outermost_expn_data(expr_expn_data); if let Some(macro_def_id) = outermost_expn_data.macro_def_id; @@ -97,7 +97,7 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs { if let Some(args) = format_args.args(); then { for (i, arg) in args.iter().enumerate() { - if !arg.is_display() { + if arg.format_trait != sym::Display { continue; } if arg.has_string_formatting() { @@ -106,8 +106,8 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs { if is_aliased(&args, i) { continue; } - check_format_in_format_args(cx, outermost_expn_data.call_site, name, arg); - check_to_string_in_format_args(cx, name, arg); + check_format_in_format_args(cx, outermost_expn_data.call_site, name, arg.value); + check_to_string_in_format_args(cx, name, arg.value); } } } @@ -122,30 +122,31 @@ fn outermost_expn_data(expn_data: ExpnData) -> ExpnData { } } -fn check_format_in_format_args(cx: &LateContext<'_>, call_site: Span, name: Symbol, arg: &FormatArgsArg<'_>) { - if_chain! { - if FormatExpn::parse(arg.value).is_some(); - if !arg.value.span.ctxt().outer_expn_data().call_site.from_expansion(); - then { - span_lint_and_then( - cx, - FORMAT_IN_FORMAT_ARGS, - call_site, - &format!("`format!` in `{}!` args", name), - |diag| { - diag.help(&format!( - "combine the `format!(..)` arguments with the outer `{}!(..)` call", - name - )); - diag.help("or consider changing `format!` to `format_args!`"); - }, - ); - } +fn check_format_in_format_args(cx: &LateContext<'_>, call_site: Span, name: Symbol, arg: &Expr<'_>) { + let expn_data = arg.span.ctxt().outer_expn_data(); + if expn_data.call_site.from_expansion() { + return; + } + let Some(mac_id) = expn_data.macro_def_id else { return }; + if !cx.tcx.is_diagnostic_item(sym::format_macro, mac_id) { + return; } + span_lint_and_then( + cx, + FORMAT_IN_FORMAT_ARGS, + call_site, + &format!("`format!` in `{}!` args", name), + |diag| { + diag.help(&format!( + "combine the `format!(..)` arguments with the outer `{}!(..)` call", + name + )); + diag.help("or consider changing `format!` to `format_args!`"); + }, + ); } -fn check_to_string_in_format_args<'tcx>(cx: &LateContext<'tcx>, name: Symbol, arg: &FormatArgsArg<'tcx>) { - let value = arg.value; +fn check_to_string_in_format_args(cx: &LateContext<'_>, name: Symbol, value: &Expr<'_>) { if_chain! { if !value.span.from_expansion(); if let ExprKind::MethodCall(_, _, [receiver], _) = value.kind; diff --git a/clippy_lints/src/manual_assert.rs b/clippy_lints/src/manual_assert.rs index 5a2a965716c..e3a34b22e32 100644 --- a/clippy_lints/src/manual_assert.rs +++ b/clippy_lints/src/manual_assert.rs @@ -1,11 +1,12 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::higher::PanicExpn; +use clippy_utils::macros::{root_macro_call, FormatArgsExpn}; use clippy_utils::source::snippet_with_applicability; -use clippy_utils::{is_expn_of, sugg}; +use clippy_utils::{peel_blocks_with_stmt, sugg}; use rustc_errors::Applicability; -use rustc_hir::{Block, Expr, ExprKind, StmtKind, UnOp}; +use rustc_hir::{Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_span::sym; declare_clippy_lint! { /// ### What it does @@ -35,64 +36,33 @@ declare_clippy_lint! { declare_lint_pass!(ManualAssert => [MANUAL_ASSERT]); impl LateLintPass<'_> for ManualAssert { - fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'tcx>) { if_chain! { - if let Expr { - kind: ExprKind:: If(cond, Expr { - kind: ExprKind::Block( - Block { - stmts: [stmt], - .. - }, - _), - .. - }, None), - .. - } = &expr; - if is_expn_of(stmt.span, "panic").is_some(); + if let ExprKind::If(cond, then, None) = expr.kind; if !matches!(cond.kind, ExprKind::Let(_)); - if let StmtKind::Semi(semi) = stmt.kind; + if !expr.span.from_expansion(); + let then = peel_blocks_with_stmt(then); + if let Some(macro_call) = root_macro_call(then.span); + if cx.tcx.item_name(macro_call.def_id) == sym::panic; if !cx.tcx.sess.source_map().is_multiline(cond.span); - + if let Some(format_args) = FormatArgsExpn::find_nested(cx, then, macro_call.expn); then { - let call = if_chain! { - if let ExprKind::Block(block, _) = semi.kind; - if let Some(init) = block.expr; - then { - init - } else { - semi - } - }; - let span = if let Some(panic_expn) = PanicExpn::parse(call) { - match *panic_expn.format_args.value_args { - [] => panic_expn.format_args.format_string_span, - [.., last] => panic_expn.format_args.format_string_span.to(last.span), - } - } else if let ExprKind::Call(_, [format_args]) = call.kind { - format_args.span - } else { - return - }; let mut applicability = Applicability::MachineApplicable; - let sugg = snippet_with_applicability(cx, span, "..", &mut applicability); - let cond_sugg = if let ExprKind::DropTemps(e, ..) = cond.kind { - if let Expr{kind: ExprKind::Unary(UnOp::Not, not_expr), ..} = e { - sugg::Sugg::hir_with_applicability(cx, not_expr, "..", &mut applicability).maybe_par().to_string() - } else { - format!("!{}", sugg::Sugg::hir_with_applicability(cx, e, "..", &mut applicability).maybe_par()) - } - } else { - format!("!{}", sugg::Sugg::hir_with_applicability(cx, cond, "..", &mut applicability).maybe_par()) + let format_args_snip = snippet_with_applicability(cx, format_args.inputs_span(), "..", &mut applicability); + let cond = cond.peel_drop_temps(); + let (cond, not) = match cond.kind { + ExprKind::Unary(UnOp::Not, e) => (e, ""), + _ => (cond, "!"), }; - + let cond_sugg = sugg::Sugg::hir_with_applicability(cx, cond, "..", &mut applicability).maybe_par(); + let sugg = format!("assert!({not}{cond_sugg}, {format_args_snip});"); span_lint_and_sugg( cx, MANUAL_ASSERT, expr.span, "only a `panic!` in `if`-then statement", "try", - format!("assert!({}, {});", cond_sugg, sugg), + sugg, Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 22970507f96..0d693499bc6 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -2,16 +2,17 @@ use clippy_utils::consts::{constant, constant_full_int, miri_to_const, FullInt}; use clippy_utils::diagnostics::{ multispan_sugg, span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then, }; -use clippy_utils::higher; +use clippy_utils::macros::{is_panic, root_macro_call}; use clippy_utils::source::{expr_block, indent_of, snippet, snippet_block, snippet_opt, snippet_with_applicability}; use clippy_utils::sugg::Sugg; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type, peel_mid_ty_refs}; use clippy_utils::visitors::is_local_used; use clippy_utils::{ - get_parent_expr, is_expn_of, is_lang_ctor, is_lint_allowed, is_refutable, is_unit_expr, is_wild, meets_msrv, msrvs, + get_parent_expr, is_lang_ctor, is_lint_allowed, is_refutable, is_unit_expr, is_wild, meets_msrv, msrvs, path_to_local, path_to_local_id, peel_blocks, peel_hir_pat_refs, peel_n_hir_expr_refs, recurse_or_patterns, strip_pat_refs, }; +use clippy_utils::{higher, peel_blocks_with_stmt}; use clippy_utils::{paths, search_same, SpanlessEq, SpanlessHash}; use core::iter::{once, ExactSizeIterator}; use if_chain::if_chain; @@ -974,7 +975,8 @@ fn check_wild_err_arm<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm } if_chain! { if matching_wild; - if is_panic_call(arm.body); + if let Some(macro_call) = root_macro_call(peel_blocks_with_stmt(arm.body).span); + if is_panic(cx, macro_call.def_id); then { // `Err(_)` or `Err(_e)` arm with `panic!` found span_lint_and_note(cx, @@ -1179,22 +1181,6 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) }; } -// If the block contains only a `panic!` macro (as expression or statement) -fn is_panic_call(expr: &Expr<'_>) -> bool { - // Unwrap any wrapping blocks - let span = if let ExprKind::Block(block, _) = expr.kind { - match (&block.expr, block.stmts.len(), block.stmts.first()) { - (&Some(exp), 0, _) => exp.span, - (&None, 1, Some(stmt)) => stmt.span, - _ => return false, - } - } else { - expr.span - }; - - is_expn_of(span, "panic").is_some() && is_expn_of(span, "unreachable").is_none() -} - fn check_match_ref_pats<'a, 'b, I>(cx: &LateContext<'_>, ex: &Expr<'_>, pats: I, expr: &Expr<'_>) where 'b: 'a, diff --git a/clippy_lints/src/methods/expect_fun_call.rs b/clippy_lints/src/methods/expect_fun_call.rs index 0ec9387f9c4..866eaff5b1d 100644 --- a/clippy_lints/src/methods/expect_fun_call.rs +++ b/clippy_lints/src/methods/expect_fun_call.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::higher::FormatExpn; +use clippy_utils::macros::{root_macro_call_first_node, FormatArgsExpn}; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; @@ -14,7 +14,13 @@ use super::EXPECT_FUN_CALL; /// Checks for the `EXPECT_FUN_CALL` lint. #[allow(clippy::too_many_lines)] -pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, method_span: Span, name: &str, args: &[hir::Expr<'_>]) { +pub(super) fn check( + cx: &LateContext<'tcx>, + expr: &hir::Expr<'_>, + method_span: Span, + name: &str, + args: &'tcx [hir::Expr<'tcx>], +) { // Strip `&`, `as_ref()` and `as_str()` off `arg` until we're left with either a `String` or // `&str` fn get_arg_root<'a>(cx: &LateContext<'_>, arg: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> { @@ -128,11 +134,12 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, method_span: Spa let mut applicability = Applicability::MachineApplicable; //Special handling for `format!` as arg_root - if let Some(format_expn) = FormatExpn::parse(arg_root) { - let span = match *format_expn.format_args.value_args { - [] => format_expn.format_args.format_string_span, - [.., last] => format_expn.format_args.format_string_span.to(last.span), - }; + if let Some(macro_call) = root_macro_call_first_node(cx, arg_root) { + if !cx.tcx.is_diagnostic_item(sym::format_macro, macro_call.def_id) { + return; + } + let Some(format_args) = FormatArgsExpn::find_nested(cx, arg_root, macro_call.expn) else { return }; + let span = format_args.inputs_span(); let sugg = snippet_with_applicability(cx, span, "..", &mut applicability); span_lint_and_sugg( cx, diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index fa7274990db..49d4b3a1850 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint; -use clippy_utils::{higher, is_direct_expn_of}; +use clippy_utils::macros::{find_assert_eq_args, root_macro_call_first_node}; use rustc_hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; use rustc_hir::{BorrowKind, Expr, ExprKind, MatchSource, Mutability}; use rustc_lint::{LateContext, LateLintPass}; @@ -34,26 +34,30 @@ declare_clippy_lint! { declare_lint_pass!(DebugAssertWithMutCall => [DEBUG_ASSERT_WITH_MUT_CALL]); -const DEBUG_MACRO_NAMES: [&str; 3] = ["debug_assert", "debug_assert_eq", "debug_assert_ne"]; - impl<'tcx> LateLintPass<'tcx> for DebugAssertWithMutCall { fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { - for dmn in &DEBUG_MACRO_NAMES { - if is_direct_expn_of(e.span, dmn).is_some() { - if let Some(macro_args) = higher::extract_assert_macro_args(e) { - for arg in macro_args { - let mut visitor = MutArgVisitor::new(cx); - visitor.visit_expr(arg); - if let Some(span) = visitor.expr_span() { - span_lint( - cx, - DEBUG_ASSERT_WITH_MUT_CALL, - span, - &format!("do not call a function with mutable arguments inside of `{}!`", dmn), - ); - } - } - } + let Some(macro_call) = root_macro_call_first_node(cx, e) else { return }; + let macro_name = cx.tcx.item_name(macro_call.def_id); + if !matches!( + macro_name.as_str(), + "debug_assert" | "debug_assert_eq" | "debug_assert_ne" + ) { + return; + } + let Some((lhs, rhs, _)) = find_assert_eq_args(cx, e, macro_call.expn) else { return }; + for arg in [lhs, rhs] { + let mut visitor = MutArgVisitor::new(cx); + visitor.visit_expr(arg); + if let Some(span) = visitor.expr_span() { + span_lint( + cx, + DEBUG_ASSERT_WITH_MUT_CALL, + span, + &format!( + "do not call a function with mutable arguments inside of `{}!`", + macro_name + ), + ); } } } diff --git a/clippy_lints/src/panic_in_result_fn.rs b/clippy_lints/src/panic_in_result_fn.rs index 8769c045214..b7a56970b33 100644 --- a/clippy_lints/src/panic_in_result_fn.rs +++ b/clippy_lints/src/panic_in_result_fn.rs @@ -1,8 +1,10 @@ use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::macros::root_macro_call_first_node; +use clippy_utils::return_ty; use clippy_utils::ty::is_type_diagnostic_item; -use clippy_utils::{find_macro_calls, is_expn_of, return_ty}; +use clippy_utils::visitors::expr_visitor_no_bodies; use rustc_hir as hir; -use rustc_hir::intravisit::FnKind; +use rustc_hir::intravisit::{FnKind, Visitor}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{sym, Span}; @@ -55,19 +57,19 @@ impl<'tcx> LateLintPass<'tcx> for PanicInResultFn { } fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, body: &'tcx hir::Body<'tcx>) { - let mut panics = find_macro_calls( - &[ - "unimplemented", - "unreachable", - "panic", - "todo", - "assert", - "assert_eq", - "assert_ne", - ], - body, - ); - panics.retain(|span| is_expn_of(*span, "debug_assert").is_none()); + let mut panics = Vec::new(); + expr_visitor_no_bodies(|expr| { + let Some(macro_call) = root_macro_call_first_node(cx, expr) else { return true }; + if matches!( + &*cx.tcx.item_name(macro_call.def_id).as_str(), + "unimplemented" | "unreachable" | "panic" | "todo" | "assert" | "assert_eq" | "assert_ne" + ) { + panics.push(macro_call.span); + return false; + } + true + }) + .visit_expr(&body.value); if !panics.is_empty() { span_lint_and_then( cx, diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index edfac824ded..6ef6b9a20aa 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -1,10 +1,8 @@ use clippy_utils::diagnostics::span_lint; -use clippy_utils::{is_expn_of, match_panic_call}; -use if_chain::if_chain; +use clippy_utils::macros::{is_panic, root_macro_call_first_node}; use rustc_hir::Expr; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; -use rustc_span::Span; declare_clippy_lint! { /// ### What it does @@ -78,37 +76,37 @@ declare_lint_pass!(PanicUnimplemented => [UNIMPLEMENTED, UNREACHABLE, TODO, PANI impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { - if match_panic_call(cx, expr).is_some() - && (is_expn_of(expr.span, "debug_assert").is_none() && is_expn_of(expr.span, "assert").is_none()) - { - let span = get_outer_span(expr); - if is_expn_of(expr.span, "unimplemented").is_some() { + let Some(macro_call) = root_macro_call_first_node(cx, expr) else { return }; + if is_panic(cx, macro_call.def_id) { + span_lint( + cx, + PANIC, + macro_call.span, + "`panic` should not be present in production code", + ); + return; + } + match cx.tcx.item_name(macro_call.def_id).as_str() { + "todo" => { + span_lint( + cx, + TODO, + macro_call.span, + "`todo` should not be present in production code", + ); + }, + "unimplemented" => { span_lint( cx, UNIMPLEMENTED, - span, + macro_call.span, "`unimplemented` should not be present in production code", ); - } else if is_expn_of(expr.span, "todo").is_some() { - span_lint(cx, TODO, span, "`todo` should not be present in production code"); - } else if is_expn_of(expr.span, "unreachable").is_some() { - span_lint(cx, UNREACHABLE, span, "usage of the `unreachable!` macro"); - } else if is_expn_of(expr.span, "panic").is_some() { - span_lint(cx, PANIC, span, "`panic` should not be present in production code"); - } - } - } -} - -fn get_outer_span(expr: &Expr<'_>) -> Span { - if_chain! { - if expr.span.from_expansion(); - let first = expr.span.ctxt().outer_expn_data().call_site; - if first.from_expansion(); - then { - first.ctxt().outer_expn_data().call_site - } else { - expr.span + }, + "unreachable" => { + span_lint(cx, UNREACHABLE, macro_call.span, "usage of the `unreachable!` macro"); + }, + _ => {}, } } } diff --git a/clippy_lints/src/unit_types/unit_cmp.rs b/clippy_lints/src/unit_types/unit_cmp.rs index 6d9aff47421..1dd8895ebd0 100644 --- a/clippy_lints/src/unit_types/unit_cmp.rs +++ b/clippy_lints/src/unit_types/unit_cmp.rs @@ -1,35 +1,29 @@ use clippy_utils::diagnostics::span_lint; +use clippy_utils::macros::{find_assert_eq_args, root_macro_call_first_node}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; -use rustc_span::hygiene::{ExpnKind, MacroKind}; use super::UNIT_CMP; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { if expr.span.from_expansion() { - if let Some(callee) = expr.span.source_callee() { - if let ExpnKind::Macro(MacroKind::Bang, symbol) = callee.kind { - if let ExprKind::Binary(ref cmp, left, _) = expr.kind { - let op = cmp.node; - if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() { - let result = match symbol.as_str() { - "assert_eq" | "debug_assert_eq" => "succeed", - "assert_ne" | "debug_assert_ne" => "fail", - _ => return, - }; - span_lint( - cx, - UNIT_CMP, - expr.span, - &format!( - "`{}` of unit values detected. This will always {}", - symbol.as_str(), - result - ), - ); - } - } + if let Some(macro_call) = root_macro_call_first_node(cx, expr) { + let macro_name = cx.tcx.item_name(macro_call.def_id); + let result = match macro_name.as_str() { + "assert_eq" | "debug_assert_eq" => "succeed", + "assert_ne" | "debug_assert_ne" => "fail", + _ => return, + }; + let Some ((left, _, _)) = find_assert_eq_args(cx, expr, macro_call.expn) else { return }; + if !cx.typeck_results().expr_ty(left).is_unit() { + return; } + span_lint( + cx, + UNIT_CMP, + macro_call.span, + &format!("`{}` of unit values detected. This will always {}", macro_name, result), + ); } return; } diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index e98dcd3cf98..165004e5b41 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -1,5 +1,6 @@ use clippy_utils::consts::{constant_simple, Constant}; use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; +use clippy_utils::macros::root_macro_call_first_node; use clippy_utils::source::snippet; use clippy_utils::ty::match_type; use clippy_utils::{ @@ -410,9 +411,13 @@ impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass { } self.declared_lints.insert(item.ident.name, item.span); } - } else if is_expn_of(item.span, "impl_lint_pass").is_some() - || is_expn_of(item.span, "declare_lint_pass").is_some() - { + } else if let Some(macro_call) = root_macro_call_first_node(cx, item) { + if !matches!( + &*cx.tcx.item_name(macro_call.def_id).as_str(), + "impl_lint_pass" | "declare_lint_pass" + ) { + return; + } if let hir::ItemKind::Impl(hir::Impl { of_trait: None, items: impl_item_refs, diff --git a/clippy_utils/Cargo.toml b/clippy_utils/Cargo.toml index 0ba0b59ed13..af1e2eb4dd1 100644 --- a/clippy_utils/Cargo.toml +++ b/clippy_utils/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" publish = false [dependencies] +arrayvec = { version = "0.7", default-features = false } if_chain = "1.0" rustc-semver = "1.1" diff --git a/clippy_utils/src/ast_utils.rs b/clippy_utils/src/ast_utils.rs index 8400bfbbd99..3d3180521ab 100644 --- a/clippy_utils/src/ast_utils.rs +++ b/clippy_utils/src/ast_utils.rs @@ -5,7 +5,6 @@ #![allow(clippy::similar_names, clippy::wildcard_imports, clippy::enum_glob_use)] use crate::{both, over}; -use if_chain::if_chain; use rustc_ast::ptr::P; use rustc_ast::{self as ast, *}; use rustc_span::symbol::Ident; @@ -679,34 +678,3 @@ pub fn eq_mac_args(l: &MacArgs, r: &MacArgs) -> bool { _ => false, } } - -/// Extract args from an assert-like macro. -/// -/// Currently working with: -/// - `assert_eq!` and `assert_ne!` -/// - `debug_assert_eq!` and `debug_assert_ne!` -/// -/// For example: -/// -/// `debug_assert_eq!(a, b)` will return Some([a, b]) -pub fn extract_assert_macro_args(mut expr: &Expr) -> Option<[&Expr; 2]> { - if_chain! { - if let ExprKind::If(_, ref block, _) = expr.kind; - if let StmtKind::Semi(ref e) = block.stmts.get(0)?.kind; - then { - expr = e; - } - } - if_chain! { - if let ExprKind::Block(ref block, _) = expr.kind; - if let StmtKind::Expr(ref expr) = block.stmts.get(0)?.kind; - if let ExprKind::Match(ref match_expr, _) = expr.kind; - if let ExprKind::Tup(ref tup) = match_expr.kind; - if let [a, b, ..] = tup.as_slice(); - if let (&ExprKind::AddrOf(_, _, ref a), &ExprKind::AddrOf(_, _, ref b)) = (&a.kind, &b.kind); - then { - return Some([&*a, &*b]); - } - } - None -} diff --git a/clippy_utils/src/higher.rs b/clippy_utils/src/higher.rs index c764c35d444..160a51740cd 100644 --- a/clippy_utils/src/higher.rs +++ b/clippy_utils/src/higher.rs @@ -3,15 +3,13 @@ #![deny(clippy::missing_docs_in_private_items)] use crate::ty::is_type_diagnostic_item; -use crate::{is_expn_of, last_path_segment, match_def_path, paths}; +use crate::{is_expn_of, match_def_path, paths}; use if_chain::if_chain; use rustc_ast::ast::{self, LitKind}; use rustc_hir as hir; -use rustc_hir::{ - Arm, Block, BorrowKind, Expr, ExprKind, HirId, LoopSource, MatchSource, Node, Pat, QPath, StmtKind, UnOp, -}; +use rustc_hir::{Arm, Block, Expr, ExprKind, HirId, LoopSource, MatchSource, Node, Pat, QPath}; use rustc_lint::LateContext; -use rustc_span::{sym, symbol, ExpnKind, Span, Symbol}; +use rustc_span::{sym, symbol, Span}; /// The essential nodes of a desugared for loop as well as the entire span: /// `for pat in arg { body }` becomes `(pat, arg, body)`. Return `(pat, arg, body, span)`. @@ -428,293 +426,6 @@ pub fn binop(op: hir::BinOpKind) -> ast::BinOpKind { } } -/// Extract args from an assert-like macro. -/// Currently working with: -/// - `assert!`, `assert_eq!` and `assert_ne!` -/// - `debug_assert!`, `debug_assert_eq!` and `debug_assert_ne!` -/// For example: -/// `assert!(expr)` will return `Some([expr])` -/// `debug_assert_eq!(a, b)` will return `Some([a, b])` -pub fn extract_assert_macro_args<'tcx>(e: &'tcx Expr<'tcx>) -> Option>> { - /// Try to match the AST for a pattern that contains a match, for example when two args are - /// compared - fn ast_matchblock(matchblock_expr: &'tcx Expr<'tcx>) -> Option>> { - if_chain! { - if let ExprKind::Match(headerexpr, _, _) = &matchblock_expr.kind; - if let ExprKind::Tup([lhs, rhs]) = &headerexpr.kind; - if let ExprKind::AddrOf(BorrowKind::Ref, _, lhs) = lhs.kind; - if let ExprKind::AddrOf(BorrowKind::Ref, _, rhs) = rhs.kind; - then { - return Some(vec![lhs, rhs]); - } - } - None - } - - if let ExprKind::Block(block, _) = e.kind { - if block.stmts.len() == 1 { - if let StmtKind::Semi(matchexpr) = block.stmts.get(0)?.kind { - // macros with unique arg: `{debug_}assert!` (e.g., `debug_assert!(some_condition)`) - if_chain! { - if let Some(If { cond, .. }) = If::hir(matchexpr); - if let ExprKind::Unary(UnOp::Not, condition) = cond.kind; - then { - return Some(vec![condition]); - } - } - - // debug macros with two args: `debug_assert_{ne, eq}` (e.g., `assert_ne!(a, b)`) - if_chain! { - if let ExprKind::Block(matchblock,_) = matchexpr.kind; - if let Some(matchblock_expr) = matchblock.expr; - then { - return ast_matchblock(matchblock_expr); - } - } - } - } else if let Some(matchblock_expr) = block.expr { - // macros with two args: `assert_{ne, eq}` (e.g., `assert_ne!(a, b)`) - return ast_matchblock(matchblock_expr); - } - } - None -} - -/// A parsed `format!` expansion -pub struct FormatExpn<'tcx> { - /// Span of `format!(..)` - pub call_site: Span, - /// Inner `format_args!` expansion - pub format_args: FormatArgsExpn<'tcx>, -} - -impl FormatExpn<'tcx> { - /// Parses an expanded `format!` invocation - pub fn parse(expr: &'tcx Expr<'tcx>) -> Option { - if_chain! { - if let ExprKind::Block(block, _) = expr.kind; - if let [stmt] = block.stmts; - if let StmtKind::Local(local) = stmt.kind; - if let Some(init) = local.init; - if let ExprKind::Call(_, [format_args]) = init.kind; - let expn_data = expr.span.ctxt().outer_expn_data(); - if let ExpnKind::Macro(_, sym::format) = expn_data.kind; - if let Some(format_args) = FormatArgsExpn::parse(format_args); - then { - Some(FormatExpn { - call_site: expn_data.call_site, - format_args, - }) - } else { - None - } - } - } -} - -/// A parsed `format_args!` expansion -pub struct FormatArgsExpn<'tcx> { - /// Span of the first argument, the format string - pub format_string_span: Span, - /// Values passed after the format string - pub value_args: Vec<&'tcx Expr<'tcx>>, - - /// String literal expressions which represent the format string split by "{}" - pub format_string_parts: &'tcx [Expr<'tcx>], - /// Symbols corresponding to [`Self::format_string_parts`] - pub format_string_symbols: Vec, - /// Expressions like `ArgumentV1::new(arg0, Debug::fmt)` - pub args: &'tcx [Expr<'tcx>], - /// The final argument passed to `Arguments::new_v1_formatted`, if applicable - pub fmt_expr: Option<&'tcx Expr<'tcx>>, -} - -impl FormatArgsExpn<'tcx> { - /// Parses an expanded `format_args!` or `format_args_nl!` invocation - pub fn parse(expr: &'tcx Expr<'tcx>) -> Option { - if_chain! { - if let ExpnKind::Macro(_, name) = expr.span.ctxt().outer_expn_data().kind; - let name = name.as_str(); - if name.ends_with("format_args") || name.ends_with("format_args_nl"); - if let ExprKind::Call(_, args) = expr.kind; - if let Some((strs_ref, args, fmt_expr)) = match args { - // Arguments::new_v1 - [strs_ref, args] => Some((strs_ref, args, None)), - // Arguments::new_v1_formatted - [strs_ref, args, fmt_expr, _unsafe_arg] => Some((strs_ref, args, Some(fmt_expr))), - _ => None, - }; - if let ExprKind::AddrOf(BorrowKind::Ref, _, strs_arr) = strs_ref.kind; - if let ExprKind::Array(format_string_parts) = strs_arr.kind; - if let Some(format_string_symbols) = format_string_parts - .iter() - .map(|e| { - if let ExprKind::Lit(lit) = &e.kind { - if let LitKind::Str(symbol, _style) = lit.node { - return Some(symbol); - } - } - None - }) - .collect(); - if let ExprKind::AddrOf(BorrowKind::Ref, _, args) = args.kind; - if let ExprKind::Match(args, [arm], _) = args.kind; - if let ExprKind::Tup(value_args) = args.kind; - if let Some(value_args) = value_args - .iter() - .map(|e| match e.kind { - ExprKind::AddrOf(_, _, e) => Some(e), - _ => None, - }) - .collect(); - if let ExprKind::Array(args) = arm.body.kind; - then { - Some(FormatArgsExpn { - format_string_span: strs_ref.span, - value_args, - format_string_parts, - format_string_symbols, - args, - fmt_expr, - }) - } else { - None - } - } - } - - /// Returns a vector of `FormatArgsArg`. - pub fn args(&self) -> Option>> { - if let Some(expr) = self.fmt_expr { - if_chain! { - if let ExprKind::AddrOf(BorrowKind::Ref, _, expr) = expr.kind; - if let ExprKind::Array(exprs) = expr.kind; - then { - exprs.iter().map(|fmt| { - if_chain! { - // struct `core::fmt::rt::v1::Argument` - if let ExprKind::Struct(_, fields, _) = fmt.kind; - if let Some(position_field) = fields.iter().find(|f| f.ident.name == sym::position); - if let ExprKind::Lit(lit) = &position_field.expr.kind; - if let LitKind::Int(position, _) = lit.node; - if let Ok(i) = usize::try_from(position); - let arg = &self.args[i]; - if let ExprKind::Call(_, [arg_name, _]) = arg.kind; - if let ExprKind::Field(_, j) = arg_name.kind; - if let Ok(j) = j.name.as_str().parse::(); - then { - Some(FormatArgsArg { value: self.value_args[j], arg, fmt: Some(fmt) }) - } else { - None - } - } - }).collect() - } else { - None - } - } - } else { - Some( - self.value_args - .iter() - .zip(self.args.iter()) - .map(|(value, arg)| FormatArgsArg { value, arg, fmt: None }) - .collect(), - ) - } - } -} - -/// Type representing a `FormatArgsExpn`'s format arguments -pub struct FormatArgsArg<'tcx> { - /// An element of `value_args` according to `position` - pub value: &'tcx Expr<'tcx>, - /// An element of `args` according to `position` - pub arg: &'tcx Expr<'tcx>, - /// An element of `fmt_expn` - pub fmt: Option<&'tcx Expr<'tcx>>, -} - -impl<'tcx> FormatArgsArg<'tcx> { - /// Returns true if any formatting parameters are used that would have an effect on strings, - /// like `{:+2}` instead of just `{}`. - pub fn has_string_formatting(&self) -> bool { - self.fmt.map_or(false, |fmt| { - // `!` because these conditions check that `self` is unformatted. - !if_chain! { - // struct `core::fmt::rt::v1::Argument` - if let ExprKind::Struct(_, fields, _) = fmt.kind; - if let Some(format_field) = fields.iter().find(|f| f.ident.name == sym::format); - // struct `core::fmt::rt::v1::FormatSpec` - if let ExprKind::Struct(_, subfields, _) = format_field.expr.kind; - let mut precision_found = false; - let mut width_found = false; - if subfields.iter().all(|field| { - match field.ident.name { - sym::precision => { - precision_found = true; - if let ExprKind::Path(ref precision_path) = field.expr.kind { - last_path_segment(precision_path).ident.name == sym::Implied - } else { - false - } - } - sym::width => { - width_found = true; - if let ExprKind::Path(ref width_qpath) = field.expr.kind { - last_path_segment(width_qpath).ident.name == sym::Implied - } else { - false - } - } - _ => true, - } - }); - if precision_found && width_found; - then { true } else { false } - } - }) - } - - /// Returns true if the argument is formatted using `Display::fmt`. - pub fn is_display(&self) -> bool { - if_chain! { - if let ExprKind::Call(_, [_, format_field]) = self.arg.kind; - if let ExprKind::Path(QPath::Resolved(_, path)) = format_field.kind; - if let [.., t, _] = path.segments; - if t.ident.name == sym::Display; - then { true } else { false } - } - } -} - -/// A parsed `panic!` expansion -pub struct PanicExpn<'tcx> { - /// Span of `panic!(..)` - pub call_site: Span, - /// Inner `format_args!` expansion - pub format_args: FormatArgsExpn<'tcx>, -} - -impl PanicExpn<'tcx> { - /// Parses an expanded `panic!` invocation - pub fn parse(expr: &'tcx Expr<'tcx>) -> Option { - if_chain! { - if let ExprKind::Call(_, [format_args]) = expr.kind; - let expn_data = expr.span.ctxt().outer_expn_data(); - if let Some(format_args) = FormatArgsExpn::parse(format_args); - then { - Some(PanicExpn { - call_site: expn_data.call_site, - format_args, - }) - } else { - None - } - } - } -} - /// A parsed `Vec` initialization expression #[derive(Clone, Copy)] pub enum VecInitKind { diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 54d470ca738..bbb70e3adb5 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -44,6 +44,7 @@ pub mod diagnostics; pub mod eager_or_lazy; pub mod higher; mod hir_utils; +pub mod macros; pub mod msrvs; pub mod numeric_literal; pub mod paths; @@ -1138,19 +1139,6 @@ pub fn contains_return(expr: &hir::Expr<'_>) -> bool { found } -/// Finds calls of the specified macros in a function body. -pub fn find_macro_calls(names: &[&str], body: &Body<'_>) -> Vec { - let mut result = Vec::new(); - expr_visitor_no_bodies(|expr| { - if names.iter().any(|fun| is_expn_of(expr.span, fun).is_some()) { - result.push(expr.span); - } - true - }) - .visit_expr(&body.value); - result -} - /// Extends the span to the beginning of the spans line, incl. whitespaces. /// /// ```rust @@ -1679,32 +1667,6 @@ pub fn match_libc_symbol(cx: &LateContext<'_>, did: DefId, name: &str) -> bool { path.first().map_or(false, |s| s.as_str() == "libc") && path.last().map_or(false, |s| s.as_str() == name) } -pub fn match_panic_call(cx: &LateContext<'_>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> { - if let ExprKind::Call(func, [arg]) = expr.kind { - expr_path_res(cx, func) - .opt_def_id() - .map_or(false, |id| match_panic_def_id(cx, id)) - .then(|| arg) - } else { - None - } -} - -pub fn match_panic_def_id(cx: &LateContext<'_>, did: DefId) -> bool { - match_any_def_paths( - cx, - did, - &[ - &paths::BEGIN_PANIC, - &paths::PANIC_ANY, - &paths::PANICKING_PANIC, - &paths::PANICKING_PANIC_FMT, - &paths::PANICKING_PANIC_STR, - ], - ) - .is_some() -} - /// Returns the list of condition expressions and the list of blocks in a /// sequence of `if/else`. /// E.g., this returns `([a, b], [c, d, e])` for the expression diff --git a/clippy_utils/src/macros.rs b/clippy_utils/src/macros.rs new file mode 100644 index 00000000000..2bf43aeb995 --- /dev/null +++ b/clippy_utils/src/macros.rs @@ -0,0 +1,539 @@ +#![allow(clippy::similar_names)] // `expr` and `expn` + +use crate::visitors::expr_visitor_no_bodies; + +use arrayvec::ArrayVec; +use if_chain::if_chain; +use rustc_ast::ast::LitKind; +use rustc_hir::intravisit::Visitor; +use rustc_hir::{self as hir, Expr, ExprKind, HirId, Node, QPath}; +use rustc_lint::LateContext; +use rustc_span::def_id::DefId; +use rustc_span::hygiene::{MacroKind, SyntaxContext}; +use rustc_span::{sym, ExpnData, ExpnId, ExpnKind, Span, Symbol}; +use std::ops::ControlFlow; + +/// A macro call, like `vec![1, 2, 3]`. +/// +/// Use `tcx.item_name(macro_call.def_id)` to get the macro name. +/// Even better is to check if it is a diagnostic item. +/// +/// This structure is similar to `ExpnData` but it precludes desugaring expansions. +#[derive(Debug)] +pub struct MacroCall { + /// Macro `DefId` + pub def_id: DefId, + /// Kind of macro + pub kind: MacroKind, + /// The expansion produced by the macro call + pub expn: ExpnId, + /// Span of the macro call site + pub span: Span, +} + +impl MacroCall { + pub fn is_local(&self) -> bool { + span_is_local(self.span) + } +} + +/// Returns an iterator of expansions that created the given span +pub fn expn_backtrace(mut span: Span) -> impl Iterator { + std::iter::from_fn(move || { + let ctxt = span.ctxt(); + if ctxt == SyntaxContext::root() { + return None; + } + let expn = ctxt.outer_expn(); + let data = expn.expn_data(); + span = data.call_site; + Some((expn, data)) + }) +} + +/// Checks whether the span is from the root expansion or a locally defined macro +pub fn span_is_local(span: Span) -> bool { + !span.from_expansion() || expn_is_local(span.ctxt().outer_expn()) +} + +/// Checks whether the expansion is the root expansion or a locally defined macro +pub fn expn_is_local(expn: ExpnId) -> bool { + if expn == ExpnId::root() { + return true; + } + let data = expn.expn_data(); + let backtrace = expn_backtrace(data.call_site); + std::iter::once((expn, data)) + .chain(backtrace) + .find_map(|(_, data)| data.macro_def_id) + .map_or(true, DefId::is_local) +} + +/// Returns an iterator of macro expansions that created the given span. +/// Note that desugaring expansions are skipped. +pub fn macro_backtrace(span: Span) -> impl Iterator { + expn_backtrace(span).filter_map(|(expn, data)| match data { + ExpnData { + kind: ExpnKind::Macro(kind, _), + macro_def_id: Some(def_id), + call_site: span, + .. + } => Some(MacroCall { + def_id, + kind, + expn, + span, + }), + _ => None, + }) +} + +/// If the macro backtrace of `span` has a macro call at the root expansion +/// (i.e. not a nested macro call), returns `Some` with the `MacroCall` +pub fn root_macro_call(span: Span) -> Option { + macro_backtrace(span).last() +} + +/// Like [`root_macro_call`], but only returns `Some` if `node` is the "first node" +/// produced by the macro call, as in [`first_node_in_macro`]. +pub fn root_macro_call_first_node(cx: &LateContext<'_>, node: &impl HirNode) -> Option { + if first_node_in_macro(cx, node) != Some(ExpnId::root()) { + return None; + } + root_macro_call(node.span()) +} + +/// Like [`macro_backtrace`], but only returns macro calls where `node` is the "first node" of the +/// macro call, as in [`first_node_in_macro`]. +pub fn first_node_macro_backtrace(cx: &LateContext<'_>, node: &impl HirNode) -> impl Iterator { + let span = node.span(); + first_node_in_macro(cx, node) + .into_iter() + .flat_map(move |expn| macro_backtrace(span).take_while(move |macro_call| macro_call.expn != expn)) +} + +/// If `node` is the "first node" in a macro expansion, returns `Some` with the `ExpnId` of the +/// macro call site (i.e. the parent of the macro expansion). This generally means that `node` +/// is the outermost node of an entire macro expansion, but there are some caveats noted below. +/// This is useful for finding macro calls while visiting the HIR without processing the macro call +/// at every node within its expansion. +/// +/// If you already have immediate access to the parent node, it is simpler to +/// just check the context of that span directly (e.g. `parent.span.from_expansion()`). +/// +/// If a macro call is in statement position, it expands to one or more statements. +/// In that case, each statement *and* their immediate descendants will all yield `Some` +/// with the `ExpnId` of the containing block. +/// +/// A node may be the "first node" of multiple macro calls in a macro backtrace. +/// The expansion of the outermost macro call site is returned in such cases. +pub fn first_node_in_macro(cx: &LateContext<'_>, node: &impl HirNode) -> Option { + // get the macro expansion or return `None` if not found + // `macro_backtrace` importantly ignores desugaring expansions + let expn = macro_backtrace(node.span()).next()?.expn; + + // get the parent node, possibly skipping over a statement + // if the parent is not found, it is sensible to return `Some(root)` + let hir = cx.tcx.hir(); + let mut parent_iter = hir.parent_iter(node.hir_id()); + let (parent_id, _) = match parent_iter.next() { + None => return Some(ExpnId::root()), + Some((_, Node::Stmt(_))) => match parent_iter.next() { + None => return Some(ExpnId::root()), + Some(next) => next, + }, + Some(next) => next, + }; + + // get the macro expansion of the parent node + let parent_span = hir.span(parent_id); + let Some(parent_macro_call) = macro_backtrace(parent_span).next() else { + // the parent node is not in a macro + return Some(ExpnId::root()); + }; + + if parent_macro_call.expn.is_descendant_of(expn) { + // `node` is input to a macro call + return None; + } + + Some(parent_macro_call.expn) +} + +/* Specific Macro Utils */ + +/// Is `def_id` of `std::panic`, `core::panic` or any inner implementation macros +pub fn is_panic(cx: &LateContext<'_>, def_id: DefId) -> bool { + let Some(name) = cx.tcx.get_diagnostic_name(def_id) else { return false }; + matches!( + name.as_str(), + "core_panic_macro" + | "std_panic_macro" + | "core_panic_2015_macro" + | "std_panic_2015_macro" + | "core_panic_2021_macro" + ) +} + +pub enum PanicExpn<'a> { + /// No arguments - `panic!()` + Empty, + /// A string literal or any `&str` - `panic!("message")` or `panic!(message)` + Str(&'a Expr<'a>), + /// A single argument that implements `Display` - `panic!("{}", object)` + Display(&'a Expr<'a>), + /// Anything else - `panic!("error {}: {}", a, b)` + Format(FormatArgsExpn<'a>), +} + +impl<'a> PanicExpn<'a> { + pub fn parse(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option { + if !macro_backtrace(expr.span).any(|macro_call| is_panic(cx, macro_call.def_id)) { + return None; + } + let ExprKind::Call(callee, [arg]) = expr.kind else { return None }; + let ExprKind::Path(QPath::Resolved(_, path)) = callee.kind else { return None }; + let result = match path.segments.last().unwrap().ident.as_str() { + "panic" if arg.span.ctxt() == expr.span.ctxt() => Self::Empty, + "panic" | "panic_str" => Self::Str(arg), + "panic_display" => { + let ExprKind::AddrOf(_, _, e) = arg.kind else { return None }; + Self::Display(e) + }, + "panic_fmt" => Self::Format(FormatArgsExpn::parse(cx, arg)?), + _ => return None, + }; + Some(result) + } +} + +/// Finds the arguments of an `assert!` or `debug_assert!` macro call within the macro expansion +pub fn find_assert_args<'a>( + cx: &LateContext<'_>, + expr: &'a Expr<'a>, + expn: ExpnId, +) -> Option<(&'a Expr<'a>, PanicExpn<'a>)> { + find_assert_args_inner(cx, expr, expn).map(|([e], p)| (e, p)) +} + +/// Finds the arguments of an `assert_eq!` or `debug_assert_eq!` macro call within the macro +/// expansion +pub fn find_assert_eq_args<'a>( + cx: &LateContext<'_>, + expr: &'a Expr<'a>, + expn: ExpnId, +) -> Option<(&'a Expr<'a>, &'a Expr<'a>, PanicExpn<'a>)> { + find_assert_args_inner(cx, expr, expn).map(|([a, b], p)| (a, b, p)) +} + +fn find_assert_args_inner<'a, const N: usize>( + cx: &LateContext<'_>, + expr: &'a Expr<'a>, + expn: ExpnId, +) -> Option<([&'a Expr<'a>; N], PanicExpn<'a>)> { + let macro_id = expn.expn_data().macro_def_id?; + let (expr, expn) = match cx.tcx.item_name(macro_id).as_str().strip_prefix("debug_") { + None => (expr, expn), + Some(inner_name) => find_assert_within_debug_assert(cx, expr, expn, Symbol::intern(inner_name))?, + }; + let mut args = ArrayVec::new(); + let mut panic_expn = None; + expr_visitor_no_bodies(|e| { + if args.is_full() { + if panic_expn.is_none() && e.span.ctxt() != expr.span.ctxt() { + panic_expn = PanicExpn::parse(cx, e); + } + panic_expn.is_none() + } else if is_assert_arg(cx, e, expn) { + args.push(e); + false + } else { + true + } + }) + .visit_expr(expr); + let args = args.into_inner().ok()?; + // if no `panic!(..)` is found, use `PanicExpn::Empty` + // to indicate that the default assertion message is used + let panic_expn = panic_expn.unwrap_or(PanicExpn::Empty); + Some((args, panic_expn)) +} + +fn find_assert_within_debug_assert<'a>( + cx: &LateContext<'_>, + expr: &'a Expr<'a>, + expn: ExpnId, + assert_name: Symbol, +) -> Option<(&'a Expr<'a>, ExpnId)> { + let mut found = None; + expr_visitor_no_bodies(|e| { + if found.is_some() || !e.span.from_expansion() { + return false; + } + let e_expn = e.span.ctxt().outer_expn(); + if e_expn == expn { + return true; + } + if e_expn.expn_data().macro_def_id.map(|id| cx.tcx.item_name(id)) == Some(assert_name) { + found = Some((e, e_expn)); + } + false + }) + .visit_expr(expr); + found +} + +fn is_assert_arg(cx: &LateContext<'_>, expr: &'a Expr<'a>, assert_expn: ExpnId) -> bool { + if !expr.span.from_expansion() { + return true; + } + let result = macro_backtrace(expr.span).try_for_each(|macro_call| { + if macro_call.expn == assert_expn { + ControlFlow::Break(false) + } else { + match cx.tcx.item_name(macro_call.def_id) { + // `cfg!(debug_assertions)` in `debug_assert!` + sym::cfg => ControlFlow::CONTINUE, + // assert!(other_macro!(..)) + _ => ControlFlow::Break(true), + } + } + }); + match result { + ControlFlow::Break(is_assert_arg) => is_assert_arg, + ControlFlow::Continue(()) => true, + } +} + +/// A parsed `format_args!` expansion +pub struct FormatArgsExpn<'tcx> { + /// Span of the first argument, the format string + pub format_string_span: Span, + /// The format string split by formatted args like `{..}` + pub format_string_parts: Vec, + /// Values passed after the format string + pub value_args: Vec<&'tcx Expr<'tcx>>, + /// Each element is a `value_args` index and a formatting trait (e.g. `sym::Debug`) + pub formatters: Vec<(usize, Symbol)>, + /// List of `fmt::v1::Argument { .. }` expressions. If this is empty, + /// then `formatters` represents the format args (`{..}`). + /// If this is non-empty, it represents the format args, and the `position` + /// parameters within the struct expressions are indexes of `formatters`. + pub specs: Vec<&'tcx Expr<'tcx>>, +} + +impl FormatArgsExpn<'tcx> { + /// Parses an expanded `format_args!` or `format_args_nl!` invocation + pub fn parse(cx: &LateContext<'_>, expr: &'tcx Expr<'tcx>) -> Option { + macro_backtrace(expr.span).find(|macro_call| { + matches!( + cx.tcx.item_name(macro_call.def_id), + sym::const_format_args | sym::format_args | sym::format_args_nl + ) + })?; + let mut format_string_span: Option = None; + let mut format_string_parts: Vec = Vec::new(); + let mut value_args: Vec<&Expr<'_>> = Vec::new(); + let mut formatters: Vec<(usize, Symbol)> = Vec::new(); + let mut specs: Vec<&Expr<'_>> = Vec::new(); + expr_visitor_no_bodies(|e| { + // if we're still inside of the macro definition... + if e.span.ctxt() == expr.span.ctxt() { + // ArgumnetV1::new(, ::fmt) + if_chain! { + if let ExprKind::Call(callee, [val, fmt_path]) = e.kind; + if let ExprKind::Path(QPath::TypeRelative(ty, seg)) = callee.kind; + if seg.ident.name == sym::new; + if let hir::TyKind::Path(QPath::Resolved(_, path)) = ty.kind; + if path.segments.last().unwrap().ident.name == sym::ArgumentV1; + if let ExprKind::Path(QPath::Resolved(_, path)) = fmt_path.kind; + if let [.., fmt_trait, _fmt] = path.segments; + then { + let val_idx = if_chain! { + if val.span.ctxt() == expr.span.ctxt(); + if let ExprKind::Field(_, field) = val.kind; + if let Ok(idx) = field.name.as_str().parse(); + then { + // tuple index + idx + } else { + // assume the value expression is passed directly + formatters.len() + } + }; + formatters.push((val_idx, fmt_trait.ident.name)); + } + } + if let ExprKind::Struct(QPath::Resolved(_, path), ..) = e.kind { + if path.segments.last().unwrap().ident.name == sym::Argument { + specs.push(e); + } + } + // walk through the macro expansion + return true; + } + // assume that the first expr with a differing context represents + // (and has the span of) the format string + if format_string_span.is_none() { + format_string_span = Some(e.span); + let span = e.span; + // walk the expr and collect string literals which are format string parts + expr_visitor_no_bodies(|e| { + if e.span.ctxt() != span.ctxt() { + // defensive check, probably doesn't happen + return false; + } + if let ExprKind::Lit(lit) = &e.kind { + if let LitKind::Str(symbol, _s) = lit.node { + format_string_parts.push(symbol); + } + } + true + }) + .visit_expr(e); + } else { + // assume that any further exprs with a differing context are value args + value_args.push(e); + } + // don't walk anything not from the macro expansion (e.a. inputs) + false + }) + .visit_expr(expr); + Some(FormatArgsExpn { + format_string_span: format_string_span?, + format_string_parts, + value_args, + formatters, + specs, + }) + } + + /// Finds a nested call to `format_args!` within a `format!`-like macro call + pub fn find_nested(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, expn_id: ExpnId) -> Option { + let mut format_args = None; + expr_visitor_no_bodies(|e| { + if format_args.is_some() { + return false; + } + let e_ctxt = e.span.ctxt(); + if e_ctxt == expr.span.ctxt() { + return true; + } + if e_ctxt.outer_expn().is_descendant_of(expn_id) { + format_args = FormatArgsExpn::parse(cx, e); + } + false + }) + .visit_expr(expr); + format_args + } + + /// Returns a vector of `FormatArgsArg`. + pub fn args(&self) -> Option>> { + if self.specs.is_empty() { + let args = std::iter::zip(&self.value_args, &self.formatters) + .map(|(value, &(_, format_trait))| FormatArgsArg { + value, + format_trait, + spec: None, + }) + .collect(); + return Some(args); + } + self.specs + .iter() + .map(|spec| { + if_chain! { + // struct `core::fmt::rt::v1::Argument` + if let ExprKind::Struct(_, fields, _) = spec.kind; + if let Some(position_field) = fields.iter().find(|f| f.ident.name == sym::position); + if let ExprKind::Lit(lit) = &position_field.expr.kind; + if let LitKind::Int(position, _) = lit.node; + if let Ok(i) = usize::try_from(position); + if let Some(&(j, format_trait)) = self.formatters.get(i); + then { + Some(FormatArgsArg { value: self.value_args[j], format_trait, spec: Some(spec) }) + } else { + None + } + } + }) + .collect() + } + + /// Span of all inputs + pub fn inputs_span(&self) -> Span { + match *self.value_args { + [] => self.format_string_span, + [.., last] => self.format_string_span.to(last.span), + } + } +} + +/// Type representing a `FormatArgsExpn`'s format arguments +pub struct FormatArgsArg<'tcx> { + /// An element of `value_args` according to `position` + pub value: &'tcx Expr<'tcx>, + /// An element of `args` according to `position` + pub format_trait: Symbol, + /// An element of `specs` + pub spec: Option<&'tcx Expr<'tcx>>, +} + +impl<'tcx> FormatArgsArg<'tcx> { + /// Returns true if any formatting parameters are used that would have an effect on strings, + /// like `{:+2}` instead of just `{}`. + pub fn has_string_formatting(&self) -> bool { + self.spec.map_or(false, |spec| { + // `!` because these conditions check that `self` is unformatted. + !if_chain! { + // struct `core::fmt::rt::v1::Argument` + if let ExprKind::Struct(_, fields, _) = spec.kind; + if let Some(format_field) = fields.iter().find(|f| f.ident.name == sym::format); + // struct `core::fmt::rt::v1::FormatSpec` + if let ExprKind::Struct(_, subfields, _) = format_field.expr.kind; + if subfields.iter().all(|field| match field.ident.name { + sym::precision | sym::width => match field.expr.kind { + ExprKind::Path(QPath::Resolved(_, path)) => { + path.segments.last().unwrap().ident.name == sym::Implied + } + _ => false, + } + _ => true, + }); + then { true } else { false } + } + }) + } +} + +/// A node with a `HirId` and a `Span` +pub trait HirNode { + fn hir_id(&self) -> HirId; + fn span(&self) -> Span; +} + +macro_rules! impl_hir_node { + ($($t:ident),*) => { + $(impl HirNode for hir::$t<'_> { + fn hir_id(&self) -> HirId { + self.hir_id + } + fn span(&self) -> Span { + self.span + } + })* + }; +} + +impl_hir_node!(Expr, Pat); + +impl HirNode for hir::Item<'_> { + fn hir_id(&self) -> HirId { + self.hir_id() + } + + fn span(&self) -> Span { + self.span + } +} diff --git a/clippy_utils/src/paths.rs b/clippy_utils/src/paths.rs index aa3b3af2356..27db53a6e6d 100644 --- a/clippy_utils/src/paths.rs +++ b/clippy_utils/src/paths.rs @@ -25,7 +25,6 @@ pub const ASSERT_MACRO: [&str; 4] = ["core", "macros", "builtin", "assert"]; pub const ASSERT_NE_MACRO: [&str; 3] = ["core", "macros", "assert_ne"]; pub const ASMUT_TRAIT: [&str; 3] = ["core", "convert", "AsMut"]; pub const ASREF_TRAIT: [&str; 3] = ["core", "convert", "AsRef"]; -pub(super) const BEGIN_PANIC: [&str; 3] = ["std", "panicking", "begin_panic"]; /// Preferably use the diagnostic item `sym::Borrow` where possible pub const BORROW_TRAIT: [&str; 3] = ["core", "borrow", "Borrow"]; pub const BORROW_MUT_TRAIT: [&str; 3] = ["core", "borrow", "BorrowMut"]; @@ -110,10 +109,6 @@ pub const OPTION_SOME: [&str; 4] = ["core", "option", "Option", "Some"]; pub const ORD: [&str; 3] = ["core", "cmp", "Ord"]; pub const OS_STRING_AS_OS_STR: [&str; 5] = ["std", "ffi", "os_str", "OsString", "as_os_str"]; pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to_os_string"]; -pub(super) const PANICKING_PANIC: [&str; 3] = ["core", "panicking", "panic"]; -pub(super) const PANICKING_PANIC_FMT: [&str; 3] = ["core", "panicking", "panic_fmt"]; -pub(super) const PANICKING_PANIC_STR: [&str; 3] = ["core", "panicking", "panic_str"]; -pub(super) const PANIC_ANY: [&str; 3] = ["std", "panic", "panic_any"]; pub const PARKING_LOT_RAWMUTEX: [&str; 3] = ["parking_lot", "raw_mutex", "RawMutex"]; pub const PARKING_LOT_RAWRWLOCK: [&str; 3] = ["parking_lot", "raw_rwlock", "RawRwLock"]; pub const PARKING_LOT_MUTEX_GUARD: [&str; 2] = ["parking_lot", "MutexGuard"]; diff --git a/tests/ui/assertions_on_constants.rs b/tests/ui/assertions_on_constants.rs index cb516d0f977..7477c01ca78 100644 --- a/tests/ui/assertions_on_constants.rs +++ b/tests/ui/assertions_on_constants.rs @@ -1,4 +1,3 @@ -//FIXME: suggestions are wrongly expanded, this should be fixed along with #7843 #![allow(non_fmt_panics)] macro_rules! assert_const { diff --git a/tests/ui/assertions_on_constants.stderr b/tests/ui/assertions_on_constants.stderr index ec80ec702fb..e1f818814d5 100644 --- a/tests/ui/assertions_on_constants.stderr +++ b/tests/ui/assertions_on_constants.stderr @@ -1,75 +1,75 @@ error: `assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:11:5 + --> $DIR/assertions_on_constants.rs:10:5 | LL | assert!(true); | ^^^^^^^^^^^^^ | = note: `-D clippy::assertions-on-constants` implied by `-D warnings` = help: remove it - = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert!(false)` should probably be replaced - --> $DIR/assertions_on_constants.rs:12:5 + --> $DIR/assertions_on_constants.rs:11:5 | LL | assert!(false); | ^^^^^^^^^^^^^^ | = help: use `panic!()` or `unreachable!()` - = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:13:5 + --> $DIR/assertions_on_constants.rs:12:5 | LL | assert!(true, "true message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: remove it - = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) -error: `assert!(false, $crate::const_format_args!($($t)+))` should probably be replaced - --> $DIR/assertions_on_constants.rs:14:5 +error: `assert!(false, ..)` should probably be replaced + --> $DIR/assertions_on_constants.rs:13:5 | LL | assert!(false, "false message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: use `panic!($crate::const_format_args!($($t)+))` or `unreachable!($crate::const_format_args!($($t)+))` - = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) + = help: use `panic!(..)` or `unreachable!(..)` + +error: `assert!(false, ..)` should probably be replaced + --> $DIR/assertions_on_constants.rs:16:5 + | +LL | assert!(false, "{}", msg.to_uppercase()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: use `panic!(..)` or `unreachable!(..)` error: `assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:20:5 + --> $DIR/assertions_on_constants.rs:19:5 | LL | assert!(B); | ^^^^^^^^^^ | = help: remove it - = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert!(false)` should probably be replaced - --> $DIR/assertions_on_constants.rs:23:5 + --> $DIR/assertions_on_constants.rs:22:5 | LL | assert!(C); | ^^^^^^^^^^ | = help: use `panic!()` or `unreachable!()` - = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) -error: `assert!(false, $crate::const_format_args!($($t)+))` should probably be replaced - --> $DIR/assertions_on_constants.rs:24:5 +error: `assert!(false, ..)` should probably be replaced + --> $DIR/assertions_on_constants.rs:23:5 | LL | assert!(C, "C message"); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: use `panic!($crate::const_format_args!($($t)+))` or `unreachable!($crate::const_format_args!($($t)+))` - = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) + = help: use `panic!(..)` or `unreachable!(..)` error: `debug_assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:26:5 + --> $DIR/assertions_on_constants.rs:25:5 | LL | debug_assert!(true); | ^^^^^^^^^^^^^^^^^^^ | = help: remove it - = note: this error originates in the macro `$crate::assert` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 8 previous errors +error: aborting due to 9 previous errors diff --git a/tests/ui/eq_op_macros.stderr b/tests/ui/eq_op_macros.stderr index 885415b42c7..cd9f1826e59 100644 --- a/tests/ui/eq_op_macros.stderr +++ b/tests/ui/eq_op_macros.stderr @@ -21,6 +21,28 @@ LL | assert_in_macro_def!(); | = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) +error: identical args used in this `debug_assert_eq!` macro call + --> $DIR/eq_op_macros.rs:9:26 + | +LL | debug_assert_eq!(a, a); + | ^^^^ +... +LL | assert_in_macro_def!(); + | ---------------------- in this macro invocation + | + = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: identical args used in this `debug_assert_ne!` macro call + --> $DIR/eq_op_macros.rs:10:26 + | +LL | debug_assert_ne!(a, a); + | ^^^^ +... +LL | assert_in_macro_def!(); + | ---------------------- in this macro invocation + | + = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) + error: identical args used in this `assert_eq!` macro call --> $DIR/eq_op_macros.rs:22:16 | @@ -45,28 +67,6 @@ error: identical args used in this `assert_ne!` macro call LL | assert_ne!(a + 1, a + 1); | ^^^^^^^^^^^^ -error: identical args used in this `debug_assert_eq!` macro call - --> $DIR/eq_op_macros.rs:9:26 - | -LL | debug_assert_eq!(a, a); - | ^^^^ -... -LL | assert_in_macro_def!(); - | ---------------------- in this macro invocation - | - = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: identical args used in this `debug_assert_ne!` macro call - --> $DIR/eq_op_macros.rs:10:26 - | -LL | debug_assert_ne!(a, a); - | ^^^^ -... -LL | assert_in_macro_def!(); - | ---------------------- in this macro invocation - | - = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) - error: identical args used in this `debug_assert_eq!` macro call --> $DIR/eq_op_macros.rs:38:22 | diff --git a/tests/ui/missing_panics_doc.stderr b/tests/ui/missing_panics_doc.stderr index 8bccbaefe23..91ebd695238 100644 --- a/tests/ui/missing_panics_doc.stderr +++ b/tests/ui/missing_panics_doc.stderr @@ -27,7 +27,6 @@ note: first possible panic found here | LL | panic!("This function panics") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:17:1 @@ -42,7 +41,6 @@ note: first possible panic found here | LL | todo!() | ^^^^^^^ - = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:22:1 @@ -61,7 +59,6 @@ note: first possible panic found here | LL | panic!() | ^^^^^^^^ - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:31:1 @@ -76,7 +73,6 @@ note: first possible panic found here | LL | if true { unreachable!() } else { panic!() } | ^^^^^^^^ - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:36:1 @@ -92,7 +88,6 @@ note: first possible panic found here | LL | assert_eq!(x, 0); | ^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:42:1 @@ -108,7 +103,6 @@ note: first possible panic found here | LL | assert_ne!(x, 0); | ^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 7 previous errors diff --git a/tests/ui/panic_in_result_fn.stderr b/tests/ui/panic_in_result_fn.stderr index 78d09b8b210..561503ae54f 100644 --- a/tests/ui/panic_in_result_fn.stderr +++ b/tests/ui/panic_in_result_fn.stderr @@ -14,7 +14,6 @@ note: return Err() instead of panicking | LL | panic!("error"); | ^^^^^^^^^^^^^^^ - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:11:5 @@ -31,7 +30,6 @@ note: return Err() instead of panicking | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:16:5 @@ -48,7 +46,6 @@ note: return Err() instead of panicking | LL | unreachable!(); | ^^^^^^^^^^^^^^ - = note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info) error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:21:5 @@ -65,7 +62,6 @@ note: return Err() instead of panicking | LL | todo!("Finish this"); | ^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:52:1 @@ -82,7 +78,6 @@ note: return Err() instead of panicking | LL | panic!("error"); | ^^^^^^^^^^^^^^^ - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:67:1 @@ -99,7 +94,6 @@ note: return Err() instead of panicking | LL | todo!("finish main method"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 6 previous errors diff --git a/tests/ui/panic_in_result_fn_assertions.stderr b/tests/ui/panic_in_result_fn_assertions.stderr index 7501d6d85ed..b6aa005e7b5 100644 --- a/tests/ui/panic_in_result_fn_assertions.stderr +++ b/tests/ui/panic_in_result_fn_assertions.stderr @@ -15,7 +15,6 @@ note: return Err() instead of panicking | LL | assert!(x == 5, "wrong argument"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn_assertions.rs:13:5 @@ -33,7 +32,6 @@ note: return Err() instead of panicking | LL | assert_eq!(x, 5); | ^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn_assertions.rs:19:5 @@ -51,7 +49,6 @@ note: return Err() instead of panicking | LL | assert_ne!(x, 1); | ^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/tests/ui/panicking_macros.stderr b/tests/ui/panicking_macros.stderr index 2b607ff5888..bfd1c7a3801 100644 --- a/tests/ui/panicking_macros.stderr +++ b/tests/ui/panicking_macros.stderr @@ -25,23 +25,18 @@ LL | todo!(); | ^^^^^^^ | = note: `-D clippy::todo` implied by `-D warnings` - = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error: `todo` should not be present in production code --> $DIR/panicking_macros.rs:17:5 | LL | todo!("message"); | ^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error: `todo` should not be present in production code --> $DIR/panicking_macros.rs:18:5 | LL | todo!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error: `unimplemented` should not be present in production code --> $DIR/panicking_macros.rs:24:5 @@ -50,23 +45,18 @@ LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::unimplemented` implied by `-D warnings` - = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) error: `unimplemented` should not be present in production code --> $DIR/panicking_macros.rs:25:5 | LL | unimplemented!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) error: `unimplemented` should not be present in production code --> $DIR/panicking_macros.rs:26:5 | LL | unimplemented!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `unreachable!` macro --> $DIR/panicking_macros.rs:32:5 @@ -75,23 +65,18 @@ LL | unreachable!(); | ^^^^^^^^^^^^^^ | = note: `-D clippy::unreachable` implied by `-D warnings` - = note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `unreachable!` macro --> $DIR/panicking_macros.rs:33:5 | LL | unreachable!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `$crate::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `unreachable!` macro --> $DIR/panicking_macros.rs:34:5 | LL | unreachable!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info) error: `panic` should not be present in production code --> $DIR/panicking_macros.rs:40:5 @@ -104,24 +89,18 @@ error: `todo` should not be present in production code | LL | todo!(); | ^^^^^^^ - | - = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info) error: `unimplemented` should not be present in production code --> $DIR/panicking_macros.rs:42:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `unreachable!` macro --> $DIR/panicking_macros.rs:43:5 | LL | unreachable!(); | ^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 16 previous errors diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index 2b5a7b348b9..824506a4257 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -33,8 +33,6 @@ LL | | }, LL | | } LL | | ); | |_____^ - | - = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: `debug_assert_eq` of unit values detected. This will always succeed --> $DIR/unit_cmp.rs:32:5 @@ -47,8 +45,6 @@ LL | | }, LL | | } LL | | ); | |_____^ - | - = note: this error originates in the macro `$crate::assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert_ne` of unit values detected. This will always fail --> $DIR/unit_cmp.rs:41:5 @@ -61,8 +57,6 @@ LL | | }, LL | | } LL | | ); | |_____^ - | - = note: this error originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info) error: `debug_assert_ne` of unit values detected. This will always fail --> $DIR/unit_cmp.rs:49:5 @@ -75,8 +69,6 @@ LL | | }, LL | | } LL | | ); | |_____^ - | - = note: this error originates in the macro `$crate::assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 6 previous errors -- cgit 1.4.1-3-g733a5 From 4e5f69cc869f734d39f74a5b0d9250eb5fc101ce Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Fri, 13 May 2022 14:20:25 +0900 Subject: Tweak some words improved representation This PR has implemented improved representation. - Use "lib" instead of "lifb" - Use "triggered" instead of "triggere" - Use "blacklisted_name" instead of "blackisted_name" - Use "stabilization" instead of "stabilisation" - Use "behavior" instead of "behaviour" - Use "target" instead of "tartet" - Use "checked_add" instead of "chcked_add" - Use "anti-pattern" instead of "antipattern" - Use "suggestion" instead of "suggesttion" - Use "example" instead of "exampel" - Use "Cheat Sheet" instead of "Cheatsheet" --- clippy_dev/src/main.rs | 2 +- clippy_dev/src/new_lint.rs | 4 ++-- clippy_lints/src/assign_ops.rs | 2 +- clippy_lints/src/casts/cast_slice_different_sizes.rs | 2 +- clippy_lints/src/casts/mod.rs | 2 +- clippy_lints/src/default_union_representation.rs | 4 ++-- clippy_lints/src/derive.rs | 4 ++-- clippy_lints/src/main_recursion.rs | 2 +- clippy_lints/src/methods/mod.rs | 2 +- clippy_lints/src/mutable_debug_assertion.rs | 2 +- clippy_lints/src/needless_bitwise_bool.rs | 4 ++-- clippy_lints/src/pass_by_ref_or_value.rs | 2 +- clippy_lints/src/redundant_clone.rs | 2 +- clippy_lints/src/transmute/mod.rs | 4 ++-- doc/adding_lints.md | 4 ++-- tests/ui/blacklisted_name.rs | 4 ++-- 16 files changed, 23 insertions(+), 23 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index dcfaabbc204..d5cd7ca96c0 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -124,7 +124,7 @@ fn get_clap_config<'a>() -> ArgMatches<'a> { * the lint count in README.md is correct\n \ * the changelog contains markdown link references at the bottom\n \ * all lint groups include the correct lints\n \ - * lint modules in `clippy_lints/*` are visible in `src/lifb.rs` via `pub mod`\n \ + * lint modules in `clippy_lints/*` are visible in `src/lib.rs` via `pub mod`\n \ * all lints are registered in the lint store", ) .arg(Arg::with_name("print-only").long("print-only").help( diff --git a/clippy_dev/src/new_lint.rs b/clippy_dev/src/new_lint.rs index 10f67d301f8..07d19638788 100644 --- a/clippy_dev/src/new_lint.rs +++ b/clippy_dev/src/new_lint.rs @@ -133,7 +133,7 @@ fn to_camel_case(name: &str) -> String { .collect() } -fn get_stabilisation_version() -> String { +fn get_stabilization_version() -> String { fn parse_manifest(contents: &str) -> Option { let version = contents .lines() @@ -199,7 +199,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String { }, }; - let version = get_stabilisation_version(); + let version = get_stabilization_version(); let lint_name = lint.name; let category = lint.category; let name_camel = to_camel_case(lint.name); diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 12c1bddf79d..4c2d3366483 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -50,7 +50,7 @@ declare_clippy_lint! { /// ### Known problems /// Clippy cannot know for sure if `a op= a op b` should have /// been `a = a op a op b` or `a = a op b`/`a op= b`. Therefore, it suggests both. - /// If `a op= a op b` is really the correct behaviour it should be + /// If `a op= a op b` is really the correct behavior it should be /// written as `a = a op a op b` as it's less confusing. /// /// ### Example diff --git a/clippy_lints/src/casts/cast_slice_different_sizes.rs b/clippy_lints/src/casts/cast_slice_different_sizes.rs index bb09a6708a0..027c660ce3b 100644 --- a/clippy_lints/src/casts/cast_slice_different_sizes.rs +++ b/clippy_lints/src/casts/cast_slice_different_sizes.rs @@ -121,7 +121,7 @@ fn expr_cast_chain_tys<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) -> Optio let to_slice_ty = get_raw_slice_ty_mut(cast_to)?; // If the expression that makes up the source of this cast is itself a cast, recursively - // call `expr_cast_chain_tys` and update the end type with the final tartet type. + // call `expr_cast_chain_tys` and update the end type with the final target type. // Otherwise, this cast is not immediately nested, just construct the info for this cast if let Some(prev_info) = expr_cast_chain_tys(cx, cast_expr) { Some(CastChainInfo { diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index 108e119c104..daf3b7b4ce4 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -306,7 +306,7 @@ declare_clippy_lint! { /// Checks for casts of `&T` to `&mut T` anywhere in the code. /// /// ### Why is this bad? - /// It’s basically guaranteed to be undefined behaviour. + /// It’s basically guaranteed to be undefined behavior. /// `UnsafeCell` is the only way to obtain aliasable data that is considered /// mutable. /// diff --git a/clippy_lints/src/default_union_representation.rs b/clippy_lints/src/default_union_representation.rs index 9b5da0bd8a6..d559ad423df 100644 --- a/clippy_lints/src/default_union_representation.rs +++ b/clippy_lints/src/default_union_representation.rs @@ -25,7 +25,7 @@ declare_clippy_lint! { /// /// fn main() { /// let _x: u32 = unsafe { - /// Foo { a: 0_i32 }.b // Undefined behaviour: `b` is allowed to be padding + /// Foo { a: 0_i32 }.b // Undefined behavior: `b` is allowed to be padding /// }; /// } /// ``` @@ -39,7 +39,7 @@ declare_clippy_lint! { /// /// fn main() { /// let _x: u32 = unsafe { - /// Foo { a: 0_i32 }.b // Now defined behaviour, this is just an i32 -> u32 transmute + /// Foo { a: 0_i32 }.b // Now defined behavior, this is just an i32 -> u32 transmute /// }; /// } /// ``` diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index a4757ebd8c7..fbbc5bf78a5 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -102,8 +102,8 @@ declare_clippy_lint! { /// types. /// /// ### Why is this bad? - /// To avoid surprising behaviour, these traits should - /// agree and the behaviour of `Copy` cannot be overridden. In almost all + /// To avoid surprising behavior, these traits should + /// agree and the behavior of `Copy` cannot be overridden. In almost all /// situations a `Copy` type should have a `Clone` implementation that does /// nothing more than copy the object, which is what `#[derive(Copy, Clone)]` /// gets you. diff --git a/clippy_lints/src/main_recursion.rs b/clippy_lints/src/main_recursion.rs index fad8fa467d4..20333c150e3 100644 --- a/clippy_lints/src/main_recursion.rs +++ b/clippy_lints/src/main_recursion.rs @@ -12,7 +12,7 @@ declare_clippy_lint! { /// /// ### Why is this bad? /// Apart from special setups (which we could detect following attributes like #![no_std]), - /// recursing into main() seems like an unintuitive antipattern we should be able to detect. + /// recursing into main() seems like an unintuitive anti-pattern we should be able to detect. /// /// ### Example /// ```no_run diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 3e07961fcb3..35fc452ed7c 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1563,7 +1563,7 @@ declare_clippy_lint! { #[clippy::version = "1.39.0"] pub MANUAL_SATURATING_ARITHMETIC, style, - "`.chcked_add/sub(x).unwrap_or(MAX/MIN)`" + "`.checked_add/sub(x).unwrap_or(MAX/MIN)`" } declare_clippy_lint! { diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 4ba68c8eacd..8dba60f3a58 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -16,7 +16,7 @@ declare_clippy_lint! { /// ### Why is this bad? /// In release builds `debug_assert!` macros are optimized out by the /// compiler. - /// Therefore mutating something in a `debug_assert!` macro results in different behaviour + /// Therefore mutating something in a `debug_assert!` macro results in different behavior /// between a release and debug build. /// /// ### Example diff --git a/clippy_lints/src/needless_bitwise_bool.rs b/clippy_lints/src/needless_bitwise_bool.rs index 95395e2e136..623d22bc9bd 100644 --- a/clippy_lints/src/needless_bitwise_bool.rs +++ b/clippy_lints/src/needless_bitwise_bool.rs @@ -53,7 +53,7 @@ fn is_bitwise_operation(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { false } -fn suggesstion_snippet(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { +fn suggestion_snippet(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { if let ExprKind::Binary(ref op, left, right) = expr.kind { if let (Some(l_snippet), Some(r_snippet)) = (snippet_opt(cx, left.span), snippet_opt(cx, right.span)) { let op_snippet = match op.node { @@ -75,7 +75,7 @@ impl LateLintPass<'_> for NeedlessBitwiseBool { expr.span, "use of bitwise operator instead of lazy operator between booleans", |diag| { - if let Some(sugg) = suggesstion_snippet(cx, expr) { + if let Some(sugg) = suggestion_snippet(cx, expr) { diag.span_suggestion(expr.span, "try", sugg, Applicability::MachineApplicable); } }, diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index c5b8b8103a1..e3ded716341 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -52,7 +52,7 @@ declare_clippy_lint! { /// to a function that needs the memory address. For further details, refer to /// [this issue](https://github.com/rust-lang/rust-clippy/issues/5953) /// that explains a real case in which this false positive - /// led to an **undefined behaviour** introduced with unsafe code. + /// led to an **undefined behavior** introduced with unsafe code. /// /// ### Example /// diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 9904617353f..b19f9aff611 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -632,7 +632,7 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> { } /// Collect possible borrowed for every `&mut` local. -/// For exampel, `_1 = &mut _2` generate _1: {_2,...} +/// For example, `_1 = &mut _2` generate _1: {_2,...} /// Known Problems: not sure all borrowed are tracked struct PossibleOriginVisitor<'a, 'tcx> { possible_origin: TransitiveRelation, diff --git a/clippy_lints/src/transmute/mod.rs b/clippy_lints/src/transmute/mod.rs index 342f23f030c..d2a040beb0c 100644 --- a/clippy_lints/src/transmute/mod.rs +++ b/clippy_lints/src/transmute/mod.rs @@ -27,7 +27,7 @@ declare_clippy_lint! { /// architecture. /// /// ### Why is this bad? - /// It's basically guaranteed to be undefined behaviour. + /// It's basically guaranteed to be undefined behavior. /// /// ### Known problems /// When accessing C, users might want to store pointer @@ -40,7 +40,7 @@ declare_clippy_lint! { #[clippy::version = "pre 1.29.0"] pub WRONG_TRANSMUTE, correctness, - "transmutes that are confusing at best, undefined behaviour at worst and always useless" + "transmutes that are confusing at best, undefined behavior at worst and always useless" } // FIXME: Move this to `complexity` again, after #5343 is fixed diff --git a/doc/adding_lints.md b/doc/adding_lints.md index 4dc94d9f5a5..e8f0c338fd5 100644 --- a/doc/adding_lints.md +++ b/doc/adding_lints.md @@ -28,7 +28,7 @@ because that's clearly a non-descriptive name. - [Debugging](#debugging) - [PR Checklist](#pr-checklist) - [Adding configuration to a lint](#adding-configuration-to-a-lint) - - [Cheatsheet](#cheatsheet) + - [Cheat Sheet](#cheat-sheet) ## Setup @@ -649,7 +649,7 @@ in the following steps: with the configuration value and a rust file that should be linted by Clippy. The test can otherwise be written as usual. -## Cheatsheet +## Cheat Sheet Here are some pointers to things you are likely going to need for every lint: diff --git a/tests/ui/blacklisted_name.rs b/tests/ui/blacklisted_name.rs index 57d7139fef5..27df732a088 100644 --- a/tests/ui/blacklisted_name.rs +++ b/tests/ui/blacklisted_name.rs @@ -46,10 +46,10 @@ fn issue_1647_ref_mut() { mod tests { fn issue_7305() { - // `blackisted_name` lint should not be triggered inside of the test code. + // `blacklisted_name` lint should not be triggered inside of the test code. let foo = 0; - // Check that even in nested functions warning is still not triggere. + // Check that even in nested functions warning is still not triggered. fn nested() { let foo = 0; } -- cgit 1.4.1-3-g733a5 From b20f95c1a1780934367a019a6adba4ec74895716 Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Wed, 1 Jun 2022 18:36:02 -0400 Subject: Combine doc examples --- clippy_lints/src/as_conversions.rs | 7 +- clippy_lints/src/attrs.rs | 6 +- clippy_lints/src/blocks_in_if_conditions.rs | 12 ++-- clippy_lints/src/double_parens.rs | 14 ++-- clippy_lints/src/eq_op.rs | 6 +- clippy_lints/src/loops/mod.rs | 15 ++--- clippy_lints/src/methods/mod.rs | 99 ++++++++++++----------------- clippy_lints/src/minmax.rs | 8 +-- clippy_lints/src/misc.rs | 14 ++-- clippy_lints/src/mutable_debug_assertion.rs | 7 +- clippy_lints/src/trait_bounds.rs | 10 +-- 11 files changed, 88 insertions(+), 110 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/as_conversions.rs b/clippy_lints/src/as_conversions.rs index 5fa8934c71b..6e5c8f44581 100644 --- a/clippy_lints/src/as_conversions.rs +++ b/clippy_lints/src/as_conversions.rs @@ -32,12 +32,11 @@ declare_clippy_lint! { /// Use instead: /// ```rust,ignore /// f(a.try_into()?); - /// ``` - /// or - /// ```rust,ignore + /// + /// // or + /// /// f(a.try_into().expect("Unexpected u16 overflow in f")); /// ``` - /// #[clippy::version = "1.41.0"] pub AS_CONVERSIONS, restriction, diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 79a5b670fc8..770cb6a3d7b 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -241,13 +241,13 @@ declare_clippy_lint! { /// /// Use instead: /// ```rust + /// # mod hidden { /// #[cfg(target_os = "linux")] /// fn conditional() { } - /// ``` + /// # } /// - /// or + /// // or /// - /// ```rust /// #[cfg(unix)] /// fn conditional() { } /// ``` diff --git a/clippy_lints/src/blocks_in_if_conditions.rs b/clippy_lints/src/blocks_in_if_conditions.rs index 86e28ea7f7a..5bd7a342389 100644 --- a/clippy_lints/src/blocks_in_if_conditions.rs +++ b/clippy_lints/src/blocks_in_if_conditions.rs @@ -22,21 +22,17 @@ declare_clippy_lint! { /// /// ### Examples /// ```rust - /// // Bad + /// # fn somefunc() -> bool { true }; /// if { true } { /* ... */ } /// - /// // Good - /// if true { /* ... */ } + /// if { let x = somefunc(); x } { /* ... */ } /// ``` /// - /// or - /// + /// Use instead: /// ```rust /// # fn somefunc() -> bool { true }; - /// // Bad - /// if { let x = somefunc(); x } { /* ... */ } + /// if true { /* ... */ } /// - /// // Good /// let res = { let x = somefunc(); x }; /// if res { /* ... */ } /// ``` diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index e10f740d24a..a33ef5ce6e3 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -13,23 +13,21 @@ declare_clippy_lint! { /// /// ### Example /// ```rust - /// // Bad /// fn simple_double_parens() -> i32 { /// ((0)) /// } /// - /// // Good + /// # fn foo(bar: usize) {} + /// foo((0)); + /// ``` + /// + /// Use instead: + /// ```rust /// fn simple_no_parens() -> i32 { /// 0 /// } /// - /// // or - /// /// # fn foo(bar: usize) {} - /// // Bad - /// foo((0)); - /// - /// // Good /// foo(0); /// ``` #[clippy::version = "pre 1.29.0"] diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index afb5d32f953..c3176d987c6 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -30,9 +30,9 @@ declare_clippy_lint! { /// ```rust /// # let x = 1; /// if x + 1 == x + 1 {} - /// ``` - /// or - /// ```rust + /// + /// // or + /// /// # let a = 3; /// # let b = 4; /// assert_eq!(a, a); diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 417248e31ae..d61be78895f 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -180,29 +180,24 @@ declare_clippy_lint! { /// ### Example /// ```rust /// # let opt = Some(1); - /// - /// // Bad + /// # let res: Result = Ok(1); /// for x in opt { /// // .. /// } /// - /// // Good - /// if let Some(x) = opt { + /// for x in &res { /// // .. /// } /// ``` /// - /// or - /// + /// Use instead: /// ```rust + /// # let opt = Some(1); /// # let res: Result = Ok(1); - /// - /// // Bad - /// for x in &res { + /// if let Some(x) = opt { /// // .. /// } /// - /// // Good /// if let Ok(x) = res { /// // .. /// } diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index eb1bce8c7d2..08c89ceb796 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -194,25 +194,18 @@ declare_clippy_lint! { /// /// ### Examples /// ```rust - /// # let opt = Some(1); - /// - /// // Bad - /// opt.unwrap(); - /// - /// // Good - /// opt.expect("more helpful message"); + /// # let option = Some(1); + /// # let result: Result = Ok(1); + /// option.unwrap(); + /// result.unwrap(); /// ``` /// - /// or - /// + /// Use instead: /// ```rust - /// # let res: Result = Ok(1); - /// - /// // Bad - /// res.unwrap(); - /// - /// // Good - /// res.expect("more helpful message"); + /// # let option = Some(1); + /// # let result: Result = Ok(1); + /// option.expect("more helpful message"); + /// result.expect("more helpful message"); /// ``` #[clippy::version = "1.45.0"] pub UNWRAP_USED, @@ -235,27 +228,21 @@ declare_clippy_lint! { /// /// ### Examples /// ```rust,ignore - /// # let opt = Some(1); - /// - /// // Bad - /// opt.expect("one"); - /// - /// // Good - /// let opt = Some(1); - /// opt?; + /// # let option = Some(1); + /// # let result: Result = Ok(1); + /// option.expect("one"); + /// result.expect("one"); /// ``` /// - /// or - /// - /// ```rust - /// # let res: Result = Ok(1); + /// Use instead: + /// ```rust,ignore + /// # let option = Some(1); + /// # let result: Result = Ok(1); + /// option?; /// - /// // Bad - /// res.expect("one"); + /// // or /// - /// // Good - /// res?; - /// # Ok::<(), ()>(()) + /// result?; /// ``` #[clippy::version = "1.45.0"] pub EXPECT_USED, @@ -431,26 +418,20 @@ declare_clippy_lint! { /// /// ### Examples /// ```rust - /// # let x = Some(1); - /// - /// // Bad - /// x.map(|a| a + 1).unwrap_or(0); - /// - /// // Good - /// x.map_or(0, |a| a + 1); + /// # let option = Some(1); + /// # let result: Result = Ok(1); + /// # fn some_function(foo: ()) -> usize { 1 } + /// option.map(|a| a + 1).unwrap_or(0); + /// result.map(|a| a + 1).unwrap_or_else(some_function); /// ``` /// - /// or - /// + /// Use instead: /// ```rust - /// # let x: Result = Ok(1); + /// # let option = Some(1); + /// # let result: Result = Ok(1); /// # fn some_function(foo: ()) -> usize { 1 } - /// - /// // Bad - /// x.map(|a| a + 1).unwrap_or_else(some_function); - /// - /// // Good - /// x.map_or_else(some_function, |a| a + 1); + /// option.map_or(0, |a| a + 1); + /// result.map_or_else(some_function, |a| a + 1); /// ``` #[clippy::version = "1.45.0"] pub MAP_UNWRAP_OR, @@ -793,13 +774,14 @@ declare_clippy_lint! { /// # let foo = Some(String::new()); /// foo.unwrap_or(String::new()); /// ``` - /// this can instead be written: + /// + /// Use instead: /// ```rust /// # let foo = Some(String::new()); /// foo.unwrap_or_else(String::new); - /// ``` - /// or - /// ```rust + /// + /// // or + /// /// # let foo = Some(String::new()); /// foo.unwrap_or_default(); /// ``` @@ -863,15 +845,14 @@ declare_clippy_lint! { /// # let err_code = "418"; /// # let err_msg = "I'm a teapot"; /// foo.expect(&format!("Err {}: {}", err_code, err_msg)); - /// ``` - /// or - /// ```rust + /// + /// // or + /// /// # let foo = Some(String::new()); - /// # let err_code = "418"; - /// # let err_msg = "I'm a teapot"; /// foo.expect(format!("Err {}: {}", err_code, err_msg).as_str()); /// ``` - /// this can instead be written: + /// + /// Use instead: /// ```rust /// # let foo = Some(String::new()); /// # let err_code = "418"; diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index 65d1f440b76..a081cde8572 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -18,11 +18,11 @@ declare_clippy_lint! { /// the least it hurts readability of the code. /// /// ### Example - /// ```ignore + /// ```rust,ignore /// min(0, max(100, x)) - /// ``` - /// or - /// ```ignore + /// + /// // or + /// /// x.max(100).min(0) /// ``` /// It will always be equal to `0`. Probably the author meant to clamp the value diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 7fdc28c5a06..55665699453 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -103,11 +103,14 @@ declare_clippy_lint! { /// let x = 1.2331f64; /// let y = 1.2332f64; /// - /// // Bad /// if y == 1.23f64 { } /// if y != x {} // where both are floats + /// ``` /// - /// // Good + /// Use instead: + /// ```rust + /// # let x = 1.2331f64; + /// # let y = 1.2332f64; /// let error_margin = f64::EPSILON; // Use an epsilon for comparison /// // Or, if Rust <= 1.42, use `std::f64::EPSILON` constant instead. /// // let error_margin = std::f64::EPSILON; @@ -258,10 +261,13 @@ declare_clippy_lint! { /// let x: f64 = 1.0; /// const ONE: f64 = 1.00; /// - /// // Bad /// if x == ONE { } // where both are floats + /// ``` /// - /// // Good + /// Use instead: + /// ```rust + /// # let x: f64 = 1.0; + /// # const ONE: f64 = 1.00; /// let error_margin = f64::EPSILON; // Use an epsilon for comparison /// // Or, if Rust <= 1.42, use `std::f64::EPSILON` constant instead. /// // let error_margin = std::f64::EPSILON; diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 8dba60f3a58..321db08dfe8 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -22,9 +22,12 @@ declare_clippy_lint! { /// ### Example /// ```rust,ignore /// debug_assert_eq!(vec![3].pop(), Some(3)); + /// /// // or - /// fn take_a_mut_parameter(_: &mut u32) -> bool { unimplemented!() } - /// debug_assert!(take_a_mut_parameter(&mut 5)); + /// + /// # let mut x = 5; + /// # fn takes_a_mut_parameter(_: &mut u32) -> bool { unimplemented!() } + /// debug_assert!(takes_a_mut_parameter(&mut x)); /// ``` #[clippy::version = "1.40.0"] pub DEBUG_ASSERT_WITH_MUT_CALL, diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index 6c60fb4b8e0..b91be0eb4be 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -54,14 +54,14 @@ declare_clippy_lint! { /// fn func(arg: T) where T: Clone + Default {} /// ``` /// - /// Could be written as: - /// + /// Use instead: /// ```rust + /// # mod hidden { /// fn func(arg: T) {} - /// ``` - /// or + /// # } + /// + /// // or /// - /// ```rust /// fn func(arg: T) where T: Clone + Default {} /// ``` #[clippy::version = "1.47.0"] -- cgit 1.4.1-3-g733a5 From e67b2bf732876eeb26e0d2fbc4b6c55e1a9f9317 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Fri, 23 Sep 2022 13:42:59 -0400 Subject: Apply uninlined_format-args to clippy_lints This change is needed for the uninlined_format-args lint to be merged. See https://github.com/rust-lang/rust-clippy/pull/9233 --- clippy_lints/src/approx_const.rs | 4 +-- clippy_lints/src/asm_syntax.rs | 2 +- clippy_lints/src/assertions_on_constants.rs | 4 +-- clippy_lints/src/assertions_on_result_states.rs | 10 +++--- clippy_lints/src/attrs.rs | 7 ++-- clippy_lints/src/bool_assert_comparison.rs | 4 +-- clippy_lints/src/booleans.rs | 5 ++- clippy_lints/src/cargo/common_metadata.rs | 2 +- clippy_lints/src/cargo/feature_name.rs | 4 +-- clippy_lints/src/cargo/mod.rs | 4 +-- clippy_lints/src/cargo/multiple_crate_versions.rs | 2 +- clippy_lints/src/casts/borrow_as_ptr.rs | 2 +- clippy_lints/src/casts/cast_lossless.rs | 12 ++----- clippy_lints/src/casts/cast_possible_truncation.rs | 16 +++------ clippy_lints/src/casts/cast_possible_wrap.rs | 5 +-- clippy_lints/src/casts/cast_ptr_alignment.rs | 4 +-- clippy_lints/src/casts/cast_sign_loss.rs | 5 +-- .../src/casts/cast_slice_different_sizes.rs | 4 +-- clippy_lints/src/casts/char_lit_as_u8.rs | 2 +- clippy_lints/src/casts/fn_to_numeric_cast.rs | 4 +-- clippy_lints/src/casts/fn_to_numeric_cast_any.rs | 4 +-- .../casts/fn_to_numeric_cast_with_truncation.rs | 7 ++-- clippy_lints/src/casts/ptr_as_ptr.rs | 4 +-- clippy_lints/src/casts/unnecessary_cast.rs | 9 ++--- clippy_lints/src/checked_conversions.rs | 2 +- clippy_lints/src/cognitive_complexity.rs | 3 +- clippy_lints/src/default.rs | 17 ++++----- clippy_lints/src/default_numeric_fallback.rs | 4 +-- clippy_lints/src/dereference.rs | 14 ++++---- clippy_lints/src/disallowed_methods.rs | 2 +- clippy_lints/src/disallowed_script_idents.rs | 3 +- clippy_lints/src/disallowed_types.rs | 4 +-- clippy_lints/src/doc.rs | 2 +- clippy_lints/src/drop_forget_ref.rs | 2 +- clippy_lints/src/entry.rs | 28 ++++----------- clippy_lints/src/enum_variants.rs | 7 ++-- clippy_lints/src/equatable_if_let.rs | 3 +- clippy_lints/src/eta_reduction.rs | 4 +-- clippy_lints/src/exhaustive_items.rs | 2 +- clippy_lints/src/explicit_write.rs | 8 ++--- clippy_lints/src/float_literal.rs | 6 ++-- clippy_lints/src/floating_point_arithmetic.rs | 7 ++-- clippy_lints/src/format.rs | 2 +- clippy_lints/src/format_args.rs | 17 ++++----- clippy_lints/src/format_impl.rs | 6 ++-- clippy_lints/src/formatting.rs | 25 +++++--------- clippy_lints/src/from_str_radix_10.rs | 2 +- clippy_lints/src/functions/must_use.rs | 2 +- clippy_lints/src/functions/too_many_arguments.rs | 5 +-- clippy_lints/src/functions/too_many_lines.rs | 5 +-- clippy_lints/src/if_then_some_else_none.rs | 9 +++-- clippy_lints/src/implicit_hasher.rs | 7 ++-- clippy_lints/src/implicit_return.rs | 4 +-- clippy_lints/src/implicit_saturating_sub.rs | 2 +- .../src/inconsistent_struct_constructor.rs | 6 ++-- clippy_lints/src/index_refutable_slice.rs | 4 +-- clippy_lints/src/inherent_to_string.rs | 12 +++---- clippy_lints/src/inline_fn_without_body.rs | 2 +- clippy_lints/src/int_plus_one.rs | 4 +-- clippy_lints/src/iter_not_returning_iterator.rs | 5 +-- clippy_lints/src/len_zero.rs | 35 ++++++++----------- clippy_lints/src/let_if_seq.rs | 3 +- clippy_lints/src/lib.rs | 11 +++--- clippy_lints/src/literal_representation.rs | 2 +- clippy_lints/src/loops/explicit_counter_loop.rs | 14 +++----- clippy_lints/src/loops/explicit_iter_loop.rs | 2 +- clippy_lints/src/loops/for_kv_map.rs | 4 +-- clippy_lints/src/loops/manual_flatten.rs | 2 +- clippy_lints/src/loops/manual_memcpy.rs | 13 ++----- clippy_lints/src/loops/needless_collect.rs | 6 ++-- clippy_lints/src/loops/needless_range_loop.rs | 10 +++--- clippy_lints/src/loops/never_loop.rs | 6 +--- clippy_lints/src/loops/same_item_push.rs | 5 +-- clippy_lints/src/loops/utils.rs | 3 +- clippy_lints/src/loops/while_let_on_iterator.rs | 2 +- clippy_lints/src/macro_use.rs | 6 ++-- clippy_lints/src/manual_async_fn.rs | 6 ++-- clippy_lints/src/manual_non_exhaustive.rs | 4 +-- clippy_lints/src/manual_retain.rs | 14 +++----- clippy_lints/src/manual_strip.rs | 9 +++-- clippy_lints/src/map_unit_fn.rs | 5 +-- clippy_lints/src/match_result_ok.rs | 6 ++-- clippy_lints/src/matches/manual_map.rs | 14 ++++---- clippy_lints/src/matches/manual_unwrap_or.rs | 6 ++-- clippy_lints/src/matches/match_as_ref.rs | 6 ++-- clippy_lints/src/matches/match_like_matches.rs | 5 ++- clippy_lints/src/matches/match_same_arms.rs | 2 +- clippy_lints/src/matches/match_single_binding.rs | 28 ++++++--------- .../src/matches/match_str_case_mismatch.rs | 4 +-- clippy_lints/src/matches/match_wild_err_arm.rs | 2 +- .../src/matches/redundant_pattern_match.rs | 8 ++--- .../src/matches/significant_drop_in_scrutinee.rs | 6 ++-- clippy_lints/src/matches/single_match.rs | 6 ++-- clippy_lints/src/matches/try_err.rs | 4 +-- clippy_lints/src/methods/bind_instead_of_map.rs | 2 +- clippy_lints/src/methods/bytes_nth.rs | 2 +- clippy_lints/src/methods/chars_cmp.rs | 5 ++- clippy_lints/src/methods/chars_cmp_with_unwrap.rs | 5 ++- clippy_lints/src/methods/clone_on_copy.rs | 13 ++++--- clippy_lints/src/methods/clone_on_ref_ptr.rs | 2 +- clippy_lints/src/methods/expect_fun_call.rs | 11 +++--- clippy_lints/src/methods/filetype_is_file.rs | 4 +-- clippy_lints/src/methods/filter_map_next.rs | 2 +- clippy_lints/src/methods/filter_next.rs | 2 +- .../src/methods/from_iter_instead_of_collect.rs | 6 ++-- clippy_lints/src/methods/get_first.rs | 4 +-- clippy_lints/src/methods/get_unwrap.rs | 11 ++---- clippy_lints/src/methods/implicit_clone.rs | 6 ++-- clippy_lints/src/methods/inefficient_to_string.rs | 7 ++-- clippy_lints/src/methods/into_iter_on_ref.rs | 3 +- clippy_lints/src/methods/is_digit_ascii_radix.rs | 7 ++-- clippy_lints/src/methods/iter_cloned_collect.rs | 4 +-- clippy_lints/src/methods/iter_count.rs | 2 +- clippy_lints/src/methods/iter_kv_map.rs | 8 ++--- clippy_lints/src/methods/iter_next_slice.rs | 2 +- clippy_lints/src/methods/iter_nth.rs | 4 +-- clippy_lints/src/methods/iter_with_drain.rs | 2 +- clippy_lints/src/methods/manual_ok_or.rs | 4 +-- .../src/methods/manual_saturating_arithmetic.rs | 5 ++- clippy_lints/src/methods/manual_str_repeat.rs | 2 +- clippy_lints/src/methods/map_clone.rs | 5 ++- clippy_lints/src/methods/map_flatten.rs | 9 ++--- clippy_lints/src/methods/map_identity.rs | 2 +- clippy_lints/src/methods/map_unwrap_or.rs | 2 +- clippy_lints/src/methods/option_as_ref_deref.rs | 9 +++-- clippy_lints/src/methods/option_map_or_none.rs | 6 ++-- clippy_lints/src/methods/option_map_unwrap_or.rs | 9 +++-- clippy_lints/src/methods/or_fun_call.rs | 10 +++--- clippy_lints/src/methods/search_is_some.rs | 14 +++----- .../src/methods/single_char_insert_string.rs | 2 +- .../src/methods/single_char_push_string.rs | 2 +- clippy_lints/src/methods/stable_sort_primitive.rs | 4 +-- clippy_lints/src/methods/string_extend_chars.rs | 3 +- clippy_lints/src/methods/suspicious_splitn.rs | 4 +-- clippy_lints/src/methods/suspicious_to_owned.rs | 4 +-- clippy_lints/src/methods/unnecessary_filter_map.rs | 2 +- clippy_lints/src/methods/unnecessary_fold.rs | 7 ++-- .../src/methods/unnecessary_iter_cloned.rs | 2 +- clippy_lints/src/methods/unnecessary_lazy_eval.rs | 4 +-- clippy_lints/src/methods/unnecessary_to_owned.rs | 21 ++++++------ clippy_lints/src/methods/useless_asref.rs | 2 +- clippy_lints/src/methods/wrong_self_convention.rs | 15 ++++---- clippy_lints/src/misc.rs | 18 ++++------ clippy_lints/src/misc_early/literal_suffix.rs | 8 ++--- clippy_lints/src/misc_early/mod.rs | 5 ++- .../src/misc_early/unneeded_field_pattern.rs | 4 +-- clippy_lints/src/mismatching_type_param_order.rs | 7 ++-- clippy_lints/src/missing_doc.rs | 2 +- clippy_lints/src/missing_enforced_import_rename.rs | 4 +-- clippy_lints/src/missing_inline.rs | 2 +- clippy_lints/src/mut_reference.rs | 2 +- clippy_lints/src/mutable_debug_assertion.rs | 5 +-- clippy_lints/src/mutex_atomic.rs | 5 ++- clippy_lints/src/needless_continue.rs | 14 +++----- clippy_lints/src/needless_late_init.rs | 10 +++--- clippy_lints/src/needless_pass_by_value.rs | 4 +-- clippy_lints/src/needless_question_mark.rs | 2 +- clippy_lints/src/neg_multiply.rs | 4 +-- clippy_lints/src/new_without_default.rs | 7 ++-- clippy_lints/src/non_expressive_names.rs | 5 +-- clippy_lints/src/nonstandard_macro_braces.rs | 12 +++---- clippy_lints/src/octal_escapes.rs | 2 +- .../src/operators/absurd_extreme_comparisons.rs | 5 ++- clippy_lints/src/operators/assign_op_pattern.rs | 2 +- clippy_lints/src/operators/bit_mask.rs | 40 +++++----------------- clippy_lints/src/operators/cmp_owned.rs | 10 +++--- clippy_lints/src/operators/duration_subsec.rs | 7 ++-- clippy_lints/src/operators/eq_op.rs | 2 +- .../src/operators/misrefactored_assign_op.rs | 12 +++---- .../src/operators/needless_bitwise_bool.rs | 2 +- clippy_lints/src/operators/ptr_eq.rs | 2 +- clippy_lints/src/operators/self_assignment.rs | 2 +- clippy_lints/src/operators/verbose_bit_mask.rs | 2 +- clippy_lints/src/option_if_let_else.rs | 2 +- clippy_lints/src/pass_by_ref_or_value.rs | 4 +-- clippy_lints/src/ptr.rs | 2 +- clippy_lints/src/ptr_offset_with_cast.rs | 4 +-- clippy_lints/src/question_mark.rs | 7 ++-- clippy_lints/src/ranges.rs | 16 ++++----- clippy_lints/src/read_zero_byte_vec.rs | 3 +- clippy_lints/src/redundant_pub_crate.rs | 2 +- clippy_lints/src/redundant_slicing.rs | 8 ++--- clippy_lints/src/redundant_static_lifetimes.rs | 2 +- clippy_lints/src/regex.rs | 4 +-- clippy_lints/src/same_name_method.rs | 4 +-- clippy_lints/src/semicolon_if_nothing_returned.rs | 2 +- clippy_lints/src/slow_vector_initialization.rs | 2 +- clippy_lints/src/strings.rs | 6 ++-- clippy_lints/src/strlen_on_c_strings.rs | 2 +- clippy_lints/src/suspicious_operation_groupings.rs | 9 ++--- clippy_lints/src/swap.rs | 19 +++++----- clippy_lints/src/swap_ptr_to_ref.rs | 2 +- clippy_lints/src/to_digit_is_some.rs | 4 +-- clippy_lints/src/trait_bounds.rs | 3 +- .../src/transmute/crosspointer_transmute.rs | 10 ++---- .../src/transmute/transmute_float_to_int.rs | 4 +-- .../src/transmute/transmute_int_to_bool.rs | 2 +- .../src/transmute/transmute_int_to_char.rs | 4 +-- .../src/transmute/transmute_int_to_float.rs | 4 +-- .../src/transmute/transmute_num_to_bytes.rs | 4 +-- clippy_lints/src/transmute/transmute_ptr_to_ref.rs | 18 ++++------ clippy_lints/src/transmute/transmute_ref_to_ref.rs | 2 +- .../src/transmute/transmute_undefined_repr.rs | 23 ++++++------- .../transmutes_expressible_as_ptr_casts.rs | 5 +-- .../src/transmute/unsound_collection_transmute.rs | 5 +-- clippy_lints/src/transmute/useless_transmute.rs | 2 +- clippy_lints/src/transmute/wrong_transmute.rs | 2 +- clippy_lints/src/types/borrowed_box.rs | 6 ++-- clippy_lints/src/types/box_collection.rs | 2 +- clippy_lints/src/types/rc_buffer.rs | 4 +-- clippy_lints/src/types/redundant_allocation.rs | 29 +++++----------- clippy_lints/src/unit_return_expecting_ord.rs | 6 ++-- clippy_lints/src/unit_types/unit_arg.rs | 7 ++-- clippy_lints/src/unit_types/unit_cmp.rs | 7 ++-- clippy_lints/src/unnecessary_self_imports.rs | 2 +- clippy_lints/src/unnecessary_wraps.rs | 7 ++-- clippy_lints/src/unsafe_removed_from_name.rs | 5 +-- clippy_lints/src/unused_rounding.rs | 4 +-- clippy_lints/src/unwrap.rs | 7 ++-- clippy_lints/src/upper_case_acronyms.rs | 2 +- clippy_lints/src/useless_conversion.rs | 10 +++--- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/conf.rs | 9 ++--- clippy_lints/src/wildcard_imports.rs | 2 +- clippy_lints/src/zero_div_zero.rs | 3 +- 225 files changed, 557 insertions(+), 842 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index 159f3b0cd01..724490fb495 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -92,7 +92,7 @@ impl ApproxConstant { cx, APPROX_CONSTANT, e.span, - &format!("approximate value of `{}::consts::{}` found", module, &name), + &format!("approximate value of `{module}::consts::{}` found", &name), None, "consider using the constant directly", ); @@ -126,7 +126,7 @@ fn is_approx_const(constant: f64, value: &str, min_digits: usize) -> bool { // The value is a truncated constant true } else { - let round_const = format!("{:.*}", value.len() - 2, constant); + let round_const = format!("{constant:.*}", value.len() - 2); value == round_const } } diff --git a/clippy_lints/src/asm_syntax.rs b/clippy_lints/src/asm_syntax.rs index f419781dbc8..ad31d708f64 100644 --- a/clippy_lints/src/asm_syntax.rs +++ b/clippy_lints/src/asm_syntax.rs @@ -44,7 +44,7 @@ fn check_expr_asm_syntax(lint: &'static Lint, cx: &EarlyContext<'_>, expr: &Expr cx, lint, expr.span, - &format!("{} x86 assembly syntax used", style), + &format!("{style} x86 assembly syntax used"), None, &format!("use {} x86 assembly syntax", !style), ); diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index 2705ffffdcb..a36df55d0bd 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -60,9 +60,9 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants { cx, ASSERTIONS_ON_CONSTANTS, macro_call.span, - &format!("`assert!(false{})` should probably be replaced", assert_arg), + &format!("`assert!(false{assert_arg})` should probably be replaced"), None, - &format!("use `panic!({})` or `unreachable!({0})`", panic_arg), + &format!("use `panic!({panic_arg})` or `unreachable!({panic_arg})`"), ); } } diff --git a/clippy_lints/src/assertions_on_result_states.rs b/clippy_lints/src/assertions_on_result_states.rs index 656dc5feeb5..f6d6c23bb6e 100644 --- a/clippy_lints/src/assertions_on_result_states.rs +++ b/clippy_lints/src/assertions_on_result_states.rs @@ -69,9 +69,8 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnResultStates { "called `assert!` with `Result::is_ok`", "replace with", format!( - "{}.unwrap(){}", - snippet_with_context(cx, recv.span, condition.span.ctxt(), "..", &mut app).0, - semicolon + "{}.unwrap(){semicolon}", + snippet_with_context(cx, recv.span, condition.span.ctxt(), "..", &mut app).0 ), app, ); @@ -84,9 +83,8 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnResultStates { "called `assert!` with `Result::is_err`", "replace with", format!( - "{}.unwrap_err(){}", - snippet_with_context(cx, recv.span, condition.span.ctxt(), "..", &mut app).0, - semicolon + "{}.unwrap_err(){semicolon}", + snippet_with_context(cx, recv.span, condition.span.ctxt(), "..", &mut app).0 ), app, ); diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 732dc2b4330..5f45c69d7f9 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -541,10 +541,7 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribut cx, INLINE_ALWAYS, attr.span, - &format!( - "you have declared `#[inline(always)]` on `{}`. This is usually a bad idea", - name - ), + &format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"), ); } } @@ -720,7 +717,7 @@ fn check_mismatched_target_os(cx: &EarlyContext<'_>, attr: &Attribute) { let mut unix_suggested = false; for (os, span) in mismatched { - let sugg = format!("target_os = \"{}\"", os); + let sugg = format!("target_os = \"{os}\""); diag.span_suggestion(span, "try", sugg, Applicability::MaybeIncorrect); if !unix_suggested && is_unix(os) { diff --git a/clippy_lints/src/bool_assert_comparison.rs b/clippy_lints/src/bool_assert_comparison.rs index 95abe8aa59f..4bd55c1429c 100644 --- a/clippy_lints/src/bool_assert_comparison.rs +++ b/clippy_lints/src/bool_assert_comparison.rs @@ -98,9 +98,9 @@ impl<'tcx> LateLintPass<'tcx> for BoolAssertComparison { cx, BOOL_ASSERT_COMPARISON, macro_call.span, - &format!("used `{}!` with a literal bool", macro_name), + &format!("used `{macro_name}!` with a literal bool"), "replace it with", - format!("{}!(..)", non_eq_mac), + format!("{non_eq_mac}!(..)"), Applicability::MaybeIncorrect, ); } diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 03d262d5a59..2a15cbc7a3c 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -263,9 +263,8 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { } .and_then(|op| { Some(format!( - "{}{}{}", + "{}{op}{}", snippet_opt(cx, lhs.span)?, - op, snippet_opt(cx, rhs.span)? )) }) @@ -285,7 +284,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { let path: &str = path.ident.name.as_str(); a == path }) - .and_then(|(_, neg_method)| Some(format!("{}.{}()", snippet_opt(cx, receiver.span)?, neg_method))) + .and_then(|(_, neg_method)| Some(format!("{}.{neg_method}()", snippet_opt(cx, receiver.span)?))) }, _ => None, } diff --git a/clippy_lints/src/cargo/common_metadata.rs b/clippy_lints/src/cargo/common_metadata.rs index e0442dda479..805121bcced 100644 --- a/clippy_lints/src/cargo/common_metadata.rs +++ b/clippy_lints/src/cargo/common_metadata.rs @@ -40,7 +40,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata, ignore_publish: b } fn missing_warning(cx: &LateContext<'_>, package: &cargo_metadata::Package, field: &str) { - let message = format!("package `{}` is missing `{}` metadata", package.name, field); + let message = format!("package `{}` is missing `{field}` metadata", package.name); span_lint(cx, CARGO_COMMON_METADATA, DUMMY_SP, &message); } diff --git a/clippy_lints/src/cargo/feature_name.rs b/clippy_lints/src/cargo/feature_name.rs index 79a469a4258..37c169dbd95 100644 --- a/clippy_lints/src/cargo/feature_name.rs +++ b/clippy_lints/src/cargo/feature_name.rs @@ -57,10 +57,8 @@ fn lint(cx: &LateContext<'_>, feature: &str, substring: &str, is_prefix: bool) { }, DUMMY_SP, &format!( - "the \"{}\" {} in the feature name \"{}\" is {}", - substring, + "the \"{substring}\" {} in the feature name \"{feature}\" is {}", if is_prefix { "prefix" } else { "suffix" }, - feature, if is_negative { "negative" } else { "redundant" } ), None, diff --git a/clippy_lints/src/cargo/mod.rs b/clippy_lints/src/cargo/mod.rs index 9f45db86a09..3a872e54c9a 100644 --- a/clippy_lints/src/cargo/mod.rs +++ b/clippy_lints/src/cargo/mod.rs @@ -196,7 +196,7 @@ impl LateLintPass<'_> for Cargo { }, Err(e) => { for lint in NO_DEPS_LINTS { - span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {}", e)); + span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {e}")); } }, } @@ -212,7 +212,7 @@ impl LateLintPass<'_> for Cargo { }, Err(e) => { for lint in WITH_DEPS_LINTS { - span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {}", e)); + span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {e}")); } }, } diff --git a/clippy_lints/src/cargo/multiple_crate_versions.rs b/clippy_lints/src/cargo/multiple_crate_versions.rs index 76fd0819a39..f9b17d45e9f 100644 --- a/clippy_lints/src/cargo/multiple_crate_versions.rs +++ b/clippy_lints/src/cargo/multiple_crate_versions.rs @@ -37,7 +37,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata) { cx, MULTIPLE_CRATE_VERSIONS, DUMMY_SP, - &format!("multiple versions for dependency `{}`: {}", name, versions), + &format!("multiple versions for dependency `{name}`: {versions}"), ); } } diff --git a/clippy_lints/src/casts/borrow_as_ptr.rs b/clippy_lints/src/casts/borrow_as_ptr.rs index 6e1f8cd64f0..294d22d34de 100644 --- a/clippy_lints/src/casts/borrow_as_ptr.rs +++ b/clippy_lints/src/casts/borrow_as_ptr.rs @@ -30,7 +30,7 @@ pub(super) fn check<'tcx>( expr.span, "borrow as raw pointer", "try", - format!("{}::ptr::{}!({})", core_or_std, macro_name, snip), + format!("{core_or_std}::ptr::{macro_name}!({snip})"), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/casts/cast_lossless.rs b/clippy_lints/src/casts/cast_lossless.rs index 938458e30ca..13c403234da 100644 --- a/clippy_lints/src/casts/cast_lossless.rs +++ b/clippy_lints/src/casts/cast_lossless.rs @@ -41,15 +41,9 @@ pub(super) fn check( ); let message = if cast_from.is_bool() { - format!( - "casting `{0:}` to `{1:}` is more cleanly stated with `{1:}::from(_)`", - cast_from, cast_to - ) + format!("casting `{cast_from:}` to `{cast_to:}` is more cleanly stated with `{cast_to:}::from(_)`") } else { - format!( - "casting `{}` to `{}` may become silently lossy if you later change the type", - cast_from, cast_to - ) + format!("casting `{cast_from}` to `{cast_to}` may become silently lossy if you later change the type") }; span_lint_and_sugg( @@ -58,7 +52,7 @@ pub(super) fn check( expr.span, &message, "try", - format!("{}::from({})", cast_to, sugg), + format!("{cast_to}::from({sugg})"), applicability, ); } diff --git a/clippy_lints/src/casts/cast_possible_truncation.rs b/clippy_lints/src/casts/cast_possible_truncation.rs index 406547a4454..88deb4565eb 100644 --- a/clippy_lints/src/casts/cast_possible_truncation.rs +++ b/clippy_lints/src/casts/cast_possible_truncation.rs @@ -103,10 +103,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, return; } - format!( - "casting `{}` to `{}` may truncate the value{}", - cast_from, cast_to, suffix, - ) + format!("casting `{cast_from}` to `{cast_to}` may truncate the value{suffix}",) }, (ty::Adt(def, _), true) if def.is_enum() => { @@ -142,20 +139,17 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, CAST_ENUM_TRUNCATION, expr.span, &format!( - "casting `{}::{}` to `{}` will truncate the value{}", - cast_from, variant.name, cast_to, suffix, + "casting `{cast_from}::{}` to `{cast_to}` will truncate the value{suffix}", + variant.name, ), ); return; } - format!( - "casting `{}` to `{}` may truncate the value{}", - cast_from, cast_to, suffix, - ) + format!("casting `{cast_from}` to `{cast_to}` may truncate the value{suffix}",) }, (ty::Float(_), true) => { - format!("casting `{}` to `{}` may truncate the value", cast_from, cast_to) + format!("casting `{cast_from}` to `{cast_to}` may truncate the value") }, (ty::Float(FloatTy::F64), false) if matches!(cast_to.kind(), &ty::Float(FloatTy::F32)) => { diff --git a/clippy_lints/src/casts/cast_possible_wrap.rs b/clippy_lints/src/casts/cast_possible_wrap.rs index 2c5c1d7cb46..28ecdea7ea0 100644 --- a/clippy_lints/src/casts/cast_possible_wrap.rs +++ b/clippy_lints/src/casts/cast_possible_wrap.rs @@ -35,10 +35,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca cx, CAST_POSSIBLE_WRAP, expr.span, - &format!( - "casting `{}` to `{}` may wrap around the value{}", - cast_from, cast_to, suffix, - ), + &format!("casting `{cast_from}` to `{cast_to}` may wrap around the value{suffix}",), ); } } diff --git a/clippy_lints/src/casts/cast_ptr_alignment.rs b/clippy_lints/src/casts/cast_ptr_alignment.rs index da7b12f6726..97054a0d101 100644 --- a/clippy_lints/src/casts/cast_ptr_alignment.rs +++ b/clippy_lints/src/casts/cast_ptr_alignment.rs @@ -49,9 +49,7 @@ fn lint_cast_ptr_alignment<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, cast_f CAST_PTR_ALIGNMENT, expr.span, &format!( - "casting from `{}` to a more-strictly-aligned pointer (`{}`) ({} < {} bytes)", - cast_from, - cast_to, + "casting from `{cast_from}` to a more-strictly-aligned pointer (`{cast_to}`) ({} < {} bytes)", from_layout.align.abi.bytes(), to_layout.align.abi.bytes(), ), diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 5b59350be04..a20a97d4e56 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -14,10 +14,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, c cx, CAST_SIGN_LOSS, expr.span, - &format!( - "casting `{}` to `{}` may lose the sign of the value", - cast_from, cast_to - ), + &format!("casting `{cast_from}` to `{cast_to}` may lose the sign of the value"), ); } } diff --git a/clippy_lints/src/casts/cast_slice_different_sizes.rs b/clippy_lints/src/casts/cast_slice_different_sizes.rs index 027c660ce3b..d31d10d22b9 100644 --- a/clippy_lints/src/casts/cast_slice_different_sizes.rs +++ b/clippy_lints/src/casts/cast_slice_different_sizes.rs @@ -35,8 +35,8 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: Optio CAST_SLICE_DIFFERENT_SIZES, expr.span, &format!( - "casting between raw pointers to `[{}]` (element size {}) and `[{}]` (element size {}) does not adjust the count", - start_ty.ty, from_size, end_ty.ty, to_size, + "casting between raw pointers to `[{}]` (element size {from_size}) and `[{}]` (element size {to_size}) does not adjust the count", + start_ty.ty, end_ty.ty, ), |diag| { let ptr_snippet = source::snippet(cx, left_cast.span, ".."); diff --git a/clippy_lints/src/casts/char_lit_as_u8.rs b/clippy_lints/src/casts/char_lit_as_u8.rs index 7cc406018db..82e07c98a7e 100644 --- a/clippy_lints/src/casts/char_lit_as_u8.rs +++ b/clippy_lints/src/casts/char_lit_as_u8.rs @@ -31,7 +31,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { diag.span_suggestion( expr.span, "use a byte literal instead", - format!("b{}", snippet), + format!("b{snippet}"), applicability, ); } diff --git a/clippy_lints/src/casts/fn_to_numeric_cast.rs b/clippy_lints/src/casts/fn_to_numeric_cast.rs index 35350d8a25b..a26bfab4e7c 100644 --- a/clippy_lints/src/casts/fn_to_numeric_cast.rs +++ b/clippy_lints/src/casts/fn_to_numeric_cast.rs @@ -25,9 +25,9 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cx, FN_TO_NUMERIC_CAST, expr.span, - &format!("casting function pointer `{}` to `{}`", from_snippet, cast_to), + &format!("casting function pointer `{from_snippet}` to `{cast_to}`"), "try", - format!("{} as usize", from_snippet), + format!("{from_snippet} as usize"), applicability, ); } diff --git a/clippy_lints/src/casts/fn_to_numeric_cast_any.rs b/clippy_lints/src/casts/fn_to_numeric_cast_any.rs index 03621887a34..75654129408 100644 --- a/clippy_lints/src/casts/fn_to_numeric_cast_any.rs +++ b/clippy_lints/src/casts/fn_to_numeric_cast_any.rs @@ -23,9 +23,9 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cx, FN_TO_NUMERIC_CAST_ANY, expr.span, - &format!("casting function pointer `{}` to `{}`", from_snippet, cast_to), + &format!("casting function pointer `{from_snippet}` to `{cast_to}`"), "did you mean to invoke the function?", - format!("{}() as {}", from_snippet, cast_to), + format!("{from_snippet}() as {cast_to}"), applicability, ); }, diff --git a/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs b/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs index 6287f479b5b..556be1d1506 100644 --- a/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs +++ b/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs @@ -24,12 +24,9 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cx, FN_TO_NUMERIC_CAST_WITH_TRUNCATION, expr.span, - &format!( - "casting function pointer `{}` to `{}`, which truncates the value", - from_snippet, cast_to - ), + &format!("casting function pointer `{from_snippet}` to `{cast_to}`, which truncates the value"), "try", - format!("{} as usize", from_snippet), + format!("{from_snippet} as usize"), applicability, ); } diff --git a/clippy_lints/src/casts/ptr_as_ptr.rs b/clippy_lints/src/casts/ptr_as_ptr.rs index 46d45d09661..c2b9253ec35 100644 --- a/clippy_lints/src/casts/ptr_as_ptr.rs +++ b/clippy_lints/src/casts/ptr_as_ptr.rs @@ -33,7 +33,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: Option Cow::Borrowed(""), TyKind::Ptr(mut_ty) if matches!(mut_ty.ty.kind, TyKind::Infer) => Cow::Borrowed(""), - _ => Cow::Owned(format!("::<{}>", to_pointee_ty)), + _ => Cow::Owned(format!("::<{to_pointee_ty}>")), }; span_lint_and_sugg( cx, @@ -41,7 +41,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: Option( cx, UNNECESSARY_CAST, expr.span, - &format!( - "casting to the same type is unnecessary (`{}` -> `{}`)", - cast_from, cast_to - ), + &format!("casting to the same type is unnecessary (`{cast_from}` -> `{cast_to}`)"), "try", literal_str, Applicability::MachineApplicable, @@ -101,9 +98,9 @@ fn lint_unnecessary_cast(cx: &LateContext<'_>, expr: &Expr<'_>, literal_str: &st cx, UNNECESSARY_CAST, expr.span, - &format!("casting {} literal to `{}` is unnecessary", literal_kind_name, cast_to), + &format!("casting {literal_kind_name} literal to `{cast_to}` is unnecessary"), "try", - format!("{}_{}", matchless.trim_end_matches('.'), cast_to), + format!("{}_{cast_to}", matchless.trim_end_matches('.')), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/checked_conversions.rs b/clippy_lints/src/checked_conversions.rs index 37b2fdcff09..1d113c7cbee 100644 --- a/clippy_lints/src/checked_conversions.rs +++ b/clippy_lints/src/checked_conversions.rs @@ -82,7 +82,7 @@ impl<'tcx> LateLintPass<'tcx> for CheckedConversions { item.span, "checked cast can be simplified", "try", - format!("{}::try_from({}).is_ok()", to_type, snippet), + format!("{to_type}::try_from({snippet}).is_ok()"), applicability, ); } diff --git a/clippy_lints/src/cognitive_complexity.rs b/clippy_lints/src/cognitive_complexity.rs index 33c44f8b2db..fed04ae7f3d 100644 --- a/clippy_lints/src/cognitive_complexity.rs +++ b/clippy_lints/src/cognitive_complexity.rs @@ -107,8 +107,7 @@ impl CognitiveComplexity { COGNITIVE_COMPLEXITY, fn_span, &format!( - "the function has a cognitive complexity of ({}/{})", - rust_cc, + "the function has a cognitive complexity of ({rust_cc}/{})", self.limit.limit() ), None, diff --git a/clippy_lints/src/default.rs b/clippy_lints/src/default.rs index 74f7df61177..cb6800c8ba2 100644 --- a/clippy_lints/src/default.rs +++ b/clippy_lints/src/default.rs @@ -105,7 +105,7 @@ impl<'tcx> LateLintPass<'tcx> for Default { cx, DEFAULT_TRAIT_ACCESS, expr.span, - &format!("calling `{}` is more clear than this expression", replacement), + &format!("calling `{replacement}` is more clear than this expression"), "try", replacement, Applicability::Unspecified, // First resolve the TODO above @@ -210,7 +210,7 @@ impl<'tcx> LateLintPass<'tcx> for Default { .map(|(field, rhs)| { // extract and store the assigned value for help message let value_snippet = snippet_with_macro_callsite(cx, rhs.span, ".."); - format!("{}: {}", field, value_snippet) + format!("{field}: {value_snippet}") }) .collect::>() .join(", "); @@ -227,7 +227,7 @@ impl<'tcx> LateLintPass<'tcx> for Default { .map(ToString::to_string) .collect::>() .join(", "); - format!("{}::<{}>", adt_def_ty_name, &tys_str) + format!("{adt_def_ty_name}::<{}>", &tys_str) } else { binding_type.to_string() } @@ -235,12 +235,12 @@ impl<'tcx> LateLintPass<'tcx> for Default { let sugg = if ext_with_default { if field_list.is_empty() { - format!("{}::default()", binding_type) + format!("{binding_type}::default()") } else { - format!("{} {{ {}, ..Default::default() }}", binding_type, field_list) + format!("{binding_type} {{ {field_list}, ..Default::default() }}") } } else { - format!("{} {{ {} }}", binding_type, field_list) + format!("{binding_type} {{ {field_list} }}") }; // span lint once per statement that binds default @@ -250,10 +250,7 @@ impl<'tcx> LateLintPass<'tcx> for Default { first_assign.unwrap().span, "field assignment outside of initializer for an instance created with Default::default()", Some(local.span), - &format!( - "consider initializing the variable with `{}` and removing relevant reassignments", - sugg - ), + &format!("consider initializing the variable with `{sugg}` and removing relevant reassignments"), ); self.reassigned_linted.insert(span); } diff --git a/clippy_lints/src/default_numeric_fallback.rs b/clippy_lints/src/default_numeric_fallback.rs index be02f328e98..3ed9cd36a22 100644 --- a/clippy_lints/src/default_numeric_fallback.rs +++ b/clippy_lints/src/default_numeric_fallback.rs @@ -95,8 +95,8 @@ impl<'a, 'tcx> NumericFallbackVisitor<'a, 'tcx> { src } else { match lit.node { - LitKind::Int(src, _) => format!("{}", src), - LitKind::Float(src, _) => format!("{}", src), + LitKind::Int(src, _) => format!("{src}"), + LitKind::Float(src, _) => format!("{src}"), _ => return, } }; diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index b965d27afce..e272283152d 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -1308,7 +1308,7 @@ fn report<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, state: State, data }; let expr_str = if !expr_is_macro_call && is_final_ufcs && expr.precedence().order() < PREC_PREFIX { - format!("({})", expr_str) + format!("({expr_str})") } else { expr_str.into_owned() }; @@ -1322,7 +1322,7 @@ fn report<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, state: State, data Mutability::Mut => "explicit `deref_mut` method call", }, "try this", - format!("{}{}{}", addr_of_str, deref_str, expr_str), + format!("{addr_of_str}{deref_str}{expr_str}"), app, ); }, @@ -1336,7 +1336,7 @@ fn report<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, state: State, data && !has_enclosing_paren(&snip) && (expr.precedence().order() < data.position.precedence() || calls_field) { - format!("({})", snip) + format!("({snip})") } else { snip.into() }; @@ -1379,9 +1379,9 @@ fn report<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, state: State, data let (snip, snip_is_macro) = snippet_with_context(cx, expr.span, data.span.ctxt(), "..", &mut app); let sugg = if !snip_is_macro && expr.precedence().order() < precedence && !has_enclosing_paren(&snip) { - format!("{}({})", prefix, snip) + format!("{prefix}({snip})") } else { - format!("{}{}", prefix, snip) + format!("{prefix}{snip}") }; diag.span_suggestion(data.span, "try this", sugg, app); }, @@ -1460,14 +1460,14 @@ impl Dereferencing { } else { pat.always_deref = false; let snip = snippet_with_context(cx, e.span, parent.span.ctxt(), "..", &mut pat.app).0; - pat.replacements.push((e.span, format!("&{}", snip))); + pat.replacements.push((e.span, format!("&{snip}"))); } }, _ if !e.span.from_expansion() => { // Double reference might be needed at this point. pat.always_deref = false; let snip = snippet_with_applicability(cx, e.span, "..", &mut pat.app); - pat.replacements.push((e.span, format!("&{}", snip))); + pat.replacements.push((e.span, format!("&{snip}"))); }, // Edge case for macros. The span of the identifier will usually match the context of the // binding, but not if the identifier was created in a macro. e.g. `concat_idents` and proc diff --git a/clippy_lints/src/disallowed_methods.rs b/clippy_lints/src/disallowed_methods.rs index 53973ab792a..b02f87c07db 100644 --- a/clippy_lints/src/disallowed_methods.rs +++ b/clippy_lints/src/disallowed_methods.rs @@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedMethods { reason: Some(reason), .. } = conf { - diag.note(&format!("{} (from clippy.toml)", reason)); + diag.note(&format!("{reason} (from clippy.toml)")); } }); } diff --git a/clippy_lints/src/disallowed_script_idents.rs b/clippy_lints/src/disallowed_script_idents.rs index 0c27c3f9255..084190f0013 100644 --- a/clippy_lints/src/disallowed_script_idents.rs +++ b/clippy_lints/src/disallowed_script_idents.rs @@ -99,8 +99,7 @@ impl EarlyLintPass for DisallowedScriptIdents { DISALLOWED_SCRIPT_IDENTS, span, &format!( - "identifier `{}` has a Unicode script that is not allowed by configuration: {}", - symbol_str, + "identifier `{symbol_str}` has a Unicode script that is not allowed by configuration: {}", script.full_name() ), ); diff --git a/clippy_lints/src/disallowed_types.rs b/clippy_lints/src/disallowed_types.rs index 14f89edce61..53451238d9a 100644 --- a/clippy_lints/src/disallowed_types.rs +++ b/clippy_lints/src/disallowed_types.rs @@ -92,7 +92,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedTypes { conf::DisallowedType::Simple(path) => (path, None), conf::DisallowedType::WithReason { path, reason } => ( path, - reason.as_ref().map(|reason| format!("{} (from clippy.toml)", reason)), + reason.as_ref().map(|reason| format!("{reason} (from clippy.toml)")), ), }; let segs: Vec<_> = path.split("::").collect(); @@ -130,7 +130,7 @@ fn emit(cx: &LateContext<'_>, name: &str, span: Span, reason: Option<&str>) { cx, DISALLOWED_TYPES, span, - &format!("`{}` is not allowed according to config", name), + &format!("`{name}` is not allowed according to config"), |diag| { if let Some(reason) = reason { diag.note(reason); diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index eb158d850fa..fa50a2d1a2c 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -790,7 +790,7 @@ fn check_word(cx: &LateContext<'_>, word: &str, span: Span) { diag.span_suggestion_with_style( span, "try", - format!("`{}`", snippet), + format!("`{snippet}`"), applicability, // always show the suggestion in a separate line, since the // inline presentation adds another pair of backticks diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index b35f0b8ca52..0ee07fbcc75 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -236,7 +236,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { expr.span, msg, Some(arg.span), - &format!("argument has type `{}`", arg_ty), + &format!("argument has type `{arg_ty}`"), ); } } diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index e70df3f53c7..9c834cf0144 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -113,13 +113,8 @@ impl<'tcx> LateLintPass<'tcx> for HashMapPass { ), }; format!( - "if let {}::{} = {}.entry({}) {} else {}", + "if let {}::{entry_kind} = {map_str}.entry({key_str}) {then_str} else {else_str}", map_ty.entry_path(), - entry_kind, - map_str, - key_str, - then_str, - else_str, ) } else { // if .. { insert } else { insert } @@ -137,16 +132,11 @@ impl<'tcx> LateLintPass<'tcx> for HashMapPass { let indent_str = snippet_indent(cx, expr.span); let indent_str = indent_str.as_deref().unwrap_or(""); format!( - "match {}.entry({}) {{\n{indent} {entry}::{} => {}\n\ - {indent} {entry}::{} => {}\n{indent}}}", - map_str, - key_str, - then_entry, + "match {map_str}.entry({key_str}) {{\n{indent_str} {entry}::{then_entry} => {}\n\ + {indent_str} {entry}::{else_entry} => {}\n{indent_str}}}", reindent_multiline(then_str.into(), true, Some(4 + indent_str.len())), - else_entry, reindent_multiline(else_str.into(), true, Some(4 + indent_str.len())), entry = map_ty.entry_path(), - indent = indent_str, ) } } else { @@ -163,20 +153,16 @@ impl<'tcx> LateLintPass<'tcx> for HashMapPass { then_search.snippet_occupied(cx, then_expr.span, &mut app) }; format!( - "if let {}::{} = {}.entry({}) {}", + "if let {}::{entry_kind} = {map_str}.entry({key_str}) {body_str}", map_ty.entry_path(), - entry_kind, - map_str, - key_str, - body_str, ) } else if let Some(insertion) = then_search.as_single_insertion() { let value_str = snippet_with_context(cx, insertion.value.span, then_expr.span.ctxt(), "..", &mut app).0; if contains_expr.negated { if insertion.value.can_have_side_effects() { - format!("{}.entry({}).or_insert_with(|| {});", map_str, key_str, value_str) + format!("{map_str}.entry({key_str}).or_insert_with(|| {value_str});") } else { - format!("{}.entry({}).or_insert({});", map_str, key_str, value_str) + format!("{map_str}.entry({key_str}).or_insert({value_str});") } } else { // TODO: suggest using `if let Some(v) = map.get_mut(k) { .. }` here. @@ -186,7 +172,7 @@ impl<'tcx> LateLintPass<'tcx> for HashMapPass { } else { let block_str = then_search.snippet_closure(cx, then_expr.span, &mut app); if contains_expr.negated { - format!("{}.entry({}).or_insert_with(|| {});", map_str, key_str, block_str) + format!("{map_str}.entry({key_str}).or_insert_with(|| {block_str});") } else { // TODO: suggest using `if let Some(v) = map.get_mut(k) { .. }` here. // This would need to be a different lint. diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index cd36f9fcd72..d8c6b4e39ae 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -202,12 +202,11 @@ fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_n cx, ENUM_VARIANT_NAMES, span, - &format!("all variants have the same {}fix: `{}`", what, value), + &format!("all variants have the same {what}fix: `{value}`"), None, &format!( - "remove the {}fixes and use full paths to \ - the variants instead of glob imports", - what + "remove the {what}fixes and use full paths to \ + the variants instead of glob imports" ), ); } diff --git a/clippy_lints/src/equatable_if_let.rs b/clippy_lints/src/equatable_if_let.rs index fdfb821ac78..7917d83c0b9 100644 --- a/clippy_lints/src/equatable_if_let.rs +++ b/clippy_lints/src/equatable_if_let.rs @@ -91,9 +91,8 @@ impl<'tcx> LateLintPass<'tcx> for PatternEquality { "this pattern matching can be expressed using equality", "try", format!( - "{} == {}", + "{} == {pat_str}", snippet_with_context(cx, let_expr.init.span, expr.span.ctxt(), "..", &mut applicability).0, - pat_str, ), applicability, ); diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 53bc617a4f5..0f9f94a6b54 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -130,7 +130,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction { then { // Mutable closure is used after current expr; we cannot consume it. - snippet = format!("&mut {}", snippet); + snippet = format!("&mut {snippet}"); } } diag.span_suggestion( @@ -158,7 +158,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction { diag.span_suggestion( expr.span, "replace the closure with the method itself", - format!("{}::{}", name, path.ident.name), + format!("{name}::{}", path.ident.name), Applicability::MachineApplicable, ); }) diff --git a/clippy_lints/src/exhaustive_items.rs b/clippy_lints/src/exhaustive_items.rs index 173d41b4b05..218e40f2b5f 100644 --- a/clippy_lints/src/exhaustive_items.rs +++ b/clippy_lints/src/exhaustive_items.rs @@ -97,7 +97,7 @@ impl LateLintPass<'_> for ExhaustiveItems { item.span, msg, |diag| { - let sugg = format!("#[non_exhaustive]\n{}", indent); + let sugg = format!("#[non_exhaustive]\n{indent}"); diag.span_suggestion(suggestion_span, "try adding #[non_exhaustive]", sugg, diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index b9ed4af0219..c0ea6f338a2 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -80,12 +80,12 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite { // used. let (used, sugg_mac) = if let Some(macro_name) = calling_macro { ( - format!("{}!({}(), ...)", macro_name, dest_name), + format!("{macro_name}!({dest_name}(), ...)"), macro_name.replace("write", "print"), ) } else { ( - format!("{}().write_fmt(...)", dest_name), + format!("{dest_name}().write_fmt(...)"), "print".into(), ) }; @@ -100,9 +100,9 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite { cx, EXPLICIT_WRITE, expr.span, - &format!("use of `{}.unwrap()`", used), + &format!("use of `{used}.unwrap()`"), "try this", - format!("{}{}!({})", prefix, sugg_mac, inputs_snippet), + format!("{prefix}{sugg_mac}!({inputs_snippet})"), applicability, ) } diff --git a/clippy_lints/src/float_literal.rs b/clippy_lints/src/float_literal.rs index f2e07980963..6fee7fb308c 100644 --- a/clippy_lints/src/float_literal.rs +++ b/clippy_lints/src/float_literal.rs @@ -173,9 +173,9 @@ impl FloatFormat { T: fmt::UpperExp + fmt::LowerExp + fmt::Display, { match self { - Self::LowerExp => format!("{:e}", f), - Self::UpperExp => format!("{:E}", f), - Self::Normal => format!("{}", f), + Self::LowerExp => format!("{f:e}"), + Self::UpperExp => format!("{f:E}"), + Self::Normal => format!("{f}"), } } } diff --git a/clippy_lints/src/floating_point_arithmetic.rs b/clippy_lints/src/floating_point_arithmetic.rs index ba53a967880..e71afec12a7 100644 --- a/clippy_lints/src/floating_point_arithmetic.rs +++ b/clippy_lints/src/floating_point_arithmetic.rs @@ -142,8 +142,7 @@ fn prepare_receiver_sugg<'a>(cx: &LateContext<'_>, mut expr: &'a Expr<'a>) -> Su if let ast::LitKind::Float(sym, ast::LitFloatType::Unsuffixed) = lit.node; then { let op = format!( - "{}{}{}", - suggestion, + "{suggestion}{}{}", // Check for float literals without numbers following the decimal // separator such as `2.` and adds a trailing zero if sym.as_str().ends_with('.') { @@ -172,7 +171,7 @@ fn check_log_base(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, ar expr.span, "logarithm for bases 2, 10 and e can be computed more accurately", "consider using", - format!("{}.{}()", Sugg::hir(cx, receiver, "..").maybe_par(), method), + format!("{}.{method}()", Sugg::hir(cx, receiver, "..").maybe_par()), Applicability::MachineApplicable, ); } @@ -251,7 +250,7 @@ fn check_powf(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args: expr.span, "exponent for bases 2 and e can be computed more accurately", "consider using", - format!("{}.{}()", prepare_receiver_sugg(cx, &args[0]), method), + format!("{}.{method}()", prepare_receiver_sugg(cx, &args[0])), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index f10d8256953..bc0c68f535a 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessFormat { [_] => { // Simulate macro expansion, converting {{ and }} to { and }. let s_expand = format_args.format_string.snippet.replace("{{", "{").replace("}}", "}"); - let sugg = format!("{}.to_string()", s_expand); + let sugg = format!("{s_expand}.to_string()"); span_useless_format(cx, call_site, sugg, applicability); }, [..] => {}, diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index e1c46fd0bfd..192f6258aa5 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -112,11 +112,10 @@ fn check_format_in_format_args(cx: &LateContext<'_>, call_site: Span, name: Symb cx, FORMAT_IN_FORMAT_ARGS, call_site, - &format!("`format!` in `{}!` args", name), + &format!("`format!` in `{name}!` args"), |diag| { diag.help(&format!( - "combine the `format!(..)` arguments with the outer `{}!(..)` call", - name + "combine the `format!(..)` arguments with the outer `{name}!(..)` call" )); diag.help("or consider changing `format!` to `format_args!`"); }, @@ -144,8 +143,7 @@ fn check_to_string_in_format_args(cx: &LateContext<'_>, name: Symbol, value: &Ex TO_STRING_IN_FORMAT_ARGS, value.span.with_lo(receiver.span.hi()), &format!( - "`to_string` applied to a type that implements `Display` in `{}!` args", - name + "`to_string` applied to a type that implements `Display` in `{name}!` args" ), "remove this", String::new(), @@ -157,16 +155,13 @@ fn check_to_string_in_format_args(cx: &LateContext<'_>, name: Symbol, value: &Ex TO_STRING_IN_FORMAT_ARGS, value.span, &format!( - "`to_string` applied to a type that implements `Display` in `{}!` args", - name + "`to_string` applied to a type that implements `Display` in `{name}!` args" ), "use this", format!( - "{}{:*>width$}{}", + "{}{:*>n_needed_derefs$}{receiver_snippet}", if needs_ref { "&" } else { "" }, - "", - receiver_snippet, - width = n_needed_derefs + "" ), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/format_impl.rs b/clippy_lints/src/format_impl.rs index b628fd9f758..ed1342a5465 100644 --- a/clippy_lints/src/format_impl.rs +++ b/clippy_lints/src/format_impl.rs @@ -214,12 +214,12 @@ fn check_print_in_format_impl(cx: &LateContext<'_>, expr: &Expr<'_>, impl_trait: cx, PRINT_IN_FORMAT_IMPL, macro_call.span, - &format!("use of `{}!` in `{}` impl", name, impl_trait.name), + &format!("use of `{name}!` in `{}` impl", impl_trait.name), "replace with", if let Some(formatter_name) = impl_trait.formatter_name { - format!("{}!({}, ..)", replacement, formatter_name) + format!("{replacement}!({formatter_name}, ..)") } else { - format!("{}!(..)", replacement) + format!("{replacement}!(..)") }, Applicability::HasPlaceholders, ); diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 01cefe4af85..a866a68987d 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -154,11 +154,10 @@ fn check_assign(cx: &EarlyContext<'_>, expr: &Expr) { eqop_span, &format!( "this looks like you are trying to use `.. {op}= ..`, but you \ - really are doing `.. = ({op} ..)`", - op = op + really are doing `.. = ({op} ..)`" ), None, - &format!("to remove this lint, use either `{op}=` or `= {op}`", op = op), + &format!("to remove this lint, use either `{op}=` or `= {op}`"), ); } } @@ -191,16 +190,12 @@ fn check_unop(cx: &EarlyContext<'_>, expr: &Expr) { SUSPICIOUS_UNARY_OP_FORMATTING, eqop_span, &format!( - "by not having a space between `{binop}` and `{unop}` it looks like \ - `{binop}{unop}` is a single operator", - binop = binop_str, - unop = unop_str + "by not having a space between `{binop_str}` and `{unop_str}` it looks like \ + `{binop_str}{unop_str}` is a single operator" ), None, &format!( - "put a space between `{binop}` and `{unop}` and remove the space after `{unop}`", - binop = binop_str, - unop = unop_str + "put a space between `{binop_str}` and `{unop_str}` and remove the space after `{unop_str}`" ), ); } @@ -246,12 +241,11 @@ fn check_else(cx: &EarlyContext<'_>, expr: &Expr) { cx, SUSPICIOUS_ELSE_FORMATTING, else_span, - &format!("this is an `else {}` but the formatting might hide it", else_desc), + &format!("this is an `else {else_desc}` but the formatting might hide it"), None, &format!( "to remove this lint, remove the `else` or remove the new line between \ - `else` and `{}`", - else_desc, + `else` and `{else_desc}`", ), ); } @@ -320,11 +314,10 @@ fn check_missing_else(cx: &EarlyContext<'_>, first: &Expr, second: &Expr) { cx, SUSPICIOUS_ELSE_FORMATTING, else_span, - &format!("this looks like {} but the `else` is missing", looks_like), + &format!("this looks like {looks_like} but the `else` is missing"), None, &format!( - "to remove this lint, add the missing `else` or add a new line before {}", - next_thing, + "to remove this lint, add the missing `else` or add a new line before {next_thing}", ), ); } diff --git a/clippy_lints/src/from_str_radix_10.rs b/clippy_lints/src/from_str_radix_10.rs index 74941d817be..2a82473be8c 100644 --- a/clippy_lints/src/from_str_radix_10.rs +++ b/clippy_lints/src/from_str_radix_10.rs @@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for FromStrRadix10 { exp.span, "this call to `from_str_radix` can be replaced with a call to `str::parse`", "try", - format!("{}.parse::<{}>()", sugg, prim_ty.name_str()), + format!("{sugg}.parse::<{}>()", prim_ty.name_str()), Applicability::MaybeIncorrect ); } diff --git a/clippy_lints/src/functions/must_use.rs b/clippy_lints/src/functions/must_use.rs index 00a4937763e..09b97bacd65 100644 --- a/clippy_lints/src/functions/must_use.rs +++ b/clippy_lints/src/functions/must_use.rs @@ -143,7 +143,7 @@ fn check_must_use_candidate<'tcx>( diag.span_suggestion( fn_span, "add the attribute", - format!("#[must_use] {}", snippet), + format!("#[must_use] {snippet}"), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/functions/too_many_arguments.rs b/clippy_lints/src/functions/too_many_arguments.rs index 5c8d8b8e755..1e08922a616 100644 --- a/clippy_lints/src/functions/too_many_arguments.rs +++ b/clippy_lints/src/functions/too_many_arguments.rs @@ -59,10 +59,7 @@ fn check_arg_number(cx: &LateContext<'_>, decl: &hir::FnDecl<'_>, fn_span: Span, cx, TOO_MANY_ARGUMENTS, fn_span, - &format!( - "this function has too many arguments ({}/{})", - args, too_many_arguments_threshold - ), + &format!("this function has too many arguments ({args}/{too_many_arguments_threshold})"), ); } } diff --git a/clippy_lints/src/functions/too_many_lines.rs b/clippy_lints/src/functions/too_many_lines.rs index 54bdea7ea25..f83f8b40f94 100644 --- a/clippy_lints/src/functions/too_many_lines.rs +++ b/clippy_lints/src/functions/too_many_lines.rs @@ -78,10 +78,7 @@ pub(super) fn check_fn( cx, TOO_MANY_LINES, span, - &format!( - "this function has too many lines ({}/{})", - line_count, too_many_lines_threshold - ), + &format!("this function has too many lines ({line_count}/{too_many_lines_threshold})"), ); } } diff --git a/clippy_lints/src/if_then_some_else_none.rs b/clippy_lints/src/if_then_some_else_none.rs index 11c43247868..0800e0644f7 100644 --- a/clippy_lints/src/if_then_some_else_none.rs +++ b/clippy_lints/src/if_then_some_else_none.rs @@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone { { let cond_snip = snippet_with_macro_callsite(cx, cond.span, "[condition]"); let cond_snip = if matches!(cond.kind, ExprKind::Unary(_, _) | ExprKind::Binary(_, _, _)) { - format!("({})", cond_snip) + format!("({cond_snip})") } else { cond_snip.into_owned() }; @@ -92,7 +92,7 @@ impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone { let mut method_body = if then_block.stmts.is_empty() { arg_snip.into_owned() } else { - format!("{{ /* snippet */ {} }}", arg_snip) + format!("{{ /* snippet */ {arg_snip} }}") }; let method_name = if switch_to_eager_eval(cx, expr) && meets_msrv(self.msrv, msrvs::BOOL_THEN_SOME) { "then_some" @@ -102,14 +102,13 @@ impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone { }; let help = format!( - "consider using `bool::{}` like: `{}.{}({})`", - method_name, cond_snip, method_name, method_body, + "consider using `bool::{method_name}` like: `{cond_snip}.{method_name}({method_body})`", ); span_lint_and_help( cx, IF_THEN_SOME_ELSE_NONE, expr.span, - &format!("this could be simplified with `bool::{}`", method_name), + &format!("this could be simplified with `bool::{method_name}`"), None, &help, ); diff --git a/clippy_lints/src/implicit_hasher.rs b/clippy_lints/src/implicit_hasher.rs index 4f9680f60fe..067af79152f 100644 --- a/clippy_lints/src/implicit_hasher.rs +++ b/clippy_lints/src/implicit_hasher.rs @@ -89,8 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher { ( generics_suggestion_span, format!( - "<{}{}S: ::std::hash::BuildHasher{}>", - generics_snip, + "<{generics_snip}{}S: ::std::hash::BuildHasher{}>", if generics_snip.is_empty() { "" } else { ", " }, if vis.suggestions.is_empty() { "" @@ -263,8 +262,8 @@ impl<'tcx> ImplicitHasherType<'tcx> { fn type_arguments(&self) -> String { match *self { - ImplicitHasherType::HashMap(.., ref k, ref v) => format!("{}, {}", k, v), - ImplicitHasherType::HashSet(.., ref t) => format!("{}", t), + ImplicitHasherType::HashMap(.., ref k, ref v) => format!("{k}, {v}"), + ImplicitHasherType::HashSet(.., ref t) => format!("{t}"), } } diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index feec8ec2e23..cfc988da233 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -53,7 +53,7 @@ fn lint_return(cx: &LateContext<'_>, emission_place: HirId, span: Span) { span, "missing `return` statement", |diag| { - diag.span_suggestion(span, "add `return` as shown", format!("return {}", snip), app); + diag.span_suggestion(span, "add `return` as shown", format!("return {snip}"), app); }, ); } @@ -71,7 +71,7 @@ fn lint_break(cx: &LateContext<'_>, emission_place: HirId, break_span: Span, exp diag.span_suggestion( break_span, "change `break` to `return` as shown", - format!("return {}", snip), + format!("return {snip}"), app, ); }, diff --git a/clippy_lints/src/implicit_saturating_sub.rs b/clippy_lints/src/implicit_saturating_sub.rs index 46654bc61e0..f0dbe17d83a 100644 --- a/clippy_lints/src/implicit_saturating_sub.rs +++ b/clippy_lints/src/implicit_saturating_sub.rs @@ -170,7 +170,7 @@ fn print_lint_and_sugg(cx: &LateContext<'_>, var_name: &str, expr: &Expr<'_>) { expr.span, "implicitly performing saturating subtraction", "try", - format!("{} = {}.saturating_sub({});", var_name, var_name, '1'), + format!("{var_name} = {var_name}.saturating_sub({});", '1'), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/inconsistent_struct_constructor.rs b/clippy_lints/src/inconsistent_struct_constructor.rs index 14b22d2b50d..e2f2d3d42e6 100644 --- a/clippy_lints/src/inconsistent_struct_constructor.rs +++ b/clippy_lints/src/inconsistent_struct_constructor.rs @@ -90,7 +90,7 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor { let mut fields_snippet = String::new(); let (last_ident, idents) = ordered_fields.split_last().unwrap(); for ident in idents { - let _ = write!(fields_snippet, "{}, ", ident); + let _ = write!(fields_snippet, "{ident}, "); } fields_snippet.push_str(&last_ident.to_string()); @@ -100,10 +100,8 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor { String::new() }; - let sugg = format!("{} {{ {}{} }}", + let sugg = format!("{} {{ {fields_snippet}{base_snippet} }}", snippet(cx, qpath.span(), ".."), - fields_snippet, - base_snippet, ); span_lint_and_sugg( diff --git a/clippy_lints/src/index_refutable_slice.rs b/clippy_lints/src/index_refutable_slice.rs index 0dd7f5bf000..c7b5badaae5 100644 --- a/clippy_lints/src/index_refutable_slice.rs +++ b/clippy_lints/src/index_refutable_slice.rs @@ -139,14 +139,14 @@ fn lint_slice(cx: &LateContext<'_>, slice: &SliceLintInformation) { .map(|(index, _)| *index) .collect::>(); - let value_name = |index| format!("{}_{}", slice.ident.name, index); + let value_name = |index| format!("{}_{index}", slice.ident.name); if let Some(max_index) = used_indices.iter().max() { let opt_ref = if slice.needs_ref { "ref " } else { "" }; let pat_sugg_idents = (0..=*max_index) .map(|index| { if used_indices.contains(&index) { - format!("{}{}", opt_ref, value_name(index)) + format!("{opt_ref}{}", value_name(index)) } else { "_".to_string() } diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index 17d867aacb5..f171ae2649d 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -131,23 +131,19 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) { INHERENT_TO_STRING_SHADOW_DISPLAY, item.span, &format!( - "type `{}` implements inherent method `to_string(&self) -> String` which shadows the implementation of `Display`", - self_type + "type `{self_type}` implements inherent method `to_string(&self) -> String` which shadows the implementation of `Display`" ), None, - &format!("remove the inherent method from type `{}`", self_type), + &format!("remove the inherent method from type `{self_type}`"), ); } else { span_lint_and_help( cx, INHERENT_TO_STRING, item.span, - &format!( - "implementation of inherent method `to_string(&self) -> String` for type `{}`", - self_type - ), + &format!("implementation of inherent method `to_string(&self) -> String` for type `{self_type}`"), None, - &format!("implement trait `Display` for type `{}` instead", self_type), + &format!("implement trait `Display` for type `{self_type}` instead"), ); } } diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index dd7177e0131..d609a5ca4d4 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -51,7 +51,7 @@ fn check_attrs(cx: &LateContext<'_>, name: Symbol, attrs: &[Attribute]) { cx, INLINE_FN_WITHOUT_BODY, attr.span, - &format!("use of `#[inline]` on trait method `{}` which has no body", name), + &format!("use of `#[inline]` on trait method `{name}` which has no body"), |diag| { diag.suggest_remove_item(cx, attr.span, "remove", Applicability::MachineApplicable); }, diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index 9a944def3eb..33491da3fc5 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -138,8 +138,8 @@ impl IntPlusOne { if let Some(snippet) = snippet_opt(cx, node.span) { if let Some(other_side_snippet) = snippet_opt(cx, other_side.span) { let rec = match side { - Side::Lhs => Some(format!("{} {} {}", snippet, binop_string, other_side_snippet)), - Side::Rhs => Some(format!("{} {} {}", other_side_snippet, binop_string, snippet)), + Side::Lhs => Some(format!("{snippet} {binop_string} {other_side_snippet}")), + Side::Rhs => Some(format!("{other_side_snippet} {binop_string} {snippet}")), }; return rec; } diff --git a/clippy_lints/src/iter_not_returning_iterator.rs b/clippy_lints/src/iter_not_returning_iterator.rs index b56d87c5348..78815ea5a0a 100644 --- a/clippy_lints/src/iter_not_returning_iterator.rs +++ b/clippy_lints/src/iter_not_returning_iterator.rs @@ -80,10 +80,7 @@ fn check_sig(cx: &LateContext<'_>, name: &str, sig: &FnSig<'_>, fn_id: LocalDefI cx, ITER_NOT_RETURNING_ITERATOR, sig.span, - &format!( - "this method is named `{}` but its return type does not implement `Iterator`", - name - ), + &format!("this method is named `{name}` but its return type does not implement `Iterator`"), ); } } diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 7ae8ef830fa..e94292b9fac 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -278,15 +278,13 @@ impl<'tcx> LenOutput<'tcx> { _ => "", }; match self { - Self::Integral => format!("expected signature: `({}self) -> bool`", self_ref), - Self::Option(_) => format!( - "expected signature: `({}self) -> bool` or `({}self) -> Option", - self_ref, self_ref - ), - Self::Result(..) => format!( - "expected signature: `({}self) -> bool` or `({}self) -> Result", - self_ref, self_ref - ), + Self::Integral => format!("expected signature: `({self_ref}self) -> bool`"), + Self::Option(_) => { + format!("expected signature: `({self_ref}self) -> bool` or `({self_ref}self) -> Option") + }, + Self::Result(..) => { + format!("expected signature: `({self_ref}self) -> bool` or `({self_ref}self) -> Result") + }, } } } @@ -326,8 +324,7 @@ fn check_for_is_empty<'tcx>( let (msg, is_empty_span, self_kind) = match is_empty { None => ( format!( - "{} `{}` has a public `len` method, but no `is_empty` method", - item_kind, + "{item_kind} `{}` has a public `len` method, but no `is_empty` method", item_name.as_str(), ), None, @@ -335,8 +332,7 @@ fn check_for_is_empty<'tcx>( ), Some(is_empty) if !cx.access_levels.is_exported(is_empty.def_id.expect_local()) => ( format!( - "{} `{}` has a public `len` method, but a private `is_empty` method", - item_kind, + "{item_kind} `{}` has a public `len` method, but a private `is_empty` method", item_name.as_str(), ), Some(cx.tcx.def_span(is_empty.def_id)), @@ -348,8 +344,7 @@ fn check_for_is_empty<'tcx>( { ( format!( - "{} `{}` has a public `len` method, but the `is_empty` method has an unexpected signature", - item_kind, + "{item_kind} `{}` has a public `len` method, but the `is_empty` method has an unexpected signature", item_name.as_str(), ), Some(cx.tcx.def_span(is_empty.def_id)), @@ -419,10 +414,9 @@ fn check_len( LEN_ZERO, span, &format!("length comparison to {}", if compare_to == 0 { "zero" } else { "one" }), - &format!("using `{}is_empty` is clearer and more explicit", op), + &format!("using `{op}is_empty` is clearer and more explicit"), format!( - "{}{}.is_empty()", - op, + "{op}{}.is_empty()", snippet_with_applicability(cx, receiver.span, "_", &mut applicability) ), applicability, @@ -439,10 +433,9 @@ fn check_empty_expr(cx: &LateContext<'_>, span: Span, lit1: &Expr<'_>, lit2: &Ex COMPARISON_TO_EMPTY, span, "comparison to empty slice", - &format!("using `{}is_empty` is clearer and more explicit", op), + &format!("using `{op}is_empty` is clearer and more explicit"), format!( - "{}{}.is_empty()", - op, + "{op}{}.is_empty()", snippet_with_applicability(cx, lit1.span, "_", &mut applicability) ), applicability, diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 10fc0f4018e..13071d64441 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -106,8 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for LetIfSeq { // use mutably after the `if` let sug = format!( - "let {mut}{name} = if {cond} {{{then} {value} }} else {{{else} {default} }};", - mut=mutability, + "let {mutability}{name} = if {cond} {{{then} {value} }} else {{{else} {default} }};", name=ident.name, cond=snippet(cx, cond.span, "_"), then=if then.stmts.len() > 1 { " ..;" } else { "" }, diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 83fdc15c9f0..8a2a1682eca 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -417,8 +417,7 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, sess: &Se let msrv = conf.msrv.as_ref().and_then(|s| { parse_msrv(s, None, None).or_else(|| { sess.err(&format!( - "error reading Clippy's configuration file. `{}` is not a valid Rust version", - s + "error reading Clippy's configuration file. `{s}` is not a valid Rust version" )); None }) @@ -434,8 +433,7 @@ fn read_msrv(conf: &Conf, sess: &Session) -> Option { let clippy_msrv = conf.msrv.as_ref().and_then(|s| { parse_msrv(s, None, None).or_else(|| { sess.err(&format!( - "error reading Clippy's configuration file. `{}` is not a valid Rust version", - s + "error reading Clippy's configuration file. `{s}` is not a valid Rust version" )); None }) @@ -446,8 +444,7 @@ fn read_msrv(conf: &Conf, sess: &Session) -> Option { // if both files have an msrv, let's compare them and emit a warning if they differ if clippy_msrv != cargo_msrv { sess.warn(&format!( - "the MSRV in `clippy.toml` and `Cargo.toml` differ; using `{}` from `clippy.toml`", - clippy_msrv + "the MSRV in `clippy.toml` and `Cargo.toml` differ; using `{clippy_msrv}` from `clippy.toml`" )); } @@ -466,7 +463,7 @@ pub fn read_conf(sess: &Session) -> Conf { Ok(Some(path)) => path, Ok(None) => return Conf::default(), Err(error) => { - sess.struct_err(&format!("error finding Clippy's configuration file: {}", error)) + sess.struct_err(&format!("error finding Clippy's configuration file: {error}")) .emit(); return Conf::default(); }, diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index fb2104861c8..25f19b9c6e6 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -478,7 +478,7 @@ impl DecimalLiteralRepresentation { if num_lit.radix == Radix::Decimal; if val >= u128::from(self.threshold); then { - let hex = format!("{:#X}", val); + let hex = format!("{val:#X}"); let num_lit = NumericLiteral::new(&hex, num_lit.suffix, false); let _ = Self::do_lint(num_lit.integer).map_err(|warning_type| { warning_type.display(num_lit.format(), cx, lit.span); diff --git a/clippy_lints/src/loops/explicit_counter_loop.rs b/clippy_lints/src/loops/explicit_counter_loop.rs index 8e3ab26a947..14f22348132 100644 --- a/clippy_lints/src/loops/explicit_counter_loop.rs +++ b/clippy_lints/src/loops/explicit_counter_loop.rs @@ -44,11 +44,10 @@ pub(super) fn check<'tcx>( cx, EXPLICIT_COUNTER_LOOP, span, - &format!("the variable `{}` is used as a loop counter", name), + &format!("the variable `{name}` is used as a loop counter"), "consider using", format!( - "for ({}, {}) in {}.enumerate()", - name, + "for ({name}, {}) in {}.enumerate()", snippet_with_applicability(cx, pat.span, "item", &mut applicability), make_iterator_snippet(cx, arg, &mut applicability), ), @@ -65,24 +64,21 @@ pub(super) fn check<'tcx>( cx, EXPLICIT_COUNTER_LOOP, span, - &format!("the variable `{}` is used as a loop counter", name), + &format!("the variable `{name}` is used as a loop counter"), |diag| { diag.span_suggestion( span, "consider using", format!( - "for ({}, {}) in (0_{}..).zip({})", - name, + "for ({name}, {}) in (0_{int_name}..).zip({})", snippet_with_applicability(cx, pat.span, "item", &mut applicability), - int_name, make_iterator_snippet(cx, arg, &mut applicability), ), applicability, ); diag.note(&format!( - "`{}` is of type `{}`, making it ineligible for `Iterator::enumerate`", - name, int_name + "`{name}` is of type `{int_name}`, making it ineligible for `Iterator::enumerate`" )); }, ); diff --git a/clippy_lints/src/loops/explicit_iter_loop.rs b/clippy_lints/src/loops/explicit_iter_loop.rs index 5f5beccd030..b1f2941622a 100644 --- a/clippy_lints/src/loops/explicit_iter_loop.rs +++ b/clippy_lints/src/loops/explicit_iter_loop.rs @@ -41,7 +41,7 @@ pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, arg: &Expr<'_>, m "it is more concise to loop over references to containers instead of using explicit \ iteration methods", "to write this more concisely, try", - format!("&{}{}", muta, object), + format!("&{muta}{object}"), applicability, ); } diff --git a/clippy_lints/src/loops/for_kv_map.rs b/clippy_lints/src/loops/for_kv_map.rs index bee0e1d7683..ed620460dbe 100644 --- a/clippy_lints/src/loops/for_kv_map.rs +++ b/clippy_lints/src/loops/for_kv_map.rs @@ -38,7 +38,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx cx, FOR_KV_MAP, arg_span, - &format!("you seem to want to iterate on a map's {}s", kind), + &format!("you seem to want to iterate on a map's {kind}s"), |diag| { let map = sugg::Sugg::hir(cx, arg, "map"); multispan_sugg( @@ -46,7 +46,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx "use the corresponding method", vec![ (pat_span, snippet(cx, new_pat_span, kind).into_owned()), - (arg_span, format!("{}.{}s{}()", map.maybe_par(), kind, mutbl)), + (arg_span, format!("{}.{kind}s{mutbl}()", map.maybe_par())), ], ); }, diff --git a/clippy_lints/src/loops/manual_flatten.rs b/clippy_lints/src/loops/manual_flatten.rs index 1d6ddf4b99f..1b36d452647 100644 --- a/clippy_lints/src/loops/manual_flatten.rs +++ b/clippy_lints/src/loops/manual_flatten.rs @@ -38,7 +38,7 @@ pub(super) fn check<'tcx>( then { let if_let_type = if some_ctor { "Some" } else { "Ok" }; // Prepare the error message - let msg = format!("unnecessary `if let` since only the `{}` variant of the iterator element is used", if_let_type); + let msg = format!("unnecessary `if let` since only the `{if_let_type}` variant of the iterator element is used"); // Prepare the help message let mut applicability = Applicability::MaybeIncorrect; diff --git a/clippy_lints/src/loops/manual_memcpy.rs b/clippy_lints/src/loops/manual_memcpy.rs index 3fc569af89e..c87fc4f90e2 100644 --- a/clippy_lints/src/loops/manual_memcpy.rs +++ b/clippy_lints/src/loops/manual_memcpy.rs @@ -177,13 +177,7 @@ fn build_manual_memcpy_suggestion<'tcx>( let dst = if dst_offset == sugg::EMPTY && dst_limit == sugg::EMPTY { dst_base_str } else { - format!( - "{}[{}..{}]", - dst_base_str, - dst_offset.maybe_par(), - dst_limit.maybe_par() - ) - .into() + format!("{dst_base_str}[{}..{}]", dst_offset.maybe_par(), dst_limit.maybe_par()).into() }; let method_str = if is_copy(cx, elem_ty) { @@ -193,10 +187,7 @@ fn build_manual_memcpy_suggestion<'tcx>( }; format!( - "{}.{}(&{}[{}..{}]);", - dst, - method_str, - src_base_str, + "{dst}.{method_str}(&{src_base_str}[{}..{}]);", src_offset.maybe_par(), src_limit.maybe_par() ) diff --git a/clippy_lints/src/loops/needless_collect.rs b/clippy_lints/src/loops/needless_collect.rs index 6e6faa79adc..66f9e28596e 100644 --- a/clippy_lints/src/loops/needless_collect.rs +++ b/clippy_lints/src/loops/needless_collect.rs @@ -45,7 +45,7 @@ fn check_needless_collect_direct_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCont let (arg, pred) = contains_arg .strip_prefix('&') .map_or(("&x", &*contains_arg), |s| ("x", s)); - format!("any(|{}| x == {})", arg, pred) + format!("any(|{arg}| x == {pred})") } _ => return, } @@ -141,9 +141,9 @@ impl IterFunction { IterFunctionKind::Contains(span) => { let s = snippet(cx, *span, ".."); if let Some(stripped) = s.strip_prefix('&') { - format!(".any(|x| x == {})", stripped) + format!(".any(|x| x == {stripped})") } else { - format!(".any(|x| x == *{})", s) + format!(".any(|x| x == *{s})") } }, } diff --git a/clippy_lints/src/loops/needless_range_loop.rs b/clippy_lints/src/loops/needless_range_loop.rs index 8ab640051b6..00cfc6d49f1 100644 --- a/clippy_lints/src/loops/needless_range_loop.rs +++ b/clippy_lints/src/loops/needless_range_loop.rs @@ -145,7 +145,7 @@ pub(super) fn check<'tcx>( cx, NEEDLESS_RANGE_LOOP, arg.span, - &format!("the loop variable `{}` is used to index `{}`", ident.name, indexed), + &format!("the loop variable `{}` is used to index `{indexed}`", ident.name), |diag| { multispan_sugg( diag, @@ -154,7 +154,7 @@ pub(super) fn check<'tcx>( (pat.span, format!("({}, )", ident.name)), ( arg.span, - format!("{}.{}().enumerate(){}{}", indexed, method, method_1, method_2), + format!("{indexed}.{method}().enumerate(){method_1}{method_2}"), ), ], ); @@ -162,16 +162,16 @@ pub(super) fn check<'tcx>( ); } else { let repl = if starts_at_zero && take_is_empty { - format!("&{}{}", ref_mut, indexed) + format!("&{ref_mut}{indexed}") } else { - format!("{}.{}(){}{}", indexed, method, method_1, method_2) + format!("{indexed}.{method}(){method_1}{method_2}") }; span_lint_and_then( cx, NEEDLESS_RANGE_LOOP, arg.span, - &format!("the loop variable `{}` is only used to index `{}`", ident.name, indexed), + &format!("the loop variable `{}` is only used to index `{indexed}`", ident.name), |diag| { multispan_sugg( diag, diff --git a/clippy_lints/src/loops/never_loop.rs b/clippy_lints/src/loops/never_loop.rs index 2386f4f4f4e..16b00ad6637 100644 --- a/clippy_lints/src/loops/never_loop.rs +++ b/clippy_lints/src/loops/never_loop.rs @@ -222,9 +222,5 @@ fn for_to_if_let_sugg(cx: &LateContext<'_>, iterator: &Expr<'_>, pat: &Pat<'_>) let pat_snippet = snippet(cx, pat.span, "_"); let iter_snippet = make_iterator_snippet(cx, iterator, &mut Applicability::Unspecified); - format!( - "if let Some({pat}) = {iter}.next()", - pat = pat_snippet, - iter = iter_snippet - ) + format!("if let Some({pat_snippet}) = {iter_snippet}.next()") } diff --git a/clippy_lints/src/loops/same_item_push.rs b/clippy_lints/src/loops/same_item_push.rs index aeefe6e33fb..07edee46fa6 100644 --- a/clippy_lints/src/loops/same_item_push.rs +++ b/clippy_lints/src/loops/same_item_push.rs @@ -30,10 +30,7 @@ pub(super) fn check<'tcx>( vec.span, "it looks like the same item is being pushed into this Vec", None, - &format!( - "try using vec![{};SIZE] or {}.resize(NEW_SIZE, {})", - item_str, vec_str, item_str - ), + &format!("try using vec![{item_str};SIZE] or {vec_str}.resize(NEW_SIZE, {item_str})"), ); } diff --git a/clippy_lints/src/loops/utils.rs b/clippy_lints/src/loops/utils.rs index 4801a84eb92..b332e8a923b 100644 --- a/clippy_lints/src/loops/utils.rs +++ b/clippy_lints/src/loops/utils.rs @@ -344,9 +344,8 @@ pub(super) fn make_iterator_snippet(cx: &LateContext<'_>, arg: &Expr<'_>, applic _ => arg, }; format!( - "{}.{}()", + "{}.{method_name}()", sugg::Sugg::hir_with_applicability(cx, caller, "_", applic_ref).maybe_par(), - method_name, ) }, _ => format!( diff --git a/clippy_lints/src/loops/while_let_on_iterator.rs b/clippy_lints/src/loops/while_let_on_iterator.rs index deb21894f36..1c6f0264cb5 100644 --- a/clippy_lints/src/loops/while_let_on_iterator.rs +++ b/clippy_lints/src/loops/while_let_on_iterator.rs @@ -67,7 +67,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { expr.span.with_hi(scrutinee_expr.span.hi()), "this loop could be written as a `for` loop", "try", - format!("for {} in {}{}", loop_var, iterator, by_ref), + format!("for {loop_var} in {iterator}{by_ref}"), applicability, ); } diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs index 6b78c162065..f5617a905ff 100644 --- a/clippy_lints/src/macro_use.rs +++ b/clippy_lints/src/macro_use.rs @@ -190,9 +190,9 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports { let mut suggestions = vec![]; for ((root, span, hir_id), path) in used { if path.len() == 1 { - suggestions.push((span, format!("{}::{}", root, path[0]), hir_id)); + suggestions.push((span, format!("{root}::{}", path[0]), hir_id)); } else { - suggestions.push((span, format!("{}::{{{}}}", root, path.join(", ")), hir_id)); + suggestions.push((span, format!("{root}::{{{}}}", path.join(", ")), hir_id)); } } @@ -200,7 +200,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports { // such as `std::prelude::v1::foo` or some other macro that expands to an import. if self.mac_refs.is_empty() { for (span, import, hir_id) in suggestions { - let help = format!("use {};", import); + let help = format!("use {import};"); span_lint_hir_and_then( cx, MACRO_USE_IMPORTS, diff --git a/clippy_lints/src/manual_async_fn.rs b/clippy_lints/src/manual_async_fn.rs index 2502c8f880d..ddd9f34cbc4 100644 --- a/clippy_lints/src/manual_async_fn.rs +++ b/clippy_lints/src/manual_async_fn.rs @@ -74,11 +74,11 @@ impl<'tcx> LateLintPass<'tcx> for ManualAsyncFn { if let Some(ret_pos) = position_before_rarrow(&header_snip); if let Some((ret_sugg, ret_snip)) = suggested_ret(cx, output); then { - let help = format!("make the function `async` and {}", ret_sugg); + let help = format!("make the function `async` and {ret_sugg}"); diag.span_suggestion( header_span, &help, - format!("async {}{}", &header_snip[..ret_pos], ret_snip), + format!("async {}{ret_snip}", &header_snip[..ret_pos]), Applicability::MachineApplicable ); @@ -196,7 +196,7 @@ fn suggested_ret(cx: &LateContext<'_>, output: &Ty<'_>) -> Option<(&'static str, }, _ => { let sugg = "return the output of the future directly"; - snippet_opt(cx, output.span).map(|snip| (sugg, format!(" -> {}", snip))) + snippet_opt(cx, output.span).map(|snip| (sugg, format!(" -> {snip}"))) }, } } diff --git a/clippy_lints/src/manual_non_exhaustive.rs b/clippy_lints/src/manual_non_exhaustive.rs index 2b04475c7a9..7d4f0b02112 100644 --- a/clippy_lints/src/manual_non_exhaustive.rs +++ b/clippy_lints/src/manual_non_exhaustive.rs @@ -133,7 +133,7 @@ impl EarlyLintPass for ManualNonExhaustiveStruct { diag.span_suggestion( header_span, "add the attribute", - format!("#[non_exhaustive] {}", snippet), + format!("#[non_exhaustive] {snippet}"), Applicability::Unspecified, ); } @@ -207,7 +207,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustiveEnum { diag.span_suggestion( header_span, "add the attribute", - format!("#[non_exhaustive] {}", snippet), + format!("#[non_exhaustive] {snippet}"), Applicability::Unspecified, ); } diff --git a/clippy_lints/src/manual_retain.rs b/clippy_lints/src/manual_retain.rs index 8476197bd12..570fe736818 100644 --- a/clippy_lints/src/manual_retain.rs +++ b/clippy_lints/src/manual_retain.rs @@ -153,7 +153,7 @@ fn suggest(cx: &LateContext<'_>, parent_expr: &hir::Expr<'_>, left_expr: &hir::E && let [filter_params] = filter_body.params && let Some(sugg) = match filter_params.pat.kind { hir::PatKind::Binding(_, _, filter_param_ident, None) => { - Some(format!("{}.retain(|{}| {})", snippet(cx, left_expr.span, ".."), filter_param_ident, snippet(cx, filter_body.value.span, ".."))) + Some(format!("{}.retain(|{filter_param_ident}| {})", snippet(cx, left_expr.span, ".."), snippet(cx, filter_body.value.span, ".."))) }, hir::PatKind::Tuple([key_pat, value_pat], _) => { make_sugg(cx, key_pat, value_pat, left_expr, filter_body) @@ -161,7 +161,7 @@ fn suggest(cx: &LateContext<'_>, parent_expr: &hir::Expr<'_>, left_expr: &hir::E hir::PatKind::Ref(pat, _) => { match pat.kind { hir::PatKind::Binding(_, _, filter_param_ident, None) => { - Some(format!("{}.retain(|{}| {})", snippet(cx, left_expr.span, ".."), filter_param_ident, snippet(cx, filter_body.value.span, ".."))) + Some(format!("{}.retain(|{filter_param_ident}| {})", snippet(cx, left_expr.span, ".."), snippet(cx, filter_body.value.span, ".."))) }, _ => None } @@ -190,23 +190,19 @@ fn make_sugg( match (&key_pat.kind, &value_pat.kind) { (hir::PatKind::Binding(_, _, key_param_ident, None), hir::PatKind::Binding(_, _, value_param_ident, None)) => { Some(format!( - "{}.retain(|{}, &mut {}| {})", + "{}.retain(|{key_param_ident}, &mut {value_param_ident}| {})", snippet(cx, left_expr.span, ".."), - key_param_ident, - value_param_ident, snippet(cx, filter_body.value.span, "..") )) }, (hir::PatKind::Binding(_, _, key_param_ident, None), hir::PatKind::Wild) => Some(format!( - "{}.retain(|{}, _| {})", + "{}.retain(|{key_param_ident}, _| {})", snippet(cx, left_expr.span, ".."), - key_param_ident, snippet(cx, filter_body.value.span, "..") )), (hir::PatKind::Wild, hir::PatKind::Binding(_, _, value_param_ident, None)) => Some(format!( - "{}.retain(|_, &mut {}| {})", + "{}.retain(|_, &mut {value_param_ident}| {})", snippet(cx, left_expr.span, ".."), - value_param_ident, snippet(cx, filter_body.value.span, "..") )), _ => None, diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index 7941c8c9c7e..0976940afac 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -108,15 +108,14 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip { }; let test_span = expr.span.until(then.span); - span_lint_and_then(cx, MANUAL_STRIP, strippings[0], &format!("stripping a {} manually", kind_word), |diag| { - diag.span_note(test_span, &format!("the {} was tested here", kind_word)); + span_lint_and_then(cx, MANUAL_STRIP, strippings[0], &format!("stripping a {kind_word} manually"), |diag| { + diag.span_note(test_span, &format!("the {kind_word} was tested here")); multispan_sugg( diag, - &format!("try using the `strip_{}` method", kind_word), + &format!("try using the `strip_{kind_word}` method"), vec![(test_span, - format!("if let Some() = {}.strip_{}({}) ", + format!("if let Some() = {}.strip_{kind_word}({}) ", snippet(cx, target_arg.span, ".."), - kind_word, snippet(cx, pattern.span, "..")))] .into_iter().chain(strippings.into_iter().map(|span| (span, "".into()))), ); diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 33d74481529..df5684541e9 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -194,10 +194,7 @@ fn let_binding_name(cx: &LateContext<'_>, var_arg: &hir::Expr<'_>) -> String { #[must_use] fn suggestion_msg(function_type: &str, map_type: &str) -> String { - format!( - "called `map(f)` on an `{0}` value where `f` is a {1} that returns the unit type `()`", - map_type, function_type - ) + format!("called `map(f)` on an `{map_type}` value where `f` is a {function_type} that returns the unit type `()`") } fn lint_map_unit_fn( diff --git a/clippy_lints/src/match_result_ok.rs b/clippy_lints/src/match_result_ok.rs index 8588ab1ed8d..a020282d234 100644 --- a/clippy_lints/src/match_result_ok.rs +++ b/clippy_lints/src/match_result_ok.rs @@ -70,9 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for MatchResultOk { let some_expr_string = snippet_with_applicability(cx, y[0].span, "", &mut applicability); let trimmed_ok = snippet_with_applicability(cx, let_expr.span.until(ok_path.ident.span), "", &mut applicability); let sugg = format!( - "{} let Ok({}) = {}", - ifwhile, - some_expr_string, + "{ifwhile} let Ok({some_expr_string}) = {}", trimmed_ok.trim().trim_end_matches('.'), ); span_lint_and_sugg( @@ -80,7 +78,7 @@ impl<'tcx> LateLintPass<'tcx> for MatchResultOk { MATCH_RESULT_OK, expr.span.with_hi(let_expr.span.hi()), "matching on `Some` with `ok()` is redundant", - &format!("consider matching on `Ok({})` and removing the call to `ok` instead", some_expr_string), + &format!("consider matching on `Ok({some_expr_string})` and removing the call to `ok` instead"), sugg, applicability, ); diff --git a/clippy_lints/src/matches/manual_map.rs b/clippy_lints/src/matches/manual_map.rs index b0198e856d5..96b8339550c 100644 --- a/clippy_lints/src/matches/manual_map.rs +++ b/clippy_lints/src/matches/manual_map.rs @@ -144,7 +144,7 @@ fn check<'tcx>( let scrutinee = peel_hir_expr_refs(scrutinee).0; let (scrutinee_str, _) = snippet_with_context(cx, scrutinee.span, expr_ctxt, "..", &mut app); let scrutinee_str = if scrutinee.span.ctxt() == expr.span.ctxt() && scrutinee.precedence().order() < PREC_POSTFIX { - format!("({})", scrutinee_str) + format!("({scrutinee_str})") } else { scrutinee_str.into() }; @@ -172,9 +172,9 @@ fn check<'tcx>( }; let expr_snip = snippet_with_context(cx, some_expr.expr.span, expr_ctxt, "..", &mut app).0; if some_expr.needs_unsafe_block { - format!("|{}{}| unsafe {{ {} }}", annotation, some_binding, expr_snip) + format!("|{annotation}{some_binding}| unsafe {{ {expr_snip} }}") } else { - format!("|{}{}| {}", annotation, some_binding, expr_snip) + format!("|{annotation}{some_binding}| {expr_snip}") } } } @@ -183,9 +183,9 @@ fn check<'tcx>( let pat_snip = snippet_with_context(cx, some_pat.span, expr_ctxt, "..", &mut app).0; let expr_snip = snippet_with_context(cx, some_expr.expr.span, expr_ctxt, "..", &mut app).0; if some_expr.needs_unsafe_block { - format!("|{}| unsafe {{ {} }}", pat_snip, expr_snip) + format!("|{pat_snip}| unsafe {{ {expr_snip} }}") } else { - format!("|{}| {}", pat_snip, expr_snip) + format!("|{pat_snip}| {expr_snip}") } } else { // Refutable bindings and mixed reference annotations can't be handled by `map`. @@ -199,9 +199,9 @@ fn check<'tcx>( "manual implementation of `Option::map`", "try this", if else_pat.is_none() && is_else_clause(cx.tcx, expr) { - format!("{{ {}{}.map({}) }}", scrutinee_str, as_ref_str, body_str) + format!("{{ {scrutinee_str}{as_ref_str}.map({body_str}) }}") } else { - format!("{}{}.map({})", scrutinee_str, as_ref_str, body_str) + format!("{scrutinee_str}{as_ref_str}.map({body_str})") }, app, ); diff --git a/clippy_lints/src/matches/manual_unwrap_or.rs b/clippy_lints/src/matches/manual_unwrap_or.rs index e1111c80f2f..2fe7fe98a2e 100644 --- a/clippy_lints/src/matches/manual_unwrap_or.rs +++ b/clippy_lints/src/matches/manual_unwrap_or.rs @@ -42,12 +42,10 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, scrutinee: span_lint_and_sugg( cx, MANUAL_UNWRAP_OR, expr.span, - &format!("this pattern reimplements `{}::unwrap_or`", ty_name), + &format!("this pattern reimplements `{ty_name}::unwrap_or`"), "replace with", format!( - "{}.unwrap_or({})", - suggestion, - reindented_or_body, + "{suggestion}.unwrap_or({reindented_or_body})", ), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/matches/match_as_ref.rs b/clippy_lints/src/matches/match_as_ref.rs index 91d17f481e2..39d30212f36 100644 --- a/clippy_lints/src/matches/match_as_ref.rs +++ b/clippy_lints/src/matches/match_as_ref.rs @@ -45,13 +45,11 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: cx, MATCH_AS_REF, expr.span, - &format!("use `{}()` instead", suggestion), + &format!("use `{suggestion}()` instead"), "try this", format!( - "{}.{}(){}", + "{}.{suggestion}(){cast}", snippet_with_applicability(cx, ex.span, "_", &mut applicability), - suggestion, - cast, ), applicability, ); diff --git a/clippy_lints/src/matches/match_like_matches.rs b/clippy_lints/src/matches/match_like_matches.rs index 34cc082687e..107fad32393 100644 --- a/clippy_lints/src/matches/match_like_matches.rs +++ b/clippy_lints/src/matches/match_like_matches.rs @@ -112,7 +112,7 @@ where .join(" | ") }; let pat_and_guard = if let Some(Guard::If(g)) = first_guard { - format!("{} if {}", pat, snippet_with_applicability(cx, g.span, "..", &mut applicability)) + format!("{pat} if {}", snippet_with_applicability(cx, g.span, "..", &mut applicability)) } else { pat }; @@ -131,10 +131,9 @@ where &format!("{} expression looks like `matches!` macro", if is_if_let { "if let .. else" } else { "match" }), "try this", format!( - "{}matches!({}, {})", + "{}matches!({}, {pat_and_guard})", if b0 { "" } else { "!" }, snippet_with_applicability(cx, ex_new.span, "..", &mut applicability), - pat_and_guard, ), applicability, ); diff --git a/clippy_lints/src/matches/match_same_arms.rs b/clippy_lints/src/matches/match_same_arms.rs index e32ef9933af..3e11016602b 100644 --- a/clippy_lints/src/matches/match_same_arms.rs +++ b/clippy_lints/src/matches/match_same_arms.rs @@ -135,7 +135,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>]) { diag.span_suggestion( keep_arm.pat.span, "try merging the arm patterns", - format!("{} | {}", keep_pat_snip, move_pat_snip), + format!("{keep_pat_snip} | {move_pat_snip}"), Applicability::MaybeIncorrect, ) .help("or try changing either arm body") diff --git a/clippy_lints/src/matches/match_single_binding.rs b/clippy_lints/src/matches/match_single_binding.rs index 5ae4a65acaf..68682cedf1d 100644 --- a/clippy_lints/src/matches/match_single_binding.rs +++ b/clippy_lints/src/matches/match_single_binding.rs @@ -75,12 +75,11 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e Some(AssignmentExpr::Local { span, pat_span }) => ( span, format!( - "let {} = {};\n{}let {} = {};", + "let {} = {};\n{}let {} = {snippet_body};", snippet_with_applicability(cx, bind_names, "..", &mut applicability), snippet_with_applicability(cx, matched_vars, "..", &mut applicability), " ".repeat(indent_of(cx, expr.span).unwrap_or(0)), - snippet_with_applicability(cx, pat_span, "..", &mut applicability), - snippet_body + snippet_with_applicability(cx, pat_span, "..", &mut applicability) ), ), None => { @@ -110,10 +109,8 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e if ex.can_have_side_effects() { let indent = " ".repeat(indent_of(cx, expr.span).unwrap_or(0)); let sugg = format!( - "{};\n{}{}", - snippet_with_applicability(cx, ex.span, "..", &mut applicability), - indent, - snippet_body + "{};\n{indent}{snippet_body}", + snippet_with_applicability(cx, ex.span, "..", &mut applicability) ); span_lint_and_sugg( @@ -178,10 +175,10 @@ fn sugg_with_curlies<'a>( let (mut cbrace_start, mut cbrace_end) = (String::new(), String::new()); if let Some(parent_expr) = get_parent_expr(cx, match_expr) { if let ExprKind::Closure { .. } = parent_expr.kind { - cbrace_end = format!("\n{}}}", indent); + cbrace_end = format!("\n{indent}}}"); // Fix body indent due to the closure indent = " ".repeat(indent_of(cx, bind_names).unwrap_or(0)); - cbrace_start = format!("{{\n{}", indent); + cbrace_start = format!("{{\n{indent}"); } } @@ -190,10 +187,10 @@ fn sugg_with_curlies<'a>( let parent_node_id = cx.tcx.hir().get_parent_node(match_expr.hir_id); if let Node::Arm(arm) = &cx.tcx.hir().get(parent_node_id) { if let ExprKind::Match(..) = arm.body.kind { - cbrace_end = format!("\n{}}}", indent); + cbrace_end = format!("\n{indent}}}"); // Fix body indent due to the match indent = " ".repeat(indent_of(cx, bind_names).unwrap_or(0)); - cbrace_start = format!("{{\n{}", indent); + cbrace_start = format!("{{\n{indent}"); } } @@ -204,13 +201,8 @@ fn sugg_with_curlies<'a>( }); format!( - "{}let {} = {};\n{}{}{}{}", - cbrace_start, + "{cbrace_start}let {} = {};\n{indent}{assignment_str}{snippet_body}{cbrace_end}", snippet_with_applicability(cx, bind_names, "..", applicability), - snippet_with_applicability(cx, matched_vars, "..", applicability), - indent, - assignment_str, - snippet_body, - cbrace_end + snippet_with_applicability(cx, matched_vars, "..", applicability) ) } diff --git a/clippy_lints/src/matches/match_str_case_mismatch.rs b/clippy_lints/src/matches/match_str_case_mismatch.rs index 1e80b6cf2d8..6647322caa3 100644 --- a/clippy_lints/src/matches/match_str_case_mismatch.rs +++ b/clippy_lints/src/matches/match_str_case_mismatch.rs @@ -118,8 +118,8 @@ fn lint(cx: &LateContext<'_>, case_method: &CaseMethod, bad_case_span: Span, bad MATCH_STR_CASE_MISMATCH, bad_case_span, "this `match` arm has a differing case than its expression", - &format!("consider changing the case of this arm to respect `{}`", method_str), - format!("\"{}\"", suggestion), + &format!("consider changing the case of this arm to respect `{method_str}`"), + format!("\"{suggestion}\""), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/matches/match_wild_err_arm.rs b/clippy_lints/src/matches/match_wild_err_arm.rs index a3aa2e4b389..42f1e2629d4 100644 --- a/clippy_lints/src/matches/match_wild_err_arm.rs +++ b/clippy_lints/src/matches/match_wild_err_arm.rs @@ -38,7 +38,7 @@ pub(crate) fn check<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm<' span_lint_and_note(cx, MATCH_WILD_ERR_ARM, arm.pat.span, - &format!("`Err({})` matches all errors", ident_bind_name), + &format!("`Err({ident_bind_name})` matches all errors"), None, "match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable", ); diff --git a/clippy_lints/src/matches/redundant_pattern_match.rs b/clippy_lints/src/matches/redundant_pattern_match.rs index f7443471e31..343b1d058b4 100644 --- a/clippy_lints/src/matches/redundant_pattern_match.rs +++ b/clippy_lints/src/matches/redundant_pattern_match.rs @@ -138,7 +138,7 @@ fn find_sugg_for_if_let<'tcx>( cx, REDUNDANT_PATTERN_MATCHING, let_pat.span, - &format!("redundant pattern matching, consider using `{}`", good_method), + &format!("redundant pattern matching, consider using `{good_method}`"), |diag| { // if/while let ... = ... { ... } // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -162,7 +162,7 @@ fn find_sugg_for_if_let<'tcx>( .maybe_par() .to_string(); - diag.span_suggestion(span, "try this", format!("{} {}.{}", keyword, sugg, good_method), app); + diag.span_suggestion(span, "try this", format!("{keyword} {sugg}.{good_method}"), app); if needs_drop { diag.note("this will change drop order of the result, as well as all temporaries"); @@ -252,12 +252,12 @@ pub(super) fn check_match<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, op cx, REDUNDANT_PATTERN_MATCHING, expr.span, - &format!("redundant pattern matching, consider using `{}`", good_method), + &format!("redundant pattern matching, consider using `{good_method}`"), |diag| { diag.span_suggestion( span, "try this", - format!("{}.{}", snippet(cx, result_expr.span, "_"), good_method), + format!("{}.{good_method}", snippet(cx, result_expr.span, "_")), Applicability::MaybeIncorrect, // snippet ); }, diff --git a/clippy_lints/src/matches/significant_drop_in_scrutinee.rs b/clippy_lints/src/matches/significant_drop_in_scrutinee.rs index 86a9df03497..85269e533a0 100644 --- a/clippy_lints/src/matches/significant_drop_in_scrutinee.rs +++ b/clippy_lints/src/matches/significant_drop_in_scrutinee.rs @@ -50,13 +50,13 @@ fn set_diagnostic<'tcx>(diag: &mut Diagnostic, cx: &LateContext<'tcx>, expr: &'t let trailing_indent = " ".repeat(indent_of(cx, found.found_span).unwrap_or(0)); let replacement = if found.lint_suggestion == LintSuggestion::MoveAndDerefToCopy { - format!("let value = *{};\n{}", original, trailing_indent) + format!("let value = *{original};\n{trailing_indent}") } else if found.is_unit_return_val { // If the return value of the expression to be moved is unit, then we don't need to // capture the result in a temporary -- we can just replace it completely with `()`. - format!("{};\n{}", original, trailing_indent) + format!("{original};\n{trailing_indent}") } else { - format!("let value = {};\n{}", original, trailing_indent) + format!("let value = {original};\n{trailing_indent}") }; let suggestion_message = if found.lint_suggestion == LintSuggestion::MoveOnly { diff --git a/clippy_lints/src/matches/single_match.rs b/clippy_lints/src/matches/single_match.rs index 38df69eeb37..6314959f818 100644 --- a/clippy_lints/src/matches/single_match.rs +++ b/clippy_lints/src/matches/single_match.rs @@ -99,23 +99,21 @@ fn report_single_pattern( let msg = "you seem to be trying to use `match` for an equality check. Consider using `if`"; let sugg = format!( - "if {} == {}{} {}{}", + "if {} == {}{} {}{els_str}", snippet(cx, ex.span, ".."), // PartialEq for different reference counts may not exist. "&".repeat(ref_count_diff), snippet(cx, arms[0].pat.span, ".."), expr_block(cx, arms[0].body, None, "..", Some(expr.span)), - els_str, ); (msg, sugg) } else { let msg = "you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`"; let sugg = format!( - "if let {} = {} {}{}", + "if let {} = {} {}{els_str}", snippet(cx, arms[0].pat.span, ".."), snippet(cx, ex.span, ".."), expr_block(cx, arms[0].body, None, "..", Some(expr.span)), - els_str, ); (msg, sugg) } diff --git a/clippy_lints/src/matches/try_err.rs b/clippy_lints/src/matches/try_err.rs index 663277d1136..a3ec1ff2482 100644 --- a/clippy_lints/src/matches/try_err.rs +++ b/clippy_lints/src/matches/try_err.rs @@ -61,9 +61,9 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, scrutine "return " }; let suggestion = if err_ty == expr_err_ty { - format!("{}{}{}{}", ret_prefix, prefix, origin_snippet, suffix) + format!("{ret_prefix}{prefix}{origin_snippet}{suffix}") } else { - format!("{}{}{}.into(){}", ret_prefix, prefix, origin_snippet, suffix) + format!("{ret_prefix}{prefix}{origin_snippet}.into(){suffix}") }; span_lint_and_sugg( diff --git a/clippy_lints/src/methods/bind_instead_of_map.rs b/clippy_lints/src/methods/bind_instead_of_map.rs index 22f5635a5bc..cc26b0f7fa8 100644 --- a/clippy_lints/src/methods/bind_instead_of_map.rs +++ b/clippy_lints/src/methods/bind_instead_of_map.rs @@ -85,7 +85,7 @@ pub(crate) trait BindInsteadOfMap { let closure_args_snip = snippet(cx, closure_args_span, ".."); let option_snip = snippet(cx, recv.span, ".."); - let note = format!("{}.{}({} {})", option_snip, Self::GOOD_METHOD_NAME, closure_args_snip, some_inner_snip); + let note = format!("{option_snip}.{}({closure_args_snip} {some_inner_snip})", Self::GOOD_METHOD_NAME); span_lint_and_sugg( cx, BIND_INSTEAD_OF_MAP, diff --git a/clippy_lints/src/methods/bytes_nth.rs b/clippy_lints/src/methods/bytes_nth.rs index 44857d61fef..2e96346be97 100644 --- a/clippy_lints/src/methods/bytes_nth.rs +++ b/clippy_lints/src/methods/bytes_nth.rs @@ -22,7 +22,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx E cx, BYTES_NTH, expr.span, - &format!("called `.bytes().nth()` on a `{}`", caller_type), + &format!("called `.bytes().nth()` on a `{caller_type}`"), "try", format!( "{}.as_bytes().get({})", diff --git a/clippy_lints/src/methods/chars_cmp.rs b/clippy_lints/src/methods/chars_cmp.rs index b2bc1ad5c9e..56b7fbb9d4b 100644 --- a/clippy_lints/src/methods/chars_cmp.rs +++ b/clippy_lints/src/methods/chars_cmp.rs @@ -33,12 +33,11 @@ pub(super) fn check( cx, lint, info.expr.span, - &format!("you should use the `{}` method", suggest), + &format!("you should use the `{suggest}` method"), "like this", - format!("{}{}.{}({})", + format!("{}{}.{suggest}({})", if info.eq { "" } else { "!" }, snippet_with_applicability(cx, args[0].0.span, "..", &mut applicability), - suggest, snippet_with_applicability(cx, arg_char.span, "..", &mut applicability)), applicability, ); diff --git a/clippy_lints/src/methods/chars_cmp_with_unwrap.rs b/clippy_lints/src/methods/chars_cmp_with_unwrap.rs index b85bfec2b12..7e808760663 100644 --- a/clippy_lints/src/methods/chars_cmp_with_unwrap.rs +++ b/clippy_lints/src/methods/chars_cmp_with_unwrap.rs @@ -26,12 +26,11 @@ pub(super) fn check<'tcx>( cx, lint, info.expr.span, - &format!("you should use the `{}` method", suggest), + &format!("you should use the `{suggest}` method"), "like this", - format!("{}{}.{}('{}')", + format!("{}{}.{suggest}('{}')", if info.eq { "" } else { "!" }, snippet_with_applicability(cx, args[0].0.span, "..", &mut applicability), - suggest, c.escape_default()), applicability, ); diff --git a/clippy_lints/src/methods/clone_on_copy.rs b/clippy_lints/src/methods/clone_on_copy.rs index 7ab6b84c207..7c7938dd2e8 100644 --- a/clippy_lints/src/methods/clone_on_copy.rs +++ b/clippy_lints/src/methods/clone_on_copy.rs @@ -49,8 +49,7 @@ pub(super) fn check( expr.span, &format!( "using `clone` on a double-reference; \ - this will copy the reference of type `{}` instead of cloning the inner type", - ty + this will copy the reference of type `{ty}` instead of cloning the inner type" ), |diag| { if let Some(snip) = sugg::Sugg::hir_opt(cx, arg) { @@ -62,11 +61,11 @@ pub(super) fn check( } let refs = "&".repeat(n + 1); let derefs = "*".repeat(n); - let explicit = format!("<{}{}>::clone({})", refs, ty, snip); + let explicit = format!("<{refs}{ty}>::clone({snip})"); diag.span_suggestion( expr.span, "try dereferencing it", - format!("{}({}{}).clone()", refs, derefs, snip.deref()), + format!("{refs}({derefs}{}).clone()", snip.deref()), Applicability::MaybeIncorrect, ); diag.span_suggestion( @@ -121,16 +120,16 @@ pub(super) fn check( let (help, sugg) = if deref_count == 0 { ("try removing the `clone` call", snip.into()) } else if parent_is_suffix_expr { - ("try dereferencing it", format!("({}{})", "*".repeat(deref_count), snip)) + ("try dereferencing it", format!("({}{snip})", "*".repeat(deref_count))) } else { - ("try dereferencing it", format!("{}{}", "*".repeat(deref_count), snip)) + ("try dereferencing it", format!("{}{snip}", "*".repeat(deref_count))) }; span_lint_and_sugg( cx, CLONE_ON_COPY, expr.span, - &format!("using `clone` on type `{}` which implements the `Copy` trait", ty), + &format!("using `clone` on type `{ty}` which implements the `Copy` trait"), help, sugg, app, diff --git a/clippy_lints/src/methods/clone_on_ref_ptr.rs b/clippy_lints/src/methods/clone_on_ref_ptr.rs index f82ca891200..355f53532e2 100644 --- a/clippy_lints/src/methods/clone_on_ref_ptr.rs +++ b/clippy_lints/src/methods/clone_on_ref_ptr.rs @@ -41,7 +41,7 @@ pub(super) fn check( expr.span, "using `.clone()` on a ref-counted pointer", "try this", - format!("{}::<{}>::clone(&{})", caller_type, subst.type_at(0), snippet), + format!("{caller_type}::<{}>::clone(&{snippet})", subst.type_at(0)), Applicability::Unspecified, // Sometimes unnecessary ::<_> after Rc/Arc/Weak ); } diff --git a/clippy_lints/src/methods/expect_fun_call.rs b/clippy_lints/src/methods/expect_fun_call.rs index bd846d71d46..d0cf411dfd3 100644 --- a/clippy_lints/src/methods/expect_fun_call.rs +++ b/clippy_lints/src/methods/expect_fun_call.rs @@ -143,9 +143,9 @@ pub(super) fn check<'tcx>( cx, EXPECT_FUN_CALL, span_replace_word, - &format!("use of `{}` followed by a function call", name), + &format!("use of `{name}` followed by a function call"), "try this", - format!("unwrap_or_else({} panic!({}))", closure_args, sugg), + format!("unwrap_or_else({closure_args} panic!({sugg}))"), applicability, ); return; @@ -160,12 +160,9 @@ pub(super) fn check<'tcx>( cx, EXPECT_FUN_CALL, span_replace_word, - &format!("use of `{}` followed by a function call", name), + &format!("use of `{name}` followed by a function call"), "try this", - format!( - "unwrap_or_else({} {{ panic!(\"{{}}\", {}) }})", - closure_args, arg_root_snippet - ), + format!("unwrap_or_else({closure_args} {{ panic!(\"{{}}\", {arg_root_snippet}) }})"), applicability, ); } diff --git a/clippy_lints/src/methods/filetype_is_file.rs b/clippy_lints/src/methods/filetype_is_file.rs index 7b2967feb0f..60f8283c3e0 100644 --- a/clippy_lints/src/methods/filetype_is_file.rs +++ b/clippy_lints/src/methods/filetype_is_file.rs @@ -35,7 +35,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr span = expr.span; } } - let lint_msg = format!("`{}FileType::is_file()` only {} regular files", lint_unary, verb); - let help_msg = format!("use `{}FileType::is_dir()` instead", help_unary); + let lint_msg = format!("`{lint_unary}FileType::is_file()` only {verb} regular files"); + let help_msg = format!("use `{help_unary}FileType::is_dir()` instead"); span_lint_and_help(cx, FILETYPE_IS_FILE, span, &lint_msg, None, &help_msg); } diff --git a/clippy_lints/src/methods/filter_map_next.rs b/clippy_lints/src/methods/filter_map_next.rs index 38ec4d8e3ab..ddf8a1f09b8 100644 --- a/clippy_lints/src/methods/filter_map_next.rs +++ b/clippy_lints/src/methods/filter_map_next.rs @@ -32,7 +32,7 @@ pub(super) fn check<'tcx>( expr.span, msg, "try this", - format!("{}.find_map({})", iter_snippet, filter_snippet), + format!("{iter_snippet}.find_map({filter_snippet})"), Applicability::MachineApplicable, ); } else { diff --git a/clippy_lints/src/methods/filter_next.rs b/clippy_lints/src/methods/filter_next.rs index bcf8d93b602..edcec0fc101 100644 --- a/clippy_lints/src/methods/filter_next.rs +++ b/clippy_lints/src/methods/filter_next.rs @@ -32,7 +32,7 @@ pub(super) fn check<'tcx>( expr.span, msg, "try this", - format!("{}.find({})", iter_snippet, filter_snippet), + format!("{iter_snippet}.find({filter_snippet})"), Applicability::MachineApplicable, ); } else { diff --git a/clippy_lints/src/methods/from_iter_instead_of_collect.rs b/clippy_lints/src/methods/from_iter_instead_of_collect.rs index 6436e28a63c..66dfce3682b 100644 --- a/clippy_lints/src/methods/from_iter_instead_of_collect.rs +++ b/clippy_lints/src/methods/from_iter_instead_of_collect.rs @@ -23,7 +23,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir::Exp // `expr` implements `FromIterator` trait let iter_expr = sugg::Sugg::hir(cx, &args[0], "..").maybe_par(); let turbofish = extract_turbofish(cx, expr, ty); - let sugg = format!("{}.collect::<{}>()", iter_expr, turbofish); + let sugg = format!("{iter_expr}.collect::<{turbofish}>()"); span_lint_and_sugg( cx, FROM_ITER_INSTEAD_OF_COLLECT, @@ -63,7 +63,7 @@ fn extract_turbofish(cx: &LateContext<'_>, expr: &hir::Expr<'_>, ty: Ty<'_>) -> if e == type_specifier { None } else { Some((*e).to_string()) } }).collect::>(); // join and add the type specifier at the end (i.e.: `collections::BTreeSet`) - format!("{}{}", without_ts.join("::"), type_specifier) + format!("{}{type_specifier}", without_ts.join("::")) } else { // type is not explicitly specified so wildcards are needed // i.e.: 2 wildcards in `std::collections::BTreeMap<&i32, &char>` @@ -72,7 +72,7 @@ fn extract_turbofish(cx: &LateContext<'_>, expr: &hir::Expr<'_>, ty: Ty<'_>) -> let end = ty_str.find('>').unwrap_or(ty_str.len()); let nb_wildcard = ty_str[start..end].split(',').count(); let wildcards = format!("_{}", ", _".repeat(nb_wildcard - 1)); - format!("{}<{}>", elements.join("::"), wildcards) + format!("{}<{wildcards}>", elements.join("::")) } } } diff --git a/clippy_lints/src/methods/get_first.rs b/clippy_lints/src/methods/get_first.rs index 4de77de7404..cb17af608a3 100644 --- a/clippy_lints/src/methods/get_first.rs +++ b/clippy_lints/src/methods/get_first.rs @@ -29,9 +29,9 @@ pub(super) fn check<'tcx>( cx, GET_FIRST, expr.span, - &format!("accessing first element with `{0}.get(0)`", slice_name), + &format!("accessing first element with `{slice_name}.get(0)`"), "try", - format!("{}.first()", slice_name), + format!("{slice_name}.first()"), app, ); } diff --git a/clippy_lints/src/methods/get_unwrap.rs b/clippy_lints/src/methods/get_unwrap.rs index 18e08d6ee23..ffc3a4d780e 100644 --- a/clippy_lints/src/methods/get_unwrap.rs +++ b/clippy_lints/src/methods/get_unwrap.rs @@ -71,16 +71,11 @@ pub(super) fn check<'tcx>( cx, GET_UNWRAP, span, - &format!( - "called `.get{0}().unwrap()` on a {1}. Using `[]` is more clear and more concise", - mut_str, caller_type - ), + &format!("called `.get{mut_str}().unwrap()` on a {caller_type}. Using `[]` is more clear and more concise"), "try this", format!( - "{}{}[{}]", - borrow_str, - snippet_with_applicability(cx, recv.span, "..", &mut applicability), - get_args_str + "{borrow_str}{}[{get_args_str}]", + snippet_with_applicability(cx, recv.span, "..", &mut applicability) ), applicability, ); diff --git a/clippy_lints/src/methods/implicit_clone.rs b/clippy_lints/src/methods/implicit_clone.rs index 9651a52be4e..429cdc1918d 100644 --- a/clippy_lints/src/methods/implicit_clone.rs +++ b/clippy_lints/src/methods/implicit_clone.rs @@ -26,12 +26,12 @@ pub fn check(cx: &LateContext<'_>, method_name: &str, expr: &hir::Expr<'_>, recv cx, IMPLICIT_CLONE, expr.span, - &format!("implicitly cloning a `{}` by calling `{}` on its dereferenced type", ty_name, method_name), + &format!("implicitly cloning a `{ty_name}` by calling `{method_name}` on its dereferenced type"), "consider using", if ref_count > 1 { - format!("({}{}).clone()", "*".repeat(ref_count - 1), recv_snip) + format!("({}{recv_snip}).clone()", "*".repeat(ref_count - 1)) } else { - format!("{}.clone()", recv_snip) + format!("{recv_snip}.clone()") }, app, ); diff --git a/clippy_lints/src/methods/inefficient_to_string.rs b/clippy_lints/src/methods/inefficient_to_string.rs index e1c9b5248a8..e5dc3711b0b 100644 --- a/clippy_lints/src/methods/inefficient_to_string.rs +++ b/clippy_lints/src/methods/inefficient_to_string.rs @@ -34,18 +34,17 @@ pub fn check<'tcx>( cx, INEFFICIENT_TO_STRING, expr.span, - &format!("calling `to_string` on `{}`", arg_ty), + &format!("calling `to_string` on `{arg_ty}`"), |diag| { diag.help(&format!( - "`{}` implements `ToString` through a slower blanket impl, but `{}` has a fast specialization of `ToString`", - self_ty, deref_self_ty + "`{self_ty}` implements `ToString` through a slower blanket impl, but `{deref_self_ty}` has a fast specialization of `ToString`" )); let mut applicability = Applicability::MachineApplicable; let arg_snippet = snippet_with_applicability(cx, receiver.span, "..", &mut applicability); diag.span_suggestion( expr.span, "try dereferencing the receiver", - format!("({}{}).to_string()", "*".repeat(deref_count), arg_snippet), + format!("({}{arg_snippet}).to_string()", "*".repeat(deref_count)), applicability, ); }, diff --git a/clippy_lints/src/methods/into_iter_on_ref.rs b/clippy_lints/src/methods/into_iter_on_ref.rs index 11e76841e9f..be56b63506a 100644 --- a/clippy_lints/src/methods/into_iter_on_ref.rs +++ b/clippy_lints/src/methods/into_iter_on_ref.rs @@ -30,8 +30,7 @@ pub(super) fn check( INTO_ITER_ON_REF, method_span, &format!( - "this `.into_iter()` call is equivalent to `.{}()` and will not consume the `{}`", - method_name, kind, + "this `.into_iter()` call is equivalent to `.{method_name}()` and will not consume the `{kind}`", ), "call directly", method_name.to_string(), diff --git a/clippy_lints/src/methods/is_digit_ascii_radix.rs b/clippy_lints/src/methods/is_digit_ascii_radix.rs index aa176dcc8b4..304024e8066 100644 --- a/clippy_lints/src/methods/is_digit_ascii_radix.rs +++ b/clippy_lints/src/methods/is_digit_ascii_radix.rs @@ -37,12 +37,11 @@ pub(super) fn check<'tcx>( cx, IS_DIGIT_ASCII_RADIX, expr.span, - &format!("use of `char::is_digit` with literal radix of {}", num), + &format!("use of `char::is_digit` with literal radix of {num}"), "try", format!( - "{}.{}()", - snippet_with_applicability(cx, self_arg.span, "..", &mut applicability), - replacement + "{}.{replacement}()", + snippet_with_applicability(cx, self_arg.span, "..", &mut applicability) ), applicability, ); diff --git a/clippy_lints/src/methods/iter_cloned_collect.rs b/clippy_lints/src/methods/iter_cloned_collect.rs index 30d56113c6c..bde6f92b076 100644 --- a/clippy_lints/src/methods/iter_cloned_collect.rs +++ b/clippy_lints/src/methods/iter_cloned_collect.rs @@ -20,8 +20,8 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, method_name: &str, expr: &hir: cx, ITER_CLONED_COLLECT, to_replace, - &format!("called `iter().{}().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and \ - more readable", method_name), + &format!("called `iter().{method_name}().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and \ + more readable"), "try", ".to_vec()".to_string(), Applicability::MachineApplicable, diff --git a/clippy_lints/src/methods/iter_count.rs b/clippy_lints/src/methods/iter_count.rs index 052be3d8ee7..bcddc7c786a 100644 --- a/clippy_lints/src/methods/iter_count.rs +++ b/clippy_lints/src/methods/iter_count.rs @@ -37,7 +37,7 @@ pub(crate) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx E cx, ITER_COUNT, expr.span, - &format!("called `.{}().count()` on a `{}`", iter_method, caller_type), + &format!("called `.{iter_method}().count()` on a `{caller_type}`"), "try", format!( "{}.len()", diff --git a/clippy_lints/src/methods/iter_kv_map.rs b/clippy_lints/src/methods/iter_kv_map.rs index a7eecabd684..2244ebfb129 100644 --- a/clippy_lints/src/methods/iter_kv_map.rs +++ b/clippy_lints/src/methods/iter_kv_map.rs @@ -54,9 +54,9 @@ pub(super) fn check<'tcx>( cx, ITER_KV_MAP, expr.span, - &format!("iterating on a map's {}s", replacement_kind), + &format!("iterating on a map's {replacement_kind}s"), "try", - format!("{}.{}{}s()", recv_snippet, into_prefix, replacement_kind), + format!("{recv_snippet}.{into_prefix}{replacement_kind}s()"), applicability, ); } else { @@ -64,9 +64,9 @@ pub(super) fn check<'tcx>( cx, ITER_KV_MAP, expr.span, - &format!("iterating on a map's {}s", replacement_kind), + &format!("iterating on a map's {replacement_kind}s"), "try", - format!("{}.{}{}s().map(|{}| {})", recv_snippet, into_prefix, replacement_kind, binded_ident, + format!("{recv_snippet}.{into_prefix}{replacement_kind}s().map(|{binded_ident}| {})", snippet_with_applicability(cx, body_expr.span, "/* body */", &mut applicability)), applicability, ); diff --git a/clippy_lints/src/methods/iter_next_slice.rs b/clippy_lints/src/methods/iter_next_slice.rs index b8d1dabe007..83c1bf20346 100644 --- a/clippy_lints/src/methods/iter_next_slice.rs +++ b/clippy_lints/src/methods/iter_next_slice.rs @@ -37,7 +37,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, cal let suggest = if start_idx == 0 { format!("{}.first()", snippet_with_applicability(cx, caller_var.span, "..", &mut applicability)) } else { - format!("{}.get({})", snippet_with_applicability(cx, caller_var.span, "..", &mut applicability), start_idx) + format!("{}.get({start_idx})", snippet_with_applicability(cx, caller_var.span, "..", &mut applicability)) }; span_lint_and_sugg( cx, diff --git a/clippy_lints/src/methods/iter_nth.rs b/clippy_lints/src/methods/iter_nth.rs index 80ca4c94219..ceee12784cb 100644 --- a/clippy_lints/src/methods/iter_nth.rs +++ b/clippy_lints/src/methods/iter_nth.rs @@ -32,8 +32,8 @@ pub(super) fn check<'tcx>( cx, ITER_NTH, expr.span, - &format!("called `.iter{0}().nth()` on a {1}", mut_str, caller_type), + &format!("called `.iter{mut_str}().nth()` on a {caller_type}"), None, - &format!("calling `.get{}()` is both faster and more readable", mut_str), + &format!("calling `.get{mut_str}()` is both faster and more readable"), ); } diff --git a/clippy_lints/src/methods/iter_with_drain.rs b/clippy_lints/src/methods/iter_with_drain.rs index a669cbbbcc6..3da230e12d7 100644 --- a/clippy_lints/src/methods/iter_with_drain.rs +++ b/clippy_lints/src/methods/iter_with_drain.rs @@ -22,7 +22,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, span cx, ITER_WITH_DRAIN, span.with_hi(expr.span.hi()), - &format!("`drain(..)` used on a `{}`", ty_name), + &format!("`drain(..)` used on a `{ty_name}`"), "try this", "into_iter()".to_string(), Applicability::MaybeIncorrect, diff --git a/clippy_lints/src/methods/manual_ok_or.rs b/clippy_lints/src/methods/manual_ok_or.rs index ffd2f4a38b8..c5c0ace7729 100644 --- a/clippy_lints/src/methods/manual_ok_or.rs +++ b/clippy_lints/src/methods/manual_ok_or.rs @@ -37,9 +37,7 @@ pub(super) fn check<'tcx>( "this pattern reimplements `Option::ok_or`", "replace with", format!( - "{}.ok_or({})", - recv_snippet, - reindented_err_arg_snippet + "{recv_snippet}.ok_or({reindented_err_arg_snippet})" ), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/methods/manual_saturating_arithmetic.rs b/clippy_lints/src/methods/manual_saturating_arithmetic.rs index 0fe510beaa0..ec694cf6882 100644 --- a/clippy_lints/src/methods/manual_saturating_arithmetic.rs +++ b/clippy_lints/src/methods/manual_saturating_arithmetic.rs @@ -57,11 +57,10 @@ pub fn check( super::MANUAL_SATURATING_ARITHMETIC, expr.span, "manual saturating arithmetic", - &format!("try using `saturating_{}`", arith), + &format!("try using `saturating_{arith}`"), format!( - "{}.saturating_{}({})", + "{}.saturating_{arith}({})", snippet_with_applicability(cx, arith_lhs.span, "..", &mut applicability), - arith, snippet_with_applicability(cx, arith_rhs.span, "..", &mut applicability), ), applicability, diff --git a/clippy_lints/src/methods/manual_str_repeat.rs b/clippy_lints/src/methods/manual_str_repeat.rs index 46d2fc493f8..67e504af161 100644 --- a/clippy_lints/src/methods/manual_str_repeat.rs +++ b/clippy_lints/src/methods/manual_str_repeat.rs @@ -91,7 +91,7 @@ pub(super) fn check( collect_expr.span, "manual implementation of `str::repeat` using iterators", "try this", - format!("{}.repeat({})", val_str, count_snip), + format!("{val_str}.repeat({count_snip})"), app ) } diff --git a/clippy_lints/src/methods/map_clone.rs b/clippy_lints/src/methods/map_clone.rs index 8261ef5e1ce..7ce14ec080b 100644 --- a/clippy_lints/src/methods/map_clone.rs +++ b/clippy_lints/src/methods/map_clone.rs @@ -111,11 +111,10 @@ fn lint_explicit_closure(cx: &LateContext<'_>, replace: Span, root: Span, is_cop MAP_CLONE, replace, message, - &format!("consider calling the dedicated `{}` method", sugg_method), + &format!("consider calling the dedicated `{sugg_method}` method"), format!( - "{}.{}()", + "{}.{sugg_method}()", snippet_with_applicability(cx, root, "..", &mut applicability), - sugg_method, ), applicability, ); diff --git a/clippy_lints/src/methods/map_flatten.rs b/clippy_lints/src/methods/map_flatten.rs index 13853dec99d..361ffcb5ef3 100644 --- a/clippy_lints/src/methods/map_flatten.rs +++ b/clippy_lints/src/methods/map_flatten.rs @@ -20,12 +20,9 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, map_ cx, MAP_FLATTEN, expr.span.with_lo(map_span.lo()), - &format!("called `map(..).flatten()` on `{}`", caller_ty_name), - &format!( - "try replacing `map` with `{}` and remove the `.flatten()`", - method_to_use - ), - format!("{}({})", method_to_use, closure_snippet), + &format!("called `map(..).flatten()` on `{caller_ty_name}`"), + &format!("try replacing `map` with `{method_to_use}` and remove the `.flatten()`"), + format!("{method_to_use}({closure_snippet})"), applicability, ); } diff --git a/clippy_lints/src/methods/map_identity.rs b/clippy_lints/src/methods/map_identity.rs index 862a9578e6f..0f25ef82ed4 100644 --- a/clippy_lints/src/methods/map_identity.rs +++ b/clippy_lints/src/methods/map_identity.rs @@ -30,7 +30,7 @@ pub(super) fn check( MAP_IDENTITY, sugg_span, "unnecessary map of the identity function", - &format!("remove the call to `{}`", name), + &format!("remove the call to `{name}`"), String::new(), Applicability::MachineApplicable, ) diff --git a/clippy_lints/src/methods/map_unwrap_or.rs b/clippy_lints/src/methods/map_unwrap_or.rs index 4a8e7ce4ddb..74fdead216b 100644 --- a/clippy_lints/src/methods/map_unwrap_or.rs +++ b/clippy_lints/src/methods/map_unwrap_or.rs @@ -65,7 +65,7 @@ pub(super) fn check<'tcx>( expr.span, msg, "try this", - format!("{}.map_or_else({}, {})", var_snippet, unwrap_snippet, map_snippet), + format!("{var_snippet}.map_or_else({unwrap_snippet}, {map_snippet})"), Applicability::MachineApplicable, ); return true; diff --git a/clippy_lints/src/methods/option_as_ref_deref.rs b/clippy_lints/src/methods/option_as_ref_deref.rs index c409268de76..6fb92d1c663 100644 --- a/clippy_lints/src/methods/option_as_ref_deref.rs +++ b/clippy_lints/src/methods/option_as_ref_deref.rs @@ -98,13 +98,12 @@ pub(super) fn check<'tcx>( format!(".as_ref().map({})", snippet(cx, map_arg.span, "..")) }; let method_hint = if is_mut { "as_deref_mut" } else { "as_deref" }; - let hint = format!("{}.{}()", snippet(cx, as_ref_recv.span, ".."), method_hint); - let suggestion = format!("try using {} instead", method_hint); + let hint = format!("{}.{method_hint}()", snippet(cx, as_ref_recv.span, "..")); + let suggestion = format!("try using {method_hint} instead"); let msg = format!( - "called `{0}` on an Option value. This can be done more directly \ - by calling `{1}` instead", - current_method, hint + "called `{current_method}` on an Option value. This can be done more directly \ + by calling `{hint}` instead" ); span_lint_and_sugg( cx, diff --git a/clippy_lints/src/methods/option_map_or_none.rs b/clippy_lints/src/methods/option_map_or_none.rs index 6657cdccd01..76572425346 100644 --- a/clippy_lints/src/methods/option_map_or_none.rs +++ b/clippy_lints/src/methods/option_map_or_none.rs @@ -87,7 +87,7 @@ pub(super) fn check<'tcx>( expr.span, msg, "try using `map` instead", - format!("{0}.map({1} {2})", self_snippet, arg_snippet,func_snippet), + format!("{self_snippet}.map({arg_snippet} {func_snippet})"), Applicability::MachineApplicable, ); } @@ -102,7 +102,7 @@ pub(super) fn check<'tcx>( expr.span, msg, "try using `and_then` instead", - format!("{0}.and_then({1})", self_snippet, func_snippet), + format!("{self_snippet}.and_then({func_snippet})"), Applicability::MachineApplicable, ); } else if f_arg_is_some { @@ -115,7 +115,7 @@ pub(super) fn check<'tcx>( expr.span, msg, "try using `ok` instead", - format!("{0}.ok()", self_snippet), + format!("{self_snippet}.ok()"), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs index 3c4002a3aef..30421a6dd5a 100644 --- a/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -65,9 +65,8 @@ pub(super) fn check<'tcx>( "map_or(, )" }; let msg = &format!( - "called `map().unwrap_or({})` on an `Option` value. \ - This can be done more directly by calling `{}` instead", - arg, suggest + "called `map().unwrap_or({arg})` on an `Option` value. \ + This can be done more directly by calling `{suggest}` instead" ); span_lint_and_then(cx, MAP_UNWRAP_OR, expr.span, msg, |diag| { @@ -82,10 +81,10 @@ pub(super) fn check<'tcx>( ]; if !unwrap_snippet_none { - suggestion.push((map_arg_span.with_hi(map_arg_span.lo()), format!("{}, ", unwrap_snippet))); + suggestion.push((map_arg_span.with_hi(map_arg_span.lo()), format!("{unwrap_snippet}, "))); } - diag.multipart_suggestion(&format!("use `{}` instead", suggest), suggestion, applicability); + diag.multipart_suggestion(&format!("use `{suggest}` instead"), suggestion, applicability); }); } } diff --git a/clippy_lints/src/methods/or_fun_call.rs b/clippy_lints/src/methods/or_fun_call.rs index b43b9258c47..6a35024d036 100644 --- a/clippy_lints/src/methods/or_fun_call.rs +++ b/clippy_lints/src/methods/or_fun_call.rs @@ -62,9 +62,9 @@ pub(super) fn check<'tcx>( cx, OR_FUN_CALL, method_span.with_hi(span.hi()), - &format!("use of `{}` followed by a call to `{}`", name, path), + &format!("use of `{name}` followed by a call to `{path}`"), "try this", - format!("{}()", sugg), + format!("{sugg}()"), Applicability::MachineApplicable, ); @@ -131,7 +131,7 @@ pub(super) fn check<'tcx>( if use_lambda { let l_arg = if fn_has_arguments { "_" } else { "" }; - format!("|{}| {}", l_arg, snippet).into() + format!("|{l_arg}| {snippet}").into() } else { snippet } @@ -141,9 +141,9 @@ pub(super) fn check<'tcx>( cx, OR_FUN_CALL, span_replace_word, - &format!("use of `{}` followed by a function call", name), + &format!("use of `{name}` followed by a function call"), "try this", - format!("{}_{}({})", name, suffix, sugg), + format!("{name}_{suffix}({sugg})"), Applicability::HasPlaceholders, ); } diff --git a/clippy_lints/src/methods/search_is_some.rs b/clippy_lints/src/methods/search_is_some.rs index 7572ba3fe9a..324c9c17b5a 100644 --- a/clippy_lints/src/methods/search_is_some.rs +++ b/clippy_lints/src/methods/search_is_some.rs @@ -30,10 +30,7 @@ pub(super) fn check<'tcx>( let option_check_method = if is_some { "is_some" } else { "is_none" }; // lint if caller of search is an Iterator if is_trait_method(cx, is_some_recv, sym::Iterator) { - let msg = format!( - "called `{}()` after searching an `Iterator` with `{}`", - option_check_method, search_method - ); + let msg = format!("called `{option_check_method}()` after searching an `Iterator` with `{search_method}`"); let search_snippet = snippet(cx, search_arg.span, ".."); if search_snippet.lines().count() <= 1 { // suggest `any(|x| ..)` instead of `any(|&x| ..)` for `find(|&x| ..).is_some()` @@ -86,8 +83,7 @@ pub(super) fn check<'tcx>( &msg, "use `!_.any()` instead", format!( - "!{}.any({})", - iter, + "!{iter}.any({})", any_search_snippet.as_ref().map_or(&*search_snippet, String::as_str) ), applicability, @@ -119,7 +115,7 @@ pub(super) fn check<'tcx>( if is_string_or_str_slice(search_recv); if is_string_or_str_slice(search_arg); then { - let msg = format!("called `{}()` after calling `find()` on a string", option_check_method); + let msg = format!("called `{option_check_method}()` after calling `find()` on a string"); match option_check_method { "is_some" => { let mut applicability = Applicability::MachineApplicable; @@ -130,7 +126,7 @@ pub(super) fn check<'tcx>( method_span.with_hi(expr.span.hi()), &msg, "use `contains()` instead", - format!("contains({})", find_arg), + format!("contains({find_arg})"), applicability, ); }, @@ -144,7 +140,7 @@ pub(super) fn check<'tcx>( expr.span, &msg, "use `!_.contains()` instead", - format!("!{}.contains({})", string, find_arg), + format!("!{string}.contains({find_arg})"), applicability, ); }, diff --git a/clippy_lints/src/methods/single_char_insert_string.rs b/clippy_lints/src/methods/single_char_insert_string.rs index 18b6b5be175..44a7ad394fa 100644 --- a/clippy_lints/src/methods/single_char_insert_string.rs +++ b/clippy_lints/src/methods/single_char_insert_string.rs @@ -14,7 +14,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, receiver: &hir:: let base_string_snippet = snippet_with_applicability(cx, receiver.span.source_callsite(), "_", &mut applicability); let pos_arg = snippet_with_applicability(cx, args[0].span, "..", &mut applicability); - let sugg = format!("{}.insert({}, {})", base_string_snippet, pos_arg, extension_string); + let sugg = format!("{base_string_snippet}.insert({pos_arg}, {extension_string})"); span_lint_and_sugg( cx, SINGLE_CHAR_ADD_STR, diff --git a/clippy_lints/src/methods/single_char_push_string.rs b/clippy_lints/src/methods/single_char_push_string.rs index 9ea6751956a..0698bd6a0c5 100644 --- a/clippy_lints/src/methods/single_char_push_string.rs +++ b/clippy_lints/src/methods/single_char_push_string.rs @@ -13,7 +13,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, receiver: &hir:: if let Some(extension_string) = get_hint_if_single_char_arg(cx, &args[0], &mut applicability) { let base_string_snippet = snippet_with_applicability(cx, receiver.span.source_callsite(), "..", &mut applicability); - let sugg = format!("{}.push({})", base_string_snippet, extension_string); + let sugg = format!("{base_string_snippet}.push({extension_string})"); span_lint_and_sugg( cx, SINGLE_CHAR_ADD_STR, diff --git a/clippy_lints/src/methods/stable_sort_primitive.rs b/clippy_lints/src/methods/stable_sort_primitive.rs index 91951c65bb3..09c8ca4cbe4 100644 --- a/clippy_lints/src/methods/stable_sort_primitive.rs +++ b/clippy_lints/src/methods/stable_sort_primitive.rs @@ -17,11 +17,11 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, recv: &'tcx cx, STABLE_SORT_PRIMITIVE, e.span, - &format!("used `sort` on primitive type `{}`", slice_type), + &format!("used `sort` on primitive type `{slice_type}`"), |diag| { let mut app = Applicability::MachineApplicable; let recv_snip = snippet_with_context(cx, recv.span, e.span.ctxt(), "..", &mut app).0; - diag.span_suggestion(e.span, "try", format!("{}.sort_unstable()", recv_snip), app); + diag.span_suggestion(e.span, "try", format!("{recv_snip}.sort_unstable()"), app); diag.note( "an unstable sort typically performs faster without any observable difference for this data type", ); diff --git a/clippy_lints/src/methods/string_extend_chars.rs b/clippy_lints/src/methods/string_extend_chars.rs index 143dcee3505..6974260f70d 100644 --- a/clippy_lints/src/methods/string_extend_chars.rs +++ b/clippy_lints/src/methods/string_extend_chars.rs @@ -34,9 +34,8 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr "calling `.extend(_.chars())`", "try this", format!( - "{}.push_str({}{})", + "{}.push_str({ref_str}{})", snippet_with_applicability(cx, recv.span, "..", &mut applicability), - ref_str, snippet_with_applicability(cx, target.span, "..", &mut applicability) ), applicability, diff --git a/clippy_lints/src/methods/suspicious_splitn.rs b/clippy_lints/src/methods/suspicious_splitn.rs index 55567d8625e..219a9edd657 100644 --- a/clippy_lints/src/methods/suspicious_splitn.rs +++ b/clippy_lints/src/methods/suspicious_splitn.rs @@ -24,10 +24,10 @@ pub(super) fn check(cx: &LateContext<'_>, method_name: &str, expr: &Expr<'_>, se } let (msg, note_msg) = if count == 0 { - (format!("`{}` called with `0` splits", method_name), + (format!("`{method_name}` called with `0` splits"), "the resulting iterator will always return `None`") } else { - (format!("`{}` called with `1` split", method_name), + (format!("`{method_name}` called with `1` split"), if self_ty.is_slice() { "the resulting iterator will always return the entire slice followed by `None`" } else { diff --git a/clippy_lints/src/methods/suspicious_to_owned.rs b/clippy_lints/src/methods/suspicious_to_owned.rs index 6b306fbf008..15c1c618c51 100644 --- a/clippy_lints/src/methods/suspicious_to_owned.rs +++ b/clippy_lints/src/methods/suspicious_to_owned.rs @@ -24,9 +24,9 @@ pub fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>) - cx, SUSPICIOUS_TO_OWNED, expr.span, - &format!("this `to_owned` call clones the {0} itself and does not cause the {0} contents to become owned", input_type), + &format!("this `to_owned` call clones the {input_type} itself and does not cause the {input_type} contents to become owned"), "consider using, depending on intent", - format!("{0}.clone()` or `{0}.into_owned()", recv_snip), + format!("{recv_snip}.clone()` or `{recv_snip}.into_owned()"), app, ); return true; diff --git a/clippy_lints/src/methods/unnecessary_filter_map.rs b/clippy_lints/src/methods/unnecessary_filter_map.rs index 4e8c201f470..ee16982d524 100644 --- a/clippy_lints/src/methods/unnecessary_filter_map.rs +++ b/clippy_lints/src/methods/unnecessary_filter_map.rs @@ -54,7 +54,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, arg: &hir::Expr< UNNECESSARY_FIND_MAP }, expr.span, - &format!("this `.{}` can be written more simply using `.{}`", name, sugg), + &format!("this `.{name}` can be written more simply using `.{sugg}`"), ); } } diff --git a/clippy_lints/src/methods/unnecessary_fold.rs b/clippy_lints/src/methods/unnecessary_fold.rs index c17ef6809f9..aa87dead38f 100644 --- a/clippy_lints/src/methods/unnecessary_fold.rs +++ b/clippy_lints/src/methods/unnecessary_fold.rs @@ -49,15 +49,12 @@ pub(super) fn check( let mut applicability = Applicability::MachineApplicable; let sugg = if replacement_has_args { format!( - "{replacement}(|{s}| {r})", - replacement = replacement_method_name, - s = second_arg_ident, + "{replacement_method_name}(|{second_arg_ident}| {r})", r = snippet_with_applicability(cx, right_expr.span, "EXPR", &mut applicability), ) } else { format!( - "{replacement}()", - replacement = replacement_method_name, + "{replacement_method_name}()", ) }; diff --git a/clippy_lints/src/methods/unnecessary_iter_cloned.rs b/clippy_lints/src/methods/unnecessary_iter_cloned.rs index 95138c0e25b..1966a85f7a7 100644 --- a/clippy_lints/src/methods/unnecessary_iter_cloned.rs +++ b/clippy_lints/src/methods/unnecessary_iter_cloned.rs @@ -68,7 +68,7 @@ pub fn check_for_loop_iter( cx, UNNECESSARY_TO_OWNED, expr.span, - &format!("unnecessary use of `{}`", method_name), + &format!("unnecessary use of `{method_name}`"), |diag| { // If `check_into_iter_call_arg` called `check_for_loop_iter` because a call to // a `to_owned`-like function was removed, then the next suggestion may be diff --git a/clippy_lints/src/methods/unnecessary_lazy_eval.rs b/clippy_lints/src/methods/unnecessary_lazy_eval.rs index a187a8d6016..ec9859fa298 100644 --- a/clippy_lints/src/methods/unnecessary_lazy_eval.rs +++ b/clippy_lints/src/methods/unnecessary_lazy_eval.rs @@ -58,8 +58,8 @@ pub(super) fn check<'tcx>( span_lint_and_then(cx, UNNECESSARY_LAZY_EVALUATIONS, expr.span, msg, |diag| { diag.span_suggestion( span, - &format!("use `{}(..)` instead", simplify_using), - format!("{}({})", simplify_using, snippet(cx, body_expr.span, "..")), + &format!("use `{simplify_using}(..)` instead"), + format!("{simplify_using}({})", snippet(cx, body_expr.span, "..")), applicability, ); }); diff --git a/clippy_lints/src/methods/unnecessary_to_owned.rs b/clippy_lints/src/methods/unnecessary_to_owned.rs index 8e9ed33e009..d27831327ac 100644 --- a/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -133,12 +133,11 @@ fn check_addr_of_expr( cx, UNNECESSARY_TO_OWNED, parent.span, - &format!("unnecessary use of `{}`", method_name), + &format!("unnecessary use of `{method_name}`"), "use", format!( - "{:&>width$}{}", + "{:&>width$}{receiver_snippet}", "", - receiver_snippet, width = n_target_refs - n_receiver_refs ), Applicability::MachineApplicable, @@ -155,7 +154,7 @@ fn check_addr_of_expr( cx, UNNECESSARY_TO_OWNED, parent.span, - &format!("unnecessary use of `{}`", method_name), + &format!("unnecessary use of `{method_name}`"), "use", receiver_snippet, Applicability::MachineApplicable, @@ -165,7 +164,7 @@ fn check_addr_of_expr( cx, UNNECESSARY_TO_OWNED, expr.span.with_lo(receiver.span.hi()), - &format!("unnecessary use of `{}`", method_name), + &format!("unnecessary use of `{method_name}`"), "remove this", String::new(), Applicability::MachineApplicable, @@ -182,9 +181,9 @@ fn check_addr_of_expr( cx, UNNECESSARY_TO_OWNED, parent.span, - &format!("unnecessary use of `{}`", method_name), + &format!("unnecessary use of `{method_name}`"), "use", - format!("{}.as_ref()", receiver_snippet), + format!("{receiver_snippet}.as_ref()"), Applicability::MachineApplicable, ); return true; @@ -229,9 +228,9 @@ fn check_into_iter_call_arg( cx, UNNECESSARY_TO_OWNED, parent.span, - &format!("unnecessary use of `{}`", method_name), + &format!("unnecessary use of `{method_name}`"), "use", - format!("{}.iter().{}()", receiver_snippet, cloned_or_copied), + format!("{receiver_snippet}.iter().{cloned_or_copied}()"), Applicability::MaybeIncorrect, ); return true; @@ -276,9 +275,9 @@ fn check_other_call_arg<'tcx>( cx, UNNECESSARY_TO_OWNED, maybe_arg.span, - &format!("unnecessary use of `{}`", method_name), + &format!("unnecessary use of `{method_name}`"), "use", - format!("{:&>width$}{}", "", receiver_snippet, width = n_refs), + format!("{:&>n_refs$}{receiver_snippet}", ""), Applicability::MachineApplicable, ); return true; diff --git a/clippy_lints/src/methods/useless_asref.rs b/clippy_lints/src/methods/useless_asref.rs index ca5d33ee8b0..0380a82411a 100644 --- a/clippy_lints/src/methods/useless_asref.rs +++ b/clippy_lints/src/methods/useless_asref.rs @@ -35,7 +35,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, call_name: &str, cx, USELESS_ASREF, expr.span, - &format!("this call to `{}` does nothing", call_name), + &format!("this call to `{call_name}` does nothing"), "try this", snippet_with_applicability(cx, recvr.span, "..", &mut applicability).to_string(), applicability, diff --git a/clippy_lints/src/methods/wrong_self_convention.rs b/clippy_lints/src/methods/wrong_self_convention.rs index 4b368d3ffae..1fbf783b886 100644 --- a/clippy_lints/src/methods/wrong_self_convention.rs +++ b/clippy_lints/src/methods/wrong_self_convention.rs @@ -61,20 +61,20 @@ impl Convention { impl fmt::Display for Convention { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { match *self { - Self::Eq(this) => format!("`{}`", this).fmt(f), - Self::StartsWith(this) => format!("`{}*`", this).fmt(f), - Self::EndsWith(this) => format!("`*{}`", this).fmt(f), - Self::NotEndsWith(this) => format!("`~{}`", this).fmt(f), + Self::Eq(this) => format!("`{this}`").fmt(f), + Self::StartsWith(this) => format!("`{this}*`").fmt(f), + Self::EndsWith(this) => format!("`*{this}`").fmt(f), + Self::NotEndsWith(this) => format!("`~{this}`").fmt(f), Self::IsSelfTypeCopy(is_true) => { format!("`self` type is{} `Copy`", if is_true { "" } else { " not" }).fmt(f) }, Self::ImplementsTrait(is_true) => { let (negation, s_suffix) = if is_true { ("", "s") } else { (" does not", "") }; - format!("method{} implement{} a trait", negation, s_suffix).fmt(f) + format!("method{negation} implement{s_suffix} a trait").fmt(f) }, Self::IsTraitItem(is_true) => { let suffix = if is_true { " is" } else { " is not" }; - format!("method{} a trait item", suffix).fmt(f) + format!("method{suffix} a trait item").fmt(f) }, } } @@ -138,8 +138,7 @@ pub(super) fn check<'tcx>( WRONG_SELF_CONVENTION, first_arg_span, &format!( - "{} usually take {}", - suggestion, + "{suggestion} usually take {}", &self_kinds .iter() .map(|k| k.description()) diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index ea245edd770..381458b91e6 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -178,7 +178,7 @@ impl<'tcx> LateLintPass<'tcx> for MiscLints { ("", sugg_init.addr()) }; let tyopt = if let Some(ty) = local.ty { - format!(": &{mutopt}{ty}", mutopt=mutopt, ty=snippet(cx, ty.span, "..")) + format!(": &{mutopt}{ty}", ty=snippet(cx, ty.span, "..")) } else { String::new() }; @@ -195,8 +195,6 @@ impl<'tcx> LateLintPass<'tcx> for MiscLints { format!( "let {name}{tyopt} = {initref};", name=snippet(cx, name.span, ".."), - tyopt=tyopt, - initref=initref, ), Applicability::MachineApplicable, ); @@ -222,8 +220,7 @@ impl<'tcx> LateLintPass<'tcx> for MiscLints { stmt.span, "replace it with", format!( - "if {} {{ {}; }}", - sugg, + "if {sugg} {{ {}; }}", &snippet(cx, b.span, ".."), ), Applicability::MachineApplicable, // snippet @@ -275,9 +272,8 @@ impl<'tcx> LateLintPass<'tcx> for MiscLints { USED_UNDERSCORE_BINDING, expr.span, &format!( - "used binding `{}` which is prefixed with an underscore. A leading \ - underscore signals that a binding will not be used", - binding + "used binding `{binding}` which is prefixed with an underscore. A leading \ + underscore signals that a binding will not be used" ), ); } @@ -328,12 +324,12 @@ fn check_cast(cx: &LateContext<'_>, span: Span, e: &Expr<'_>, ty: &hir::Ty<'_>) }; let (sugg, appl) = if let TyKind::Infer = mut_ty.ty.kind { - (format!("{}()", sugg_fn), Applicability::MachineApplicable) + (format!("{sugg_fn}()"), Applicability::MachineApplicable) } else if let Some(mut_ty_snip) = snippet_opt(cx, mut_ty.ty.span) { - (format!("{}::<{}>()", sugg_fn, mut_ty_snip), Applicability::MachineApplicable) + (format!("{sugg_fn}::<{mut_ty_snip}>()"), Applicability::MachineApplicable) } else { // `MaybeIncorrect` as type inference may not work with the suggested code - (format!("{}()", sugg_fn), Applicability::MaybeIncorrect) + (format!("{sugg_fn}()"), Applicability::MaybeIncorrect) }; span_lint_and_sugg(cx, ZERO_PTR, span, msg, "try", sugg, appl); } diff --git a/clippy_lints/src/misc_early/literal_suffix.rs b/clippy_lints/src/misc_early/literal_suffix.rs index 1165c19a0cf..62c6ca32d31 100644 --- a/clippy_lints/src/misc_early/literal_suffix.rs +++ b/clippy_lints/src/misc_early/literal_suffix.rs @@ -18,9 +18,9 @@ pub(super) fn check(cx: &EarlyContext<'_>, lit: &Lit, lit_snip: &str, suffix: &s cx, SEPARATED_LITERAL_SUFFIX, lit.span, - &format!("{} type suffix should not be separated by an underscore", sugg_type), + &format!("{sugg_type} type suffix should not be separated by an underscore"), "remove the underscore", - format!("{}{}", &lit_snip[..maybe_last_sep_idx], suffix), + format!("{}{suffix}", &lit_snip[..maybe_last_sep_idx]), Applicability::MachineApplicable, ); } else { @@ -28,9 +28,9 @@ pub(super) fn check(cx: &EarlyContext<'_>, lit: &Lit, lit_snip: &str, suffix: &s cx, UNSEPARATED_LITERAL_SUFFIX, lit.span, - &format!("{} type suffix should be separated by an underscore", sugg_type), + &format!("{sugg_type} type suffix should be separated by an underscore"), "add an underscore", - format!("{}_{}", &lit_snip[..=maybe_last_sep_idx], suffix), + format!("{}_{suffix}", &lit_snip[..=maybe_last_sep_idx]), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/misc_early/mod.rs b/clippy_lints/src/misc_early/mod.rs index 704918c0b97..c8227ca4450 100644 --- a/clippy_lints/src/misc_early/mod.rs +++ b/clippy_lints/src/misc_early/mod.rs @@ -357,9 +357,8 @@ impl EarlyLintPass for MiscEarlyLints { DUPLICATE_UNDERSCORE_ARGUMENT, *correspondence, &format!( - "`{}` already exists, having another argument having almost the same \ - name makes code comprehension and documentation more difficult", - arg_name + "`{arg_name}` already exists, having another argument having almost the same \ + name makes code comprehension and documentation more difficult" ), ); } diff --git a/clippy_lints/src/misc_early/unneeded_field_pattern.rs b/clippy_lints/src/misc_early/unneeded_field_pattern.rs index fff533167ed..676e5d40bb7 100644 --- a/clippy_lints/src/misc_early/unneeded_field_pattern.rs +++ b/clippy_lints/src/misc_early/unneeded_field_pattern.rs @@ -27,7 +27,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, pat: &Pat) { pat.span, "all the struct fields are matched to a wildcard pattern, consider using `..`", None, - &format!("try with `{} {{ .. }}` instead", type_name), + &format!("try with `{type_name} {{ .. }}` instead"), ); return; } @@ -63,7 +63,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, pat: &Pat) { "you matched a field with a wildcard pattern, consider using `..` \ instead", None, - &format!("try with `{} {{ {}, .. }}`", type_name, normal[..].join(", ")), + &format!("try with `{type_name} {{ {}, .. }}`", normal[..].join(", ")), ); } } diff --git a/clippy_lints/src/mismatching_type_param_order.rs b/clippy_lints/src/mismatching_type_param_order.rs index 020efeaebf0..6dd76a6531e 100644 --- a/clippy_lints/src/mismatching_type_param_order.rs +++ b/clippy_lints/src/mismatching_type_param_order.rs @@ -91,10 +91,9 @@ impl<'tcx> LateLintPass<'tcx> for TypeParamMismatch { let type_name = segment.ident; for (i, (impl_param_name, impl_param_span)) in impl_params.iter().enumerate() { if mismatch_param_name(i, impl_param_name, &type_param_names_hashmap) { - let msg = format!("`{}` has a similarly named generic type parameter `{}` in its declaration, but in a different order", - type_name, impl_param_name); - let help = format!("try `{}`, or a name that does not conflict with `{}`'s generic params", - type_param_names[i], type_name); + let msg = format!("`{type_name}` has a similarly named generic type parameter `{impl_param_name}` in its declaration, but in a different order"); + let help = format!("try `{}`, or a name that does not conflict with `{type_name}`'s generic params", + type_param_names[i]); span_lint_and_help( cx, MISMATCHING_TYPE_PARAM_ORDER, diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index ee81f72a0e7..97c8fb17638 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -104,7 +104,7 @@ impl MissingDoc { cx, MISSING_DOCS_IN_PRIVATE_ITEMS, sp, - &format!("missing documentation for {} {}", article, desc), + &format!("missing documentation for {article} {desc}"), ); } } diff --git a/clippy_lints/src/missing_enforced_import_rename.rs b/clippy_lints/src/missing_enforced_import_rename.rs index 3d0a2382283..697e6fd24dd 100644 --- a/clippy_lints/src/missing_enforced_import_rename.rs +++ b/clippy_lints/src/missing_enforced_import_rename.rs @@ -90,9 +90,7 @@ impl LateLintPass<'_> for ImportRename { "this import should be renamed", "try", format!( - "{} as {}", - import, - name, + "{import} as {name}", ), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 07bc2ca5d3c..18c45120091 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -65,7 +65,7 @@ fn check_missing_inline_attrs(cx: &LateContext<'_>, attrs: &[ast::Attribute], sp cx, MISSING_INLINE_IN_PUBLIC_ITEMS, sp, - &format!("missing `#[inline]` for {}", desc), + &format!("missing `#[inline]` for {desc}"), ); } } diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 82dc03ef5c5..463da11774a 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -88,7 +88,7 @@ fn check_arguments<'tcx>( cx, UNNECESSARY_MUT_PASSED, argument.span, - &format!("the {} `{}` doesn't need a mutable reference", fn_kind, name), + &format!("the {fn_kind} `{name}` doesn't need a mutable reference"), ); } }, diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 321db08dfe8..3ef0c663459 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -56,10 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for DebugAssertWithMutCall { cx, DEBUG_ASSERT_WITH_MUT_CALL, span, - &format!( - "do not call a function with mutable arguments inside of `{}!`", - macro_name - ), + &format!("do not call a function with mutable arguments inside of `{macro_name}!`"), ); } } diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index a98577093ed..09cb5333176 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -84,9 +84,8 @@ impl<'tcx> LateLintPass<'tcx> for Mutex { let mutex_param = subst.type_at(0); if let Some(atomic_name) = get_atomic_name(mutex_param) { let msg = format!( - "consider using an `{}` instead of a `Mutex` here; if you just want the locking \ - behavior and not the internal type, consider using `Mutex<()>`", - atomic_name + "consider using an `{atomic_name}` instead of a `Mutex` here; if you just want the locking \ + behavior and not the internal type, consider using `Mutex<()>`" ); match *mutex_param.kind() { ty::Uint(t) if t != ty::UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index 98a3bce1ff3..6f0e755466e 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -309,7 +309,7 @@ fn emit_warning<'a>(cx: &EarlyContext<'_>, data: &'a LintData<'_>, header: &str, expr.span, message, None, - &format!("{}\n{}", header, snip), + &format!("{header}\n{snip}"), ); } @@ -322,10 +322,7 @@ fn suggestion_snippet_for_continue_inside_if<'a>(cx: &EarlyContext<'_>, data: &' let indent_if = indent_of(cx, data.if_expr.span).unwrap_or(0); format!( - "{indent}if {} {}\n{indent}{}", - cond_code, - continue_code, - else_code, + "{indent}if {cond_code} {continue_code}\n{indent}{else_code}", indent = " ".repeat(indent_if), ) } @@ -349,7 +346,7 @@ fn suggestion_snippet_for_continue_inside_else<'a>(cx: &EarlyContext<'_>, data: let span = cx.sess().source_map().stmt_span(stmt.span, data.loop_block.span); let snip = snippet_block(cx, span, "..", None).into_owned(); snip.lines() - .map(|line| format!("{}{}", " ".repeat(indent), line)) + .map(|line| format!("{}{line}", " ".repeat(indent))) .collect::>() .join("\n") }) @@ -358,10 +355,7 @@ fn suggestion_snippet_for_continue_inside_else<'a>(cx: &EarlyContext<'_>, data: let indent_if = indent_of(cx, data.if_expr.span).unwrap_or(0); format!( - "{indent_if}if {} {}\n{indent}// merged code follows:\n{}\n{indent_if}}}", - cond_code, - block_code, - to_annex, + "{indent_if}if {cond_code} {block_code}\n{indent}// merged code follows:\n{to_annex}\n{indent_if}}}", indent = " ".repeat(indent), indent_if = " ".repeat(indent_if), ) diff --git a/clippy_lints/src/needless_late_init.rs b/clippy_lints/src/needless_late_init.rs index de99f1d7078..cbad53f4450 100644 --- a/clippy_lints/src/needless_late_init.rs +++ b/clippy_lints/src/needless_late_init.rs @@ -287,7 +287,7 @@ fn check<'tcx>( diag.span_suggestion( assign.lhs_span, - &format!("declare `{}` here", binding_name), + &format!("declare `{binding_name}` here"), let_snippet, Applicability::MachineApplicable, ); @@ -307,8 +307,8 @@ fn check<'tcx>( diag.span_suggestion_verbose( usage.stmt.span.shrink_to_lo(), - &format!("declare `{}` here", binding_name), - format!("{} = ", let_snippet), + &format!("declare `{binding_name}` here"), + format!("{let_snippet} = "), applicability, ); @@ -338,8 +338,8 @@ fn check<'tcx>( diag.span_suggestion_verbose( usage.stmt.span.shrink_to_lo(), - &format!("declare `{}` here", binding_name), - format!("{} = ", let_snippet), + &format!("declare `{binding_name}` here"), + format!("{let_snippet} = "), applicability, ); diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 6d17c7a7346..d7e6e7de2cc 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -236,7 +236,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { snippet_opt(cx, span) .map_or( "change the call to".into(), - |x| Cow::from(format!("change `{}` to", x)), + |x| Cow::from(format!("change `{x}` to")), ) .as_ref(), suggestion, @@ -266,7 +266,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { snippet_opt(cx, span) .map_or( "change the call to".into(), - |x| Cow::from(format!("change `{}` to", x)) + |x| Cow::from(format!("change `{x}` to")) ) .as_ref(), suggestion, diff --git a/clippy_lints/src/needless_question_mark.rs b/clippy_lints/src/needless_question_mark.rs index 8f85b00596c..59b6492e112 100644 --- a/clippy_lints/src/needless_question_mark.rs +++ b/clippy_lints/src/needless_question_mark.rs @@ -134,7 +134,7 @@ fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { NEEDLESS_QUESTION_MARK, expr.span, "question mark operator is useless here", - &format!("try removing question mark and `{}`", sugg_remove), + &format!("try removing question mark and `{sugg_remove}`"), format!("{}", snippet(cx, inner_expr.span, r#""...""#)), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index b087cfb36b1..fb9a4abd0b4 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -62,9 +62,9 @@ fn check_mul(cx: &LateContext<'_>, span: Span, lit: &Expr<'_>, exp: &Expr<'_>) { let mut applicability = Applicability::MachineApplicable; let snip = snippet_with_applicability(cx, exp.span, "..", &mut applicability); let suggestion = if exp.precedence().order() < PREC_PREFIX && !has_enclosing_paren(&snip) { - format!("-({})", snip) + format!("-({snip})") } else { - format!("-{}", snip) + format!("-{snip}") }; span_lint_and_sugg( cx, diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 5c45ee6d94a..cfd24e9b2d3 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -136,8 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault { id, impl_item.span, &format!( - "you should consider adding a `Default` implementation for `{}`", - self_type_snip + "you should consider adding a `Default` implementation for `{self_type_snip}`" ), |diag| { diag.suggest_prepend_item( @@ -161,9 +160,9 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault { fn create_new_without_default_suggest_msg(self_type_snip: &str, generics_sugg: &str) -> String { #[rustfmt::skip] format!( -"impl{} Default for {} {{ +"impl{generics_sugg} Default for {self_type_snip} {{ fn default() -> Self {{ Self::new() }} -}}", generics_sugg, self_type_snip) +}}") } diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index b96af06b8d7..03fddd207ec 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -108,10 +108,7 @@ impl<'a, 'tcx> SimilarNamesLocalVisitor<'a, 'tcx> { self.cx, MANY_SINGLE_CHAR_NAMES, span, - &format!( - "{} bindings with single-character names in scope", - num_single_char_names - ), + &format!("{num_single_char_names} bindings with single-character names in scope"), ); } } diff --git a/clippy_lints/src/nonstandard_macro_braces.rs b/clippy_lints/src/nonstandard_macro_braces.rs index 5e38a95c40b..0ca0befc135 100644 --- a/clippy_lints/src/nonstandard_macro_braces.rs +++ b/clippy_lints/src/nonstandard_macro_braces.rs @@ -107,11 +107,11 @@ fn is_offending_macro<'a>(cx: &EarlyContext<'_>, span: Span, mac_braces: &'a Mac if let Some(snip) = snippet_opt(cx, span_call_site); // we must check only invocation sites // https://github.com/rust-lang/rust-clippy/issues/7422 - if snip.starts_with(&format!("{}!", name)); + if snip.starts_with(&format!("{name}!")); if unnested_or_local(); // make formatting consistent let c = snip.replace(' ', ""); - if !c.starts_with(&format!("{}!{}", name, braces.0)); + if !c.starts_with(&format!("{name}!{}", braces.0)); if !mac_braces.done.contains(&span_call_site); then { Some((span_call_site, braces, snip)) @@ -131,9 +131,9 @@ fn emit_help(cx: &EarlyContext<'_>, snip: &str, braces: &(String, String), span: cx, NONSTANDARD_MACRO_BRACES, span, - &format!("use of irregular braces for `{}!` macro", macro_name), + &format!("use of irregular braces for `{macro_name}!` macro"), "consider writing", - format!("{}!{}{}{}", macro_name, braces.0, macro_args, braces.1), + format!("{macro_name}!{}{macro_args}{}", braces.0, braces.1), Applicability::MachineApplicable, ); } @@ -266,9 +266,7 @@ impl<'de> Deserialize<'de> for MacroMatcher { .iter() .find(|b| b.0 == brace) .map(|(o, c)| ((*o).to_owned(), (*c).to_owned())) - .ok_or_else(|| { - de::Error::custom(&format!("expected one of `(`, `{{`, `[` found `{}`", brace)) - })?, + .ok_or_else(|| de::Error::custom(&format!("expected one of `(`, `{{`, `[` found `{brace}`")))?, }) } } diff --git a/clippy_lints/src/octal_escapes.rs b/clippy_lints/src/octal_escapes.rs index bffbf20b4d2..f380a506582 100644 --- a/clippy_lints/src/octal_escapes.rs +++ b/clippy_lints/src/octal_escapes.rs @@ -102,7 +102,7 @@ fn check_lit(cx: &EarlyContext<'_>, lit: &Lit, span: Span, is_string: bool) { // construct a replacement escape // the maximum value is \077, or \x3f, so u8 is sufficient here if let Ok(n) = u8::from_str_radix(&contents[from + 1..to], 8) { - write!(suggest_1, "\\x{:02x}", n).unwrap(); + write!(suggest_1, "\\x{n:02x}").unwrap(); } // append the null byte as \x00 and the following digits literally diff --git a/clippy_lints/src/operators/absurd_extreme_comparisons.rs b/clippy_lints/src/operators/absurd_extreme_comparisons.rs index 1ec4240afef..d29ca37eaeb 100644 --- a/clippy_lints/src/operators/absurd_extreme_comparisons.rs +++ b/clippy_lints/src/operators/absurd_extreme_comparisons.rs @@ -34,13 +34,12 @@ pub(super) fn check<'tcx>( }; let help = format!( - "because `{}` is the {} value for this type, {}", + "because `{}` is the {} value for this type, {conclusion}", snippet(cx, culprit.expr.span, "x"), match culprit.which { ExtremeType::Minimum => "minimum", ExtremeType::Maximum => "maximum", - }, - conclusion + } ); span_lint_and_help(cx, ABSURD_EXTREME_COMPARISONS, expr.span, msg, None, &help); diff --git a/clippy_lints/src/operators/assign_op_pattern.rs b/clippy_lints/src/operators/assign_op_pattern.rs index 945a09a647c..cb5abfb809e 100644 --- a/clippy_lints/src/operators/assign_op_pattern.rs +++ b/clippy_lints/src/operators/assign_op_pattern.rs @@ -55,7 +55,7 @@ pub(super) fn check<'tcx>( diag.span_suggestion( expr.span, "replace it with", - format!("{} {}= {}", snip_a, op.node.as_str(), snip_r), + format!("{snip_a} {}= {snip_r}", op.node.as_str()), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/operators/bit_mask.rs b/clippy_lints/src/operators/bit_mask.rs index 74387fbc87b..1369b3e7462 100644 --- a/clippy_lints/src/operators/bit_mask.rs +++ b/clippy_lints/src/operators/bit_mask.rs @@ -64,10 +64,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!( - "incompatible bit mask: `_ & {}` can never be equal to `{}`", - mask_value, cmp_value - ), + &format!("incompatible bit mask: `_ & {mask_value}` can never be equal to `{cmp_value}`"), ); } } else if mask_value == 0 { @@ -80,10 +77,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!( - "incompatible bit mask: `_ | {}` can never be equal to `{}`", - mask_value, cmp_value - ), + &format!("incompatible bit mask: `_ | {mask_value}` can never be equal to `{cmp_value}`"), ); } }, @@ -96,10 +90,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!( - "incompatible bit mask: `_ & {}` will always be lower than `{}`", - mask_value, cmp_value - ), + &format!("incompatible bit mask: `_ & {mask_value}` will always be lower than `{cmp_value}`"), ); } else if mask_value == 0 { span_lint(cx, BAD_BIT_MASK, span, "&-masking with zero"); @@ -111,10 +102,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!( - "incompatible bit mask: `_ | {}` will never be lower than `{}`", - mask_value, cmp_value - ), + &format!("incompatible bit mask: `_ | {mask_value}` will never be lower than `{cmp_value}`"), ); } else { check_ineffective_lt(cx, span, mask_value, cmp_value, "|"); @@ -130,10 +118,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!( - "incompatible bit mask: `_ & {}` will never be higher than `{}`", - mask_value, cmp_value - ), + &format!("incompatible bit mask: `_ & {mask_value}` will never be higher than `{cmp_value}`"), ); } else if mask_value == 0 { span_lint(cx, BAD_BIT_MASK, span, "&-masking with zero"); @@ -145,10 +130,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!( - "incompatible bit mask: `_ | {}` will always be higher than `{}`", - mask_value, cmp_value - ), + &format!("incompatible bit mask: `_ | {mask_value}` will always be higher than `{cmp_value}`"), ); } else { check_ineffective_gt(cx, span, mask_value, cmp_value, "|"); @@ -167,10 +149,7 @@ fn check_ineffective_lt(cx: &LateContext<'_>, span: Span, m: u128, c: u128, op: cx, INEFFECTIVE_BIT_MASK, span, - &format!( - "ineffective bit mask: `x {} {}` compared to `{}`, is the same as x compared directly", - op, m, c - ), + &format!("ineffective bit mask: `x {op} {m}` compared to `{c}`, is the same as x compared directly"), ); } } @@ -181,10 +160,7 @@ fn check_ineffective_gt(cx: &LateContext<'_>, span: Span, m: u128, c: u128, op: cx, INEFFECTIVE_BIT_MASK, span, - &format!( - "ineffective bit mask: `x {} {}` compared to `{}`, is the same as x compared directly", - op, m, c - ), + &format!("ineffective bit mask: `x {op} {m}` compared to `{c}`, is the same as x compared directly"), ); } } diff --git a/clippy_lints/src/operators/cmp_owned.rs b/clippy_lints/src/operators/cmp_owned.rs index 638a514ff9b..c9c777f1bd8 100644 --- a/clippy_lints/src/operators/cmp_owned.rs +++ b/clippy_lints/src/operators/cmp_owned.rs @@ -99,7 +99,7 @@ fn check_op(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool) let expr_snip; let eq_impl; if with_deref.is_implemented() { - expr_snip = format!("*{}", arg_snip); + expr_snip = format!("*{arg_snip}"); eq_impl = with_deref; } else { expr_snip = arg_snip.to_string(); @@ -121,17 +121,15 @@ fn check_op(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool) }; if eq_impl.ty_eq_other { hint = format!( - "{}{}{}", - expr_snip, + "{expr_snip}{}{}", snippet(cx, cmp_span, ".."), snippet(cx, other.span, "..") ); } else { hint = format!( - "{}{}{}", + "{}{}{expr_snip}", snippet(cx, other.span, ".."), - snippet(cx, cmp_span, ".."), - expr_snip + snippet(cx, cmp_span, "..") ); } } diff --git a/clippy_lints/src/operators/duration_subsec.rs b/clippy_lints/src/operators/duration_subsec.rs index 827a2b26709..49e662cacb0 100644 --- a/clippy_lints/src/operators/duration_subsec.rs +++ b/clippy_lints/src/operators/duration_subsec.rs @@ -31,12 +31,11 @@ pub(crate) fn check<'tcx>( cx, DURATION_SUBSEC, expr.span, - &format!("calling `{}()` is more concise than this calculation", suggested_fn), + &format!("calling `{suggested_fn}()` is more concise than this calculation"), "try", format!( - "{}.{}()", - snippet_with_applicability(cx, self_arg.span, "_", &mut applicability), - suggested_fn + "{}.{suggested_fn}()", + snippet_with_applicability(cx, self_arg.span, "_", &mut applicability) ), applicability, ); diff --git a/clippy_lints/src/operators/eq_op.rs b/clippy_lints/src/operators/eq_op.rs index 44cf0bb0612..67913f7392c 100644 --- a/clippy_lints/src/operators/eq_op.rs +++ b/clippy_lints/src/operators/eq_op.rs @@ -22,7 +22,7 @@ pub(crate) fn check_assert<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { cx, EQ_OP, lhs.span.to(rhs.span), - &format!("identical args used in this `{}!` macro call", macro_name), + &format!("identical args used in this `{macro_name}!` macro call"), ); } } diff --git a/clippy_lints/src/operators/misrefactored_assign_op.rs b/clippy_lints/src/operators/misrefactored_assign_op.rs index 0024384d927..ae805147f07 100644 --- a/clippy_lints/src/operators/misrefactored_assign_op.rs +++ b/clippy_lints/src/operators/misrefactored_assign_op.rs @@ -47,18 +47,14 @@ fn lint_misrefactored_assign_op( if let (Some(snip_a), Some(snip_r)) = (snippet_opt(cx, assignee.span), snippet_opt(cx, rhs_other.span)) { let a = &sugg::Sugg::hir(cx, assignee, ".."); let r = &sugg::Sugg::hir(cx, rhs, ".."); - let long = format!("{} = {}", snip_a, sugg::make_binop(op.into(), a, r)); + let long = format!("{snip_a} = {}", sugg::make_binop(op.into(), a, r)); diag.span_suggestion( expr.span, &format!( - "did you mean `{} = {} {} {}` or `{}`? Consider replacing it with", - snip_a, - snip_a, - op.as_str(), - snip_r, - long + "did you mean `{snip_a} = {snip_a} {} {snip_r}` or `{long}`? Consider replacing it with", + op.as_str() ), - format!("{} {}= {}", snip_a, op.as_str(), snip_r), + format!("{snip_a} {}= {snip_r}", op.as_str()), Applicability::MaybeIncorrect, ); diag.span_suggestion( diff --git a/clippy_lints/src/operators/needless_bitwise_bool.rs b/clippy_lints/src/operators/needless_bitwise_bool.rs index e902235a014..ab5fb178700 100644 --- a/clippy_lints/src/operators/needless_bitwise_bool.rs +++ b/clippy_lints/src/operators/needless_bitwise_bool.rs @@ -27,7 +27,7 @@ pub(super) fn check(cx: &LateContext<'_>, e: &Expr<'_>, op: BinOpKind, lhs: &Exp if let Some(lhs_snip) = snippet_opt(cx, lhs.span) && let Some(rhs_snip) = snippet_opt(cx, rhs.span) { - let sugg = format!("{} {} {}", lhs_snip, op_str, rhs_snip); + let sugg = format!("{lhs_snip} {op_str} {rhs_snip}"); diag.span_suggestion(e.span, "try", sugg, Applicability::MachineApplicable); } }, diff --git a/clippy_lints/src/operators/ptr_eq.rs b/clippy_lints/src/operators/ptr_eq.rs index 1aefc2741c2..1229c202f5a 100644 --- a/clippy_lints/src/operators/ptr_eq.rs +++ b/clippy_lints/src/operators/ptr_eq.rs @@ -34,7 +34,7 @@ pub(super) fn check<'tcx>( expr.span, LINT_MSG, "try", - format!("std::ptr::eq({}, {})", left_snip, right_snip), + format!("std::ptr::eq({left_snip}, {right_snip})"), Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/operators/self_assignment.rs b/clippy_lints/src/operators/self_assignment.rs index 9d6bec05bf0..7c9d5320a3a 100644 --- a/clippy_lints/src/operators/self_assignment.rs +++ b/clippy_lints/src/operators/self_assignment.rs @@ -14,7 +14,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, lhs: &'tcx cx, SELF_ASSIGNMENT, e.span, - &format!("self-assignment of `{}` to `{}`", rhs, lhs), + &format!("self-assignment of `{rhs}` to `{lhs}`"), ); } } diff --git a/clippy_lints/src/operators/verbose_bit_mask.rs b/clippy_lints/src/operators/verbose_bit_mask.rs index ff85fd55429..fbf65e92b32 100644 --- a/clippy_lints/src/operators/verbose_bit_mask.rs +++ b/clippy_lints/src/operators/verbose_bit_mask.rs @@ -35,7 +35,7 @@ pub(super) fn check<'tcx>( diag.span_suggestion( e.span, "try", - format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()), + format!("{sugg}.trailing_zeros() >= {}", n.count_ones()), Applicability::MaybeIncorrect, ); }, diff --git a/clippy_lints/src/option_if_let_else.rs b/clippy_lints/src/option_if_let_else.rs index 0315678bf97..256d2450001 100644 --- a/clippy_lints/src/option_if_let_else.rs +++ b/clippy_lints/src/option_if_let_else.rs @@ -163,7 +163,7 @@ fn try_get_option_occurence<'tcx>( return Some(OptionOccurence { option: format_option_in_sugg(cx, cond_expr, as_ref, as_mut), method_sugg: method_sugg.to_string(), - some_expr: format!("|{}{}| {}", capture_mut, capture_name, Sugg::hir_with_macro_callsite(cx, some_body, "..")), + some_expr: format!("|{capture_mut}{capture_name}| {}", Sugg::hir_with_macro_callsite(cx, some_body, "..")), none_expr: format!("{}{}", if method_sugg == "map_or" { "" } else { "|| " }, Sugg::hir_with_macro_callsite(cx, none_body, "..")), }); } diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index 0960b050c24..152e0c5ec9a 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -209,7 +209,7 @@ impl<'tcx> PassByRefOrValue { cx, TRIVIALLY_COPY_PASS_BY_REF, input.span, - &format!("this argument ({} byte) is passed by reference, but would be more efficient if passed by value (limit: {} byte)", size, self.ref_min_size), + &format!("this argument ({size} byte) is passed by reference, but would be more efficient if passed by value (limit: {} byte)", self.ref_min_size), "consider passing by value instead", value_type, Applicability::Unspecified, @@ -237,7 +237,7 @@ impl<'tcx> PassByRefOrValue { cx, LARGE_TYPES_PASSED_BY_VALUE, input.span, - &format!("this argument ({} byte) is passed by value, but might be more efficient if passed by reference (limit: {} byte)", size, self.value_max_size), + &format!("this argument ({size} byte) is passed by value, but might be more efficient if passed by reference (limit: {} byte)", self.value_max_size), "consider passing by reference instead", format!("&{}", snippet(cx, input.span, "_")), Applicability::MaybeIncorrect, diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index 41d1baba64f..85e0710eb50 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -463,7 +463,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>( diag.span_suggestion( hir_ty.span, "change this to", - format!("&{}{}", mutability.prefix_str(), ty_name), + format!("&{}{ty_name}", mutability.prefix_str()), Applicability::Unspecified, ); } diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 4dc65da3ea1..b0a5d1a6758 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -60,7 +60,7 @@ impl<'tcx> LateLintPass<'tcx> for PtrOffsetWithCast { None => return, }; - let msg = format!("use of `{}` with a `usize` casted to an `isize`", method); + let msg = format!("use of `{method}` with a `usize` casted to an `isize`"); if let Some(sugg) = build_suggestion(cx, method, receiver_expr, cast_lhs_expr) { span_lint_and_sugg( cx, @@ -124,7 +124,7 @@ fn build_suggestion<'tcx>( ) -> Option { let receiver = snippet_opt(cx, receiver_expr.span)?; let cast_lhs = snippet_opt(cx, cast_lhs_expr.span)?; - Some(format!("{}.{}({})", receiver, method.suggestion(), cast_lhs)) + Some(format!("{receiver}.{}({cast_lhs})", method.suggestion())) } #[derive(Copy, Clone)] diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index f4f1fd336df..d53614722aa 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -97,12 +97,12 @@ fn check_is_none_or_err_and_early_return<'tcx>(cx: &LateContext<'tcx>, expr: &Ex !matches!(caller.kind, ExprKind::Call(..) | ExprKind::MethodCall(..)); let sugg = if let Some(else_inner) = r#else { if eq_expr_value(cx, caller, peel_blocks(else_inner)) { - format!("Some({}?)", receiver_str) + format!("Some({receiver_str}?)") } else { return; } } else { - format!("{}{}?;", receiver_str, if by_ref { ".as_ref()" } else { "" }) + format!("{receiver_str}{}?;", if by_ref { ".as_ref()" } else { "" }) }; span_lint_and_sugg( @@ -134,8 +134,7 @@ fn check_if_let_some_or_err_and_early_return<'tcx>(cx: &LateContext<'tcx>, expr: let receiver_str = snippet_with_applicability(cx, let_expr.span, "..", &mut applicability); let requires_semi = matches!(get_parent_node(cx.tcx, expr.hir_id), Some(Node::Stmt(_))); let sugg = format!( - "{}{}?{}", - receiver_str, + "{receiver_str}{}?{}", if by_ref == ByRef::Yes { ".as_ref()" } else { "" }, if requires_semi { ";" } else { "" } ); diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 918d624eec6..c6fbb5e805a 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -243,9 +243,9 @@ fn check_possible_range_contains( cx, MANUAL_RANGE_CONTAINS, span, - &format!("manual `{}::contains` implementation", range_type), + &format!("manual `{range_type}::contains` implementation"), "use", - format!("({}{}{}{}).contains(&{})", lo, space, range_op, hi, name), + format!("({lo}{space}{range_op}{hi}).contains(&{name})"), applicability, ); } else if !combine_and && ord == Some(l.ord) { @@ -273,9 +273,9 @@ fn check_possible_range_contains( cx, MANUAL_RANGE_CONTAINS, span, - &format!("manual `!{}::contains` implementation", range_type), + &format!("manual `!{range_type}::contains` implementation"), "use", - format!("!({}{}{}{}).contains(&{})", lo, space, range_op, hi, name), + format!("!({lo}{space}{range_op}{hi}).contains(&{name})"), applicability, ); } @@ -372,14 +372,14 @@ fn check_exclusive_range_plus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { diag.span_suggestion( span, "use", - format!("({}..={})", start, end), + format!("({start}..={end})"), Applicability::MaybeIncorrect, ); } else { diag.span_suggestion( span, "use", - format!("{}..={}", start, end), + format!("{start}..={end}"), Applicability::MachineApplicable, // snippet ); } @@ -408,7 +408,7 @@ fn check_inclusive_range_minus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { diag.span_suggestion( expr.span, "use", - format!("{}..{}", start, end), + format!("{start}..{end}"), Applicability::MachineApplicable, // snippet ); }, @@ -486,7 +486,7 @@ fn check_reversed_empty_range(cx: &LateContext<'_>, expr: &Expr<'_>) { expr.span, "consider using the following if you are attempting to iterate over this \ range in reverse", - format!("({}{}{}).rev()", end_snippet, dots, start_snippet), + format!("({end_snippet}{dots}{start_snippet}).rev()"), Applicability::MaybeIncorrect, ); } diff --git a/clippy_lints/src/read_zero_byte_vec.rs b/clippy_lints/src/read_zero_byte_vec.rs index 94dec191103..ae80b6f1269 100644 --- a/clippy_lints/src/read_zero_byte_vec.rs +++ b/clippy_lints/src/read_zero_byte_vec.rs @@ -101,9 +101,8 @@ impl<'tcx> LateLintPass<'tcx> for ReadZeroByteVec { next_stmt_span, "reading zero byte data to `Vec`", "try", - format!("{}.resize({}, 0); {}", + format!("{}.resize({len}, 0); {}", ident.as_str(), - len, snippet(cx, next_stmt_span, "..") ), applicability, diff --git a/clippy_lints/src/redundant_pub_crate.rs b/clippy_lints/src/redundant_pub_crate.rs index 323326381d4..9c71a3daeee 100644 --- a/clippy_lints/src/redundant_pub_crate.rs +++ b/clippy_lints/src/redundant_pub_crate.rs @@ -56,7 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate { cx, REDUNDANT_PUB_CRATE, span, - &format!("pub(crate) {} inside private module", descr), + &format!("pub(crate) {descr} inside private module"), |diag| { diag.span_suggestion( item.vis_span, diff --git a/clippy_lints/src/redundant_slicing.rs b/clippy_lints/src/redundant_slicing.rs index 8693ca9af83..245a02ea26e 100644 --- a/clippy_lints/src/redundant_slicing.rs +++ b/clippy_lints/src/redundant_slicing.rs @@ -127,9 +127,9 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing { let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0; let sugg = if (deref_count != 0 || !reborrow_str.is_empty()) && needs_parens_for_prefix { - format!("({}{}{})", reborrow_str, "*".repeat(deref_count), snip) + format!("({reborrow_str}{}{snip})", "*".repeat(deref_count)) } else { - format!("{}{}{}", reborrow_str, "*".repeat(deref_count), snip) + format!("{reborrow_str}{}{snip}", "*".repeat(deref_count)) }; (lint, help_str, sugg) @@ -141,9 +141,9 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing { if deref_ty == expr_ty { let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0; let sugg = if needs_parens_for_prefix { - format!("(&{}{}*{})", mutability.prefix_str(), "*".repeat(indexed_ref_count), snip) + format!("(&{}{}*{snip})", mutability.prefix_str(), "*".repeat(indexed_ref_count)) } else { - format!("&{}{}*{}", mutability.prefix_str(), "*".repeat(indexed_ref_count), snip) + format!("&{}{}*{snip}", mutability.prefix_str(), "*".repeat(indexed_ref_count)) }; (DEREF_BY_SLICING_LINT, "dereference the original value instead", sugg) } else { diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index 2d751c27467..60ba62c4a43 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -67,7 +67,7 @@ impl RedundantStaticLifetimes { TyKind::Path(..) | TyKind::Slice(..) | TyKind::Array(..) | TyKind::Tup(..) => { if lifetime.ident.name == rustc_span::symbol::kw::StaticLifetime { let snip = snippet(cx, borrow_type.ty.span, ""); - let sugg = format!("&{}", snip); + let sugg = format!("&{snip}"); span_lint_and_then( cx, REDUNDANT_STATIC_LIFETIMES, diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 6bcae0da8f4..1fda58fa54d 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -172,7 +172,7 @@ fn check_regex<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, utf8: bool) { ); }, Err(e) => { - span_lint(cx, INVALID_REGEX, expr.span, &format!("regex syntax error: {}", e)); + span_lint(cx, INVALID_REGEX, expr.span, &format!("regex syntax error: {e}")); }, } } @@ -200,7 +200,7 @@ fn check_regex<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, utf8: bool) { ); }, Err(e) => { - span_lint(cx, INVALID_REGEX, expr.span, &format!("regex syntax error: {}", e)); + span_lint(cx, INVALID_REGEX, expr.span, &format!("regex syntax error: {e}")); }, } } diff --git a/clippy_lints/src/same_name_method.rs b/clippy_lints/src/same_name_method.rs index 73f8e083b29..dead36e3bea 100644 --- a/clippy_lints/src/same_name_method.rs +++ b/clippy_lints/src/same_name_method.rs @@ -108,7 +108,7 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod { |diag| { diag.span_note( trait_method_span, - &format!("existing `{}` defined here", method_name), + &format!("existing `{method_name}` defined here"), ); }, ); @@ -151,7 +151,7 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod { // iterate on trait_spans? diag.span_note( trait_spans[0], - &format!("existing `{}` defined here", method_name), + &format!("existing `{method_name}` defined here"), ); }, ); diff --git a/clippy_lints/src/semicolon_if_nothing_returned.rs b/clippy_lints/src/semicolon_if_nothing_returned.rs index 729694da46d..66638eed998 100644 --- a/clippy_lints/src/semicolon_if_nothing_returned.rs +++ b/clippy_lints/src/semicolon_if_nothing_returned.rs @@ -54,7 +54,7 @@ impl<'tcx> LateLintPass<'tcx> for SemicolonIfNothingReturned { } let sugg = sugg::Sugg::hir_with_macro_callsite(cx, expr, ".."); - let suggestion = format!("{0};", sugg); + let suggestion = format!("{sugg};"); span_lint_and_sugg( cx, SEMICOLON_IF_NOTHING_RETURNED, diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index c07aa00a127..e57ab8cd7a3 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -174,7 +174,7 @@ impl SlowVectorInit { diag.span_suggestion( vec_alloc.allocation_expr.span, "consider replace allocation with", - format!("vec![0; {}]", len_expr), + format!("vec![0; {len_expr}]"), Applicability::Unspecified, ); }); diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 662d399ca53..d356c99c8fc 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -284,7 +284,7 @@ impl<'tcx> LateLintPass<'tcx> for StringLitAsBytes { e.span, "calling a slice of `as_bytes()` with `from_utf8` should be not necessary", "try", - format!("Some(&{}[{}])", snippet_app, snippet(cx, right.span, "..")), + format!("Some(&{snippet_app}[{}])", snippet(cx, right.span, "..")), applicability ) } @@ -500,8 +500,8 @@ impl<'tcx> LateLintPass<'tcx> for TrimSplitWhitespace { cx, TRIM_SPLIT_WHITESPACE, trim_span.with_hi(split_ws_span.lo()), - &format!("found call to `str::{}` before `str::split_whitespace`", trim_fn_name), - &format!("remove `{}()`", trim_fn_name), + &format!("found call to `str::{trim_fn_name}` before `str::split_whitespace`"), + &format!("remove `{trim_fn_name}()`"), String::new(), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/strlen_on_c_strings.rs b/clippy_lints/src/strlen_on_c_strings.rs index 78403d9fdb7..03324c66e8e 100644 --- a/clippy_lints/src/strlen_on_c_strings.rs +++ b/clippy_lints/src/strlen_on_c_strings.rs @@ -79,7 +79,7 @@ impl<'tcx> LateLintPass<'tcx> for StrlenOnCStrings { span, "using `libc::strlen` on a `CString` or `CStr` value", "try this", - format!("{}.{}().len()", val_name, method_name), + format!("{val_name}.{method_name}().len()"), app, ); } diff --git a/clippy_lints/src/suspicious_operation_groupings.rs b/clippy_lints/src/suspicious_operation_groupings.rs index 5d36f0f5ff8..eef9bdc7849 100644 --- a/clippy_lints/src/suspicious_operation_groupings.rs +++ b/clippy_lints/src/suspicious_operation_groupings.rs @@ -326,8 +326,7 @@ fn replace_left_sugg( applicability: &mut Applicability, ) -> String { format!( - "{} {} {}", - left_suggestion, + "{left_suggestion} {} {}", binop.op.to_string(), snippet_with_applicability(cx, binop.right.span, "..", applicability), ) @@ -340,10 +339,9 @@ fn replace_right_sugg( applicability: &mut Applicability, ) -> String { format!( - "{} {} {}", + "{} {} {right_suggestion}", snippet_with_applicability(cx, binop.left.span, "..", applicability), binop.op.to_string(), - right_suggestion, ) } @@ -676,9 +674,8 @@ fn suggestion_with_swapped_ident( } Some(format!( - "{}{}{}", + "{}{new_ident}{}", snippet_with_applicability(cx, expr.span.with_hi(current_ident.span.lo()), "..", applicability), - new_ident, snippet_with_applicability(cx, expr.span.with_lo(current_ident.span.hi()), "..", applicability), )) }) diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 1885f3ca414..f46c21e1265 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -96,7 +96,7 @@ fn generate_swap_warning(cx: &LateContext<'_>, e1: &Expr<'_>, e2: &Expr<'_>, spa cx, MANUAL_SWAP, span, - &format!("this looks like you are swapping elements of `{}` manually", slice), + &format!("this looks like you are swapping elements of `{slice}` manually"), "try", format!( "{}.swap({}, {})", @@ -121,16 +121,16 @@ fn generate_swap_warning(cx: &LateContext<'_>, e1: &Expr<'_>, e2: &Expr<'_>, spa cx, MANUAL_SWAP, span, - &format!("this looks like you are swapping `{}` and `{}` manually", first, second), + &format!("this looks like you are swapping `{first}` and `{second}` manually"), |diag| { diag.span_suggestion( span, "try", - format!("{}::mem::swap({}, {})", sugg, first.mut_addr(), second.mut_addr()), + format!("{sugg}::mem::swap({}, {})", first.mut_addr(), second.mut_addr()), applicability, ); if !is_xor_based { - diag.note(&format!("or maybe you should use `{}::mem::replace`?", sugg)); + diag.note(&format!("or maybe you should use `{sugg}::mem::replace`?")); } }, ); @@ -182,7 +182,7 @@ fn check_suspicious_swap(cx: &LateContext<'_>, block: &Block<'_>) { let rhs0 = Sugg::hir_opt(cx, rhs0); let (what, lhs, rhs) = if let (Some(first), Some(second)) = (lhs0, rhs0) { ( - format!(" `{}` and `{}`", first, second), + format!(" `{first}` and `{second}`"), first.mut_addr().to_string(), second.mut_addr().to_string(), ) @@ -196,22 +196,19 @@ fn check_suspicious_swap(cx: &LateContext<'_>, block: &Block<'_>) { span_lint_and_then(cx, ALMOST_SWAPPED, span, - &format!("this looks like you are trying to swap{}", what), + &format!("this looks like you are trying to swap{what}"), |diag| { if !what.is_empty() { diag.span_suggestion( span, "try", format!( - "{}::mem::swap({}, {})", - sugg, - lhs, - rhs, + "{sugg}::mem::swap({lhs}, {rhs})", ), Applicability::MaybeIncorrect, ); diag.note( - &format!("or maybe you should use `{}::mem::replace`?", sugg) + &format!("or maybe you should use `{sugg}::mem::replace`?") ); } }); diff --git a/clippy_lints/src/swap_ptr_to_ref.rs b/clippy_lints/src/swap_ptr_to_ref.rs index 3cbbda80f3a..d085dda3582 100644 --- a/clippy_lints/src/swap_ptr_to_ref.rs +++ b/clippy_lints/src/swap_ptr_to_ref.rs @@ -58,7 +58,7 @@ impl LateLintPass<'_> for SwapPtrToRef { let mut app = Applicability::MachineApplicable; let snip1 = snippet_with_context(cx, arg1_span.unwrap_or(arg1.span), ctxt, "..", &mut app).0; let snip2 = snippet_with_context(cx, arg2_span.unwrap_or(arg2.span), ctxt, "..", &mut app).0; - diag.span_suggestion(e.span, "use ptr::swap", format!("core::ptr::swap({}, {})", snip1, snip2), app); + diag.span_suggestion(e.span, "use ptr::swap", format!("core::ptr::swap({snip1}, {snip2})"), app); } } ); diff --git a/clippy_lints/src/to_digit_is_some.rs b/clippy_lints/src/to_digit_is_some.rs index 651201f34ed..2512500a6be 100644 --- a/clippy_lints/src/to_digit_is_some.rs +++ b/clippy_lints/src/to_digit_is_some.rs @@ -84,9 +84,9 @@ impl<'tcx> LateLintPass<'tcx> for ToDigitIsSome { "use of `.to_digit(..).is_some()`", "try this", if is_method_call { - format!("{}.is_digit({})", char_arg_snip, radix_snip) + format!("{char_arg_snip}.is_digit({radix_snip})") } else { - format!("char::is_digit({}, {})", char_arg_snip, radix_snip) + format!("char::is_digit({char_arg_snip}, {radix_snip})") }, applicability, ); diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index a25be93b8d6..bb146441f87 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -215,9 +215,8 @@ impl TraitBounds { .map(|(_, _, span)| snippet_with_applicability(cx, span, "..", &mut applicability)) .join(" + "); let hint_string = format!( - "consider combining the bounds: `{}: {}`", + "consider combining the bounds: `{}: {trait_bounds}`", snippet(cx, p.bounded_ty.span, "_"), - trait_bounds, ); span_lint_and_help( cx, diff --git a/clippy_lints/src/transmute/crosspointer_transmute.rs b/clippy_lints/src/transmute/crosspointer_transmute.rs index 25d0543c861..c4b9d82fc73 100644 --- a/clippy_lints/src/transmute/crosspointer_transmute.rs +++ b/clippy_lints/src/transmute/crosspointer_transmute.rs @@ -13,10 +13,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty cx, CROSSPOINTER_TRANSMUTE, e.span, - &format!( - "transmute from a type (`{}`) to the type that it points to (`{}`)", - from_ty, to_ty - ), + &format!("transmute from a type (`{from_ty}`) to the type that it points to (`{to_ty}`)"), ); true }, @@ -25,10 +22,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty cx, CROSSPOINTER_TRANSMUTE, e.span, - &format!( - "transmute from a type (`{}`) to a pointer to that type (`{}`)", - from_ty, to_ty - ), + &format!("transmute from a type (`{from_ty}`) to a pointer to that type (`{to_ty}`)"), ); true }, diff --git a/clippy_lints/src/transmute/transmute_float_to_int.rs b/clippy_lints/src/transmute/transmute_float_to_int.rs index 1bde977cfa2..5ecba512b0f 100644 --- a/clippy_lints/src/transmute/transmute_float_to_int.rs +++ b/clippy_lints/src/transmute/transmute_float_to_int.rs @@ -24,7 +24,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_FLOAT_TO_INT, e.span, - &format!("transmute from a `{}` to a `{}`", from_ty, to_ty), + &format!("transmute from a `{from_ty}` to a `{to_ty}`"), |diag| { let mut sugg = sugg::Sugg::hir(cx, arg, ".."); @@ -38,7 +38,7 @@ pub(super) fn check<'tcx>( if let ExprKind::Lit(lit) = &arg.kind; if let ast::LitKind::Float(_, ast::LitFloatType::Unsuffixed) = lit.node; then { - let op = format!("{}{}", sugg, float_ty.name_str()).into(); + let op = format!("{sugg}{}", float_ty.name_str()).into(); match sugg { sugg::Sugg::MaybeParen(_) => sugg = sugg::Sugg::MaybeParen(op), _ => sugg = sugg::Sugg::NonParen(op) diff --git a/clippy_lints/src/transmute/transmute_int_to_bool.rs b/clippy_lints/src/transmute/transmute_int_to_bool.rs index 8c50b58ca4b..58227c53de2 100644 --- a/clippy_lints/src/transmute/transmute_int_to_bool.rs +++ b/clippy_lints/src/transmute/transmute_int_to_bool.rs @@ -23,7 +23,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_INT_TO_BOOL, e.span, - &format!("transmute from a `{}` to a `bool`", from_ty), + &format!("transmute from a `{from_ty}` to a `bool`"), |diag| { let arg = sugg::Sugg::hir(cx, arg, ".."); let zero = sugg::Sugg::NonParen(Cow::from("0")); diff --git a/clippy_lints/src/transmute/transmute_int_to_char.rs b/clippy_lints/src/transmute/transmute_int_to_char.rs index 9e1823c373b..7d31c375f8c 100644 --- a/clippy_lints/src/transmute/transmute_int_to_char.rs +++ b/clippy_lints/src/transmute/transmute_int_to_char.rs @@ -23,7 +23,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_INT_TO_CHAR, e.span, - &format!("transmute from a `{}` to a `char`", from_ty), + &format!("transmute from a `{from_ty}` to a `char`"), |diag| { let arg = sugg::Sugg::hir(cx, arg, ".."); let arg = if let ty::Int(_) = from_ty.kind() { @@ -34,7 +34,7 @@ pub(super) fn check<'tcx>( diag.span_suggestion( e.span, "consider using", - format!("std::char::from_u32({}).unwrap()", arg), + format!("std::char::from_u32({arg}).unwrap()"), Applicability::Unspecified, ); }, diff --git a/clippy_lints/src/transmute/transmute_int_to_float.rs b/clippy_lints/src/transmute/transmute_int_to_float.rs index b8703052e6c..cc3422edbbf 100644 --- a/clippy_lints/src/transmute/transmute_int_to_float.rs +++ b/clippy_lints/src/transmute/transmute_int_to_float.rs @@ -22,7 +22,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_INT_TO_FLOAT, e.span, - &format!("transmute from a `{}` to a `{}`", from_ty, to_ty), + &format!("transmute from a `{from_ty}` to a `{to_ty}`"), |diag| { let arg = sugg::Sugg::hir(cx, arg, ".."); let arg = if let ty::Int(int_ty) = from_ty.kind() { @@ -36,7 +36,7 @@ pub(super) fn check<'tcx>( diag.span_suggestion( e.span, "consider using", - format!("{}::from_bits({})", to_ty, arg), + format!("{to_ty}::from_bits({arg})"), Applicability::Unspecified, ); }, diff --git a/clippy_lints/src/transmute/transmute_num_to_bytes.rs b/clippy_lints/src/transmute/transmute_num_to_bytes.rs index 52d193d11e1..009d5a7c8ae 100644 --- a/clippy_lints/src/transmute/transmute_num_to_bytes.rs +++ b/clippy_lints/src/transmute/transmute_num_to_bytes.rs @@ -31,13 +31,13 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_NUM_TO_BYTES, e.span, - &format!("transmute from a `{}` to a `{}`", from_ty, to_ty), + &format!("transmute from a `{from_ty}` to a `{to_ty}`"), |diag| { let arg = sugg::Sugg::hir(cx, arg, ".."); diag.span_suggestion( e.span, "consider using `to_ne_bytes()`", - format!("{}.to_ne_bytes()", arg), + format!("{arg}.to_ne_bytes()"), Applicability::Unspecified, ); }, diff --git a/clippy_lints/src/transmute/transmute_ptr_to_ref.rs b/clippy_lints/src/transmute/transmute_ptr_to_ref.rs index 5eb03275b8e..12d0b866e1c 100644 --- a/clippy_lints/src/transmute/transmute_ptr_to_ref.rs +++ b/clippy_lints/src/transmute/transmute_ptr_to_ref.rs @@ -25,10 +25,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_PTR_TO_REF, e.span, - &format!( - "transmute from a pointer type (`{}`) to a reference type (`{}`)", - from_ty, to_ty - ), + &format!("transmute from a pointer type (`{from_ty}`) to a reference type (`{to_ty}`)"), |diag| { let arg = sugg::Sugg::hir(cx, arg, ".."); let (deref, cast) = if *mutbl == Mutability::Mut { @@ -41,26 +38,25 @@ pub(super) fn check<'tcx>( let sugg = if let Some(ty) = get_explicit_type(path) { let ty_snip = snippet_with_applicability(cx, ty.span, "..", &mut app); if meets_msrv(msrv, msrvs::POINTER_CAST) { - format!("{}{}.cast::<{}>()", deref, arg.maybe_par(), ty_snip) + format!("{deref}{}.cast::<{ty_snip}>()", arg.maybe_par()) } else if from_ptr_ty.has_erased_regions() { - sugg::make_unop(deref, arg.as_ty(format!("{} () as {} {}", cast, cast, ty_snip))) - .to_string() + sugg::make_unop(deref, arg.as_ty(format!("{cast} () as {cast} {ty_snip}"))).to_string() } else { - sugg::make_unop(deref, arg.as_ty(format!("{} {}", cast, ty_snip))).to_string() + sugg::make_unop(deref, arg.as_ty(format!("{cast} {ty_snip}"))).to_string() } } else if from_ptr_ty.ty == *to_ref_ty { if from_ptr_ty.has_erased_regions() { if meets_msrv(msrv, msrvs::POINTER_CAST) { - format!("{}{}.cast::<{}>()", deref, arg.maybe_par(), to_ref_ty) + format!("{deref}{}.cast::<{to_ref_ty}>()", arg.maybe_par()) } else { - sugg::make_unop(deref, arg.as_ty(format!("{} () as {} {}", cast, cast, to_ref_ty))) + sugg::make_unop(deref, arg.as_ty(format!("{cast} () as {cast} {to_ref_ty}"))) .to_string() } } else { sugg::make_unop(deref, arg).to_string() } } else { - sugg::make_unop(deref, arg.as_ty(format!("{} {}", cast, to_ref_ty))).to_string() + sugg::make_unop(deref, arg.as_ty(format!("{cast} {to_ref_ty}"))).to_string() }; diag.span_suggestion(e.span, "try", sugg, app); diff --git a/clippy_lints/src/transmute/transmute_ref_to_ref.rs b/clippy_lints/src/transmute/transmute_ref_to_ref.rs index 707a11d361c..afb7f2e1326 100644 --- a/clippy_lints/src/transmute/transmute_ref_to_ref.rs +++ b/clippy_lints/src/transmute/transmute_ref_to_ref.rs @@ -38,7 +38,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_BYTES_TO_STR, e.span, - &format!("transmute from a `{}` to a `{}`", from_ty, to_ty), + &format!("transmute from a `{from_ty}` to a `{to_ty}`"), "consider using", if const_context { format!("std::str::from_utf8_unchecked{postfix}({snippet})") diff --git a/clippy_lints/src/transmute/transmute_undefined_repr.rs b/clippy_lints/src/transmute/transmute_undefined_repr.rs index b6d7d9f5b42..cac620cf8e8 100644 --- a/clippy_lints/src/transmute/transmute_undefined_repr.rs +++ b/clippy_lints/src/transmute/transmute_undefined_repr.rs @@ -75,10 +75,10 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_UNDEFINED_REPR, e.span, - &format!("transmute from `{}` which has an undefined layout", from_ty_orig), + &format!("transmute from `{from_ty_orig}` which has an undefined layout"), |diag| { if from_ty_orig.peel_refs() != from_ty.peel_refs() { - diag.note(&format!("the contained type `{}` has an undefined layout", from_ty)); + diag.note(&format!("the contained type `{from_ty}` has an undefined layout")); } }, ); @@ -89,10 +89,10 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_UNDEFINED_REPR, e.span, - &format!("transmute to `{}` which has an undefined layout", to_ty_orig), + &format!("transmute to `{to_ty_orig}` which has an undefined layout"), |diag| { if to_ty_orig.peel_refs() != to_ty.peel_refs() { - diag.note(&format!("the contained type `{}` has an undefined layout", to_ty)); + diag.note(&format!("the contained type `{to_ty}` has an undefined layout")); } }, ); @@ -116,8 +116,7 @@ pub(super) fn check<'tcx>( TRANSMUTE_UNDEFINED_REPR, e.span, &format!( - "transmute from `{}` to `{}`, both of which have an undefined layout", - from_ty_orig, to_ty_orig + "transmute from `{from_ty_orig}` to `{to_ty_orig}`, both of which have an undefined layout" ), |diag| { if let Some(same_adt_did) = same_adt_did { @@ -127,10 +126,10 @@ pub(super) fn check<'tcx>( )); } else { if from_ty_orig.peel_refs() != from_ty { - diag.note(&format!("the contained type `{}` has an undefined layout", from_ty)); + diag.note(&format!("the contained type `{from_ty}` has an undefined layout")); } if to_ty_orig.peel_refs() != to_ty { - diag.note(&format!("the contained type `{}` has an undefined layout", to_ty)); + diag.note(&format!("the contained type `{to_ty}` has an undefined layout")); } } }, @@ -145,10 +144,10 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_UNDEFINED_REPR, e.span, - &format!("transmute from `{}` which has an undefined layout", from_ty_orig), + &format!("transmute from `{from_ty_orig}` which has an undefined layout"), |diag| { if from_ty_orig.peel_refs() != from_ty { - diag.note(&format!("the contained type `{}` has an undefined layout", from_ty)); + diag.note(&format!("the contained type `{from_ty}` has an undefined layout")); } }, ); @@ -162,10 +161,10 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_UNDEFINED_REPR, e.span, - &format!("transmute into `{}` which has an undefined layout", to_ty_orig), + &format!("transmute into `{to_ty_orig}` which has an undefined layout"), |diag| { if to_ty_orig.peel_refs() != to_ty { - diag.note(&format!("the contained type `{}` has an undefined layout", to_ty)); + diag.note(&format!("the contained type `{to_ty}` has an undefined layout")); } }, ); diff --git a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs index 626d7cd46fc..6b444922a7c 100644 --- a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs +++ b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs @@ -21,10 +21,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS, e.span, - &format!( - "transmute from `{}` to `{}` which could be expressed as a pointer cast instead", - from_ty, to_ty - ), + &format!("transmute from `{from_ty}` to `{to_ty}` which could be expressed as a pointer cast instead"), |diag| { if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) { let sugg = arg.as_ty(&to_ty.to_string()).to_string(); diff --git a/clippy_lints/src/transmute/unsound_collection_transmute.rs b/clippy_lints/src/transmute/unsound_collection_transmute.rs index 831b0d450d2..b1445311b71 100644 --- a/clippy_lints/src/transmute/unsound_collection_transmute.rs +++ b/clippy_lints/src/transmute/unsound_collection_transmute.rs @@ -37,10 +37,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty cx, UNSOUND_COLLECTION_TRANSMUTE, e.span, - &format!( - "transmute from `{}` to `{}` with mismatched layout is unsound", - from_ty, to_ty - ), + &format!("transmute from `{from_ty}` to `{to_ty}` with mismatched layout is unsound"), ); true } else { diff --git a/clippy_lints/src/transmute/useless_transmute.rs b/clippy_lints/src/transmute/useless_transmute.rs index 8122cd716e0..f919bbd5afc 100644 --- a/clippy_lints/src/transmute/useless_transmute.rs +++ b/clippy_lints/src/transmute/useless_transmute.rs @@ -21,7 +21,7 @@ pub(super) fn check<'tcx>( cx, USELESS_TRANSMUTE, e.span, - &format!("transmute from a type (`{}`) to itself", from_ty), + &format!("transmute from a type (`{from_ty}`) to itself"), ); true }, diff --git a/clippy_lints/src/transmute/wrong_transmute.rs b/clippy_lints/src/transmute/wrong_transmute.rs index 2118f3d6950..d1965565b92 100644 --- a/clippy_lints/src/transmute/wrong_transmute.rs +++ b/clippy_lints/src/transmute/wrong_transmute.rs @@ -13,7 +13,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty cx, WRONG_TRANSMUTE, e.span, - &format!("transmute from a `{}` to a pointer", from_ty), + &format!("transmute from a `{from_ty}` to a pointer"), ); true }, diff --git a/clippy_lints/src/types/borrowed_box.rs b/clippy_lints/src/types/borrowed_box.rs index 94945b2e1a9..0a779b37860 100644 --- a/clippy_lints/src/types/borrowed_box.rs +++ b/clippy_lints/src/types/borrowed_box.rs @@ -49,15 +49,15 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, m let inner_snippet = snippet(cx, inner.span, ".."); let suggestion = match &inner.kind { TyKind::TraitObject(bounds, lt_bound, _) if bounds.len() > 1 || !lt_bound.is_elided() => { - format!("&{}({})", ltopt, &inner_snippet) + format!("&{ltopt}({})", &inner_snippet) }, TyKind::Path(qpath) if get_bounds_if_impl_trait(cx, qpath, inner.hir_id) .map_or(false, |bounds| bounds.len() > 1) => { - format!("&{}({})", ltopt, &inner_snippet) + format!("&{ltopt}({})", &inner_snippet) }, - _ => format!("&{}{}", ltopt, &inner_snippet), + _ => format!("&{ltopt}{}", &inner_snippet), }; span_lint_and_sugg( cx, diff --git a/clippy_lints/src/types/box_collection.rs b/clippy_lints/src/types/box_collection.rs index ba51404d214..08020ce6638 100644 --- a/clippy_lints/src/types/box_collection.rs +++ b/clippy_lints/src/types/box_collection.rs @@ -16,7 +16,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_ _ => "<..>", }; - let box_content = format!("{outer}{generic}", outer = item_type); + let box_content = format!("{item_type}{generic}"); span_lint_and_help( cx, BOX_COLLECTION, diff --git a/clippy_lints/src/types/rc_buffer.rs b/clippy_lints/src/types/rc_buffer.rs index 4d72a29e8c7..6b9de64e24c 100644 --- a/clippy_lints/src/types/rc_buffer.rs +++ b/clippy_lints/src/types/rc_buffer.rs @@ -17,7 +17,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_ hir_ty.span, "usage of `Rc` when T is a buffer type", "try", - format!("Rc<{}>", alternate), + format!("Rc<{alternate}>"), Applicability::MachineApplicable, ); } else { @@ -57,7 +57,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_ hir_ty.span, "usage of `Arc` when T is a buffer type", "try", - format!("Arc<{}>", alternate), + format!("Arc<{alternate}>"), Applicability::MachineApplicable, ); } else if let Some(ty) = qpath_generic_tys(qpath).next() { diff --git a/clippy_lints/src/types/redundant_allocation.rs b/clippy_lints/src/types/redundant_allocation.rs index a1312fcda0b..b95f0213e0c 100644 --- a/clippy_lints/src/types/redundant_allocation.rs +++ b/clippy_lints/src/types/redundant_allocation.rs @@ -27,13 +27,11 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_ cx, REDUNDANT_ALLOCATION, hir_ty.span, - &format!("usage of `{}<{}>`", outer_sym, generic_snippet), + &format!("usage of `{outer_sym}<{generic_snippet}>`"), |diag| { - diag.span_suggestion(hir_ty.span, "try", format!("{}", generic_snippet), applicability); + diag.span_suggestion(hir_ty.span, "try", format!("{generic_snippet}"), applicability); diag.note(&format!( - "`{generic}` is already a pointer, `{outer}<{generic}>` allocates a pointer on the heap", - outer = outer_sym, - generic = generic_snippet + "`{generic_snippet}` is already a pointer, `{outer_sym}<{generic_snippet}>` allocates a pointer on the heap" )); }, ); @@ -72,19 +70,16 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_ cx, REDUNDANT_ALLOCATION, hir_ty.span, - &format!("usage of `{}<{}<{}>>`", outer_sym, inner_sym, generic_snippet), + &format!("usage of `{outer_sym}<{inner_sym}<{generic_snippet}>>`"), |diag| { diag.span_suggestion( hir_ty.span, "try", - format!("{}<{}>", outer_sym, generic_snippet), + format!("{outer_sym}<{generic_snippet}>"), applicability, ); diag.note(&format!( - "`{inner}<{generic}>` is already on the heap, `{outer}<{inner}<{generic}>>` makes an extra allocation", - outer = outer_sym, - inner = inner_sym, - generic = generic_snippet + "`{inner_sym}<{generic_snippet}>` is already on the heap, `{outer_sym}<{inner_sym}<{generic_snippet}>>` makes an extra allocation" )); }, ); @@ -94,19 +89,13 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_ cx, REDUNDANT_ALLOCATION, hir_ty.span, - &format!("usage of `{}<{}<{}>>`", outer_sym, inner_sym, generic_snippet), + &format!("usage of `{outer_sym}<{inner_sym}<{generic_snippet}>>`"), |diag| { diag.note(&format!( - "`{inner}<{generic}>` is already on the heap, `{outer}<{inner}<{generic}>>` makes an extra allocation", - outer = outer_sym, - inner = inner_sym, - generic = generic_snippet + "`{inner_sym}<{generic_snippet}>` is already on the heap, `{outer_sym}<{inner_sym}<{generic_snippet}>>` makes an extra allocation" )); diag.help(&format!( - "consider using just `{outer}<{generic}>` or `{inner}<{generic}>`", - outer = outer_sym, - inner = inner_sym, - generic = generic_snippet + "consider using just `{outer_sym}<{generic_snippet}>` or `{inner_sym}<{generic_snippet}>`" )); }, ); diff --git a/clippy_lints/src/unit_return_expecting_ord.rs b/clippy_lints/src/unit_return_expecting_ord.rs index c0a4f3fbacd..57aff5367dd 100644 --- a/clippy_lints/src/unit_return_expecting_ord.rs +++ b/clippy_lints/src/unit_return_expecting_ord.rs @@ -157,8 +157,7 @@ impl<'tcx> LateLintPass<'tcx> for UnitReturnExpectingOrd { span, &format!( "this closure returns \ - the unit type which also implements {}", - trait_name + the unit type which also implements {trait_name}" ), ); }, @@ -169,8 +168,7 @@ impl<'tcx> LateLintPass<'tcx> for UnitReturnExpectingOrd { span, &format!( "this closure returns \ - the unit type which also implements {}", - trait_name + the unit type which also implements {trait_name}" ), Some(last_semi), "probably caused by this trailing semicolon", diff --git a/clippy_lints/src/unit_types/unit_arg.rs b/clippy_lints/src/unit_types/unit_arg.rs index a6f777abc6e..f6d3fb00f4e 100644 --- a/clippy_lints/src/unit_types/unit_arg.rs +++ b/clippy_lints/src/unit_types/unit_arg.rs @@ -74,7 +74,7 @@ fn lint_unit_args(cx: &LateContext<'_>, expr: &Expr<'_>, args_to_recover: &[&Exp cx, UNIT_ARG, expr.span, - &format!("passing {}unit value{} to a function", singular, plural), + &format!("passing {singular}unit value{plural} to a function"), |db| { let mut or = ""; args_to_recover @@ -129,7 +129,7 @@ fn lint_unit_args(cx: &LateContext<'_>, expr: &Expr<'_>, args_to_recover: &[&Exp if arg_snippets_without_empty_blocks.is_empty() { db.multipart_suggestion( - &format!("use {}unit literal{} instead", singular, plural), + &format!("use {singular}unit literal{plural} instead"), args_to_recover .iter() .map(|arg| (arg.span, "()".to_string())) @@ -143,8 +143,7 @@ fn lint_unit_args(cx: &LateContext<'_>, expr: &Expr<'_>, args_to_recover: &[&Exp db.span_suggestion( expr.span, &format!( - "{}move the expression{} in front of the call and replace {} with the unit literal `()`", - or, empty_or_s, it_or_them + "{or}move the expression{empty_or_s} in front of the call and replace {it_or_them} with the unit literal `()`" ), sugg, applicability, diff --git a/clippy_lints/src/unit_types/unit_cmp.rs b/clippy_lints/src/unit_types/unit_cmp.rs index 1dd8895ebd0..226495dcbda 100644 --- a/clippy_lints/src/unit_types/unit_cmp.rs +++ b/clippy_lints/src/unit_types/unit_cmp.rs @@ -22,7 +22,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { cx, UNIT_CMP, macro_call.span, - &format!("`{}` of unit values detected. This will always {}", macro_name, result), + &format!("`{macro_name}` of unit values detected. This will always {result}"), ); } return; @@ -40,9 +40,8 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { UNIT_CMP, expr.span, &format!( - "{}-comparison of unit values detected. This will always be {}", - op.as_str(), - result + "{}-comparison of unit values detected. This will always be {result}", + op.as_str() ), ); } diff --git a/clippy_lints/src/unnecessary_self_imports.rs b/clippy_lints/src/unnecessary_self_imports.rs index 839a4bdab09..bc0dd263d88 100644 --- a/clippy_lints/src/unnecessary_self_imports.rs +++ b/clippy_lints/src/unnecessary_self_imports.rs @@ -57,7 +57,7 @@ impl EarlyLintPass for UnnecessarySelfImports { format!( "{}{};", last_segment.ident, - if let UseTreeKind::Simple(Some(alias), ..) = self_tree.kind { format!(" as {}", alias) } else { String::new() }, + if let UseTreeKind::Simple(Some(alias), ..) = self_tree.kind { format!(" as {alias}") } else { String::new() }, ), Applicability::MaybeIncorrect, ); diff --git a/clippy_lints/src/unnecessary_wraps.rs b/clippy_lints/src/unnecessary_wraps.rs index 2c40827db0e..83ef3b0fac8 100644 --- a/clippy_lints/src/unnecessary_wraps.rs +++ b/clippy_lints/src/unnecessary_wraps.rs @@ -153,11 +153,8 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps { ) } else { ( - format!( - "this function's return value is unnecessarily wrapped by `{}`", - return_type_label - ), - format!("remove `{}` from the return type...", return_type_label), + format!("this function's return value is unnecessarily wrapped by `{return_type_label}`"), + format!("remove `{return_type_label}` from the return type..."), inner_type.to_string(), "...and then change returning expressions", ) diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index 64f7a055cd9..32cd4681201 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -65,10 +65,7 @@ fn unsafe_to_safe_check(old_name: Ident, new_name: Ident, cx: &EarlyContext<'_>, cx, UNSAFE_REMOVED_FROM_NAME, span, - &format!( - "removed `unsafe` from the name of `{}` in use as `{}`", - old_str, new_str - ), + &format!("removed `unsafe` from the name of `{old_str}` in use as `{new_str}`"), ); } } diff --git a/clippy_lints/src/unused_rounding.rs b/clippy_lints/src/unused_rounding.rs index b8a5d4ea8c9..3164937293b 100644 --- a/clippy_lints/src/unused_rounding.rs +++ b/clippy_lints/src/unused_rounding.rs @@ -58,8 +58,8 @@ impl EarlyLintPass for UnusedRounding { cx, UNUSED_ROUNDING, expr.span, - &format!("used the `{}` method with a whole number float", method_name), - &format!("remove the `{}` method call", method_name), + &format!("used the `{method_name}` method with a whole number float"), + &format!("remove the `{method_name}` method call"), float, Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 7e451b7b7a4..45e2f550236 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -257,9 +257,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> { expr.hir_id, expr.span, &format!( - "called `{}` on `{}` after checking its variant with `{}`", + "called `{}` on `{unwrappable_variable_name}` after checking its variant with `{}`", method_name.ident.name, - unwrappable_variable_name, unwrappable.check_name.ident.as_str(), ), |diag| { @@ -268,9 +267,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> { unwrappable.check.span.with_lo(unwrappable.if_expr.span.lo()), "try", format!( - "if let {} = {}", - suggested_pattern, - unwrappable_variable_name, + "if let {suggested_pattern} = {unwrappable_variable_name}", ), // We don't track how the unwrapped value is used inside the // block or suggest deleting the unwrap, so we can't offer a diff --git a/clippy_lints/src/upper_case_acronyms.rs b/clippy_lints/src/upper_case_acronyms.rs index 02bf09ed506..378cc427f5a 100644 --- a/clippy_lints/src/upper_case_acronyms.rs +++ b/clippy_lints/src/upper_case_acronyms.rs @@ -93,7 +93,7 @@ fn check_ident(cx: &LateContext<'_>, ident: &Ident, be_aggressive: bool) { cx, UPPER_CASE_ACRONYMS, span, - &format!("name `{}` contains a capitalized acronym", ident), + &format!("name `{ident}` contains a capitalized acronym"), "consider making the acronym lowercase, except the initial letter", corrected, Applicability::MaybeIncorrect, diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index f1b6463ad0f..50c5a832430 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { cx, USELESS_CONVERSION, e.span, - &format!("useless conversion to the same type: `{}`", b), + &format!("useless conversion to the same type: `{b}`"), "consider removing `.into()`", sugg, Applicability::MachineApplicable, // snippet @@ -97,7 +97,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { cx, USELESS_CONVERSION, e.span, - &format!("useless conversion to the same type: `{}`", b), + &format!("useless conversion to the same type: `{b}`"), "consider removing `.into_iter()`", sugg, Applicability::MachineApplicable, // snippet @@ -118,7 +118,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { cx, USELESS_CONVERSION, e.span, - &format!("useless conversion to the same type: `{}`", b), + &format!("useless conversion to the same type: `{b}`"), None, "consider removing `.try_into()`", ); @@ -146,7 +146,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { cx, USELESS_CONVERSION, e.span, - &format!("useless conversion to the same type: `{}`", b), + &format!("useless conversion to the same type: `{b}`"), None, &hint, ); @@ -165,7 +165,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { cx, USELESS_CONVERSION, e.span, - &format!("useless conversion to the same type: `{}`", b), + &format!("useless conversion to the same type: `{b}`"), &sugg_msg, sugg.to_string(), Applicability::MachineApplicable, // snippet diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 4003fff27c0..65576b7203f 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -739,7 +739,7 @@ fn path_to_string(path: &QPath<'_>) -> String { *s += ", "; write!(s, "{:?}", segment.ident.as_str()).unwrap(); }, - other => write!(s, "/* unimplemented: {:?}*/", other).unwrap(), + other => write!(s, "/* unimplemented: {other:?}*/").unwrap(), }, QPath::LangItem(..) => panic!("path_to_string: called for lang item qpath"), } diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index 2be3fa99c81..6f5a638be12 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -482,16 +482,13 @@ pub fn format_error(error: Box) -> String { let field = fields.get(index).copied().unwrap_or_default(); write!( msg, - "{:separator_width$}{:field_width$}", - " ", - field, - separator_width = SEPARATOR_WIDTH, - field_width = column_width + "{:SEPARATOR_WIDTH$}{field:column_width$}", + " " ) .unwrap(); } } - write!(msg, "\n{}", suffix).unwrap(); + write!(msg, "\n{suffix}").unwrap(); msg } else { s diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index 5418eca382d..33138551011 100644 --- a/clippy_lints/src/wildcard_imports.rs +++ b/clippy_lints/src/wildcard_imports.rs @@ -173,7 +173,7 @@ impl LateLintPass<'_> for WildcardImports { let sugg = if braced_glob { imports_string } else { - format!("{}::{}", import_source_snippet, imports_string) + format!("{import_source_snippet}::{imports_string}") }; let (lint, message) = if let Res::Def(DefKind::Enum, _) = use_path.res { diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index 50d3c079fe6..9b3de35dbd3 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -57,8 +57,7 @@ impl<'tcx> LateLintPass<'tcx> for ZeroDiv { "constant division of `0.0` with `0.0` will always result in NaN", None, &format!( - "consider using `{}::NAN` if you would like a constant representing NaN", - float_type, + "consider using `{float_type}::NAN` if you would like a constant representing NaN", ), ); } -- cgit 1.4.1-3-g733a5 From 7093444bfac3b24e380d645b0da4f16ef5c25970 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Sat, 25 Nov 2023 17:45:27 +0000 Subject: Use absolute path for `declare_tool_lint` in `declare_clippy_lint` --- book/src/development/adding_lints.md | 2 +- clippy_dev/src/new_lint.rs | 4 ++-- clippy_lints/src/absolute_paths.rs | 2 +- clippy_lints/src/allow_attributes.rs | 2 +- clippy_lints/src/almost_complete_range.rs | 2 +- clippy_lints/src/approx_const.rs | 2 +- clippy_lints/src/arc_with_non_send_sync.rs | 2 +- clippy_lints/src/as_conversions.rs | 2 +- clippy_lints/src/asm_syntax.rs | 2 +- clippy_lints/src/assertions_on_constants.rs | 2 +- clippy_lints/src/assertions_on_result_states.rs | 2 +- clippy_lints/src/async_yields_async.rs | 2 +- clippy_lints/src/attrs.rs | 2 +- clippy_lints/src/await_holding_invalid.rs | 2 +- clippy_lints/src/blocks_in_if_conditions.rs | 2 +- clippy_lints/src/bool_assert_comparison.rs | 2 +- clippy_lints/src/bool_to_int_with_if.rs | 2 +- clippy_lints/src/booleans.rs | 2 +- clippy_lints/src/borrow_deref_ref.rs | 2 +- clippy_lints/src/box_default.rs | 2 +- clippy_lints/src/cargo/mod.rs | 2 +- clippy_lints/src/casts/mod.rs | 2 +- clippy_lints/src/checked_conversions.rs | 2 +- clippy_lints/src/cognitive_complexity.rs | 2 +- clippy_lints/src/collapsible_if.rs | 2 +- clippy_lints/src/collection_is_never_read.rs | 2 +- clippy_lints/src/comparison_chain.rs | 2 +- clippy_lints/src/copies.rs | 2 +- clippy_lints/src/copy_iterator.rs | 2 +- clippy_lints/src/crate_in_macro_def.rs | 2 +- clippy_lints/src/create_dir.rs | 2 +- clippy_lints/src/dbg_macro.rs | 2 +- clippy_lints/src/default.rs | 2 +- clippy_lints/src/default_constructed_unit_structs.rs | 2 +- clippy_lints/src/default_instead_of_iter_empty.rs | 2 +- clippy_lints/src/default_numeric_fallback.rs | 2 +- clippy_lints/src/default_union_representation.rs | 2 +- clippy_lints/src/dereference.rs | 2 +- clippy_lints/src/derivable_impls.rs | 2 +- clippy_lints/src/derive.rs | 2 +- clippy_lints/src/disallowed_macros.rs | 2 +- clippy_lints/src/disallowed_methods.rs | 2 +- clippy_lints/src/disallowed_names.rs | 2 +- clippy_lints/src/disallowed_script_idents.rs | 2 +- clippy_lints/src/disallowed_types.rs | 2 +- clippy_lints/src/doc/mod.rs | 2 +- clippy_lints/src/double_parens.rs | 2 +- clippy_lints/src/drop_forget_ref.rs | 2 +- clippy_lints/src/duplicate_mod.rs | 2 +- clippy_lints/src/else_if_without_else.rs | 2 +- clippy_lints/src/empty_drop.rs | 2 +- clippy_lints/src/empty_enum.rs | 2 +- clippy_lints/src/empty_structs_with_brackets.rs | 2 +- clippy_lints/src/endian_bytes.rs | 2 +- clippy_lints/src/entry.rs | 2 +- clippy_lints/src/enum_clike.rs | 2 +- clippy_lints/src/equatable_if_let.rs | 2 +- clippy_lints/src/error_impl_error.rs | 2 +- clippy_lints/src/escape.rs | 2 +- clippy_lints/src/eta_reduction.rs | 2 +- clippy_lints/src/excessive_bools.rs | 2 +- clippy_lints/src/excessive_nesting.rs | 2 +- clippy_lints/src/exhaustive_items.rs | 2 +- clippy_lints/src/exit.rs | 2 +- clippy_lints/src/explicit_write.rs | 2 +- clippy_lints/src/extra_unused_type_parameters.rs | 2 +- clippy_lints/src/fallible_impl_from.rs | 2 +- clippy_lints/src/float_literal.rs | 2 +- clippy_lints/src/floating_point_arithmetic.rs | 2 +- clippy_lints/src/format.rs | 2 +- clippy_lints/src/format_args.rs | 2 +- clippy_lints/src/format_impl.rs | 2 +- clippy_lints/src/format_push_string.rs | 2 +- clippy_lints/src/formatting.rs | 2 +- clippy_lints/src/four_forward_slashes.rs | 2 +- clippy_lints/src/from_over_into.rs | 2 +- clippy_lints/src/from_raw_with_void_ptr.rs | 2 +- clippy_lints/src/from_str_radix_10.rs | 2 +- clippy_lints/src/functions/mod.rs | 2 +- clippy_lints/src/future_not_send.rs | 2 +- clippy_lints/src/if_let_mutex.rs | 2 +- clippy_lints/src/if_not_else.rs | 2 +- clippy_lints/src/if_then_some_else_none.rs | 2 +- clippy_lints/src/ignored_unit_patterns.rs | 2 +- clippy_lints/src/impl_hash_with_borrow_str_and_bytes.rs | 2 +- clippy_lints/src/implicit_hasher.rs | 2 +- clippy_lints/src/implicit_return.rs | 2 +- clippy_lints/src/implicit_saturating_add.rs | 2 +- clippy_lints/src/implicit_saturating_sub.rs | 2 +- clippy_lints/src/implied_bounds_in_impls.rs | 2 +- clippy_lints/src/inconsistent_struct_constructor.rs | 2 +- clippy_lints/src/index_refutable_slice.rs | 2 +- clippy_lints/src/indexing_slicing.rs | 2 +- clippy_lints/src/infinite_iter.rs | 2 +- clippy_lints/src/inherent_impl.rs | 2 +- clippy_lints/src/inherent_to_string.rs | 2 +- clippy_lints/src/init_numbered_fields.rs | 2 +- clippy_lints/src/inline_fn_without_body.rs | 2 +- clippy_lints/src/instant_subtraction.rs | 2 +- clippy_lints/src/int_plus_one.rs | 2 +- clippy_lints/src/invalid_upcast_comparisons.rs | 2 +- clippy_lints/src/item_name_repetitions.rs | 2 +- clippy_lints/src/items_after_statements.rs | 2 +- clippy_lints/src/items_after_test_module.rs | 2 +- clippy_lints/src/iter_not_returning_iterator.rs | 2 +- clippy_lints/src/iter_over_hash_type.rs | 2 +- clippy_lints/src/iter_without_into_iter.rs | 2 +- clippy_lints/src/large_const_arrays.rs | 2 +- clippy_lints/src/large_enum_variant.rs | 2 +- clippy_lints/src/large_futures.rs | 2 +- clippy_lints/src/large_include_file.rs | 2 +- clippy_lints/src/large_stack_arrays.rs | 2 +- clippy_lints/src/large_stack_frames.rs | 2 +- clippy_lints/src/len_zero.rs | 2 +- clippy_lints/src/let_if_seq.rs | 2 +- clippy_lints/src/let_underscore.rs | 2 +- clippy_lints/src/let_with_type_underscore.rs | 2 +- clippy_lints/src/lifetimes.rs | 2 +- clippy_lints/src/lines_filter_map_ok.rs | 2 +- clippy_lints/src/literal_representation.rs | 2 +- clippy_lints/src/loops/mod.rs | 2 +- clippy_lints/src/macro_use.rs | 2 +- clippy_lints/src/main_recursion.rs | 2 +- clippy_lints/src/manual_assert.rs | 2 +- clippy_lints/src/manual_async_fn.rs | 2 +- clippy_lints/src/manual_bits.rs | 2 +- clippy_lints/src/manual_clamp.rs | 2 +- clippy_lints/src/manual_float_methods.rs | 2 +- clippy_lints/src/manual_hash_one.rs | 2 +- clippy_lints/src/manual_is_ascii_check.rs | 2 +- clippy_lints/src/manual_let_else.rs | 2 +- clippy_lints/src/manual_main_separator_str.rs | 2 +- clippy_lints/src/manual_non_exhaustive.rs | 2 +- clippy_lints/src/manual_range_patterns.rs | 2 +- clippy_lints/src/manual_rem_euclid.rs | 2 +- clippy_lints/src/manual_retain.rs | 2 +- clippy_lints/src/manual_slice_size_calculation.rs | 2 +- clippy_lints/src/manual_string_new.rs | 2 +- clippy_lints/src/manual_strip.rs | 2 +- clippy_lints/src/map_unit_fn.rs | 2 +- clippy_lints/src/match_result_ok.rs | 2 +- clippy_lints/src/matches/mod.rs | 2 +- clippy_lints/src/mem_replace.rs | 2 +- clippy_lints/src/methods/mod.rs | 2 +- clippy_lints/src/min_ident_chars.rs | 2 +- clippy_lints/src/minmax.rs | 2 +- clippy_lints/src/misc.rs | 2 +- clippy_lints/src/misc_early/mod.rs | 2 +- clippy_lints/src/mismatching_type_param_order.rs | 2 +- clippy_lints/src/missing_assert_message.rs | 2 +- clippy_lints/src/missing_asserts_for_indexing.rs | 2 +- clippy_lints/src/missing_const_for_fn.rs | 2 +- clippy_lints/src/missing_doc.rs | 2 +- clippy_lints/src/missing_enforced_import_rename.rs | 2 +- clippy_lints/src/missing_fields_in_debug.rs | 2 +- clippy_lints/src/missing_inline.rs | 2 +- clippy_lints/src/missing_trait_methods.rs | 2 +- clippy_lints/src/mixed_read_write_in_expression.rs | 2 +- clippy_lints/src/module_style.rs | 2 +- clippy_lints/src/multi_assignments.rs | 2 +- clippy_lints/src/multiple_unsafe_ops_per_block.rs | 2 +- clippy_lints/src/mut_key.rs | 2 +- clippy_lints/src/mut_mut.rs | 2 +- clippy_lints/src/mut_reference.rs | 2 +- clippy_lints/src/mutable_debug_assertion.rs | 2 +- clippy_lints/src/mutex_atomic.rs | 2 +- clippy_lints/src/needless_arbitrary_self_type.rs | 2 +- clippy_lints/src/needless_bool.rs | 2 +- clippy_lints/src/needless_borrowed_ref.rs | 2 +- clippy_lints/src/needless_borrows_for_generic_args.rs | 2 +- clippy_lints/src/needless_continue.rs | 2 +- clippy_lints/src/needless_else.rs | 2 +- clippy_lints/src/needless_for_each.rs | 2 +- clippy_lints/src/needless_if.rs | 2 +- clippy_lints/src/needless_late_init.rs | 2 +- clippy_lints/src/needless_parens_on_range_literals.rs | 2 +- clippy_lints/src/needless_pass_by_ref_mut.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/needless_question_mark.rs | 2 +- clippy_lints/src/needless_update.rs | 2 +- clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 2 +- clippy_lints/src/neg_multiply.rs | 2 +- clippy_lints/src/new_without_default.rs | 2 +- clippy_lints/src/no_effect.rs | 2 +- clippy_lints/src/no_mangle_with_rust_abi.rs | 2 +- clippy_lints/src/non_canonical_impls.rs | 2 +- clippy_lints/src/non_copy_const.rs | 2 +- clippy_lints/src/non_expressive_names.rs | 2 +- clippy_lints/src/non_octal_unix_permissions.rs | 2 +- clippy_lints/src/non_send_fields_in_send_ty.rs | 2 +- clippy_lints/src/nonstandard_macro_braces.rs | 2 +- clippy_lints/src/octal_escapes.rs | 2 +- clippy_lints/src/only_used_in_recursion.rs | 2 +- clippy_lints/src/operators/mod.rs | 2 +- clippy_lints/src/option_env_unwrap.rs | 2 +- clippy_lints/src/option_if_let_else.rs | 2 +- clippy_lints/src/overflow_check_conditional.rs | 2 +- clippy_lints/src/panic_in_result_fn.rs | 2 +- clippy_lints/src/panic_unimplemented.rs | 2 +- clippy_lints/src/partial_pub_fields.rs | 2 +- clippy_lints/src/partialeq_ne_impl.rs | 2 +- clippy_lints/src/partialeq_to_none.rs | 2 +- clippy_lints/src/pass_by_ref_or_value.rs | 2 +- clippy_lints/src/pattern_type_mismatch.rs | 2 +- clippy_lints/src/permissions_set_readonly_false.rs | 2 +- clippy_lints/src/precedence.rs | 2 +- clippy_lints/src/ptr.rs | 2 +- clippy_lints/src/ptr_offset_with_cast.rs | 2 +- clippy_lints/src/pub_use.rs | 2 +- clippy_lints/src/question_mark.rs | 2 +- clippy_lints/src/question_mark_used.rs | 2 +- clippy_lints/src/ranges.rs | 2 +- clippy_lints/src/raw_strings.rs | 2 +- clippy_lints/src/rc_clone_in_vec_init.rs | 2 +- clippy_lints/src/read_zero_byte_vec.rs | 2 +- clippy_lints/src/redundant_async_block.rs | 2 +- clippy_lints/src/redundant_clone.rs | 2 +- clippy_lints/src/redundant_closure_call.rs | 2 +- clippy_lints/src/redundant_else.rs | 2 +- clippy_lints/src/redundant_field_names.rs | 2 +- clippy_lints/src/redundant_locals.rs | 2 +- clippy_lints/src/redundant_pub_crate.rs | 2 +- clippy_lints/src/redundant_slicing.rs | 2 +- clippy_lints/src/redundant_static_lifetimes.rs | 2 +- clippy_lints/src/redundant_type_annotations.rs | 2 +- clippy_lints/src/ref_option_ref.rs | 2 +- clippy_lints/src/ref_patterns.rs | 2 +- clippy_lints/src/reference.rs | 2 +- clippy_lints/src/regex.rs | 2 +- clippy_lints/src/reserve_after_initialization.rs | 2 +- clippy_lints/src/return_self_not_must_use.rs | 2 +- clippy_lints/src/returns.rs | 2 +- clippy_lints/src/same_name_method.rs | 2 +- clippy_lints/src/self_named_constructors.rs | 2 +- clippy_lints/src/semicolon_block.rs | 2 +- clippy_lints/src/semicolon_if_nothing_returned.rs | 2 +- clippy_lints/src/serde_api.rs | 2 +- clippy_lints/src/shadow.rs | 2 +- clippy_lints/src/significant_drop_tightening.rs | 2 +- clippy_lints/src/single_call_fn.rs | 2 +- clippy_lints/src/single_char_lifetime_names.rs | 2 +- clippy_lints/src/single_component_path_imports.rs | 2 +- clippy_lints/src/single_range_in_vec_init.rs | 2 +- clippy_lints/src/size_of_in_element_count.rs | 2 +- clippy_lints/src/size_of_ref.rs | 2 +- clippy_lints/src/slow_vector_initialization.rs | 2 +- clippy_lints/src/std_instead_of_core.rs | 2 +- clippy_lints/src/strings.rs | 2 +- clippy_lints/src/strlen_on_c_strings.rs | 2 +- clippy_lints/src/suspicious_operation_groupings.rs | 2 +- clippy_lints/src/suspicious_trait_impl.rs | 2 +- clippy_lints/src/suspicious_xor_used_as_pow.rs | 2 +- clippy_lints/src/swap.rs | 2 +- clippy_lints/src/swap_ptr_to_ref.rs | 2 +- clippy_lints/src/tabs_in_doc_comments.rs | 2 +- clippy_lints/src/temporary_assignment.rs | 2 +- clippy_lints/src/tests_outside_test_module.rs | 2 +- clippy_lints/src/to_digit_is_some.rs | 2 +- clippy_lints/src/trailing_empty_array.rs | 2 +- clippy_lints/src/trait_bounds.rs | 2 +- clippy_lints/src/transmute/mod.rs | 2 +- clippy_lints/src/tuple_array_conversions.rs | 2 +- clippy_lints/src/types/mod.rs | 2 +- clippy_lints/src/undocumented_unsafe_blocks.rs | 2 +- clippy_lints/src/unicode.rs | 2 +- clippy_lints/src/uninit_vec.rs | 2 +- clippy_lints/src/unit_return_expecting_ord.rs | 2 +- clippy_lints/src/unit_types/mod.rs | 2 +- clippy_lints/src/unnamed_address.rs | 2 +- clippy_lints/src/unnecessary_box_returns.rs | 2 +- clippy_lints/src/unnecessary_map_on_constructor.rs | 2 +- clippy_lints/src/unnecessary_owned_empty_strings.rs | 2 +- clippy_lints/src/unnecessary_self_imports.rs | 2 +- clippy_lints/src/unnecessary_struct_initialization.rs | 2 +- clippy_lints/src/unnecessary_wraps.rs | 2 +- clippy_lints/src/unnested_or_patterns.rs | 2 +- clippy_lints/src/unsafe_removed_from_name.rs | 2 +- clippy_lints/src/unused_async.rs | 2 +- clippy_lints/src/unused_io_amount.rs | 2 +- clippy_lints/src/unused_peekable.rs | 2 +- clippy_lints/src/unused_rounding.rs | 2 +- clippy_lints/src/unused_self.rs | 2 +- clippy_lints/src/unused_unit.rs | 2 +- clippy_lints/src/unwrap.rs | 2 +- clippy_lints/src/unwrap_in_result.rs | 2 +- clippy_lints/src/upper_case_acronyms.rs | 2 +- clippy_lints/src/use_self.rs | 2 +- clippy_lints/src/useless_conversion.rs | 2 +- .../src/utils/internal_lints/almost_standard_lint_formulation.rs | 2 +- clippy_lints/src/utils/internal_lints/collapsible_calls.rs | 2 +- clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs | 2 +- clippy_lints/src/utils/internal_lints/interning_defined_symbol.rs | 2 +- clippy_lints/src/utils/internal_lints/invalid_paths.rs | 2 +- clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs | 2 +- clippy_lints/src/utils/internal_lints/metadata_collector.rs | 2 +- clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs | 2 +- clippy_lints/src/utils/internal_lints/outer_expn_data_pass.rs | 2 +- clippy_lints/src/utils/internal_lints/produce_ice.rs | 2 +- clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs | 2 +- clippy_lints/src/utils/internal_lints/unsorted_clippy_utils_paths.rs | 2 +- clippy_lints/src/vec.rs | 2 +- clippy_lints/src/vec_init_then_push.rs | 2 +- clippy_lints/src/visibility.rs | 2 +- clippy_lints/src/wildcard_imports.rs | 2 +- clippy_lints/src/write.rs | 2 +- clippy_lints/src/zero_div_zero.rs | 2 +- clippy_lints/src/zero_sized_map_values.rs | 2 +- declare_clippy_lint/src/lib.rs | 2 +- 308 files changed, 309 insertions(+), 309 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/book/src/development/adding_lints.md b/book/src/development/adding_lints.md index e79e5e75cd1..e30a5f9fe10 100644 --- a/book/src/development/adding_lints.md +++ b/book/src/development/adding_lints.md @@ -202,7 +202,7 @@ is. This file has already imported some initial things we will need: ```rust use rustc_lint::{EarlyLintPass, EarlyContext}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_ast::ast::*; ``` diff --git a/clippy_dev/src/new_lint.rs b/clippy_dev/src/new_lint.rs index ddc20f7f37f..31a42734c13 100644 --- a/clippy_dev/src/new_lint.rs +++ b/clippy_dev/src/new_lint.rs @@ -283,7 +283,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String { use clippy_utils::msrvs::{{self, Msrv}}; {pass_import} use rustc_lint::{{{context_import}, {pass_type}, LintContext}}; - use rustc_session::{{declare_tool_lint, impl_lint_pass}}; + use rustc_session::impl_lint_pass; "# ) @@ -292,7 +292,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String { r#" {pass_import} use rustc_lint::{{{context_import}, {pass_type}}}; - use rustc_session::{{declare_lint_pass, declare_tool_lint}}; + use rustc_session::declare_lint_pass; "# ) diff --git a/clippy_lints/src/absolute_paths.rs b/clippy_lints/src/absolute_paths.rs index 582423603eb..83d15c0c425 100644 --- a/clippy_lints/src/absolute_paths.rs +++ b/clippy_lints/src/absolute_paths.rs @@ -5,7 +5,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX}; use rustc_hir::{HirId, ItemKind, Node, Path}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; declare_clippy_lint! { diff --git a/clippy_lints/src/allow_attributes.rs b/clippy_lints/src/allow_attributes.rs index 98299e1e4bd..39fc49dee37 100644 --- a/clippy_lints/src/allow_attributes.rs +++ b/clippy_lints/src/allow_attributes.rs @@ -5,7 +5,7 @@ use rustc_ast as ast; use rustc_errors::Applicability; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/almost_complete_range.rs b/clippy_lints/src/almost_complete_range.rs index e85878eb570..57a5cd8fba8 100644 --- a/clippy_lints/src/almost_complete_range.rs +++ b/clippy_lints/src/almost_complete_range.rs @@ -5,7 +5,7 @@ use rustc_ast::ast::{Expr, ExprKind, LitKind, Pat, PatKind, RangeEnd, RangeLimit use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index b4f778f12b9..409ae0c85ac 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -4,7 +4,7 @@ use rustc_ast::ast::{FloatTy, LitFloatType, LitKind}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_semver::RustcVersion; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol; use std::f64::consts as f64; diff --git a/clippy_lints/src/arc_with_non_send_sync.rs b/clippy_lints/src/arc_with_non_send_sync.rs index 9799e703afe..657d52d0e9e 100644 --- a/clippy_lints/src/arc_with_non_send_sync.rs +++ b/clippy_lints/src/arc_with_non_send_sync.rs @@ -6,7 +6,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::GenericArgKind; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/as_conversions.rs b/clippy_lints/src/as_conversions.rs index b9dda49ca41..e052d36f115 100644 --- a/clippy_lints/src/as_conversions.rs +++ b/clippy_lints/src/as_conversions.rs @@ -3,7 +3,7 @@ use clippy_utils::is_from_proc_macro; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/asm_syntax.rs b/clippy_lints/src/asm_syntax.rs index 9717aa9e981..feb6437ee26 100644 --- a/clippy_lints/src/asm_syntax.rs +++ b/clippy_lints/src/asm_syntax.rs @@ -3,7 +3,7 @@ use std::fmt; use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions}; use rustc_lint::{EarlyContext, EarlyLintPass, Lint}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; #[derive(Clone, Copy, PartialEq, Eq)] enum AsmStyle { diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index b90914e936a..a15ec199a28 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::macros::{find_assert_args, root_macro_call_first_node, PanicExpn}; use rustc_hir::Expr; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/assertions_on_result_states.rs b/clippy_lints/src/assertions_on_result_states.rs index 71ec87a8874..aec22965b1b 100644 --- a/clippy_lints/src/assertions_on_result_states.rs +++ b/clippy_lints/src/assertions_on_result_states.rs @@ -9,7 +9,7 @@ use rustc_hir::def::Res; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/async_yields_async.rs b/clippy_lints/src/async_yields_async.rs index ec2447dae96..3e5a01c45df 100644 --- a/clippy_lints/src/async_yields_async.rs +++ b/clippy_lints/src/async_yields_async.rs @@ -4,7 +4,7 @@ use clippy_utils::ty::implements_trait; use rustc_errors::Applicability; use rustc_hir::{Body, BodyId, CoroutineKind, CoroutineSource, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 694bc8755a6..da38422874b 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -17,7 +17,7 @@ use rustc_hir::{ use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass}; +use rustc_session::{declare_lint_pass, impl_lint_pass}; use rustc_span::symbol::Symbol; use rustc_span::{sym, Span, DUMMY_SP}; use semver::Version; diff --git a/clippy_lints/src/await_holding_invalid.rs b/clippy_lints/src/await_holding_invalid.rs index 06b74b972b7..9894a163961 100644 --- a/clippy_lints/src/await_holding_invalid.rs +++ b/clippy_lints/src/await_holding_invalid.rs @@ -6,7 +6,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::{Body, CoroutineKind, CoroutineSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::CoroutineLayout; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{sym, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/blocks_in_if_conditions.rs b/clippy_lints/src/blocks_in_if_conditions.rs index 28bd3fc7011..692309629b7 100644 --- a/clippy_lints/src/blocks_in_if_conditions.rs +++ b/clippy_lints/src/blocks_in_if_conditions.rs @@ -8,7 +8,7 @@ use rustc_errors::Applicability; use rustc_hir::{BlockCheckMode, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/bool_assert_comparison.rs b/clippy_lints/src/bool_assert_comparison.rs index 665dbd6f708..74201e9cc30 100644 --- a/clippy_lints/src/bool_assert_comparison.rs +++ b/clippy_lints/src/bool_assert_comparison.rs @@ -7,7 +7,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, Lit}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::Ident; declare_clippy_lint! { diff --git a/clippy_lints/src/bool_to_int_with_if.rs b/clippy_lints/src/bool_to_int_with_if.rs index 156cb34df9c..cfb76cab6dc 100644 --- a/clippy_lints/src/bool_to_int_with_if.rs +++ b/clippy_lints/src/bool_to_int_with_if.rs @@ -2,7 +2,7 @@ use clippy_utils::higher::If; use rustc_ast::LitKind; use rustc_hir::{Block, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::sugg::Sugg; diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index d4f2e316890..e68ea2571b6 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -7,7 +7,7 @@ use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_expr, FnKind, Visitor}; use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, UnOp}; use rustc_lint::{LateContext, LateLintPass, Level}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/borrow_deref_ref.rs b/clippy_lints/src/borrow_deref_ref.rs index 789cd3b6c21..d3d4f3c41c8 100644 --- a/clippy_lints/src/borrow_deref_ref.rs +++ b/clippy_lints/src/borrow_deref_ref.rs @@ -8,7 +8,7 @@ use rustc_hir::{ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::Mutability; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/box_default.rs b/clippy_lints/src/box_default.rs index 9c78c6e532d..b69dc5c1291 100644 --- a/clippy_lints/src/box_default.rs +++ b/clippy_lints/src/box_default.rs @@ -10,7 +10,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::IsSuggestable; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/cargo/mod.rs b/clippy_lints/src/cargo/mod.rs index 3a872e54c9a..fea6924d89e 100644 --- a/clippy_lints/src/cargo/mod.rs +++ b/clippy_lints/src/cargo/mod.rs @@ -8,7 +8,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::is_lint_allowed; use rustc_hir::hir_id::CRATE_HIR_ID; use rustc_lint::{LateContext, LateLintPass, Lint}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::DUMMY_SP; declare_clippy_lint! { diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index 49a90a2f3c2..e05b8f66d86 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -27,7 +27,7 @@ use clippy_utils::is_hir_ty_cfg_dependant; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/checked_conversions.rs b/clippy_lints/src/checked_conversions.rs index 69fa0821e3f..92810ea2aa0 100644 --- a/clippy_lints/src/checked_conversions.rs +++ b/clippy_lints/src/checked_conversions.rs @@ -8,7 +8,7 @@ use rustc_errors::Applicability; use rustc_hir::{BinOp, BinOpKind, Expr, ExprKind, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/cognitive_complexity.rs b/clippy_lints/src/cognitive_complexity.rs index 74ecaa60c7c..60f436dc5d2 100644 --- a/clippy_lints/src/cognitive_complexity.rs +++ b/clippy_lints/src/cognitive_complexity.rs @@ -10,7 +10,7 @@ use rustc_ast::ast::Attribute; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, Expr, ExprKind, FnDecl}; use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{sym, BytePos, Span}; diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index e5aaf88ab6c..07b02c98df1 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -18,7 +18,7 @@ use clippy_utils::sugg::Sugg; use rustc_ast::ast; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/collection_is_never_read.rs b/clippy_lints/src/collection_is_never_read.rs index 1dfc2e251d9..d0c989cfff3 100644 --- a/clippy_lints/src/collection_is_never_read.rs +++ b/clippy_lints/src/collection_is_never_read.rs @@ -5,7 +5,7 @@ use clippy_utils::{get_enclosing_block, get_parent_node, path_to_local_id}; use core::ops::ControlFlow; use rustc_hir::{Block, ExprKind, HirId, LangItem, Local, Node, PatKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; use rustc_span::Symbol; diff --git a/clippy_lints/src/comparison_chain.rs b/clippy_lints/src/comparison_chain.rs index 0fe973b49a3..2c23c0b4f15 100644 --- a/clippy_lints/src/comparison_chain.rs +++ b/clippy_lints/src/comparison_chain.rs @@ -3,7 +3,7 @@ use clippy_utils::ty::implements_trait; use clippy_utils::{if_sequence, in_constant, is_else_clause, SpanlessEq}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 3b6d4886ba3..d91af76f5e0 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -13,7 +13,7 @@ use rustc_hir::def_id::DefIdSet; use rustc_hir::{intravisit, BinOpKind, Block, Expr, ExprKind, HirId, HirIdSet, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::query::Key; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::hygiene::walk_chain; use rustc_span::source_map::SourceMap; use rustc_span::{BytePos, Span, Symbol}; diff --git a/clippy_lints/src/copy_iterator.rs b/clippy_lints/src/copy_iterator.rs index db850edd640..50fd76a3a47 100644 --- a/clippy_lints/src/copy_iterator.rs +++ b/clippy_lints/src/copy_iterator.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_note; use clippy_utils::ty::is_copy; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/crate_in_macro_def.rs b/clippy_lints/src/crate_in_macro_def.rs index 637d5aae1be..d4828778be2 100644 --- a/clippy_lints/src/crate_in_macro_def.rs +++ b/clippy_lints/src/crate_in_macro_def.rs @@ -4,7 +4,7 @@ use rustc_ast::token::{Token, TokenKind}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; use rustc_span::Span; diff --git a/clippy_lints/src/create_dir.rs b/clippy_lints/src/create_dir.rs index 97b736dfd8f..7a3d5a07091 100644 --- a/clippy_lints/src/create_dir.rs +++ b/clippy_lints/src/create_dir.rs @@ -3,7 +3,7 @@ use clippy_utils::source::snippet; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/dbg_macro.rs b/clippy_lints/src/dbg_macro.rs index 4774917c7b5..9424a9103db 100644 --- a/clippy_lints/src/dbg_macro.rs +++ b/clippy_lints/src/dbg_macro.rs @@ -5,7 +5,7 @@ use clippy_utils::{is_in_cfg_test, is_in_test_function}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, Node}; use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/default.rs b/clippy_lints/src/default.rs index b325449c5a3..d8a070b785d 100644 --- a/clippy_lints/src/default.rs +++ b/clippy_lints/src/default.rs @@ -9,7 +9,7 @@ use rustc_hir::{Block, Expr, ExprKind, PatKind, QPath, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_middle::ty::print::with_forced_trimmed_paths; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/default_constructed_unit_structs.rs b/clippy_lints/src/default_constructed_unit_structs.rs index b90d01b765a..9ce5acfbcc2 100644 --- a/clippy_lints/src/default_constructed_unit_structs.rs +++ b/clippy_lints/src/default_constructed_unit_structs.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/default_instead_of_iter_empty.rs b/clippy_lints/src/default_instead_of_iter_empty.rs index 553b670fdb7..2472e2ee76f 100644 --- a/clippy_lints/src/default_instead_of_iter_empty.rs +++ b/clippy_lints/src/default_instead_of_iter_empty.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet_with_context; use rustc_errors::Applicability; use rustc_hir::{def, Expr, ExprKind, GenericArg, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, SyntaxContext}; declare_clippy_lint! { diff --git a/clippy_lints/src/default_numeric_fallback.rs b/clippy_lints/src/default_numeric_fallback.rs index fb29703957d..64a924a776a 100644 --- a/clippy_lints/src/default_numeric_fallback.rs +++ b/clippy_lints/src/default_numeric_fallback.rs @@ -8,7 +8,7 @@ use rustc_hir::{Body, Expr, ExprKind, HirId, ItemKind, Lit, Node, Stmt, StmtKind use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, FloatTy, IntTy, PolyFnSig, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use std::iter; declare_clippy_lint! { diff --git a/clippy_lints/src/default_union_representation.rs b/clippy_lints/src/default_union_representation.rs index 8c6749a95fa..db01ff2cd22 100644 --- a/clippy_lints/src/default_union_representation.rs +++ b/clippy_lints/src/default_union_representation.rs @@ -3,7 +3,7 @@ use rustc_hir::{HirId, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, FieldDef, GenericArg, List}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index afca8850ac5..09cb8feac6a 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -17,7 +17,7 @@ use rustc_hir::{ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability}; use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeVisitableExt, TypeckResults}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::sym; use rustc_span::{Span, Symbol}; diff --git a/clippy_lints/src/derivable_impls.rs b/clippy_lints/src/derivable_impls.rs index 9db56fa8ad0..53ef6d7e387 100644 --- a/clippy_lints/src/derivable_impls.rs +++ b/clippy_lints/src/derivable_impls.rs @@ -10,7 +10,7 @@ use rustc_hir::{ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::adjustment::{Adjust, PointerCoercion}; use rustc_middle::ty::{self, Adt, AdtDef, GenericArgsRef, Ty, TypeckResults}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 169c2a15db7..77f15aa776b 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -14,7 +14,7 @@ use rustc_middle::ty::{ self, ClauseKind, GenericArgKind, GenericParamDefKind, ImplPolarity, ParamEnv, ToPredicate, TraitPredicate, Ty, TyCtxt, }; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/disallowed_macros.rs b/clippy_lints/src/disallowed_macros.rs index 324b5e0798e..656b3d9bfaf 100644 --- a/clippy_lints/src/disallowed_macros.rs +++ b/clippy_lints/src/disallowed_macros.rs @@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_hir::def_id::DefIdMap; use rustc_hir::{Expr, ExprKind, ForeignItem, HirId, ImplItem, Item, Pat, Path, Stmt, TraitItem, Ty}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{ExpnId, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/disallowed_methods.rs b/clippy_lints/src/disallowed_methods.rs index d23aeebb5a8..1868d3cd391 100644 --- a/clippy_lints/src/disallowed_methods.rs +++ b/clippy_lints/src/disallowed_methods.rs @@ -4,7 +4,7 @@ use clippy_utils::{fn_def_id, get_parent_expr, path_def_id}; use rustc_hir::def_id::DefIdMap; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/disallowed_names.rs b/clippy_lints/src/disallowed_names.rs index a1dd4805b9c..09dad5554ad 100644 --- a/clippy_lints/src/disallowed_names.rs +++ b/clippy_lints/src/disallowed_names.rs @@ -3,7 +3,7 @@ use clippy_utils::is_test_module_or_function; use rustc_data_structures::fx::FxHashSet; use rustc_hir::{Item, Pat, PatKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/disallowed_script_idents.rs b/clippy_lints/src/disallowed_script_idents.rs index 96a7f0e4fde..d5205e65cef 100644 --- a/clippy_lints/src/disallowed_script_idents.rs +++ b/clippy_lints/src/disallowed_script_idents.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint; use rustc_ast::ast; use rustc_data_structures::fx::FxHashSet; use rustc_lint::{EarlyContext, EarlyLintPass, Level, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use unicode_script::{Script, UnicodeScript}; declare_clippy_lint! { diff --git a/clippy_lints/src/disallowed_types.rs b/clippy_lints/src/disallowed_types.rs index 3578fb640fc..130f56b698f 100644 --- a/clippy_lints/src/disallowed_types.rs +++ b/clippy_lints/src/disallowed_types.rs @@ -5,7 +5,7 @@ use rustc_hir::def::Res; use rustc_hir::def_id::DefId; use rustc_hir::{Item, ItemKind, PolyTraitRef, PrimTy, Ty, TyKind, UseKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 607af6ba905..18874b1cb8e 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -21,7 +21,7 @@ use rustc_middle::ty; use rustc_resolve::rustdoc::{ add_doc_fragment, attrs_to_doc_fragments, main_body_opts, source_span_for_markdown_range, DocFragment, }; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::edition::Edition; use rustc_span::{sym, Span}; use std::ops::Range; diff --git a/clippy_lints/src/double_parens.rs b/clippy_lints/src/double_parens.rs index 63f32173b05..b51bb7951b7 100644 --- a/clippy_lints/src/double_parens.rs +++ b/clippy_lints/src/double_parens.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Expr, ExprKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index 177e04dfa6b..124d78fc4ff 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -3,7 +3,7 @@ use clippy_utils::ty::{is_copy, is_must_use_ty, is_type_lang_item}; use clippy_utils::{get_parent_node, is_must_use_func_call}; use rustc_hir::{Arm, Expr, ExprKind, LangItem, Node}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; use std::borrow::Cow; diff --git a/clippy_lints/src/duplicate_mod.rs b/clippy_lints/src/duplicate_mod.rs index 7ff7068f0b0..471335c098f 100644 --- a/clippy_lints/src/duplicate_mod.rs +++ b/clippy_lints/src/duplicate_mod.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Crate, Inline, Item, ItemKind, ModKind}; use rustc_errors::MultiSpan; use rustc_lint::{EarlyContext, EarlyLintPass, Level, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{FileName, Span}; use std::collections::BTreeMap; use std::path::PathBuf; diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs index 61db1c1abd1..47780cab9ed 100644 --- a/clippy_lints/src/else_if_without_else.rs +++ b/clippy_lints/src/else_if_without_else.rs @@ -4,7 +4,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Expr, ExprKind}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/empty_drop.rs b/clippy_lints/src/empty_drop.rs index 17be95780cc..e97030cc8b6 100644 --- a/clippy_lints/src/empty_drop.rs +++ b/clippy_lints/src/empty_drop.rs @@ -3,7 +3,7 @@ use clippy_utils::peel_blocks; use rustc_errors::Applicability; use rustc_hir::{Body, ExprKind, Impl, ImplItemKind, Item, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs index a5699727b5b..420888b6ccb 100644 --- a/clippy_lints/src/empty_enum.rs +++ b/clippy_lints/src/empty_enum.rs @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/empty_structs_with_brackets.rs b/clippy_lints/src/empty_structs_with_brackets.rs index 4e2a8b73c0a..3cf67b3ecbf 100644 --- a/clippy_lints/src/empty_structs_with_brackets.rs +++ b/clippy_lints/src/empty_structs_with_brackets.rs @@ -4,7 +4,7 @@ use rustc_ast::ast::{Item, ItemKind, VariantData}; use rustc_errors::Applicability; use rustc_lexer::TokenKind; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/endian_bytes.rs b/clippy_lints/src/endian_bytes.rs index 6f5a0cb8801..b8a817e21b1 100644 --- a/clippy_lints/src/endian_bytes.rs +++ b/clippy_lints/src/endian_bytes.rs @@ -5,7 +5,7 @@ use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::Ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Symbol; use std::borrow::Cow; diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 3e3c62e85d0..ce0a1dfdc61 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -10,7 +10,7 @@ use rustc_hir::hir_id::HirIdSet; use rustc_hir::intravisit::{walk_expr, Visitor}; use rustc_hir::{Block, Expr, ExprKind, Guard, HirId, Let, Pat, Stmt, StmtKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{Span, SyntaxContext, DUMMY_SP}; declare_clippy_lint! { diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index 003b5fc7261..30eb643c42e 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -7,7 +7,7 @@ use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::{self, IntTy, UintTy}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/equatable_if_let.rs b/clippy_lints/src/equatable_if_let.rs index 575fead5bf3..9ea52750c84 100644 --- a/clippy_lints/src/equatable_if_let.rs +++ b/clippy_lints/src/equatable_if_let.rs @@ -6,7 +6,7 @@ use rustc_hir::{Expr, ExprKind, Pat, PatKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::Ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/error_impl_error.rs b/clippy_lints/src/error_impl_error.rs index bc878555c66..c077bdd788c 100644 --- a/clippy_lints/src/error_impl_error.rs +++ b/clippy_lints/src/error_impl_error.rs @@ -5,7 +5,7 @@ use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Visibility; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 2f22f344a21..546b228b1b0 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -6,7 +6,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, TraitRef, Ty}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::kw; use rustc_span::Span; diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 241b51eeca0..450cee4007c 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -13,7 +13,7 @@ use rustc_middle::ty::{ self, Binder, ClosureArgs, ClosureKind, EarlyBinder, FnSig, GenericArg, GenericArgKind, GenericArgsRef, ImplPolarity, List, Region, RegionKind, Ty, TypeVisitableExt, TypeckResults, }; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; use rustc_target::spec::abi::Abi; use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _; diff --git a/clippy_lints/src/excessive_bools.rs b/clippy_lints/src/excessive_bools.rs index 1d18e194d15..815352010f7 100644 --- a/clippy_lints/src/excessive_bools.rs +++ b/clippy_lints/src/excessive_bools.rs @@ -3,7 +3,7 @@ use clippy_utils::{get_parent_as_impl, has_repr_attr, is_bool}; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl, Item, ItemKind, TraitFn, TraitItem, TraitItemKind, Ty}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::Span; use rustc_target::spec::abi::Abi; diff --git a/clippy_lints/src/excessive_nesting.rs b/clippy_lints/src/excessive_nesting.rs index 83480fc5eeb..4b0d11c5d1b 100644 --- a/clippy_lints/src/excessive_nesting.rs +++ b/clippy_lints/src/excessive_nesting.rs @@ -5,7 +5,7 @@ use rustc_ast::visit::{walk_block, walk_item, Visitor}; use rustc_ast::{Block, Crate, Inline, Item, ItemKind, ModKind, NodeId}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/exhaustive_items.rs b/clippy_lints/src/exhaustive_items.rs index b7e62e082e4..3a621d967f4 100644 --- a/clippy_lints/src/exhaustive_items.rs +++ b/clippy_lints/src/exhaustive_items.rs @@ -3,7 +3,7 @@ use clippy_utils::source::indent_of; use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/exit.rs b/clippy_lints/src/exit.rs index 07d025f68c3..a974c10bc7d 100644 --- a/clippy_lints/src/exit.rs +++ b/clippy_lints/src/exit.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::is_entrypoint_fn; use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index 08cb2114a2b..4e2e1d1724a 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::{BindingAnnotation, Block, BlockCheckMode, Expr, ExprKind, Node, PatKind, QPath, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, ExpnId}; declare_clippy_lint! { diff --git a/clippy_lints/src/extra_unused_type_parameters.rs b/clippy_lints/src/extra_unused_type_parameters.rs index d6c746901fc..538d29eb43d 100644 --- a/clippy_lints/src/extra_unused_type_parameters.rs +++ b/clippy_lints/src/extra_unused_type_parameters.rs @@ -10,7 +10,7 @@ use rustc_hir::{ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::hir::nested_filter; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::Span; diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 753f75d83a8..0446943321a 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -5,7 +5,7 @@ use clippy_utils::ty::is_type_diagnostic_item; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/float_literal.rs b/clippy_lints/src/float_literal.rs index 663c33e8cee..38a16c5c8b0 100644 --- a/clippy_lints/src/float_literal.rs +++ b/clippy_lints/src/float_literal.rs @@ -5,7 +5,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, FloatTy}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use std::fmt; declare_clippy_lint! { diff --git a/clippy_lints/src/floating_point_arithmetic.rs b/clippy_lints/src/floating_point_arithmetic.rs index d522873472b..aaf1fee3f00 100644 --- a/clippy_lints/src/floating_point_arithmetic.rs +++ b/clippy_lints/src/floating_point_arithmetic.rs @@ -8,7 +8,7 @@ use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, PathSegment, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::source_map::Spanned; use rustc_ast::ast; diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 18ed05c1ca6..8a0cd155d21 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -7,7 +7,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index c9868255dcf..8af321e4d55 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -19,7 +19,7 @@ use rustc_hir::{Expr, ExprKind, LangItem}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::adjustment::{Adjust, Adjustment}; use rustc_middle::ty::Ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::DefId; use rustc_span::edition::Edition::Edition2021; use rustc_span::{sym, Span, Symbol}; diff --git a/clippy_lints/src/format_impl.rs b/clippy_lints/src/format_impl.rs index ec87629a344..9360eb1fa91 100644 --- a/clippy_lints/src/format_impl.rs +++ b/clippy_lints/src/format_impl.rs @@ -5,7 +5,7 @@ use rustc_ast::{FormatArgsPiece, FormatTrait}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, Impl, ImplItem, ImplItemKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; use rustc_span::{sym, Span, Symbol}; diff --git a/clippy_lints/src/format_push_string.rs b/clippy_lints/src/format_push_string.rs index ac45f5aedfa..3901dd984f9 100644 --- a/clippy_lints/src/format_push_string.rs +++ b/clippy_lints/src/format_push_string.rs @@ -3,7 +3,7 @@ use clippy_utils::ty::is_type_lang_item; use clippy_utils::{higher, match_def_path, paths}; use rustc_hir::{BinOpKind, Expr, ExprKind, LangItem, MatchSource}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 70892ce608f..cdb593d9b0c 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet_opt; use rustc_ast::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/four_forward_slashes.rs b/clippy_lints/src/four_forward_slashes.rs index 69bc0b726fc..0599e08e6c0 100644 --- a/clippy_lints/src/four_forward_slashes.rs +++ b/clippy_lints/src/four_forward_slashes.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use rustc_errors::Applicability; use rustc_hir::Item; use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/from_over_into.rs b/clippy_lints/src/from_over_into.rs index 5477532bb95..fa1f98ba013 100644 --- a/clippy_lints/src/from_over_into.rs +++ b/clippy_lints/src/from_over_into.rs @@ -12,7 +12,7 @@ use rustc_hir::{ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter::OnlyBodies; use rustc_middle::ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::{kw, sym}; use rustc_span::{Span, Symbol}; diff --git a/clippy_lints/src/from_raw_with_void_ptr.rs b/clippy_lints/src/from_raw_with_void_ptr.rs index d9138d48b2c..c8d10dc4b92 100644 --- a/clippy_lints/src/from_raw_with_void_ptr.rs +++ b/clippy_lints/src/from_raw_with_void_ptr.rs @@ -5,7 +5,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{RawPtr, TypeAndMut}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/from_str_radix_10.rs b/clippy_lints/src/from_str_radix_10.rs index 18d11ccc0b5..633ed96d6a6 100644 --- a/clippy_lints/src/from_str_radix_10.rs +++ b/clippy_lints/src/from_str_radix_10.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::{def, Expr, ExprKind, LangItem, PrimTy, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/functions/mod.rs b/clippy_lints/src/functions/mod.rs index 3f5cceec70e..9cc958db645 100644 --- a/clippy_lints/src/functions/mod.rs +++ b/clippy_lints/src/functions/mod.rs @@ -9,7 +9,7 @@ mod too_many_lines; use rustc_hir as hir; use rustc_hir::intravisit; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::Span; diff --git a/clippy_lints/src/future_not_send.rs b/clippy_lints/src/future_not_send.rs index eee5b7540ba..2c162baad1e 100644 --- a/clippy_lints/src/future_not_send.rs +++ b/clippy_lints/src/future_not_send.rs @@ -5,7 +5,7 @@ use rustc_hir::{Body, FnDecl}; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, AliasTy, ClauseKind, PredicateKind}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{sym, Span}; use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt; diff --git a/clippy_lints/src/if_let_mutex.rs b/clippy_lints/src/if_let_mutex.rs index 644b9cdaeb2..5e354209cbf 100644 --- a/clippy_lints/src/if_let_mutex.rs +++ b/clippy_lints/src/if_let_mutex.rs @@ -5,7 +5,7 @@ use rustc_errors::Diagnostic; use rustc_hir::intravisit::{self as visit, Visitor}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/if_not_else.rs b/clippy_lints/src/if_not_else.rs index cae561f7802..4dc1ff83771 100644 --- a/clippy_lints/src/if_not_else.rs +++ b/clippy_lints/src/if_not_else.rs @@ -6,7 +6,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::is_else_clause; use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/if_then_some_else_none.rs b/clippy_lints/src/if_then_some_else_none.rs index 66c10ab228f..cd6c46a71a8 100644 --- a/clippy_lints/src/if_then_some_else_none.rs +++ b/clippy_lints/src/if_then_some_else_none.rs @@ -9,7 +9,7 @@ use rustc_hir::LangItem::{OptionNone, OptionSome}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/ignored_unit_patterns.rs b/clippy_lints/src/ignored_unit_patterns.rs index 76bdfb94eb8..0a2fd0c663e 100644 --- a/clippy_lints/src/ignored_unit_patterns.rs +++ b/clippy_lints/src/ignored_unit_patterns.rs @@ -3,7 +3,7 @@ use hir::{Node, PatKind}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/impl_hash_with_borrow_str_and_bytes.rs b/clippy_lints/src/impl_hash_with_borrow_str_and_bytes.rs index 9374582b54b..940adbae428 100644 --- a/clippy_lints/src/impl_hash_with_borrow_str_and_bytes.rs +++ b/clippy_lints/src/impl_hash_with_borrow_str_and_bytes.rs @@ -4,7 +4,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Item, ItemKind, Path, TraitRef}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/implicit_hasher.rs b/clippy_lints/src/implicit_hasher.rs index 6594636d884..43eb6a9b838 100644 --- a/clippy_lints/src/implicit_hasher.rs +++ b/clippy_lints/src/implicit_hasher.rs @@ -9,7 +9,7 @@ use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{Ty, TypeckResults}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; use rustc_span::Span; diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index c6bcf3ba40c..d68c5c4bac6 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -8,7 +8,7 @@ use rustc_hir::intravisit::FnKind; use rustc_hir::{Block, Body, Expr, ExprKind, FnDecl, FnRetTy, HirId}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{Span, SyntaxContext}; diff --git a/clippy_lints/src/implicit_saturating_add.rs b/clippy_lints/src/implicit_saturating_add.rs index f2fac9a29cb..cc74844f294 100644 --- a/clippy_lints/src/implicit_saturating_add.rs +++ b/clippy_lints/src/implicit_saturating_add.rs @@ -7,7 +7,7 @@ use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Block, Expr, ExprKind, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{Int, IntTy, Ty, Uint, UintTy}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/implicit_saturating_sub.rs b/clippy_lints/src/implicit_saturating_sub.rs index fc66f86ae86..81df1a889c7 100644 --- a/clippy_lints/src/implicit_saturating_sub.rs +++ b/clippy_lints/src/implicit_saturating_sub.rs @@ -4,7 +4,7 @@ use rustc_ast::ast::LitKind; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/implied_bounds_in_impls.rs b/clippy_lints/src/implied_bounds_in_impls.rs index 232d8eeb11b..589fcfbf1ea 100644 --- a/clippy_lints/src/implied_bounds_in_impls.rs +++ b/clippy_lints/src/implied_bounds_in_impls.rs @@ -10,7 +10,7 @@ use rustc_hir::{ use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, ClauseKind, Generics, Ty, TyCtxt}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/inconsistent_struct_constructor.rs b/clippy_lints/src/inconsistent_struct_constructor.rs index f6e1281a291..1075975f0a2 100644 --- a/clippy_lints/src/inconsistent_struct_constructor.rs +++ b/clippy_lints/src/inconsistent_struct_constructor.rs @@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; use rustc_hir::{self as hir, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::Symbol; use std::fmt::{self, Write as _}; diff --git a/clippy_lints/src/index_refutable_slice.rs b/clippy_lints/src/index_refutable_slice.rs index fa6536db796..b6f9d8b81f8 100644 --- a/clippy_lints/src/index_refutable_slice.rs +++ b/clippy_lints/src/index_refutable_slice.rs @@ -11,7 +11,7 @@ use rustc_hir::intravisit::{self, Visitor}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_middle::ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::Ident; use rustc_span::Span; diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index 1ce7d85d382..0ae03d101ab 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -7,7 +7,7 @@ use rustc_ast::ast::RangeLimits; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index e9c53671a93..9ad02735878 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -3,7 +3,7 @@ use clippy_utils::higher; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use rustc_hir::{BorrowKind, Closure, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::{sym, Symbol}; declare_clippy_lint! { diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index a61a6416193..35b45a5b505 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::LocalDefId; use rustc_hir::{Item, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; use std::collections::hash_map::Entry; diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index fe5eb5ccac5..ca2ac60306b 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -3,7 +3,7 @@ use clippy_utils::ty::{implements_trait, is_type_lang_item}; use clippy_utils::{return_ty, trait_ref_of_method}; use rustc_hir::{GenericParamKind, ImplItem, ImplItemKind, LangItem, Unsafety}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; use rustc_target::spec::abi::Abi; diff --git a/clippy_lints/src/init_numbered_fields.rs b/clippy_lints/src/init_numbered_fields.rs index 269311a67d6..e486563808a 100644 --- a/clippy_lints/src/init_numbered_fields.rs +++ b/clippy_lints/src/init_numbered_fields.rs @@ -4,7 +4,7 @@ use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use std::borrow::Cow; use std::cmp::Reverse; use std::collections::BinaryHeap; diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index 899126565f7..bc236c5c71f 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -6,7 +6,7 @@ use rustc_ast::ast::Attribute; use rustc_errors::Applicability; use rustc_hir::{TraitFn, TraitItem, TraitItemKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Symbol}; declare_clippy_lint! { diff --git a/clippy_lints/src/instant_subtraction.rs b/clippy_lints/src/instant_subtraction.rs index 8e84c73666f..655f4b82aa4 100644 --- a/clippy_lints/src/instant_subtraction.rs +++ b/clippy_lints/src/instant_subtraction.rs @@ -6,7 +6,7 @@ use clippy_utils::ty; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::sym; diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index 9ffcee07d28..b8e0eef7c7e 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -6,7 +6,7 @@ use rustc_ast::ast::{BinOpKind, Expr, ExprKind, LitKind}; use rustc_ast::token; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/invalid_upcast_comparisons.rs b/clippy_lints/src/invalid_upcast_comparisons.rs index de82935e66b..8bcd9b532bd 100644 --- a/clippy_lints/src/invalid_upcast_comparisons.rs +++ b/clippy_lints/src/invalid_upcast_comparisons.rs @@ -2,7 +2,7 @@ use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, IntTy, UintTy}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; use clippy_utils::comparisons; diff --git a/clippy_lints/src/item_name_repetitions.rs b/clippy_lints/src/item_name_repetitions.rs index 2b131d27b7b..b6aacba2517 100644 --- a/clippy_lints/src/item_name_repetitions.rs +++ b/clippy_lints/src/item_name_repetitions.rs @@ -6,7 +6,7 @@ use clippy_utils::source::is_present_in_source; use clippy_utils::str_utils::{camel_case_split, count_match_end, count_match_start, to_camel_case, to_snake_case}; use rustc_hir::{EnumDef, FieldDef, Item, ItemKind, OwnerId, Variant, VariantData}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::Symbol; use rustc_span::Span; diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index 9605d76fbf0..39223c20470 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -4,7 +4,7 @@ use clippy_utils::diagnostics::span_lint_hir; use rustc_hir::{Block, ItemKind, StmtKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/items_after_test_module.rs b/clippy_lints/src/items_after_test_module.rs index 35e01862cee..3614fb8cc96 100644 --- a/clippy_lints/src/items_after_test_module.rs +++ b/clippy_lints/src/items_after_test_module.rs @@ -4,7 +4,7 @@ use clippy_utils::{fulfill_or_allowed, is_cfg_test, is_from_proc_macro}; use rustc_errors::{Applicability, SuggestionStyle}; use rustc_hir::{HirId, Item, ItemKind, Mod}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::hygiene::AstPass; use rustc_span::{sym, ExpnKind}; diff --git a/clippy_lints/src/iter_not_returning_iterator.rs b/clippy_lints/src/iter_not_returning_iterator.rs index 505aadd1a11..00ddadbaa4f 100644 --- a/clippy_lints/src/iter_not_returning_iterator.rs +++ b/clippy_lints/src/iter_not_returning_iterator.rs @@ -4,7 +4,7 @@ use clippy_utils::ty::implements_trait; use rustc_hir::def_id::LocalDefId; use rustc_hir::{FnSig, ImplItem, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/iter_over_hash_type.rs b/clippy_lints/src/iter_over_hash_type.rs index 7755adc4c1d..8110c1970d9 100644 --- a/clippy_lints/src/iter_over_hash_type.rs +++ b/clippy_lints/src/iter_over_hash_type.rs @@ -7,7 +7,7 @@ use clippy_utils::paths::{ }; use clippy_utils::ty::is_type_diagnostic_item; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/iter_without_into_iter.rs b/clippy_lints/src/iter_without_into_iter.rs index 3c291f25590..3a5756482a1 100644 --- a/clippy_lints/src/iter_without_into_iter.rs +++ b/clippy_lints/src/iter_without_into_iter.rs @@ -7,7 +7,7 @@ use rustc_errors::Applicability; use rustc_hir::{FnRetTy, ImplItemKind, ImplicitSelfKind, ItemKind, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Symbol}; use std::iter; diff --git a/clippy_lints/src/large_const_arrays.rs b/clippy_lints/src/large_const_arrays.rs index 7db088f986f..b561054b582 100644 --- a/clippy_lints/src/large_const_arrays.rs +++ b/clippy_lints/src/large_const_arrays.rs @@ -4,7 +4,7 @@ use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, ConstKind}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{BytePos, Pos, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index 0bf9b8718cd..6feb1885576 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -8,7 +8,7 @@ use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{Adt, Ty}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/large_futures.rs b/clippy_lints/src/large_futures.rs index 26a7278524e..eb7570e9b44 100644 --- a/clippy_lints/src/large_futures.rs +++ b/clippy_lints/src/large_futures.rs @@ -4,7 +4,7 @@ use clippy_utils::ty::implements_trait; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, LangItem, MatchSource, QPath}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_target::abi::Size; declare_clippy_lint! { diff --git a/clippy_lints/src/large_include_file.rs b/clippy_lints/src/large_include_file.rs index 902b72ba5e4..1b5981ecc28 100644 --- a/clippy_lints/src/large_include_file.rs +++ b/clippy_lints/src/large_include_file.rs @@ -4,7 +4,7 @@ use clippy_utils::macros::root_macro_call_first_node; use rustc_ast::LitKind; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/large_stack_arrays.rs b/clippy_lints/src/large_stack_arrays.rs index 5e312ab7240..fd33ba91bfd 100644 --- a/clippy_lints/src/large_stack_arrays.rs +++ b/clippy_lints/src/large_stack_arrays.rs @@ -4,7 +4,7 @@ use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, ConstKind}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/large_stack_frames.rs b/clippy_lints/src/large_stack_frames.rs index 33636eb687f..b397180a69c 100644 --- a/clippy_lints/src/large_stack_frames.rs +++ b/clippy_lints/src/large_stack_frames.rs @@ -6,7 +6,7 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 6fc14dd8941..08819b9f541 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -13,7 +13,7 @@ use rustc_hir::{ }; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, AssocKind, FnSig, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::symbol::sym; use rustc_span::{Span, Symbol}; diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index da269ec61ff..270162ae771 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::{BindingAnnotation, Mutability}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index 04f23a213f2..606c2ed72be 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -5,7 +5,7 @@ use rustc_hir::{Local, PatKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{GenericArgKind, IsSuggestable}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{BytePos, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/let_with_type_underscore.rs b/clippy_lints/src/let_with_type_underscore.rs index d4f410de957..5f3f9b43f45 100644 --- a/clippy_lints/src/let_with_type_underscore.rs +++ b/clippy_lints/src/let_with_type_underscore.rs @@ -3,7 +3,7 @@ use clippy_utils::source::snippet; use rustc_hir::{Local, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index bb0edec3373..17ca48683b3 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -18,7 +18,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::hir::map::Map; use rustc_middle::hir::nested_filter as middle_nested_filter; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_span::Span; diff --git a/clippy_lints/src/lines_filter_map_ok.rs b/clippy_lints/src/lines_filter_map_ok.rs index 00ca553445f..8a0955147bb 100644 --- a/clippy_lints/src/lines_filter_map_ok.rs +++ b/clippy_lints/src/lines_filter_map_ok.rs @@ -4,7 +4,7 @@ use clippy_utils::{is_diag_item_method, is_trait_method, match_def_path, path_to use rustc_errors::Applicability; use rustc_hir::{Body, Closure, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index 8f34a9b1fed..f33151cf4c5 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -9,7 +9,7 @@ use rustc_ast::token; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; use std::iter; diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 67c80fb8387..892336878c7 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -24,7 +24,7 @@ use clippy_config::msrvs::Msrv; use clippy_utils::higher; use rustc_hir::{Expr, ExprKind, LoopSource, Pat}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; use utils::{make_iterator_snippet, IncrementVisitor, InitializeVisitor}; diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs index 2744b0ca416..aea973bd249 100644 --- a/clippy_lints/src/macro_use.rs +++ b/clippy_lints/src/macro_use.rs @@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::edition::Edition; use rustc_span::{sym, Span}; use std::collections::BTreeMap; diff --git a/clippy_lints/src/main_recursion.rs b/clippy_lints/src/main_recursion.rs index ea1d25d80e1..a381b35cf2e 100644 --- a/clippy_lints/src/main_recursion.rs +++ b/clippy_lints/src/main_recursion.rs @@ -3,7 +3,7 @@ use clippy_utils::source::snippet; use clippy_utils::{is_entrypoint_fn, is_no_std_crate}; use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/manual_assert.rs b/clippy_lints/src/manual_assert.rs index 9a3da975f83..4f6a2cf017c 100644 --- a/clippy_lints/src/manual_assert.rs +++ b/clippy_lints/src/manual_assert.rs @@ -5,7 +5,7 @@ use clippy_utils::{is_else_clause, peel_blocks_with_stmt, span_extract_comment, use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/manual_async_fn.rs b/clippy_lints/src/manual_async_fn.rs index a5d91c949bc..41599f39d3a 100644 --- a/clippy_lints/src/manual_async_fn.rs +++ b/clippy_lints/src/manual_async_fn.rs @@ -7,7 +7,7 @@ use rustc_hir::{ ImplItem, Item, ItemKind, LifetimeName, Node, Term, TraitRef, Ty, TyKind, TypeBindingKind, }; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/manual_bits.rs b/clippy_lints/src/manual_bits.rs index 69c65cf305c..96c652283da 100644 --- a/clippy_lints/src/manual_bits.rs +++ b/clippy_lints/src/manual_bits.rs @@ -8,7 +8,7 @@ use rustc_hir::{BinOpKind, Expr, ExprKind, GenericArg, QPath}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/manual_clamp.rs b/clippy_lints/src/manual_clamp.rs index 09c90e38e11..385fe387a31 100644 --- a/clippy_lints/src/manual_clamp.rs +++ b/clippy_lints/src/manual_clamp.rs @@ -14,7 +14,7 @@ use rustc_hir::def::Res; use rustc_hir::{Arm, BinOpKind, Block, Expr, ExprKind, Guard, HirId, PatKind, PathSegment, PrimTy, QPath, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::sym; use rustc_span::Span; use std::ops::Deref; diff --git a/clippy_lints/src/manual_float_methods.rs b/clippy_lints/src/manual_float_methods.rs index 0c4101ceb6b..31cfb41640d 100644 --- a/clippy_lints/src/manual_float_methods.rs +++ b/clippy_lints/src/manual_float_methods.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Constness, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, Lint, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/manual_hash_one.rs b/clippy_lints/src/manual_hash_one.rs index 472b4eb9006..252b3a83a18 100644 --- a/clippy_lints/src/manual_hash_one.rs +++ b/clippy_lints/src/manual_hash_one.rs @@ -6,7 +6,7 @@ use clippy_utils::{is_trait_method, path_to_local_id}; use rustc_errors::Applicability; use rustc_hir::{BindingAnnotation, ExprKind, Local, Node, PatKind, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/manual_is_ascii_check.rs b/clippy_lints/src/manual_is_ascii_check.rs index 468f4170732..e433c5a3b32 100644 --- a/clippy_lints/src/manual_is_ascii_check.rs +++ b/clippy_lints/src/manual_is_ascii_check.rs @@ -8,7 +8,7 @@ use rustc_ast::LitKind::{Byte, Char}; use rustc_errors::Applicability; use rustc_hir::{BorrowKind, Expr, ExprKind, PatKind, RangeEnd}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::DefId; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/manual_let_else.rs b/clippy_lints/src/manual_let_else.rs index 01eccb56a0a..92dc4d57ab1 100644 --- a/clippy_lints/src/manual_let_else.rs +++ b/clippy_lints/src/manual_let_else.rs @@ -11,7 +11,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, MatchSource, Pat, PatKind, QPath, Stmt, StmtKind}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::declare_tool_lint; + use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use std::slice; diff --git a/clippy_lints/src/manual_main_separator_str.rs b/clippy_lints/src/manual_main_separator_str.rs index 23f47c86fcc..5732bdda7f2 100644 --- a/clippy_lints/src/manual_main_separator_str.rs +++ b/clippy_lints/src/manual_main_separator_str.rs @@ -6,7 +6,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Expr, ExprKind, Mutability, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/manual_non_exhaustive.rs b/clippy_lints/src/manual_non_exhaustive.rs index fb30e371f59..7e60764115e 100644 --- a/clippy_lints/src/manual_non_exhaustive.rs +++ b/clippy_lints/src/manual_non_exhaustive.rs @@ -9,7 +9,7 @@ use rustc_errors::Applicability; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::{self as hir, Expr, ExprKind, QPath}; use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/manual_range_patterns.rs b/clippy_lints/src/manual_range_patterns.rs index d24bfe18224..d585290f777 100644 --- a/clippy_lints/src/manual_range_patterns.rs +++ b/clippy_lints/src/manual_range_patterns.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, PatKind, RangeEnd, UnOp}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{Span, DUMMY_SP}; declare_clippy_lint! { diff --git a/clippy_lints/src/manual_rem_euclid.rs b/clippy_lints/src/manual_rem_euclid.rs index bc8372fbd41..e006df7d666 100644 --- a/clippy_lints/src/manual_rem_euclid.rs +++ b/clippy_lints/src/manual_rem_euclid.rs @@ -7,7 +7,7 @@ use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, Node, TyKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/manual_retain.rs b/clippy_lints/src/manual_retain.rs index 2f8682d0418..1fe247dacb9 100644 --- a/clippy_lints/src/manual_retain.rs +++ b/clippy_lints/src/manual_retain.rs @@ -9,7 +9,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::ExprKind::Assign; use rustc_lint::{LateContext, LateLintPass}; use rustc_semver::RustcVersion; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::sym; const ACCEPTABLE_METHODS: [&[&str]; 5] = [ diff --git a/clippy_lints/src/manual_slice_size_calculation.rs b/clippy_lints/src/manual_slice_size_calculation.rs index 3b97d165998..1de686dbcb5 100644 --- a/clippy_lints/src/manual_slice_size_calculation.rs +++ b/clippy_lints/src/manual_slice_size_calculation.rs @@ -5,7 +5,7 @@ use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/manual_string_new.rs b/clippy_lints/src/manual_string_new.rs index f8afae0e1f5..737c70496c2 100644 --- a/clippy_lints/src/manual_string_new.rs +++ b/clippy_lints/src/manual_string_new.rs @@ -4,7 +4,7 @@ use rustc_errors::Applicability::MachineApplicable; use rustc_hir::{Expr, ExprKind, PathSegment, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, symbol, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index b41bf2d767e..7b04fd28b89 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -10,7 +10,7 @@ use rustc_hir::intravisit::{walk_expr, Visitor}; use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::Span; diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 147e72ea894..3b82c50a84e 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/match_result_ok.rs b/clippy_lints/src/match_result_ok.rs index bf035969477..62cedc8847b 100644 --- a/clippy_lints/src/match_result_ok.rs +++ b/clippy_lints/src/match_result_ok.rs @@ -5,7 +5,7 @@ use clippy_utils::{higher, is_res_lang_ctor}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, LangItem, PatKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/matches/mod.rs b/clippy_lints/src/matches/mod.rs index dea46d4d360..4c7568f39b4 100644 --- a/clippy_lints/src/matches/mod.rs +++ b/clippy_lints/src/matches/mod.rs @@ -31,7 +31,7 @@ use rustc_hir::{Arm, Expr, ExprKind, Local, MatchSource, Pat}; use rustc_lexer::TokenKind; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{Span, SpanData, SyntaxContext}; declare_clippy_lint! { diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index 1517223ab9a..c22f76484d0 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -9,7 +9,7 @@ use rustc_hir::LangItem::OptionNone; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::sym; use rustc_span::Span; diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 7ce14242cae..1f48b13987d 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -133,7 +133,7 @@ use rustc_hir::{Expr, ExprKind, Node, Stmt, StmtKind, TraitItem, TraitItemKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, TraitRef, Ty}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{sym, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/min_ident_chars.rs b/clippy_lints/src/min_ident_chars.rs index 4ad12e899fe..f5b749c7f80 100644 --- a/clippy_lints/src/min_ident_chars.rs +++ b/clippy_lints/src/min_ident_chars.rs @@ -6,7 +6,7 @@ use rustc_hir::intravisit::{walk_item, Visitor}; use rustc_hir::{GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; use std::borrow::Cow; diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index e0904f17b8d..fca626fa5c3 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::is_trait_method; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; use std::cmp::Ordering; diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 814fc3303b0..b9784a58596 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -13,7 +13,7 @@ use rustc_hir::{ }; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::Span; diff --git a/clippy_lints/src/misc_early/mod.rs b/clippy_lints/src/misc_early/mod.rs index df0dd9e4e39..abe5b00e888 100644 --- a/clippy_lints/src/misc_early/mod.rs +++ b/clippy_lints/src/misc_early/mod.rs @@ -16,7 +16,7 @@ use rustc_ast::visit::FnKind; use rustc_data_structures::fx::FxHashMap; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/mismatching_type_param_order.rs b/clippy_lints/src/mismatching_type_param_order.rs index c74d0d623df..0739b49fe19 100644 --- a/clippy_lints/src/mismatching_type_param_order.rs +++ b/clippy_lints/src/mismatching_type_param_order.rs @@ -4,7 +4,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::{GenericArg, Item, ItemKind, QPath, Ty, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::GenericParamDefKind; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/missing_assert_message.rs b/clippy_lints/src/missing_assert_message.rs index 4e00215c5cb..04df7b7a7e5 100644 --- a/clippy_lints/src/missing_assert_message.rs +++ b/clippy_lints/src/missing_assert_message.rs @@ -3,7 +3,7 @@ use clippy_utils::macros::{find_assert_args, find_assert_eq_args, root_macro_cal use clippy_utils::{is_in_cfg_test, is_in_test_function}; use rustc_hir::Expr; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/missing_asserts_for_indexing.rs b/clippy_lints/src/missing_asserts_for_indexing.rs index 5d6dc8d5582..8f2a5390781 100644 --- a/clippy_lints/src/missing_asserts_for_indexing.rs +++ b/clippy_lints/src/missing_asserts_for_indexing.rs @@ -11,7 +11,7 @@ use rustc_data_structures::unhash::UnhashMap; use rustc_errors::{Applicability, Diagnostic}; use rustc_hir::{BinOp, Block, Body, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/missing_const_for_fn.rs b/clippy_lints/src/missing_const_for_fn.rs index 97522cbe6ce..c8d8920635c 100644 --- a/clippy_lints/src/missing_const_for_fn.rs +++ b/clippy_lints/src/missing_const_for_fn.rs @@ -9,7 +9,7 @@ use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, Constness, FnDecl, GenericParamKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::Span; diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index b5a884f7c8b..bf4af7946f4 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -13,7 +13,7 @@ use rustc_hir as hir; use rustc_hir::def_id::LocalDefId; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::Visibility; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::CRATE_DEF_ID; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/missing_enforced_import_rename.rs b/clippy_lints/src/missing_enforced_import_rename.rs index f7e42815104..c1f6c71a63e 100644 --- a/clippy_lints/src/missing_enforced_import_rename.rs +++ b/clippy_lints/src/missing_enforced_import_rename.rs @@ -7,7 +7,7 @@ use rustc_hir::def::Res; use rustc_hir::def_id::DefId; use rustc_hir::{Item, ItemKind, UseKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Symbol; declare_clippy_lint! { diff --git a/clippy_lints/src/missing_fields_in_debug.rs b/clippy_lints/src/missing_fields_in_debug.rs index 95f9df4e42a..8be45b8c2f3 100644 --- a/clippy_lints/src/missing_fields_in_debug.rs +++ b/clippy_lints/src/missing_fields_in_debug.rs @@ -12,7 +12,7 @@ use rustc_hir::{ }; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{Ty, TypeckResults}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span, Symbol}; declare_clippy_lint! { diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index b815da79b69..07bcbfc4ff4 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint; use rustc_ast::ast; use rustc_hir as hir; use rustc_lint::{self, LateContext, LateLintPass, LintContext}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/missing_trait_methods.rs b/clippy_lints/src/missing_trait_methods.rs index ad5f45a3280..6bbf18d52d1 100644 --- a/clippy_lints/src/missing_trait_methods.rs +++ b/clippy_lints/src/missing_trait_methods.rs @@ -5,7 +5,7 @@ use rustc_hir::def_id::DefIdMap; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::AssocItem; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/mixed_read_write_in_expression.rs b/clippy_lints/src/mixed_read_write_in_expression.rs index b46c006cd57..9cea0ebff03 100644 --- a/clippy_lints/src/mixed_read_write_in_expression.rs +++ b/clippy_lints/src/mixed_read_write_in_expression.rs @@ -4,7 +4,7 @@ use rustc_hir::intravisit::{walk_expr, Visitor}; use rustc_hir::{BinOpKind, Block, Expr, ExprKind, Guard, HirId, Local, Node, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/module_style.rs b/clippy_lints/src/module_style.rs index cd45467407e..0226b31dd19 100644 --- a/clippy_lints/src/module_style.rs +++ b/clippy_lints/src/module_style.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_lint::{EarlyContext, EarlyLintPass, Level, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LOCAL_CRATE; use rustc_span::{FileName, SourceFile, Span, SyntaxContext}; use std::ffi::OsStr; diff --git a/clippy_lints/src/multi_assignments.rs b/clippy_lints/src/multi_assignments.rs index b42dce7a13a..9a6b1dfc52b 100644 --- a/clippy_lints/src/multi_assignments.rs +++ b/clippy_lints/src/multi_assignments.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Expr, ExprKind, Stmt, StmtKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/multiple_unsafe_ops_per_block.rs b/clippy_lints/src/multiple_unsafe_ops_per_block.rs index d4f8008aece..049f44f3246 100644 --- a/clippy_lints/src/multiple_unsafe_ops_per_block.rs +++ b/clippy_lints/src/multiple_unsafe_ops_per_block.rs @@ -8,7 +8,7 @@ use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{DesugaringKind, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/mut_key.rs b/clippy_lints/src/mut_key.rs index 823715f8840..a8ec1d8cf1b 100644 --- a/clippy_lints/src/mut_key.rs +++ b/clippy_lints/src/mut_key.rs @@ -6,7 +6,7 @@ use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::query::Key; use rustc_middle::ty::{Adt, Ty}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::sym; use rustc_span::Span; diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index 6989504a4a9..72a2cca1e40 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -5,7 +5,7 @@ use rustc_hir::intravisit; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 4f8e244222d..f905a4e5b64 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint; use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use std::iter; declare_clippy_lint! { diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 9256119e6a4..2d7ce7b52ae 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -5,7 +5,7 @@ use rustc_hir::{BorrowKind, Expr, ExprKind, MatchSource, Mutability}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index 9d8c06cd077..a23e12f7a18 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -7,7 +7,7 @@ use clippy_utils::ty::is_type_diagnostic_item; use rustc_hir::Expr; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/needless_arbitrary_self_type.rs b/clippy_lints/src/needless_arbitrary_self_type.rs index 1712262ff3e..2ab83f733cb 100644 --- a/clippy_lints/src/needless_arbitrary_self_type.rs +++ b/clippy_lints/src/needless_arbitrary_self_type.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use rustc_ast::ast::{BindingAnnotation, ByRef, Lifetime, Mutability, Param, PatKind, Path, TyKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::kw; use rustc_span::Span; diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 02c177c9227..218ca5e80f3 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -13,7 +13,7 @@ use rustc_ast::ast::LitKind; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Block, Expr, ExprKind, HirId, Node, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::Span; diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index fdb91f0dc0d..4710a69443b 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use rustc_errors::Applicability; use rustc_hir::{BindingAnnotation, Mutability, Node, Pat, PatKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/needless_borrows_for_generic_args.rs b/clippy_lints/src/needless_borrows_for_generic_args.rs index f25475aaa8e..85166b0dd95 100644 --- a/clippy_lints/src/needless_borrows_for_generic_args.rs +++ b/clippy_lints/src/needless_borrows_for_generic_args.rs @@ -15,7 +15,7 @@ use rustc_middle::mir::{Rvalue, StatementKind}; use rustc_middle::ty::{ self, ClauseKind, EarlyBinder, FnSig, GenericArg, GenericArgKind, List, ParamTy, ProjectionPredicate, Ty, }; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::sym; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; use rustc_trait_selection::traits::{Obligation, ObligationCause}; diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index 6803034f475..4b9ab50e4fd 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -37,7 +37,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::{indent_of, snippet, snippet_block}; use rustc_ast::ast; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/needless_else.rs b/clippy_lints/src/needless_else.rs index d881c13f84a..b6aad69d166 100644 --- a/clippy_lints/src/needless_else.rs +++ b/clippy_lints/src/needless_else.rs @@ -3,7 +3,7 @@ use clippy_utils::source::{snippet_opt, trim_span}; use rustc_ast::ast::{Expr, ExprKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/needless_for_each.rs b/clippy_lints/src/needless_for_each.rs index 70571d18e78..84a07df1bb0 100644 --- a/clippy_lints/src/needless_for_each.rs +++ b/clippy_lints/src/needless_for_each.rs @@ -2,7 +2,7 @@ use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_expr, Visitor}; use rustc_hir::{Closure, Expr, ExprKind, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span, Symbol}; use clippy_utils::diagnostics::span_lint_and_then; diff --git a/clippy_lints/src/needless_if.rs b/clippy_lints/src/needless_if.rs index 1ed7ea6b325..41d05d72284 100644 --- a/clippy_lints/src/needless_if.rs +++ b/clippy_lints/src/needless_if.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::{ExprKind, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/needless_late_init.rs b/clippy_lints/src/needless_late_init.rs index 0a95678d31a..3e63c0a1d36 100644 --- a/clippy_lints/src/needless_late_init.rs +++ b/clippy_lints/src/needless_late_init.rs @@ -10,7 +10,7 @@ use rustc_hir::{ StmtKind, }; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/needless_parens_on_range_literals.rs b/clippy_lints/src/needless_parens_on_range_literals.rs index 490c3f9c1ab..8a62106377c 100644 --- a/clippy_lints/src/needless_parens_on_range_literals.rs +++ b/clippy_lints/src/needless_parens_on_range_literals.rs @@ -7,7 +7,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/needless_pass_by_ref_mut.rs b/clippy_lints/src/needless_pass_by_ref_mut.rs index d610ba520a4..c55031f4722 100644 --- a/clippy_lints/src/needless_pass_by_ref_mut.rs +++ b/clippy_lints/src/needless_pass_by_ref_mut.rs @@ -17,7 +17,7 @@ use rustc_middle::hir::map::associated_body; use rustc_middle::hir::nested_filter::OnlyBodies; use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::{self, Ty, TyCtxt, UpvarId, UpvarPath}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::kw; use rustc_span::Span; diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 7c48b84e430..0fc2f03c6e2 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -17,7 +17,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::{self, Ty, TypeVisitableExt}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::kw; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/needless_question_mark.rs b/clippy_lints/src/needless_question_mark.rs index 7ec0879ba38..a4d3aaf0de9 100644 --- a/clippy_lints/src/needless_question_mark.rs +++ b/clippy_lints/src/needless_question_mark.rs @@ -5,7 +5,7 @@ use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Block, Body, CoroutineKind, CoroutineSource, Expr, ExprKind, LangItem, MatchSource, QPath}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/needless_update.rs b/clippy_lints/src/needless_update.rs index f8888d36878..6a2893cefbd 100644 --- a/clippy_lints/src/needless_update.rs +++ b/clippy_lints/src/needless_update.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does 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 30aed8cc04a..f7621822b66 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -3,7 +3,7 @@ use clippy_utils::ty::implements_trait; use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index a6adb7c8a5f..f84d9fadb85 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -6,7 +6,7 @@ use rustc_ast::util::parser::PREC_PREFIX; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index abba622a285..5af0e8b10d7 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -7,7 +7,7 @@ use rustc_hir as hir; use rustc_hir::HirIdSet; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index de8bb123e9b..6e65dd628a4 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -10,7 +10,7 @@ use rustc_hir::{ use rustc_infer::infer::TyCtxtInferExt as _; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use std::ops::Deref; declare_clippy_lint! { diff --git a/clippy_lints/src/no_mangle_with_rust_abi.rs b/clippy_lints/src/no_mangle_with_rust_abi.rs index 04d75014892..8d5a523fd8f 100644 --- a/clippy_lints/src/no_mangle_with_rust_abi.rs +++ b/clippy_lints/src/no_mangle_with_rust_abi.rs @@ -3,7 +3,7 @@ use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{BytePos, Pos}; use rustc_target::spec::abi::Abi; diff --git a/clippy_lints/src/non_canonical_impls.rs b/clippy_lints/src/non_canonical_impls.rs index 9689f63a013..63050080ac6 100644 --- a/clippy_lints/src/non_canonical_impls.rs +++ b/clippy_lints/src/non_canonical_impls.rs @@ -6,7 +6,7 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::{Expr, ExprKind, ImplItem, ImplItemKind, LangItem, Node, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::EarlyBinder; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; use rustc_span::symbol::kw; diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 3059eb25d29..4f8922aea17 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -18,7 +18,7 @@ use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult, GlobalId}; use rustc_middle::query::Key; use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{sym, InnerSpan, Span}; use rustc_target::abi::VariantIdx; diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 649a23565a9..70b7ef1a5ea 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -5,7 +5,7 @@ use rustc_ast::ast::{ use rustc_ast::visit::{walk_block, walk_expr, walk_pat, Visitor}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::{sym, Span}; use std::cmp::Ordering; diff --git a/clippy_lints/src/non_octal_unix_permissions.rs b/clippy_lints/src/non_octal_unix_permissions.rs index 6cfcc81025d..49e9e2c00cc 100644 --- a/clippy_lints/src/non_octal_unix_permissions.rs +++ b/clippy_lints/src/non_octal_unix_permissions.rs @@ -4,7 +4,7 @@ use clippy_utils::{match_def_path, paths}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/non_send_fields_in_send_ty.rs b/clippy_lints/src/non_send_fields_in_send_ty.rs index df1476e6809..433664cda64 100644 --- a/clippy_lints/src/non_send_fields_in_send_ty.rs +++ b/clippy_lints/src/non_send_fields_in_send_ty.rs @@ -8,7 +8,7 @@ use rustc_hir::{FieldDef, Item, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, GenericArgKind, Ty}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/nonstandard_macro_braces.rs b/clippy_lints/src/nonstandard_macro_braces.rs index 1c6a8e16ae2..1c6069e9c65 100644 --- a/clippy_lints/src/nonstandard_macro_braces.rs +++ b/clippy_lints/src/nonstandard_macro_braces.rs @@ -6,7 +6,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::Applicability; use rustc_hir::def_id::DefId; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::Span; diff --git a/clippy_lints/src/octal_escapes.rs b/clippy_lints/src/octal_escapes.rs index 0faf4ce3d3e..8822dfeeddd 100644 --- a/clippy_lints/src/octal_escapes.rs +++ b/clippy_lints/src/octal_escapes.rs @@ -4,7 +4,7 @@ use rustc_ast::token::{Lit, LitKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; use std::fmt::Write; diff --git a/clippy_lints/src/only_used_in_recursion.rs b/clippy_lints/src/only_used_in_recursion.rs index ef7b367649f..d621051ef16 100644 --- a/clippy_lints/src/only_used_in_recursion.rs +++ b/clippy_lints/src/only_used_in_recursion.rs @@ -8,7 +8,7 @@ use rustc_hir::hir_id::HirIdMap; use rustc_hir::{Body, Expr, ExprKind, HirId, ImplItem, ImplItemKind, Node, PatKind, TraitItem, TraitItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, ConstKind, EarlyBinder, GenericArgKind, GenericArgsRef}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::{kw, Ident}; use rustc_span::Span; use std::iter; diff --git a/clippy_lints/src/operators/mod.rs b/clippy_lints/src/operators/mod.rs index ee79ea27689..4c09c4eea58 100644 --- a/clippy_lints/src/operators/mod.rs +++ b/clippy_lints/src/operators/mod.rs @@ -25,7 +25,7 @@ pub(crate) mod arithmetic_side_effects; use rustc_hir::{Body, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/option_env_unwrap.rs b/clippy_lints/src/option_env_unwrap.rs index 7792efe6acd..4bfb26209d2 100644 --- a/clippy_lints/src/option_env_unwrap.rs +++ b/clippy_lints/src/option_env_unwrap.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::is_direct_expn_of; use rustc_ast::ast::{Expr, ExprKind, MethodCall}; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/option_if_let_else.rs b/clippy_lints/src/option_if_let_else.rs index 6e4e0c98d29..cca90d813e0 100644 --- a/clippy_lints/src/option_if_let_else.rs +++ b/clippy_lints/src/option_if_let_else.rs @@ -9,7 +9,7 @@ use rustc_hir::def::Res; use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk}; use rustc_hir::{Arm, BindingAnnotation, Expr, ExprKind, MatchSource, Mutability, Pat, PatKind, Path, QPath, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::SyntaxContext; declare_clippy_lint! { diff --git a/clippy_lints/src/overflow_check_conditional.rs b/clippy_lints/src/overflow_check_conditional.rs index e661bfbb96c..de789879331 100644 --- a/clippy_lints/src/overflow_check_conditional.rs +++ b/clippy_lints/src/overflow_check_conditional.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::SpanlessEq; use rustc_hir::{BinOpKind, Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/panic_in_result_fn.rs b/clippy_lints/src/panic_in_result_fn.rs index 6a760f9fe64..1d6a3f37eed 100644 --- a/clippy_lints/src/panic_in_result_fn.rs +++ b/clippy_lints/src/panic_in_result_fn.rs @@ -7,7 +7,7 @@ use core::ops::ControlFlow; use rustc_hir as hir; use rustc_hir::intravisit::FnKind; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index f4f1f6ddb3f..ef51a9a9a1c 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::macros::{is_panic, root_macro_call_first_node}; use rustc_hir::Expr; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/partial_pub_fields.rs b/clippy_lints/src/partial_pub_fields.rs index 99ba55b6b31..ffa403e27ca 100644 --- a/clippy_lints/src/partial_pub_fields.rs +++ b/clippy_lints/src/partial_pub_fields.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Item, ItemKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/partialeq_ne_impl.rs b/clippy_lints/src/partialeq_ne_impl.rs index 1b06762415d..18e6aad9c9a 100644 --- a/clippy_lints/src/partialeq_ne_impl.rs +++ b/clippy_lints/src/partialeq_ne_impl.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_hir; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/partialeq_to_none.rs b/clippy_lints/src/partialeq_to_none.rs index 11e9a2bc394..6d4216970cc 100644 --- a/clippy_lints/src/partialeq_to_none.rs +++ b/clippy_lints/src/partialeq_to_none.rs @@ -4,7 +4,7 @@ use clippy_utils::{is_res_lang_ctor, path_res, peel_hir_expr_refs, peel_ref_oper use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, LangItem}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index 0f6ddb35da3..2cb36af7b44 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -15,7 +15,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::adjustment::{Adjust, PointerCoercion}; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, RegionKind}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{sym, Span}; use rustc_target::spec::abi::Abi; diff --git a/clippy_lints/src/pattern_type_mismatch.rs b/clippy_lints/src/pattern_type_mismatch.rs index dcd1e7af0c2..60ced9c1208 100644 --- a/clippy_lints/src/pattern_type_mismatch.rs +++ b/clippy_lints/src/pattern_type_mismatch.rs @@ -3,7 +3,7 @@ use rustc_hir::{intravisit, Body, Expr, ExprKind, FnDecl, Let, LocalSource, Muta use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::Span; diff --git a/clippy_lints/src/permissions_set_readonly_false.rs b/clippy_lints/src/permissions_set_readonly_false.rs index b98005d5922..704acdc103e 100644 --- a/clippy_lints/src/permissions_set_readonly_false.rs +++ b/clippy_lints/src/permissions_set_readonly_false.rs @@ -3,7 +3,7 @@ use clippy_utils::ty::is_type_diagnostic_item; use rustc_ast::ast::LitKind; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/precedence.rs b/clippy_lints/src/precedence.rs index b638e83997a..3cb9e05e912 100644 --- a/clippy_lints/src/precedence.rs +++ b/clippy_lints/src/precedence.rs @@ -4,7 +4,7 @@ use rustc_ast::ast::{BinOpKind, Expr, ExprKind, MethodCall, UnOp}; use rustc_ast::token; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::source_map::Spanned; const ALLOWED_ODD_FUNCTIONS: [&str; 14] = [ diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index 410f4ec651b..16581a934f2 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -20,7 +20,7 @@ use rustc_infer::traits::{Obligation, ObligationCause}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, Binder, ClauseKind, ExistentialPredicate, List, PredicateKind, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::Symbol; use rustc_span::{sym, Span}; use rustc_target::spec::abi::Abi; diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index 66d869bc45a..ff8ec2ad57c 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -3,7 +3,7 @@ use clippy_utils::source::snippet_opt; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; use std::fmt; diff --git a/clippy_lints/src/pub_use.rs b/clippy_lints/src/pub_use.rs index 316a72988aa..c0e999e76ef 100644 --- a/clippy_lints/src/pub_use.rs +++ b/clippy_lints/src/pub_use.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Item, ItemKind, VisibilityKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index 5c395143b9a..fc5835408a9 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -18,7 +18,7 @@ use rustc_hir::{ }; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::sym; use rustc_span::symbol::Symbol; diff --git a/clippy_lints/src/question_mark_used.rs b/clippy_lints/src/question_mark_used.rs index d0de33e3c4f..ddfc53083c4 100644 --- a/clippy_lints/src/question_mark_used.rs +++ b/clippy_lints/src/question_mark_used.rs @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::macros::span_is_local; use rustc_hir::{Expr, ExprKind, MatchSource}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index fd9de76bacf..6b54258dd61 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -9,7 +9,7 @@ use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, HirId}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::Span; use std::cmp::Ordering; diff --git a/clippy_lints/src/raw_strings.rs b/clippy_lints/src/raw_strings.rs index 98f5a07da0d..ac29d27303c 100644 --- a/clippy_lints/src/raw_strings.rs +++ b/clippy_lints/src/raw_strings.rs @@ -8,7 +8,7 @@ use rustc_ast::token::LitKind; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{BytePos, Pos, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/rc_clone_in_vec_init.rs b/clippy_lints/src/rc_clone_in_vec_init.rs index b99af44655d..d0b45b59526 100644 --- a/clippy_lints/src/rc_clone_in_vec_init.rs +++ b/clippy_lints/src/rc_clone_in_vec_init.rs @@ -7,7 +7,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span, Symbol}; declare_clippy_lint! { diff --git a/clippy_lints/src/read_zero_byte_vec.rs b/clippy_lints/src/read_zero_byte_vec.rs index b27d4cc6e4f..62f3c09aa7e 100644 --- a/clippy_lints/src/read_zero_byte_vec.rs +++ b/clippy_lints/src/read_zero_byte_vec.rs @@ -7,7 +7,7 @@ use hir::{Expr, ExprKind, Local, PatKind, PathSegment, QPath, StmtKind}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/redundant_async_block.rs b/clippy_lints/src/redundant_async_block.rs index 90297ca8bb6..19d9d64b31e 100644 --- a/clippy_lints/src/redundant_async_block.rs +++ b/clippy_lints/src/redundant_async_block.rs @@ -9,7 +9,7 @@ use rustc_hir::{Closure, CoroutineKind, CoroutineSource, Expr, ExprKind, MatchSo use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::UpvarCapture; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 698af9fb192..c62c351e716 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -9,7 +9,7 @@ use rustc_hir::{def_id, Body, FnDecl, LangItem}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{sym, BytePos, Span}; diff --git a/clippy_lints/src/redundant_closure_call.rs b/clippy_lints/src/redundant_closure_call.rs index f2a006ebdfc..7971a5d86e3 100644 --- a/clippy_lints/src/redundant_closure_call.rs +++ b/clippy_lints/src/redundant_closure_call.rs @@ -10,7 +10,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/redundant_else.rs b/clippy_lints/src/redundant_else.rs index 221aa317e5d..1168e79bb0d 100644 --- a/clippy_lints/src/redundant_else.rs +++ b/clippy_lints/src/redundant_else.rs @@ -3,7 +3,7 @@ use rustc_ast::ast::{Block, Expr, ExprKind, Stmt, StmtKind}; use rustc_ast::visit::{walk_expr, Visitor}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index b8e606df737..fb000cd7184 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -4,7 +4,7 @@ use rustc_ast::ast::{Expr, ExprKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/redundant_locals.rs b/clippy_lints/src/redundant_locals.rs index 15b784039b6..8c374d7d6db 100644 --- a/clippy_lints/src/redundant_locals.rs +++ b/clippy_lints/src/redundant_locals.rs @@ -6,7 +6,7 @@ use rustc_hir::def::Res; use rustc_hir::{BindingAnnotation, ByRef, ExprKind, HirId, Local, Node, Pat, PatKind, QPath}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::Ident; use rustc_span::DesugaringKind; diff --git a/clippy_lints/src/redundant_pub_crate.rs b/clippy_lints/src/redundant_pub_crate.rs index 32e0c3749ab..0e43e4a7ee5 100644 --- a/clippy_lints/src/redundant_pub_crate.rs +++ b/clippy_lints/src/redundant_pub_crate.rs @@ -4,7 +4,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::CRATE_DEF_ID; use rustc_span::hygiene::MacroKind; diff --git a/clippy_lints/src/redundant_slicing.rs b/clippy_lints/src/redundant_slicing.rs index c9fc65653c2..c99b657c23a 100644 --- a/clippy_lints/src/redundant_slicing.rs +++ b/clippy_lints/src/redundant_slicing.rs @@ -8,7 +8,7 @@ use rustc_hir::{BorrowKind, Expr, ExprKind, LangItem, Mutability}; use rustc_lint::{LateContext, LateLintPass, Lint}; use rustc_middle::ty::adjustment::{Adjust, AutoBorrow, AutoBorrowMutability}; use rustc_middle::ty::{GenericArg, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index a70b831a80c..07b604f2326 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet; use rustc_ast::ast::{ConstItem, Item, ItemKind, StaticItem, Ty, TyKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; declare_clippy_lint! { diff --git a/clippy_lints/src/redundant_type_annotations.rs b/clippy_lints/src/redundant_type_annotations.rs index f6af9cac3de..07fcb69afbc 100644 --- a/clippy_lints/src/redundant_type_annotations.rs +++ b/clippy_lints/src/redundant_type_annotations.rs @@ -5,7 +5,7 @@ use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/ref_option_ref.rs b/clippy_lints/src/ref_option_ref.rs index 0ba898e75a1..19ce08bde10 100644 --- a/clippy_lints/src/ref_option_ref.rs +++ b/clippy_lints/src/ref_option_ref.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet; use rustc_errors::Applicability; use rustc_hir::{GenericArg, GenericArgsParentheses, Mutability, Ty, TyKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/ref_patterns.rs b/clippy_lints/src/ref_patterns.rs index 8b3dabde9be..a4be78b310b 100644 --- a/clippy_lints/src/ref_patterns.rs +++ b/clippy_lints/src/ref_patterns.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{BindingAnnotation, Pat, PatKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs index 69818db7c82..16086ba6637 100644 --- a/clippy_lints/src/reference.rs +++ b/clippy_lints/src/reference.rs @@ -3,7 +3,7 @@ use clippy_utils::source::{snippet_opt, snippet_with_applicability}; use rustc_ast::ast::{Expr, ExprKind, Mutability, UnOp}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::BytePos; declare_clippy_lint! { diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index ae8be006781..687bad35a36 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -8,7 +8,7 @@ use rustc_ast::ast::{LitKind, StrStyle}; use rustc_hir::def_id::DefIdMap; use rustc_hir::{BorrowKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{BytePos, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/reserve_after_initialization.rs b/clippy_lints/src/reserve_after_initialization.rs index b4842e7d48a..ca7a0c7c87b 100644 --- a/clippy_lints/src/reserve_after_initialization.rs +++ b/clippy_lints/src/reserve_after_initialization.rs @@ -7,7 +7,7 @@ use rustc_hir::def::Res; use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, Local, PatKind, QPath, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/return_self_not_must_use.rs b/clippy_lints/src/return_self_not_must_use.rs index ad22b751bef..b84a8500c81 100644 --- a/clippy_lints/src/return_self_not_must_use.rs +++ b/clippy_lints/src/return_self_not_must_use.rs @@ -6,7 +6,7 @@ use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl, OwnerId, TraitItem, TraitItemKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index d64e931a2f3..c32cc8b73d2 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -14,7 +14,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::{self, GenericArgKind, Ty}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{BytePos, Pos, Span}; use std::borrow::Cow; diff --git a/clippy_lints/src/same_name_method.rs b/clippy_lints/src/same_name_method.rs index 52475ff9ef7..cddbbb317ef 100644 --- a/clippy_lints/src/same_name_method.rs +++ b/clippy_lints/src/same_name_method.rs @@ -4,7 +4,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::{HirId, Impl, ItemKind, Node, Path, QPath, TraitRef, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::AssocKind; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::Symbol; use rustc_span::Span; use std::collections::{BTreeMap, BTreeSet}; diff --git a/clippy_lints/src/self_named_constructors.rs b/clippy_lints/src/self_named_constructors.rs index c1edcf509ef..015f37abcbc 100644 --- a/clippy_lints/src/self_named_constructors.rs +++ b/clippy_lints/src/self_named_constructors.rs @@ -3,7 +3,7 @@ use clippy_utils::return_ty; use clippy_utils::ty::contains_adt_constructor; use rustc_hir::{Impl, ImplItem, ImplItemKind, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/semicolon_block.rs b/clippy_lints/src/semicolon_block.rs index b0601bba4af..0b3adfb7a4b 100644 --- a/clippy_lints/src/semicolon_block.rs +++ b/clippy_lints/src/semicolon_block.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{multispan_sugg_with_applicability, span_lint_and use rustc_errors::Applicability; use rustc_hir::{Block, Expr, ExprKind, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/semicolon_if_nothing_returned.rs b/clippy_lints/src/semicolon_if_nothing_returned.rs index 3aabcadaa1f..2cd3e57f885 100644 --- a/clippy_lints/src/semicolon_if_nothing_returned.rs +++ b/clippy_lints/src/semicolon_if_nothing_returned.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet_with_context; use rustc_errors::Applicability; use rustc_hir::{Block, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/serde_api.rs b/clippy_lints/src/serde_api.rs index fc1c2af9257..90834d784a5 100644 --- a/clippy_lints/src/serde_api.rs +++ b/clippy_lints/src/serde_api.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::{get_trait_def_id, paths}; use rustc_hir::{Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 41c10b34a42..c74364d89d6 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -7,7 +7,7 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::hir_id::ItemLocalId; use rustc_hir::{Block, Body, BodyOwnerKind, Expr, ExprKind, HirId, Let, Node, Pat, PatKind, QPath, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{Span, Symbol}; declare_clippy_lint! { diff --git a/clippy_lints/src/significant_drop_tightening.rs b/clippy_lints/src/significant_drop_tightening.rs index 57bcee1a871..6c99ccda7ea 100644 --- a/clippy_lints/src/significant_drop_tightening.rs +++ b/clippy_lints/src/significant_drop_tightening.rs @@ -8,7 +8,7 @@ use rustc_hir::intravisit::{walk_expr, Visitor}; use rustc_hir::{self as hir}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::{GenericArgKind, Ty, TypeAndMut}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::Ident; use rustc_span::{sym, Span, DUMMY_SP}; use std::borrow::Cow; diff --git a/clippy_lints/src/single_call_fn.rs b/clippy_lints/src/single_call_fn.rs index ae81e1198af..396d2717a13 100644 --- a/clippy_lints/src/single_call_fn.rs +++ b/clippy_lints/src/single_call_fn.rs @@ -7,7 +7,7 @@ use rustc_hir::{Body, Expr, ExprKind, FnDecl}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::hir::nested_filter::OnlyBodies; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/single_char_lifetime_names.rs b/clippy_lints/src/single_char_lifetime_names.rs index 74ee8ce2de7..42f1564db35 100644 --- a/clippy_lints/src/single_char_lifetime_names.rs +++ b/clippy_lints/src/single_char_lifetime_names.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{GenericParam, GenericParamKind}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/single_component_path_imports.rs b/clippy_lints/src/single_component_path_imports.rs index 9c21d70c82c..18fbbdb4079 100644 --- a/clippy_lints/src/single_component_path_imports.rs +++ b/clippy_lints/src/single_component_path_imports.rs @@ -5,7 +5,7 @@ use rustc_ast::visit::{walk_expr, Visitor}; use rustc_ast::{Crate, Expr, ExprKind, Item, ItemKind, MacroDef, ModKind, Ty, TyKind, UseTreeKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::edition::Edition; use rustc_span::symbol::kw; use rustc_span::{Span, Symbol}; diff --git a/clippy_lints/src/single_range_in_vec_init.rs b/clippy_lints/src/single_range_in_vec_init.rs index 099743d229d..95b4a11a783 100644 --- a/clippy_lints/src/single_range_in_vec_init.rs +++ b/clippy_lints/src/single_range_in_vec_init.rs @@ -8,7 +8,7 @@ use rustc_ast::{LitIntType, LitKind, UintTy}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, LangItem, QPath}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use std::fmt::{self, Display, Formatter}; declare_clippy_lint! { diff --git a/clippy_lints/src/size_of_in_element_count.rs b/clippy_lints/src/size_of_in_element_count.rs index 0385f1a98e5..756e47cbdf0 100644 --- a/clippy_lints/src/size_of_in_element_count.rs +++ b/clippy_lints/src/size_of_in_element_count.rs @@ -5,7 +5,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, Ty, TypeAndMut}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/size_of_ref.rs b/clippy_lints/src/size_of_ref.rs index 7de029b7b94..14ca7a3f004 100644 --- a/clippy_lints/src/size_of_ref.rs +++ b/clippy_lints/src/size_of_ref.rs @@ -3,7 +3,7 @@ use clippy_utils::path_def_id; use clippy_utils::ty::peel_mid_ty_refs; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index 733da790441..c4a5e48e855 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -9,7 +9,7 @@ use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_block, walk_expr, walk_stmt, Visitor}; use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, PatKind, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/std_instead_of_core.rs b/clippy_lints/src/std_instead_of_core.rs index d07a44770cc..38fd54a0f1e 100644 --- a/clippy_lints/src/std_instead_of_core.rs +++ b/clippy_lints/src/std_instead_of_core.rs @@ -6,7 +6,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::{HirId, Path, PathSegment}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index baa9750cc01..13ae1ff52dd 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -11,7 +11,7 @@ use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, LangItem, Node, QPath}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::sym; diff --git a/clippy_lints/src/strlen_on_c_strings.rs b/clippy_lints/src/strlen_on_c_strings.rs index 644664b104d..8cf4715eeb8 100644 --- a/clippy_lints/src/strlen_on_c_strings.rs +++ b/clippy_lints/src/strlen_on_c_strings.rs @@ -6,7 +6,7 @@ use clippy_utils::{get_parent_node, match_libc_symbol}; use rustc_errors::Applicability; use rustc_hir::{Block, BlockCheckMode, Expr, ExprKind, LangItem, Node, UnsafeSource}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/suspicious_operation_groupings.rs b/clippy_lints/src/suspicious_operation_groupings.rs index 92de7917871..4cfccc3d869 100644 --- a/clippy_lints/src/suspicious_operation_groupings.rs +++ b/clippy_lints/src/suspicious_operation_groupings.rs @@ -6,7 +6,7 @@ use rustc_ast::ast::{BinOpKind, Expr, ExprKind, StmtKind}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::symbol::Ident; use rustc_span::Span; diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index 3244933a124..268c0c1b2df 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -4,7 +4,7 @@ use clippy_utils::{binop_traits, trait_ref_of_method, BINOP_TRAITS, OP_ASSIGN_TR use core::ops::ControlFlow; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/suspicious_xor_used_as_pow.rs b/clippy_lints/src/suspicious_xor_used_as_pow.rs index 4340c23f830..1cc27670fa8 100644 --- a/clippy_lints/src/suspicious_xor_used_as_pow.rs +++ b/clippy_lints/src/suspicious_xor_used_as_pow.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 285f2f4f6f9..daa6fe8715c 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -8,7 +8,7 @@ use rustc_hir::{BinOpKind, Block, Expr, ExprKind, PatKind, QPath, Stmt, StmtKind use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::symbol::Ident; use rustc_span::{sym, Span, SyntaxContext}; diff --git a/clippy_lints/src/swap_ptr_to_ref.rs b/clippy_lints/src/swap_ptr_to_ref.rs index 6a6c94425d1..20e9608a15d 100644 --- a/clippy_lints/src/swap_ptr_to_ref.rs +++ b/clippy_lints/src/swap_ptr_to_ref.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet_with_context; use rustc_errors::Applicability; use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span, SyntaxContext}; declare_clippy_lint! { diff --git a/clippy_lints/src/tabs_in_doc_comments.rs b/clippy_lints/src/tabs_in_doc_comments.rs index dcf1fac023a..af9e13dba36 100644 --- a/clippy_lints/src/tabs_in_doc_comments.rs +++ b/clippy_lints/src/tabs_in_doc_comments.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use rustc_ast::ast; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{BytePos, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/temporary_assignment.rs b/clippy_lints/src/temporary_assignment.rs index c717ccc35a6..8151dd8f2cf 100644 --- a/clippy_lints/src/temporary_assignment.rs +++ b/clippy_lints/src/temporary_assignment.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::is_adjusted; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/tests_outside_test_module.rs b/clippy_lints/src/tests_outside_test_module.rs index 9481c78a505..da557582647 100644 --- a/clippy_lints/src/tests_outside_test_module.rs +++ b/clippy_lints/src/tests_outside_test_module.rs @@ -3,7 +3,7 @@ use clippy_utils::{is_in_cfg_test, is_in_test_function}; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::Span; diff --git a/clippy_lints/src/to_digit_is_some.rs b/clippy_lints/src/to_digit_is_some.rs index 1dca523a966..dafe9e38818 100644 --- a/clippy_lints/src/to_digit_is_some.rs +++ b/clippy_lints/src/to_digit_is_some.rs @@ -5,7 +5,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/trailing_empty_array.rs b/clippy_lints/src/trailing_empty_array.rs index 7eef02b3c65..cbdf31c9336 100644 --- a/clippy_lints/src/trailing_empty_array.rs +++ b/clippy_lints/src/trailing_empty_array.rs @@ -3,7 +3,7 @@ use clippy_utils::has_repr_attr; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Const; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index e624bbe5ff1..e4054393d0a 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -13,7 +13,7 @@ use rustc_hir::{ TraitBoundModifier, TraitItem, TraitRef, Ty, TyKind, WherePredicate, }; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{BytePos, Span}; use std::collections::hash_map::Entry; diff --git a/clippy_lints/src/transmute/mod.rs b/clippy_lints/src/transmute/mod.rs index a3a50acb609..95a92afea66 100644 --- a/clippy_lints/src/transmute/mod.rs +++ b/clippy_lints/src/transmute/mod.rs @@ -21,7 +21,7 @@ use clippy_config::msrvs::Msrv; use clippy_utils::in_constant; use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/tuple_array_conversions.rs b/clippy_lints/src/tuple_array_conversions.rs index 642e39e8270..e1cd82e18d5 100644 --- a/clippy_lints/src/tuple_array_conversions.rs +++ b/clippy_lints/src/tuple_array_conversions.rs @@ -8,7 +8,7 @@ use rustc_hir::{Expr, ExprKind, Node, PatKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use std::iter::once; use std::ops::ControlFlow; diff --git a/clippy_lints/src/types/mod.rs b/clippy_lints/src/types/mod.rs index f333b2cdcb4..4b6810b684b 100644 --- a/clippy_lints/src/types/mod.rs +++ b/clippy_lints/src/types/mod.rs @@ -16,7 +16,7 @@ use rustc_hir::{ TraitItemKind, TyKind, }; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::Span; diff --git a/clippy_lints/src/undocumented_unsafe_blocks.rs b/clippy_lints/src/undocumented_unsafe_blocks.rs index 32aebdd8c0f..2e68bfe391e 100644 --- a/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -11,7 +11,7 @@ use rustc_hir::{Block, BlockCheckMode, ItemKind, Node, UnsafeSource}; use rustc_lexer::{tokenize, TokenKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{BytePos, Pos, RelativeBytePos, Span, SyntaxContext}; declare_clippy_lint! { diff --git a/clippy_lints/src/unicode.rs b/clippy_lints/src/unicode.rs index b824deac2c8..3d319b9fe76 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -6,7 +6,7 @@ use rustc_ast::ast::LitKind; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, HirId}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; use unicode_normalization::UnicodeNormalization; diff --git a/clippy_lints/src/uninit_vec.rs b/clippy_lints/src/uninit_vec.rs index a7119434517..fc8519d5628 100644 --- a/clippy_lints/src/uninit_vec.rs +++ b/clippy_lints/src/uninit_vec.rs @@ -6,7 +6,7 @@ use rustc_hir::{Block, Expr, ExprKind, HirId, PatKind, PathSegment, Stmt, StmtKi use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span}; // TODO: add `ReadBuf` (RFC 2930) in "How to fix" once it is available in std diff --git a/clippy_lints/src/unit_return_expecting_ord.rs b/clippy_lints/src/unit_return_expecting_ord.rs index 385f8255a39..ad76e4c1f53 100644 --- a/clippy_lints/src/unit_return_expecting_ord.rs +++ b/clippy_lints/src/unit_return_expecting_ord.rs @@ -4,7 +4,7 @@ use rustc_hir::{Closure, Expr, ExprKind, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_middle::ty::{ClauseKind, GenericPredicates, ProjectionPredicate, TraitPredicate}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, BytePos, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/unit_types/mod.rs b/clippy_lints/src/unit_types/mod.rs index 884c6ca4d31..0abd48e6423 100644 --- a/clippy_lints/src/unit_types/mod.rs +++ b/clippy_lints/src/unit_types/mod.rs @@ -5,7 +5,7 @@ mod utils; use rustc_hir::{Expr, Local}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/unnamed_address.rs b/clippy_lints/src/unnamed_address.rs index 2223cbcb060..41e13e13e56 100644 --- a/clippy_lints/src/unnamed_address.rs +++ b/clippy_lints/src/unnamed_address.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/unnecessary_box_returns.rs b/clippy_lints/src/unnecessary_box_returns.rs index ca159eb4d5f..a05fa149c4d 100644 --- a/clippy_lints/src/unnecessary_box_returns.rs +++ b/clippy_lints/src/unnecessary_box_returns.rs @@ -4,7 +4,7 @@ use rustc_errors::Applicability; use rustc_hir::def_id::LocalDefId; use rustc_hir::{FnDecl, FnRetTy, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Symbol; declare_clippy_lint! { diff --git a/clippy_lints/src/unnecessary_map_on_constructor.rs b/clippy_lints/src/unnecessary_map_on_constructor.rs index 5c880288430..148ad87beb2 100644 --- a/clippy_lints/src/unnecessary_map_on_constructor.rs +++ b/clippy_lints/src/unnecessary_map_on_constructor.rs @@ -4,7 +4,7 @@ use clippy_utils::ty::get_type_diagnostic_name; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/unnecessary_owned_empty_strings.rs b/clippy_lints/src/unnecessary_owned_empty_strings.rs index 14694bb3a28..6b5e6c6ab20 100644 --- a/clippy_lints/src/unnecessary_owned_empty_strings.rs +++ b/clippy_lints/src/unnecessary_owned_empty_strings.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::{BorrowKind, Expr, ExprKind, LangItem, Mutability}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/unnecessary_self_imports.rs b/clippy_lints/src/unnecessary_self_imports.rs index 1e2b20469ef..ddee06b59ca 100644 --- a/clippy_lints/src/unnecessary_self_imports.rs +++ b/clippy_lints/src/unnecessary_self_imports.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use rustc_ast::{Item, ItemKind, UseTreeKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::kw; declare_clippy_lint! { diff --git a/clippy_lints/src/unnecessary_struct_initialization.rs b/clippy_lints/src/unnecessary_struct_initialization.rs index c35a2afab48..ed4d87ef8f8 100644 --- a/clippy_lints/src/unnecessary_struct_initialization.rs +++ b/clippy_lints/src/unnecessary_struct_initialization.rs @@ -4,7 +4,7 @@ use clippy_utils::ty::is_copy; use clippy_utils::{get_parent_expr, path_to_local}; use rustc_hir::{BindingAnnotation, Expr, ExprKind, Node, PatKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/unnecessary_wraps.rs b/clippy_lints/src/unnecessary_wraps.rs index 5599a9dc4e8..a5f087aaf5b 100644 --- a/clippy_lints/src/unnecessary_wraps.rs +++ b/clippy_lints/src/unnecessary_wraps.rs @@ -8,7 +8,7 @@ use rustc_hir::LangItem::{OptionSome, ResultOk}; use rustc_hir::{Body, ExprKind, FnDecl, Impl, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::sym; use rustc_span::Span; diff --git a/clippy_lints/src/unnested_or_patterns.rs b/clippy_lints/src/unnested_or_patterns.rs index 8ff088a208f..14d5bac7177 100644 --- a/clippy_lints/src/unnested_or_patterns.rs +++ b/clippy_lints/src/unnested_or_patterns.rs @@ -11,7 +11,7 @@ use rustc_ast::{self as ast, Mutability, Pat, PatKind, DUMMY_NODE_ID}; use rustc_ast_pretty::pprust; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::DUMMY_SP; use std::cell::Cell; use std::mem; diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index a7b2d2148e9..3f2f765f751 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Item, ItemKind, UseTree, UseTreeKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::Ident; use rustc_span::Span; diff --git a/clippy_lints/src/unused_async.rs b/clippy_lints/src/unused_async.rs index aea72c798be..d72adf678a6 100644 --- a/clippy_lints/src/unused_async.rs +++ b/clippy_lints/src/unused_async.rs @@ -5,7 +5,7 @@ use rustc_hir::intravisit::{walk_body, walk_expr, walk_fn, FnKind, Visitor}; use rustc_hir::{Body, Expr, ExprKind, FnDecl, Node, YieldSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::def_id::{LocalDefId, LocalDefIdSet}; use rustc_span::Span; diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index 0fcb62017c6..1de9adfcb96 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use clippy_utils::{is_trait_method, is_try, match_trait_method, paths}; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/unused_peekable.rs b/clippy_lints/src/unused_peekable.rs index 0473ecaabeb..ba72b3450b9 100644 --- a/clippy_lints/src/unused_peekable.rs +++ b/clippy_lints/src/unused_peekable.rs @@ -6,7 +6,7 @@ use rustc_hir::intravisit::{walk_expr, Visitor}; use rustc_hir::{Block, Expr, ExprKind, HirId, Local, Node, PatKind, PathSegment, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter::OnlyBodies; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/clippy_lints/src/unused_rounding.rs b/clippy_lints/src/unused_rounding.rs index fbb36bea068..d5ca844b9e2 100644 --- a/clippy_lints/src/unused_rounding.rs +++ b/clippy_lints/src/unused_rounding.rs @@ -3,7 +3,7 @@ use clippy_utils::source::snippet; use rustc_ast::ast::{Expr, ExprKind, MethodCall}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/unused_self.rs b/clippy_lints/src/unused_self.rs index 532207310bc..a67f53f00ae 100644 --- a/clippy_lints/src/unused_self.rs +++ b/clippy_lints/src/unused_self.rs @@ -3,7 +3,7 @@ use clippy_utils::macros::root_macro_call_first_node; use clippy_utils::visitors::is_local_used; use rustc_hir::{Body, Impl, ImplItem, ImplItemKind, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use std::ops::ControlFlow; declare_clippy_lint! { diff --git a/clippy_lints/src/unused_unit.rs b/clippy_lints/src/unused_unit.rs index 9627f4c7454..0a73da202ec 100644 --- a/clippy_lints/src/unused_unit.rs +++ b/clippy_lints/src/unused_unit.rs @@ -4,7 +4,7 @@ use rustc_ast::visit::FnKind; use rustc_ast::{ast, ClosureBinder}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{BytePos, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 6e1d0e09fe2..ae2ac38cffe 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -12,7 +12,7 @@ use rustc_middle::hir::nested_filter; use rustc_middle::lint::in_external_macro; use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/unwrap_in_result.rs b/clippy_lints/src/unwrap_in_result.rs index df4b42133f8..a615ef11691 100644 --- a/clippy_lints/src/unwrap_in_result.rs +++ b/clippy_lints/src/unwrap_in_result.rs @@ -6,7 +6,7 @@ use core::ops::ControlFlow; use rustc_hir as hir; use rustc_hir::ImplItemKind; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::{sym, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/upper_case_acronyms.rs b/clippy_lints/src/upper_case_acronyms.rs index de6a75b79fc..0d559821386 100644 --- a/clippy_lints/src/upper_case_acronyms.rs +++ b/clippy_lints/src/upper_case_acronyms.rs @@ -4,7 +4,7 @@ use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::Ident; declare_clippy_lint! { diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index f058fe5f831..4fa92a45b96 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -13,7 +13,7 @@ use rustc_hir::{ }; use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index 52327b82e84..ab6bd10aaba 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -12,7 +12,7 @@ use rustc_infer::traits::Obligation; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::traits::ObligationCause; use rustc_middle::ty::{self, EarlyBinder, GenericArg, GenericArgsRef, Ty, TypeVisitableExt}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{sym, Span}; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; diff --git a/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs b/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs index d78f67c05f0..5ddedb24b15 100644 --- a/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs +++ b/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs @@ -4,7 +4,7 @@ use regex::Regex; use rustc_ast as ast; use rustc_hir::{Item, ItemKind, Mutability}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/utils/internal_lints/collapsible_calls.rs b/clippy_lints/src/utils/internal_lints/collapsible_calls.rs index f514f166cff..7c70d3f45db 100644 --- a/clippy_lints/src/utils/internal_lints/collapsible_calls.rs +++ b/clippy_lints/src/utils/internal_lints/collapsible_calls.rs @@ -5,7 +5,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::{Closure, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use std::borrow::{Borrow, Cow}; diff --git a/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs b/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs index 5aa1417cfb4..5059712d69c 100644 --- a/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs +++ b/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs @@ -4,7 +4,7 @@ use clippy_utils::{is_lint_allowed, paths}; use rustc_data_structures::fx::FxHashMap; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/utils/internal_lints/interning_defined_symbol.rs b/clippy_lints/src/utils/internal_lints/interning_defined_symbol.rs index 16d0636b834..07879e81fc2 100644 --- a/clippy_lints/src/utils/internal_lints/interning_defined_symbol.rs +++ b/clippy_lints/src/utils/internal_lints/interning_defined_symbol.rs @@ -11,7 +11,7 @@ use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::ConstValue; use rustc_middle::ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::sym; use rustc_span::symbol::Symbol; diff --git a/clippy_lints/src/utils/internal_lints/invalid_paths.rs b/clippy_lints/src/utils/internal_lints/invalid_paths.rs index 66d32087fcd..4fb615e1d57 100644 --- a/clippy_lints/src/utils/internal_lints/invalid_paths.rs +++ b/clippy_lints/src/utils/internal_lints/invalid_paths.rs @@ -7,7 +7,7 @@ use rustc_hir::Item; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::FloatTy; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::Symbol; declare_clippy_lint! { diff --git a/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs b/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs index 486e8220484..370ed430bcf 100644 --- a/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs +++ b/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs @@ -11,7 +11,7 @@ use rustc_hir::{ExprKind, HirId, Item, MutTy, Mutability, Path, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_semver::RustcVersion; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::symbol::Symbol; use rustc_span::{sym, Span}; diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index 8ecdba47f89..f60ff1a93c7 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -22,7 +22,7 @@ use rustc_hir::intravisit::Visitor; use rustc_hir::{self as hir, intravisit, Closure, ExprKind, Item, ItemKind, Mutability, QPath}; use rustc_lint::{CheckLintNameResult, LateContext, LateLintPass, LintContext, LintId}; use rustc_middle::hir::nested_filter; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::Ident; use rustc_span::{sym, Loc, Span, Symbol}; use serde::ser::SerializeStruct; diff --git a/clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs b/clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs index 86b1a0ae624..6d5240db832 100644 --- a/clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs +++ b/clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::{self, EarlyBinder, GenericArgKind}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/utils/internal_lints/outer_expn_data_pass.rs b/clippy_lints/src/utils/internal_lints/outer_expn_data_pass.rs index 77b95e51f62..326e1721461 100644 --- a/clippy_lints/src/utils/internal_lints/outer_expn_data_pass.rs +++ b/clippy_lints/src/utils/internal_lints/outer_expn_data_pass.rs @@ -4,7 +4,7 @@ use clippy_utils::{is_lint_allowed, method_calls, paths}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::Symbol; declare_clippy_lint! { diff --git a/clippy_lints/src/utils/internal_lints/produce_ice.rs b/clippy_lints/src/utils/internal_lints/produce_ice.rs index 5899b94e16b..9169e2968eb 100644 --- a/clippy_lints/src/utils/internal_lints/produce_ice.rs +++ b/clippy_lints/src/utils/internal_lints/produce_ice.rs @@ -1,7 +1,7 @@ use rustc_ast::ast::NodeId; use rustc_ast::visit::FnKind; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::Span; declare_clippy_lint! { diff --git a/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs b/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs index 9aa23b6efe3..70ca1b206b4 100644 --- a/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs +++ b/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs @@ -12,7 +12,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::interpret::{Allocation, GlobalAlloc}; use rustc_middle::mir::ConstValue; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::Symbol; use rustc_span::Span; diff --git a/clippy_lints/src/utils/internal_lints/unsorted_clippy_utils_paths.rs b/clippy_lints/src/utils/internal_lints/unsorted_clippy_utils_paths.rs index fd51bca9e5b..a5c4bf474f7 100644 --- a/clippy_lints/src/utils/internal_lints/unsorted_clippy_utils_paths.rs +++ b/clippy_lints/src/utils/internal_lints/unsorted_clippy_utils_paths.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Crate, ItemKind, ModKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index f58641289f8..d49d3cc4cc9 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -12,7 +12,7 @@ use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Node, PatKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, Ty}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{sym, Span}; #[expect(clippy::module_name_repetitions)] diff --git a/clippy_lints/src/vec_init_then_push.rs b/clippy_lints/src/vec_init_then_push.rs index c8b9402f1ae..ac3b2bdaf65 100644 --- a/clippy_lints/src/vec_init_then_push.rs +++ b/clippy_lints/src/vec_init_then_push.rs @@ -11,7 +11,7 @@ use rustc_hir::{ }; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{Span, Symbol}; declare_clippy_lint! { diff --git a/clippy_lints/src/visibility.rs b/clippy_lints/src/visibility.rs index 8abcc964b89..83369c66367 100644 --- a/clippy_lints/src/visibility.rs +++ b/clippy_lints/src/visibility.rs @@ -4,7 +4,7 @@ use rustc_ast::ast::{Item, VisibilityKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::symbol::kw; use rustc_span::Span; diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index 5c1bea74486..9b0dac6af25 100644 --- a/clippy_lints/src/wildcard_imports.rs +++ b/clippy_lints/src/wildcard_imports.rs @@ -6,7 +6,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Item, ItemKind, PathSegment, UseKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; use rustc_span::{sym, BytePos}; diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index b6f942a90d3..be16d2e5cc3 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -10,7 +10,7 @@ use rustc_ast::{ use rustc_errors::Applicability; use rustc_hir::{Expr, Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_session::impl_lint_pass; use rustc_span::{sym, BytePos, Span}; declare_clippy_lint! { diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index 1d6217d186c..d3623d6fda4 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -2,7 +2,7 @@ use clippy_utils::consts::{constant_simple, Constant}; use clippy_utils::diagnostics::span_lint_and_help; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/zero_sized_map_values.rs b/clippy_lints/src/zero_sized_map_values.rs index 41c1757fde8..fba3808261a 100644 --- a/clippy_lints/src/zero_sized_map_values.rs +++ b/clippy_lints/src/zero_sized_map_values.rs @@ -5,7 +5,7 @@ use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::layout::LayoutOf as _; use rustc_middle::ty::{Adt, Ty, TypeVisitableExt}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_session::declare_lint_pass; use rustc_span::sym; declare_clippy_lint! { diff --git a/declare_clippy_lint/src/lib.rs b/declare_clippy_lint/src/lib.rs index dc3037f6669..25b2fc9395c 100644 --- a/declare_clippy_lint/src/lib.rs +++ b/declare_clippy_lint/src/lib.rs @@ -148,7 +148,7 @@ pub fn declare_clippy_lint(input: TokenStream) -> TokenStream { let category_variant = format_ident!("{category}"); let output = quote! { - declare_tool_lint! { + rustc_session::declare_tool_lint! { #(#attrs)* pub clippy::#name, #level, -- cgit 1.4.1-3-g733a5 From 91f514cc8360b369a7fe5f6108aae025b22a38db Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sat, 23 Mar 2024 06:52:11 +0100 Subject: fix fallout from previous commit --- clippy_lints/src/approx_const.rs | 2 +- clippy_lints/src/asm_syntax.rs | 4 ++-- clippy_lints/src/assertions_on_constants.rs | 6 +++--- .../src/attrs/allow_attributes_without_reason.rs | 2 +- clippy_lints/src/attrs/inline_always.rs | 2 +- clippy_lints/src/attrs/maybe_misused_cfg.rs | 2 +- clippy_lints/src/attrs/unnecessary_clippy_cfg.rs | 2 +- clippy_lints/src/await_holding_invalid.rs | 2 +- clippy_lints/src/blocks_in_conditions.rs | 4 ++-- clippy_lints/src/bool_assert_comparison.rs | 2 +- clippy_lints/src/cargo/common_metadata.rs | 2 +- clippy_lints/src/cargo/feature_name.rs | 4 ++-- clippy_lints/src/cargo/lint_groups_priority.rs | 2 +- clippy_lints/src/cargo/mod.rs | 4 ++-- clippy_lints/src/cargo/multiple_crate_versions.rs | 2 +- clippy_lints/src/cargo/wildcard_dependencies.rs | 2 +- clippy_lints/src/casts/as_ptr_cast_mut.rs | 2 +- clippy_lints/src/casts/cast_abs_to_unsigned.rs | 2 +- clippy_lints/src/casts/cast_lossless.rs | 2 +- clippy_lints/src/casts/cast_nan_to_int.rs | 2 +- clippy_lints/src/casts/cast_possible_truncation.rs | 4 ++-- clippy_lints/src/casts/cast_possible_wrap.rs | 2 +- clippy_lints/src/casts/cast_precision_loss.rs | 2 +- clippy_lints/src/casts/cast_ptr_alignment.rs | 2 +- clippy_lints/src/casts/cast_sign_loss.rs | 2 +- clippy_lints/src/casts/cast_slice_different_sizes.rs | 2 +- clippy_lints/src/casts/cast_slice_from_raw_parts.rs | 2 +- clippy_lints/src/casts/fn_to_numeric_cast.rs | 2 +- clippy_lints/src/casts/fn_to_numeric_cast_any.rs | 2 +- .../src/casts/fn_to_numeric_cast_with_truncation.rs | 2 +- clippy_lints/src/casts/ptr_cast_constness.rs | 2 +- clippy_lints/src/casts/unnecessary_cast.rs | 6 +++--- clippy_lints/src/cognitive_complexity.rs | 2 +- clippy_lints/src/default.rs | 4 ++-- clippy_lints/src/default_instead_of_iter_empty.rs | 2 +- clippy_lints/src/default_union_representation.rs | 2 +- clippy_lints/src/disallowed_macros.rs | 4 ++-- clippy_lints/src/disallowed_methods.rs | 2 +- clippy_lints/src/disallowed_names.rs | 2 +- clippy_lints/src/disallowed_script_idents.rs | 2 +- clippy_lints/src/disallowed_types.rs | 2 +- clippy_lints/src/drop_forget_ref.rs | 4 ++-- clippy_lints/src/duplicate_mod.rs | 2 +- clippy_lints/src/endian_bytes.rs | 2 +- clippy_lints/src/entry.rs | 2 +- clippy_lints/src/excessive_bools.rs | 4 ++-- clippy_lints/src/explicit_write.rs | 2 +- clippy_lints/src/extra_unused_type_parameters.rs | 8 ++++---- clippy_lints/src/format_args.rs | 6 +++--- clippy_lints/src/format_impl.rs | 4 ++-- clippy_lints/src/formatting.rs | 16 ++++++++-------- clippy_lints/src/from_raw_with_void_ptr.rs | 2 +- clippy_lints/src/functions/must_use.rs | 2 +- clippy_lints/src/functions/too_many_arguments.rs | 2 +- clippy_lints/src/functions/too_many_lines.rs | 2 +- clippy_lints/src/if_then_some_else_none.rs | 4 ++-- clippy_lints/src/implicit_hasher.rs | 4 ++-- clippy_lints/src/implied_bounds_in_impls.rs | 2 +- clippy_lints/src/incompatible_msrv.rs | 2 +- clippy_lints/src/inherent_to_string.rs | 8 ++++---- clippy_lints/src/inline_fn_without_body.rs | 2 +- clippy_lints/src/integer_division_remainder_used.rs | 2 +- clippy_lints/src/invalid_upcast_comparisons.rs | 2 +- clippy_lints/src/item_name_repetitions.rs | 8 ++++---- clippy_lints/src/iter_not_returning_iterator.rs | 2 +- clippy_lints/src/iter_without_into_iter.rs | 4 ++-- clippy_lints/src/large_futures.rs | 2 +- clippy_lints/src/large_include_file.rs | 2 +- clippy_lints/src/large_stack_arrays.rs | 4 ++-- clippy_lints/src/large_stack_frames.rs | 2 +- clippy_lints/src/len_zero.rs | 10 +++++----- clippy_lints/src/lifetimes.rs | 2 +- clippy_lints/src/lines_filter_map_ok.rs | 2 +- clippy_lints/src/loops/explicit_counter_loop.rs | 4 ++-- clippy_lints/src/loops/for_kv_map.rs | 2 +- clippy_lints/src/loops/manual_flatten.rs | 2 +- clippy_lints/src/loops/needless_range_loop.rs | 4 ++-- clippy_lints/src/loops/same_item_push.rs | 2 +- clippy_lints/src/loops/single_element_loop.rs | 2 +- clippy_lints/src/main_recursion.rs | 2 +- clippy_lints/src/manual_strip.rs | 4 ++-- clippy_lints/src/map_unit_fn.rs | 4 ++-- clippy_lints/src/match_result_ok.rs | 2 +- clippy_lints/src/matches/collapsible_match.rs | 2 +- clippy_lints/src/matches/manual_unwrap_or.rs | 2 +- clippy_lints/src/matches/match_as_ref.rs | 2 +- clippy_lints/src/matches/match_like_matches.rs | 2 +- clippy_lints/src/matches/match_str_case_mismatch.rs | 2 +- clippy_lints/src/matches/match_wild_err_arm.rs | 2 +- clippy_lints/src/matches/redundant_pattern_match.rs | 8 ++++---- clippy_lints/src/mem_replace.rs | 2 +- clippy_lints/src/methods/bind_instead_of_map.rs | 6 +++--- clippy_lints/src/methods/bytes_nth.rs | 4 ++-- clippy_lints/src/methods/chars_cmp.rs | 2 +- clippy_lints/src/methods/chars_cmp_with_unwrap.rs | 2 +- clippy_lints/src/methods/clear_with_drain.rs | 2 +- clippy_lints/src/methods/clone_on_copy.rs | 2 +- clippy_lints/src/methods/drain_collect.rs | 2 +- clippy_lints/src/methods/expect_fun_call.rs | 4 ++-- clippy_lints/src/methods/filetype_is_file.rs | 2 +- clippy_lints/src/methods/filter_map.rs | 2 +- clippy_lints/src/methods/get_first.rs | 4 ++-- clippy_lints/src/methods/get_last_with_len.rs | 2 +- clippy_lints/src/methods/get_unwrap.rs | 2 +- clippy_lints/src/methods/implicit_clone.rs | 2 +- clippy_lints/src/methods/inefficient_to_string.rs | 2 +- clippy_lints/src/methods/into_iter_on_ref.rs | 2 +- clippy_lints/src/methods/is_digit_ascii_radix.rs | 2 +- clippy_lints/src/methods/is_empty.rs | 2 +- clippy_lints/src/methods/iter_cloned_collect.rs | 2 +- clippy_lints/src/methods/iter_count.rs | 2 +- clippy_lints/src/methods/iter_kv_map.rs | 4 ++-- clippy_lints/src/methods/iter_nth.rs | 2 +- .../src/methods/iter_on_single_or_empty_collections.rs | 4 ++-- clippy_lints/src/methods/iter_with_drain.rs | 2 +- clippy_lints/src/methods/manual_saturating_arithmetic.rs | 2 +- clippy_lints/src/methods/map_clone.rs | 4 ++-- clippy_lints/src/methods/map_flatten.rs | 4 ++-- clippy_lints/src/methods/map_identity.rs | 2 +- clippy_lints/src/methods/mod.rs | 4 ++-- clippy_lints/src/methods/open_options.rs | 2 +- clippy_lints/src/methods/option_as_ref_cloned.rs | 2 +- clippy_lints/src/methods/option_as_ref_deref.rs | 4 ++-- clippy_lints/src/methods/option_map_unwrap_or.rs | 2 +- clippy_lints/src/methods/or_fun_call.rs | 4 ++-- clippy_lints/src/methods/range_zip_with_len.rs | 2 +- clippy_lints/src/methods/search_is_some.rs | 10 +++++----- clippy_lints/src/methods/stable_sort_primitive.rs | 2 +- clippy_lints/src/methods/str_splitn.rs | 4 ++-- clippy_lints/src/methods/suspicious_splitn.rs | 2 +- clippy_lints/src/methods/suspicious_to_owned.rs | 2 +- clippy_lints/src/methods/type_id_on_box.rs | 2 +- clippy_lints/src/methods/unnecessary_filter_map.rs | 2 +- clippy_lints/src/methods/unnecessary_get_then_check.rs | 4 ++-- clippy_lints/src/methods/unnecessary_iter_cloned.rs | 2 +- clippy_lints/src/methods/unnecessary_literal_unwrap.rs | 2 +- clippy_lints/src/methods/unnecessary_to_owned.rs | 16 ++++++++-------- clippy_lints/src/methods/unwrap_expect_used.rs | 2 +- clippy_lints/src/methods/useless_asref.rs | 4 ++-- clippy_lints/src/methods/verbose_file_reads.rs | 2 +- clippy_lints/src/methods/wrong_self_convention.rs | 2 +- clippy_lints/src/min_ident_chars.rs | 2 +- clippy_lints/src/misc.rs | 2 +- clippy_lints/src/misc_early/builtin_type_shadow.rs | 2 +- clippy_lints/src/misc_early/literal_suffix.rs | 4 ++-- clippy_lints/src/misc_early/mod.rs | 2 +- clippy_lints/src/misc_early/redundant_pattern.rs | 2 +- clippy_lints/src/misc_early/unneeded_field_pattern.rs | 4 ++-- clippy_lints/src/mismatching_type_param_order.rs | 2 +- clippy_lints/src/missing_asserts_for_indexing.rs | 2 +- clippy_lints/src/missing_doc.rs | 2 +- clippy_lints/src/missing_inline.rs | 2 +- clippy_lints/src/missing_trait_methods.rs | 2 +- clippy_lints/src/mixed_read_write_in_expression.rs | 2 +- clippy_lints/src/module_style.rs | 8 ++++---- clippy_lints/src/multiple_unsafe_ops_per_block.rs | 2 +- clippy_lints/src/mut_reference.rs | 2 +- clippy_lints/src/mutable_debug_assertion.rs | 2 +- clippy_lints/src/mutex_atomic.rs | 6 +++--- clippy_lints/src/needless_bool.rs | 16 ++++++++-------- clippy_lints/src/needless_borrowed_ref.rs | 2 +- clippy_lints/src/needless_continue.rs | 2 +- clippy_lints/src/needless_question_mark.rs | 2 +- clippy_lints/src/new_without_default.rs | 4 +--- clippy_lints/src/non_expressive_names.rs | 2 +- clippy_lints/src/non_send_fields_in_send_ty.rs | 2 +- clippy_lints/src/nonstandard_macro_braces.rs | 2 +- clippy_lints/src/octal_escapes.rs | 2 +- clippy_lints/src/operators/absurd_extreme_comparisons.rs | 2 +- clippy_lints/src/operators/bit_mask.rs | 16 ++++++++-------- clippy_lints/src/operators/const_comparisons.rs | 6 +++--- clippy_lints/src/operators/duration_subsec.rs | 2 +- clippy_lints/src/operators/eq_op.rs | 4 ++-- clippy_lints/src/operators/modulo_arithmetic.rs | 2 +- clippy_lints/src/operators/ptr_eq.rs | 2 +- clippy_lints/src/operators/self_assignment.rs | 2 +- clippy_lints/src/option_if_let_else.rs | 2 +- clippy_lints/src/pass_by_ref_or_value.rs | 4 ++-- clippy_lints/src/pattern_type_mismatch.rs | 2 +- clippy_lints/src/ptr.rs | 4 ++-- clippy_lints/src/ptr_offset_with_cast.rs | 4 ++-- clippy_lints/src/ranges.rs | 4 ++-- clippy_lints/src/redundant_locals.rs | 4 ++-- clippy_lints/src/redundant_pub_crate.rs | 2 +- clippy_lints/src/redundant_static_lifetimes.rs | 2 +- clippy_lints/src/regex.rs | 6 +++--- clippy_lints/src/repeat_vec_with_capacity.rs | 2 +- clippy_lints/src/self_named_constructors.rs | 2 +- clippy_lints/src/shadow.rs | 2 +- clippy_lints/src/single_range_in_vec_init.rs | 2 +- clippy_lints/src/slow_vector_initialization.rs | 2 +- clippy_lints/src/std_instead_of_core.rs | 4 ++-- clippy_lints/src/strings.rs | 4 ++-- clippy_lints/src/suspicious_trait_impl.rs | 2 +- clippy_lints/src/swap.rs | 6 +++--- clippy_lints/src/trailing_empty_array.rs | 2 +- clippy_lints/src/trait_bounds.rs | 8 ++++++-- clippy_lints/src/transmute/crosspointer_transmute.rs | 4 ++-- clippy_lints/src/transmute/transmute_float_to_int.rs | 2 +- clippy_lints/src/transmute/transmute_int_to_bool.rs | 2 +- clippy_lints/src/transmute/transmute_int_to_char.rs | 2 +- clippy_lints/src/transmute/transmute_int_to_float.rs | 2 +- clippy_lints/src/transmute/transmute_int_to_non_zero.rs | 2 +- clippy_lints/src/transmute/transmute_num_to_bytes.rs | 2 +- clippy_lints/src/transmute/transmute_ptr_to_ref.rs | 2 +- clippy_lints/src/transmute/transmute_ref_to_ref.rs | 2 +- clippy_lints/src/transmute/transmute_undefined_repr.rs | 10 +++++----- .../src/transmute/transmutes_expressible_as_ptr_casts.rs | 2 +- .../src/transmute/unsound_collection_transmute.rs | 2 +- clippy_lints/src/transmute/useless_transmute.rs | 2 +- clippy_lints/src/transmute/wrong_transmute.rs | 2 +- clippy_lints/src/types/box_collection.rs | 4 ++-- clippy_lints/src/types/redundant_allocation.rs | 6 +++--- clippy_lints/src/undocumented_unsafe_blocks.rs | 4 ++-- clippy_lints/src/unit_return_expecting_ord.rs | 4 ++-- clippy_lints/src/unit_types/unit_arg.rs | 2 +- clippy_lints/src/unit_types/unit_cmp.rs | 4 ++-- clippy_lints/src/unnecessary_box_returns.rs | 2 +- clippy_lints/src/unnecessary_map_on_constructor.rs | 2 +- clippy_lints/src/unnecessary_wraps.rs | 2 +- clippy_lints/src/unsafe_removed_from_name.rs | 2 +- clippy_lints/src/unused_rounding.rs | 4 ++-- clippy_lints/src/unwrap.rs | 4 ++-- clippy_lints/src/upper_case_acronyms.rs | 2 +- clippy_lints/src/useless_conversion.rs | 14 +++++++------- .../internal_lints/almost_standard_lint_formulation.rs | 2 +- .../src/utils/internal_lints/compiler_lint_functions.rs | 2 +- .../src/utils/internal_lints/lint_without_lint_pass.rs | 6 +++--- .../src/utils/internal_lints/metadata_collector.rs | 2 +- clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs | 4 ++-- .../src/utils/internal_lints/unnecessary_def_path.rs | 4 ++-- clippy_lints/src/visibility.rs | 2 +- clippy_lints/src/write.rs | 8 ++++---- clippy_lints/src/zero_div_zero.rs | 2 +- 234 files changed, 373 insertions(+), 371 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index 25606f4253e..ec28fd46111 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -95,7 +95,7 @@ impl ApproxConstant { cx, APPROX_CONSTANT, e.span, - &format!("approximate value of `{module}::consts::{}` found", &name), + format!("approximate value of `{module}::consts::{}` found", &name), None, "consider using the constant directly", ); diff --git a/clippy_lints/src/asm_syntax.rs b/clippy_lints/src/asm_syntax.rs index c2fa56e1360..7c88bfc97ca 100644 --- a/clippy_lints/src/asm_syntax.rs +++ b/clippy_lints/src/asm_syntax.rs @@ -53,9 +53,9 @@ fn check_asm_syntax( cx, lint, span, - &format!("{style} x86 assembly syntax used"), + format!("{style} x86 assembly syntax used"), None, - &format!("use {} x86 assembly syntax", !style), + format!("use {} x86 assembly syntax", !style), ); } } diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index 9365fbfaed0..2003dd1fb0e 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants { cx, ASSERTIONS_ON_CONSTANTS, macro_call.span, - &format!( + format!( "`{}!(true)` will be optimized out by the compiler", cx.tcx.item_name(macro_call.def_id) ), @@ -74,9 +74,9 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants { cx, ASSERTIONS_ON_CONSTANTS, macro_call.span, - &format!("`assert!(false{assert_arg})` should probably be replaced"), + format!("`assert!(false{assert_arg})` should probably be replaced"), None, - &format!("use `panic!({panic_arg})` or `unreachable!({panic_arg})`"), + format!("use `panic!({panic_arg})` or `unreachable!({panic_arg})`"), ); } } diff --git a/clippy_lints/src/attrs/allow_attributes_without_reason.rs b/clippy_lints/src/attrs/allow_attributes_without_reason.rs index df00f23e37e..4a22e17463f 100644 --- a/clippy_lints/src/attrs/allow_attributes_without_reason.rs +++ b/clippy_lints/src/attrs/allow_attributes_without_reason.rs @@ -30,7 +30,7 @@ pub(super) fn check<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[NestedMet cx, ALLOW_ATTRIBUTES_WITHOUT_REASON, attr.span, - &format!("`{}` attribute without specifying a reason", name.as_str()), + format!("`{}` attribute without specifying a reason", name.as_str()), None, "try adding a reason at the end with `, reason = \"..\"`", ); diff --git a/clippy_lints/src/attrs/inline_always.rs b/clippy_lints/src/attrs/inline_always.rs index cfcd2cc6a00..3b5b80ffefa 100644 --- a/clippy_lints/src/attrs/inline_always.rs +++ b/clippy_lints/src/attrs/inline_always.rs @@ -21,7 +21,7 @@ pub(super) fn check(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Att cx, INLINE_ALWAYS, attr.span, - &format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"), + format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"), ); } } diff --git a/clippy_lints/src/attrs/maybe_misused_cfg.rs b/clippy_lints/src/attrs/maybe_misused_cfg.rs index 5a70866eda5..e6b2e835be8 100644 --- a/clippy_lints/src/attrs/maybe_misused_cfg.rs +++ b/clippy_lints/src/attrs/maybe_misused_cfg.rs @@ -40,7 +40,7 @@ fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) { cx, MAYBE_MISUSED_CFG, meta.span, - &format!("'test' may be misspelled as '{}'", ident.name.as_str()), + format!("'test' may be misspelled as '{}'", ident.name.as_str()), "did you mean", "test".to_string(), Applicability::MaybeIncorrect, diff --git a/clippy_lints/src/attrs/unnecessary_clippy_cfg.rs b/clippy_lints/src/attrs/unnecessary_clippy_cfg.rs index 05da69636c6..486e7c6ec4f 100644 --- a/clippy_lints/src/attrs/unnecessary_clippy_cfg.rs +++ b/clippy_lints/src/attrs/unnecessary_clippy_cfg.rs @@ -58,7 +58,7 @@ pub(super) fn check( clippy_lints, "no need to put clippy lints behind a `clippy` cfg", None, - &format!( + format!( "write instead: `#{}[{}({})]`", if attr.style == AttrStyle::Inner { "!" } else { "" }, ident.name, diff --git a/clippy_lints/src/await_holding_invalid.rs b/clippy_lints/src/await_holding_invalid.rs index 765cc7c0a54..f25a474d9bb 100644 --- a/clippy_lints/src/await_holding_invalid.rs +++ b/clippy_lints/src/await_holding_invalid.rs @@ -267,7 +267,7 @@ fn emit_invalid_type(cx: &LateContext<'_>, span: Span, disallowed: &DisallowedPa cx, AWAIT_HOLDING_INVALID_TYPE, span, - &format!( + format!( "`{}` may not be held across an `await` point per `clippy.toml`", disallowed.path() ), diff --git a/clippy_lints/src/blocks_in_conditions.rs b/clippy_lints/src/blocks_in_conditions.rs index 2eb0dac9742..171f3031860 100644 --- a/clippy_lints/src/blocks_in_conditions.rs +++ b/clippy_lints/src/blocks_in_conditions.rs @@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInConditions { else { return; }; - let complex_block_message = &format!( + let complex_block_message = format!( "in {desc}, avoid complex blocks or closures with blocks; \ instead, move the block or closure higher and bind it with a `let`", ); @@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInConditions { let ex = &body.value; if let ExprKind::Block(block, _) = ex.kind { if !body.value.span.from_expansion() && !block.stmts.is_empty() { - span_lint(cx, BLOCKS_IN_CONDITIONS, ex.span, complex_block_message); + span_lint(cx, BLOCKS_IN_CONDITIONS, ex.span, complex_block_message.clone()); return ControlFlow::Continue(Descend::No); } } diff --git a/clippy_lints/src/bool_assert_comparison.rs b/clippy_lints/src/bool_assert_comparison.rs index 74201e9cc30..58c1a2f2706 100644 --- a/clippy_lints/src/bool_assert_comparison.rs +++ b/clippy_lints/src/bool_assert_comparison.rs @@ -121,7 +121,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolAssertComparison { cx, BOOL_ASSERT_COMPARISON, macro_call.span, - &format!("used `{macro_name}!` with a literal bool"), + format!("used `{macro_name}!` with a literal bool"), |diag| { // assert_eq!(...) // ^^^^^^^^^ diff --git a/clippy_lints/src/cargo/common_metadata.rs b/clippy_lints/src/cargo/common_metadata.rs index 99fe6c1e790..3af2d8c0256 100644 --- a/clippy_lints/src/cargo/common_metadata.rs +++ b/clippy_lints/src/cargo/common_metadata.rs @@ -41,7 +41,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata, ignore_publish: b fn missing_warning(cx: &LateContext<'_>, package: &cargo_metadata::Package, field: &str) { let message = format!("package `{}` is missing `{field}` metadata", package.name); - span_lint(cx, CARGO_COMMON_METADATA, DUMMY_SP, &message); + span_lint(cx, CARGO_COMMON_METADATA, DUMMY_SP, message); } fn is_empty_str>(value: &Option) -> bool { diff --git a/clippy_lints/src/cargo/feature_name.rs b/clippy_lints/src/cargo/feature_name.rs index 9e69919c727..6982b96dd3b 100644 --- a/clippy_lints/src/cargo/feature_name.rs +++ b/clippy_lints/src/cargo/feature_name.rs @@ -56,13 +56,13 @@ fn lint(cx: &LateContext<'_>, feature: &str, substring: &str, is_prefix: bool) { REDUNDANT_FEATURE_NAMES }, DUMMY_SP, - &format!( + format!( "the \"{substring}\" {} in the feature name \"{feature}\" is {}", if is_prefix { "prefix" } else { "suffix" }, if is_negative { "negative" } else { "redundant" } ), None, - &format!( + format!( "consider renaming the feature to \"{}\"{}", if is_prefix { feature.strip_prefix(substring) diff --git a/clippy_lints/src/cargo/lint_groups_priority.rs b/clippy_lints/src/cargo/lint_groups_priority.rs index a39b972b56a..a3291c9da10 100644 --- a/clippy_lints/src/cargo/lint_groups_priority.rs +++ b/clippy_lints/src/cargo/lint_groups_priority.rs @@ -102,7 +102,7 @@ fn check_table(cx: &LateContext<'_>, table: LintTable, groups: &FxHashSet<&str>, cx, LINT_GROUPS_PRIORITY, toml_span(group.span(), file), - &format!( + format!( "lint group `{}` has the same priority ({priority}) as a lint", group.as_ref() ), diff --git a/clippy_lints/src/cargo/mod.rs b/clippy_lints/src/cargo/mod.rs index 95d5449781b..ca7fa4e5a41 100644 --- a/clippy_lints/src/cargo/mod.rs +++ b/clippy_lints/src/cargo/mod.rs @@ -241,7 +241,7 @@ impl LateLintPass<'_> for Cargo { }, Err(e) => { for lint in NO_DEPS_LINTS { - span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {e}")); + span_lint(cx, lint, DUMMY_SP, format!("could not read cargo metadata: {e}")); } }, } @@ -257,7 +257,7 @@ impl LateLintPass<'_> for Cargo { }, Err(e) => { for lint in WITH_DEPS_LINTS { - span_lint(cx, lint, DUMMY_SP, &format!("could not read cargo metadata: {e}")); + span_lint(cx, lint, DUMMY_SP, format!("could not read cargo metadata: {e}")); } }, } diff --git a/clippy_lints/src/cargo/multiple_crate_versions.rs b/clippy_lints/src/cargo/multiple_crate_versions.rs index 3f30a77fcfe..2769463c8a5 100644 --- a/clippy_lints/src/cargo/multiple_crate_versions.rs +++ b/clippy_lints/src/cargo/multiple_crate_versions.rs @@ -52,7 +52,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata, allowed_duplicate cx, MULTIPLE_CRATE_VERSIONS, DUMMY_SP, - &format!("multiple versions for dependency `{name}`: {versions}"), + format!("multiple versions for dependency `{name}`: {versions}"), ); } } diff --git a/clippy_lints/src/cargo/wildcard_dependencies.rs b/clippy_lints/src/cargo/wildcard_dependencies.rs index 244e98eb666..0cf687d0192 100644 --- a/clippy_lints/src/cargo/wildcard_dependencies.rs +++ b/clippy_lints/src/cargo/wildcard_dependencies.rs @@ -17,7 +17,7 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata) { cx, WILDCARD_DEPENDENCIES, DUMMY_SP, - &format!("wildcard dependency for `{}`", dep.name), + format!("wildcard dependency for `{}`", dep.name), ); } } diff --git a/clippy_lints/src/casts/as_ptr_cast_mut.rs b/clippy_lints/src/casts/as_ptr_cast_mut.rs index 8bfb7383f14..2209ae3cad9 100644 --- a/clippy_lints/src/casts/as_ptr_cast_mut.rs +++ b/clippy_lints/src/casts/as_ptr_cast_mut.rs @@ -33,7 +33,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cx, AS_PTR_CAST_MUT, expr.span, - &format!("casting the result of `as_ptr` to *mut {ptrty}"), + format!("casting the result of `as_ptr` to *mut {ptrty}"), "replace with", format!("{recv}.as_mut_ptr()"), applicability, diff --git a/clippy_lints/src/casts/cast_abs_to_unsigned.rs b/clippy_lints/src/casts/cast_abs_to_unsigned.rs index c1663348321..d4d5ee37bcc 100644 --- a/clippy_lints/src/casts/cast_abs_to_unsigned.rs +++ b/clippy_lints/src/casts/cast_abs_to_unsigned.rs @@ -34,7 +34,7 @@ pub(super) fn check( cx, CAST_ABS_TO_UNSIGNED, span, - &format!("casting the result of `{cast_from}::abs()` to {cast_to}"), + format!("casting the result of `{cast_from}::abs()` to {cast_to}"), "replace with", format!("{}.unsigned_abs()", Sugg::hir(cx, receiver, "..").maybe_par()), Applicability::MachineApplicable, diff --git a/clippy_lints/src/casts/cast_lossless.rs b/clippy_lints/src/casts/cast_lossless.rs index 86f4332d05a..d52ad1c6f23 100644 --- a/clippy_lints/src/casts/cast_lossless.rs +++ b/clippy_lints/src/casts/cast_lossless.rs @@ -68,7 +68,7 @@ pub(super) fn check( cx, CAST_LOSSLESS, expr.span, - &message, + message, "try", format!("{cast_to_fmt}::from({sugg})"), app, diff --git a/clippy_lints/src/casts/cast_nan_to_int.rs b/clippy_lints/src/casts/cast_nan_to_int.rs index da756129db3..1743ce71add 100644 --- a/clippy_lints/src/casts/cast_nan_to_int.rs +++ b/clippy_lints/src/casts/cast_nan_to_int.rs @@ -12,7 +12,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cx, CAST_NAN_TO_INT, expr.span, - &format!("casting a known NaN to {to_ty}"), + format!("casting a known NaN to {to_ty}"), None, "this always evaluates to 0", ); diff --git a/clippy_lints/src/casts/cast_possible_truncation.rs b/clippy_lints/src/casts/cast_possible_truncation.rs index 32e45bd0a79..dbfa8e1ee91 100644 --- a/clippy_lints/src/casts/cast_possible_truncation.rs +++ b/clippy_lints/src/casts/cast_possible_truncation.rs @@ -142,7 +142,7 @@ pub(super) fn check( cx, CAST_ENUM_TRUNCATION, expr.span, - &format!( + format!( "casting `{cast_from}::{}` to `{cast_to}` will truncate the value{suffix}", variant.name, ), @@ -163,7 +163,7 @@ pub(super) fn check( _ => return, }; - span_lint_and_then(cx, CAST_POSSIBLE_TRUNCATION, expr.span, &msg, |diag| { + span_lint_and_then(cx, CAST_POSSIBLE_TRUNCATION, expr.span, msg, |diag| { diag.help("if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ..."); if !cast_from.is_floating_point() { offer_suggestion(cx, expr, cast_expr, cast_to_span, diag); diff --git a/clippy_lints/src/casts/cast_possible_wrap.rs b/clippy_lints/src/casts/cast_possible_wrap.rs index 2ddb0f00ecd..11274383595 100644 --- a/clippy_lints/src/casts/cast_possible_wrap.rs +++ b/clippy_lints/src/casts/cast_possible_wrap.rs @@ -79,7 +79,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca ), }; - span_lint_and_then(cx, CAST_POSSIBLE_WRAP, expr.span, &message, |diag| { + span_lint_and_then(cx, CAST_POSSIBLE_WRAP, expr.span, message, |diag| { if let EmitState::LintOnPtrSize(16) = should_lint { diag .note("`usize` and `isize` may be as small as 16 bits on some platforms") diff --git a/clippy_lints/src/casts/cast_precision_loss.rs b/clippy_lints/src/casts/cast_precision_loss.rs index 334e1646cd4..035666e4d4c 100644 --- a/clippy_lints/src/casts/cast_precision_loss.rs +++ b/clippy_lints/src/casts/cast_precision_loss.rs @@ -38,7 +38,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca cx, CAST_PRECISION_LOSS, expr.span, - &format!( + format!( "casting `{0}` to `{1}` causes a loss of precision {2}(`{0}` is {3} bits wide, \ but `{1}`'s mantissa is only {4} bits wide)", cast_from, diff --git a/clippy_lints/src/casts/cast_ptr_alignment.rs b/clippy_lints/src/casts/cast_ptr_alignment.rs index f12f03fbe79..83fe324fc7e 100644 --- a/clippy_lints/src/casts/cast_ptr_alignment.rs +++ b/clippy_lints/src/casts/cast_ptr_alignment.rs @@ -48,7 +48,7 @@ fn lint_cast_ptr_alignment<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, cast_f cx, CAST_PTR_ALIGNMENT, expr.span, - &format!( + format!( "casting from `{cast_from}` to a more-strictly-aligned pointer (`{cast_to}`) ({} < {} bytes)", from_layout.align.abi.bytes(), to_layout.align.abi.bytes(), diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 90786175562..2b6e17dc103 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -47,7 +47,7 @@ pub(super) fn check<'cx>( cx, CAST_SIGN_LOSS, expr.span, - &format!("casting `{cast_from}` to `{cast_to}` may lose the sign of the value"), + format!("casting `{cast_from}` to `{cast_to}` may lose the sign of the value"), ); } } diff --git a/clippy_lints/src/casts/cast_slice_different_sizes.rs b/clippy_lints/src/casts/cast_slice_different_sizes.rs index a31943f0021..79dbc99bbf3 100644 --- a/clippy_lints/src/casts/cast_slice_different_sizes.rs +++ b/clippy_lints/src/casts/cast_slice_different_sizes.rs @@ -35,7 +35,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Msrv cx, CAST_SLICE_DIFFERENT_SIZES, expr.span, - &format!( + format!( "casting between raw pointers to `[{}]` (element size {from_size}) and `[{}]` (element size {to_size}) does not adjust the count", start_ty.ty, end_ty.ty, ), diff --git a/clippy_lints/src/casts/cast_slice_from_raw_parts.rs b/clippy_lints/src/casts/cast_slice_from_raw_parts.rs index 3db1e3e6d97..c70adc544d4 100644 --- a/clippy_lints/src/casts/cast_slice_from_raw_parts.rs +++ b/clippy_lints/src/casts/cast_slice_from_raw_parts.rs @@ -46,7 +46,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cx, CAST_SLICE_FROM_RAW_PARTS, span, - &format!("casting the result of `{func}` to {cast_to}"), + format!("casting the result of `{func}` to {cast_to}"), "replace with", format!("core::ptr::slice_{func}({ptr}, {len})"), applicability, diff --git a/clippy_lints/src/casts/fn_to_numeric_cast.rs b/clippy_lints/src/casts/fn_to_numeric_cast.rs index a26bfab4e7c..f263bec1576 100644 --- a/clippy_lints/src/casts/fn_to_numeric_cast.rs +++ b/clippy_lints/src/casts/fn_to_numeric_cast.rs @@ -25,7 +25,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cx, FN_TO_NUMERIC_CAST, expr.span, - &format!("casting function pointer `{from_snippet}` to `{cast_to}`"), + format!("casting function pointer `{from_snippet}` to `{cast_to}`"), "try", format!("{from_snippet} as usize"), applicability, diff --git a/clippy_lints/src/casts/fn_to_numeric_cast_any.rs b/clippy_lints/src/casts/fn_to_numeric_cast_any.rs index 75654129408..826589bf303 100644 --- a/clippy_lints/src/casts/fn_to_numeric_cast_any.rs +++ b/clippy_lints/src/casts/fn_to_numeric_cast_any.rs @@ -23,7 +23,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cx, FN_TO_NUMERIC_CAST_ANY, expr.span, - &format!("casting function pointer `{from_snippet}` to `{cast_to}`"), + format!("casting function pointer `{from_snippet}` to `{cast_to}`"), "did you mean to invoke the function?", format!("{from_snippet}() as {cast_to}"), applicability, diff --git a/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs b/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs index 556be1d1506..0e11bcfb8ec 100644 --- a/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs +++ b/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs @@ -24,7 +24,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cx, FN_TO_NUMERIC_CAST_WITH_TRUNCATION, expr.span, - &format!("casting function pointer `{from_snippet}` to `{cast_to}`, which truncates the value"), + format!("casting function pointer `{from_snippet}` to `{cast_to}`, which truncates the value"), "try", format!("{from_snippet} as usize"), applicability, diff --git a/clippy_lints/src/casts/ptr_cast_constness.rs b/clippy_lints/src/casts/ptr_cast_constness.rs index ff069860a11..c807788b7bc 100644 --- a/clippy_lints/src/casts/ptr_cast_constness.rs +++ b/clippy_lints/src/casts/ptr_cast_constness.rs @@ -42,7 +42,7 @@ pub(super) fn check<'tcx>( PTR_CAST_CONSTNESS, expr.span, "`as` casting between raw pointers while changing only its constness", - &format!("try `pointer::cast_{constness}`, a safer alternative"), + format!("try `pointer::cast_{constness}`, a safer alternative"), format!("{}.cast_{constness}()", sugg.maybe_par()), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/casts/unnecessary_cast.rs b/clippy_lints/src/casts/unnecessary_cast.rs index 08341ff32f3..d63f5ac6655 100644 --- a/clippy_lints/src/casts/unnecessary_cast.rs +++ b/clippy_lints/src/casts/unnecessary_cast.rs @@ -51,7 +51,7 @@ pub(super) fn check<'tcx>( cx, UNNECESSARY_CAST, expr.span, - &format!( + format!( "casting raw pointers to the same type and constness is unnecessary (`{cast_from}` -> `{cast_to}`)" ), "try", @@ -166,7 +166,7 @@ pub(super) fn check<'tcx>( cx, UNNECESSARY_CAST, expr.span, - &format!("casting to the same type is unnecessary (`{cast_from}` -> `{cast_to}`)"), + format!("casting to the same type is unnecessary (`{cast_from}` -> `{cast_to}`)"), "try", if needs_block { format!("{{ {cast_str} }}") @@ -209,7 +209,7 @@ fn lint_unnecessary_cast( cx, UNNECESSARY_CAST, expr.span, - &format!("casting {literal_kind_name} literal to `{cast_to}` is unnecessary"), + format!("casting {literal_kind_name} literal to `{cast_to}` is unnecessary"), "try", sugg, Applicability::MachineApplicable, diff --git a/clippy_lints/src/cognitive_complexity.rs b/clippy_lints/src/cognitive_complexity.rs index 60f436dc5d2..4ac2da19145 100644 --- a/clippy_lints/src/cognitive_complexity.rs +++ b/clippy_lints/src/cognitive_complexity.rs @@ -121,7 +121,7 @@ impl CognitiveComplexity { cx, COGNITIVE_COMPLEXITY, fn_span, - &format!( + format!( "the function has a cognitive complexity of ({cc}/{})", self.limit.limit() ), diff --git a/clippy_lints/src/default.rs b/clippy_lints/src/default.rs index 98a6d9370c3..2b3f4854255 100644 --- a/clippy_lints/src/default.rs +++ b/clippy_lints/src/default.rs @@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for Default { cx, DEFAULT_TRAIT_ACCESS, expr.span, - &format!("calling `{replacement}` is more clear than this expression"), + format!("calling `{replacement}` is more clear than this expression"), "try", replacement, Applicability::Unspecified, // First resolve the TODO above @@ -243,7 +243,7 @@ impl<'tcx> LateLintPass<'tcx> for Default { first_assign.unwrap().span, "field assignment outside of initializer for an instance created with Default::default()", Some(local.span), - &format!("consider initializing the variable with `{sugg}` and removing relevant reassignments"), + format!("consider initializing the variable with `{sugg}` and removing relevant reassignments"), ); self.reassigned_linted.insert(span); } diff --git a/clippy_lints/src/default_instead_of_iter_empty.rs b/clippy_lints/src/default_instead_of_iter_empty.rs index 61f68fdb66c..ac49e6f1a48 100644 --- a/clippy_lints/src/default_instead_of_iter_empty.rs +++ b/clippy_lints/src/default_instead_of_iter_empty.rs @@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultIterEmpty { cx, DEFAULT_INSTEAD_OF_ITER_EMPTY, expr.span, - &format!("`{path}()` is the more idiomatic way"), + format!("`{path}()` is the more idiomatic way"), "try", sugg, applicability, diff --git a/clippy_lints/src/default_union_representation.rs b/clippy_lints/src/default_union_representation.rs index bfd89bfd2c7..3f87ed8df2b 100644 --- a/clippy_lints/src/default_union_representation.rs +++ b/clippy_lints/src/default_union_representation.rs @@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultUnionRepresentation { item.span, "this union has the default representation", None, - &format!( + format!( "consider annotating `{}` with `#[repr(C)]` to explicitly specify memory layout", cx.tcx.def_path_str(item.owner_id) ), diff --git a/clippy_lints/src/disallowed_macros.rs b/clippy_lints/src/disallowed_macros.rs index 4a617ba34d5..871f529da6c 100644 --- a/clippy_lints/src/disallowed_macros.rs +++ b/clippy_lints/src/disallowed_macros.rs @@ -102,11 +102,11 @@ impl DisallowedMacros { DISALLOWED_MACROS, cx.tcx.local_def_id_to_hir_id(derive_src.def_id), mac.span, - &msg, + msg, add_note, ); } else { - span_lint_and_then(cx, DISALLOWED_MACROS, mac.span, &msg, add_note); + span_lint_and_then(cx, DISALLOWED_MACROS, mac.span, msg, add_note); } } } diff --git a/clippy_lints/src/disallowed_methods.rs b/clippy_lints/src/disallowed_methods.rs index 1868d3cd391..9de879604e2 100644 --- a/clippy_lints/src/disallowed_methods.rs +++ b/clippy_lints/src/disallowed_methods.rs @@ -99,7 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedMethods { None => return, }; let msg = format!("use of a disallowed method `{}`", conf.path()); - span_lint_and_then(cx, DISALLOWED_METHODS, expr.span, &msg, |diag| { + span_lint_and_then(cx, DISALLOWED_METHODS, expr.span, msg, |diag| { if let Some(reason) = conf.reason() { diag.note(reason); } diff --git a/clippy_lints/src/disallowed_names.rs b/clippy_lints/src/disallowed_names.rs index 09dad5554ad..2afbf184117 100644 --- a/clippy_lints/src/disallowed_names.rs +++ b/clippy_lints/src/disallowed_names.rs @@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedNames { cx, DISALLOWED_NAMES, ident.span, - &format!("use of a disallowed/placeholder name `{}`", ident.name), + format!("use of a disallowed/placeholder name `{}`", ident.name), ); } } diff --git a/clippy_lints/src/disallowed_script_idents.rs b/clippy_lints/src/disallowed_script_idents.rs index 0c1bb2da7e8..def4b5932b4 100644 --- a/clippy_lints/src/disallowed_script_idents.rs +++ b/clippy_lints/src/disallowed_script_idents.rs @@ -98,7 +98,7 @@ impl EarlyLintPass for DisallowedScriptIdents { cx, DISALLOWED_SCRIPT_IDENTS, span, - &format!( + format!( "identifier `{symbol_str}` has a Unicode script that is not allowed by configuration: {}", script.full_name() ), diff --git a/clippy_lints/src/disallowed_types.rs b/clippy_lints/src/disallowed_types.rs index 130f56b698f..4196309a22a 100644 --- a/clippy_lints/src/disallowed_types.rs +++ b/clippy_lints/src/disallowed_types.rs @@ -127,7 +127,7 @@ fn emit(cx: &LateContext<'_>, name: &str, span: Span, conf: &DisallowedPath) { cx, DISALLOWED_TYPES, span, - &format!("`{name}` is not allowed according to config"), + format!("`{name}` is not allowed according to config"), |diag| { if let Some(reason) = conf.reason() { diag.note(reason); diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index bf6f54c1e72..119473c2454 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -129,9 +129,9 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { cx, lint, expr.span, - &msg, + msg, note_span, - &format!("argument has type `{arg_ty}`"), + format!("argument has type `{arg_ty}`"), ); } } diff --git a/clippy_lints/src/duplicate_mod.rs b/clippy_lints/src/duplicate_mod.rs index 471335c098f..ed27e38ef2d 100644 --- a/clippy_lints/src/duplicate_mod.rs +++ b/clippy_lints/src/duplicate_mod.rs @@ -119,7 +119,7 @@ impl EarlyLintPass for DuplicateMod { cx, DUPLICATE_MOD, multi_span, - &format!("file is loaded as a module multiple times: `{}`", local_path.display()), + format!("file is loaded as a module multiple times: `{}`", local_path.display()), None, "replace all but one `mod` item with `use` items", ); diff --git a/clippy_lints/src/endian_bytes.rs b/clippy_lints/src/endian_bytes.rs index b8a817e21b1..dd03df797de 100644 --- a/clippy_lints/src/endian_bytes.rs +++ b/clippy_lints/src/endian_bytes.rs @@ -197,7 +197,7 @@ fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: Prefix cx, lint.as_lint(), expr.span, - &format!( + format!( "usage of the {}`{ty}::{}`{}", if prefix == Prefix::From { "function " } else { "" }, lint.as_name(prefix), diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index dafbf6c8846..b7c9d3d0385 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -186,7 +186,7 @@ impl<'tcx> LateLintPass<'tcx> for HashMapPass { cx, MAP_ENTRY, expr.span, - &format!("usage of `contains_key` followed by `insert` on a `{}`", map_ty.name()), + format!("usage of `contains_key` followed by `insert` on a `{}`", map_ty.name()), "try", sugg, app, diff --git a/clippy_lints/src/excessive_bools.rs b/clippy_lints/src/excessive_bools.rs index c5f7212c4c0..62d5ce24d40 100644 --- a/clippy_lints/src/excessive_bools.rs +++ b/clippy_lints/src/excessive_bools.rs @@ -120,7 +120,7 @@ impl ExcessiveBools { cx, FN_PARAMS_EXCESSIVE_BOOLS, span, - &format!("more than {} bools in function parameters", self.max_fn_params_bools), + format!("more than {} bools in function parameters", self.max_fn_params_bools), None, "consider refactoring bools into two-variant enums", ); @@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for ExcessiveBools { cx, STRUCT_EXCESSIVE_BOOLS, item.span, - &format!("more than {} bools in a struct", self.max_struct_bools), + format!("more than {} bools in a struct", self.max_struct_bools), None, "consider using a state machine or refactoring bools into two-variant enums", ); diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index 2e9bec6a7b0..33bd5a5a9d3 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite { cx, EXPLICIT_WRITE, expr.span, - &format!("use of `{used}.unwrap()`"), + format!("use of `{used}.unwrap()`"), "try", format!("{prefix}{sugg_mac}!({inputs_snippet})"), applicability, diff --git a/clippy_lints/src/extra_unused_type_parameters.rs b/clippy_lints/src/extra_unused_type_parameters.rs index 538d29eb43d..7484f772e08 100644 --- a/clippy_lints/src/extra_unused_type_parameters.rs +++ b/clippy_lints/src/extra_unused_type_parameters.rs @@ -110,11 +110,11 @@ impl<'cx, 'tcx> TypeWalker<'cx, 'tcx> { .map_or(param.span, |bound_span| param.span.with_hi(bound_span.hi())) } - fn emit_help(&self, spans: Vec, msg: &str, help: &'static str) { + fn emit_help(&self, spans: Vec, msg: String, help: &'static str) { span_lint_and_help(self.cx, EXTRA_UNUSED_TYPE_PARAMETERS, spans, msg, None, help); } - fn emit_sugg(&self, spans: Vec, msg: &str, help: &'static str) { + fn emit_sugg(&self, spans: Vec, msg: String, help: &'static str) { let suggestions: Vec<(Span, String)> = spans.iter().copied().zip(std::iter::repeat(String::new())).collect(); span_lint_and_then(self.cx, EXTRA_UNUSED_TYPE_PARAMETERS, spans, msg, |diag| { diag.multipart_suggestion(help, suggestions, Applicability::MachineApplicable); @@ -167,7 +167,7 @@ impl<'cx, 'tcx> TypeWalker<'cx, 'tcx> { .iter() .map(|(_, param)| self.get_bound_span(param)) .collect::>(); - self.emit_help(spans, &msg, help); + self.emit_help(spans, msg, help); } else { let spans = if explicit_params.len() == extra_params.len() { vec![self.generics.span] // Remove the entire list of generics @@ -196,7 +196,7 @@ impl<'cx, 'tcx> TypeWalker<'cx, 'tcx> { }) .collect() }; - self.emit_sugg(spans, &msg, help); + self.emit_sugg(spans, msg, help); }; } } diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index 61f550ce0be..80db617c639 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -401,7 +401,7 @@ impl<'a, 'tcx> FormatArgsExpr<'a, 'tcx> { self.cx, FORMAT_IN_FORMAT_ARGS, self.macro_call.span, - &format!("`format!` in `{name}!` args"), + format!("`format!` in `{name}!` args"), |diag| { diag.help(format!( "combine the `format!(..)` arguments with the outer `{name}!(..)` call" @@ -431,7 +431,7 @@ impl<'a, 'tcx> FormatArgsExpr<'a, 'tcx> { cx, TO_STRING_IN_FORMAT_ARGS, to_string_span.with_lo(receiver.span.hi()), - &format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), + format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), "remove this", String::new(), Applicability::MachineApplicable, @@ -441,7 +441,7 @@ impl<'a, 'tcx> FormatArgsExpr<'a, 'tcx> { cx, TO_STRING_IN_FORMAT_ARGS, value.span, - &format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), + format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), "use this", format!( "{}{:*>n_needed_derefs$}{receiver_snippet}", diff --git a/clippy_lints/src/format_impl.rs b/clippy_lints/src/format_impl.rs index 93517076cda..0a52347940a 100644 --- a/clippy_lints/src/format_impl.rs +++ b/clippy_lints/src/format_impl.rs @@ -214,7 +214,7 @@ impl<'a, 'tcx> FormatImplExpr<'a, 'tcx> { self.cx, RECURSIVE_FORMAT_IMPL, self.expr.span, - &format!("using `self` as `{name}` in `impl {name}` will cause infinite recursion"), + format!("using `self` as `{name}` in `impl {name}` will cause infinite recursion"), ); } } @@ -235,7 +235,7 @@ impl<'a, 'tcx> FormatImplExpr<'a, 'tcx> { self.cx, PRINT_IN_FORMAT_IMPL, macro_call.span, - &format!("use of `{name}!` in `{}` impl", self.format_trait_impl.name), + format!("use of `{name}!` in `{}` impl", self.format_trait_impl.name), "replace with", if let Some(formatter_name) = self.format_trait_impl.formatter_name { format!("{replacement}!({formatter_name}, ..)") diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 5f8d787357d..34e93bdb9b9 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -151,12 +151,12 @@ fn check_assign(cx: &EarlyContext<'_>, expr: &Expr) { cx, SUSPICIOUS_ASSIGNMENT_FORMATTING, eqop_span, - &format!( + format!( "this looks like you are trying to use `.. {op}= ..`, but you \ really are doing `.. = ({op} ..)`" ), None, - &format!("to remove this lint, use either `{op}=` or `= {op}`"), + format!("to remove this lint, use either `{op}=` or `= {op}`"), ); } } @@ -187,12 +187,12 @@ fn check_unop(cx: &EarlyContext<'_>, expr: &Expr) { cx, SUSPICIOUS_UNARY_OP_FORMATTING, eqop_span, - &format!( + format!( "by not having a space between `{binop_str}` and `{unop_str}` it looks like \ `{binop_str}{unop_str}` is a single operator" ), None, - &format!("put a space between `{binop_str}` and `{unop_str}` and remove the space after `{unop_str}`"), + format!("put a space between `{binop_str}` and `{unop_str}` and remove the space after `{unop_str}`"), ); } } @@ -239,9 +239,9 @@ fn check_else(cx: &EarlyContext<'_>, expr: &Expr) { cx, SUSPICIOUS_ELSE_FORMATTING, else_span, - &format!("this is an `else {else_desc}` but the formatting might hide it"), + format!("this is an `else {else_desc}` but the formatting might hide it"), None, - &format!( + format!( "to remove this lint, remove the `else` or remove the new line between \ `else` and `{else_desc}`", ), @@ -309,9 +309,9 @@ fn check_missing_else(cx: &EarlyContext<'_>, first: &Expr, second: &Expr) { cx, SUSPICIOUS_ELSE_FORMATTING, else_span, - &format!("this looks like {looks_like} but the `else` is missing"), + format!("this looks like {looks_like} but the `else` is missing"), None, - &format!("to remove this lint, add the missing `else` or add a new line before {next_thing}",), + format!("to remove this lint, add the missing `else` or add a new line before {next_thing}",), ); } } diff --git a/clippy_lints/src/from_raw_with_void_ptr.rs b/clippy_lints/src/from_raw_with_void_ptr.rs index c8d10dc4b92..b6d7cb87480 100644 --- a/clippy_lints/src/from_raw_with_void_ptr.rs +++ b/clippy_lints/src/from_raw_with_void_ptr.rs @@ -52,7 +52,7 @@ impl LateLintPass<'_> for FromRawWithVoidPtr { cx, FROM_RAW_WITH_VOID_PTR, expr.span, - &msg, + msg, Some(arg.span), "cast this to a pointer of the appropriate type", ); diff --git a/clippy_lints/src/functions/must_use.rs b/clippy_lints/src/functions/must_use.rs index 3aaf63ce340..d0d81c06950 100644 --- a/clippy_lints/src/functions/must_use.rs +++ b/clippy_lints/src/functions/must_use.rs @@ -142,7 +142,7 @@ fn check_must_use_candidate<'tcx>( item_span: Span, item_id: hir::OwnerId, fn_span: Span, - msg: &str, + msg: &'static str, ) { if has_mutable_arg(cx, body) || mutates_static(cx, body) diff --git a/clippy_lints/src/functions/too_many_arguments.rs b/clippy_lints/src/functions/too_many_arguments.rs index 1e08922a616..e72a2ad49d8 100644 --- a/clippy_lints/src/functions/too_many_arguments.rs +++ b/clippy_lints/src/functions/too_many_arguments.rs @@ -59,7 +59,7 @@ fn check_arg_number(cx: &LateContext<'_>, decl: &hir::FnDecl<'_>, fn_span: Span, cx, TOO_MANY_ARGUMENTS, fn_span, - &format!("this function has too many arguments ({args}/{too_many_arguments_threshold})"), + format!("this function has too many arguments ({args}/{too_many_arguments_threshold})"), ); } } diff --git a/clippy_lints/src/functions/too_many_lines.rs b/clippy_lints/src/functions/too_many_lines.rs index 34f1bf3b2b1..586ca58d60d 100644 --- a/clippy_lints/src/functions/too_many_lines.rs +++ b/clippy_lints/src/functions/too_many_lines.rs @@ -77,7 +77,7 @@ pub(super) fn check_fn( cx, TOO_MANY_LINES, span, - &format!("this function has too many lines ({line_count}/{too_many_lines_threshold})"), + format!("this function has too many lines ({line_count}/{too_many_lines_threshold})"), ); } } diff --git a/clippy_lints/src/if_then_some_else_none.rs b/clippy_lints/src/if_then_some_else_none.rs index 8f48941c4a9..f5ba62ae432 100644 --- a/clippy_lints/src/if_then_some_else_none.rs +++ b/clippy_lints/src/if_then_some_else_none.rs @@ -117,9 +117,9 @@ impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone { cx, IF_THEN_SOME_ELSE_NONE, expr.span, - &format!("this could be simplified with `bool::{method_name}`"), + format!("this could be simplified with `bool::{method_name}`"), None, - &help, + help, ); } } diff --git a/clippy_lints/src/implicit_hasher.rs b/clippy_lints/src/implicit_hasher.rs index a79bf66ae01..e1950d6218c 100644 --- a/clippy_lints/src/implicit_hasher.rs +++ b/clippy_lints/src/implicit_hasher.rs @@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher { cx, IMPLICIT_HASHER, target.span(), - &format!( + format!( "impl for `{}` should be generalized over different hashers", target.type_name() ), @@ -187,7 +187,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher { cx, IMPLICIT_HASHER, target.span(), - &format!( + format!( "parameter of type `{}` should be generalized over different hashers", target.type_name() ), diff --git a/clippy_lints/src/implied_bounds_in_impls.rs b/clippy_lints/src/implied_bounds_in_impls.rs index 79078055cc3..fb4ba175233 100644 --- a/clippy_lints/src/implied_bounds_in_impls.rs +++ b/clippy_lints/src/implied_bounds_in_impls.rs @@ -65,7 +65,7 @@ fn emit_lint( cx, IMPLIED_BOUNDS_IN_IMPLS, poly_trait.span, - &format!("this bound is already specified as the supertrait of `{implied_by}`"), + format!("this bound is already specified as the supertrait of `{implied_by}`"), |diag| { // If we suggest removing a bound, we may also need to extend the span // to include the `+` token that is ahead or behind, diff --git a/clippy_lints/src/incompatible_msrv.rs b/clippy_lints/src/incompatible_msrv.rs index 23bcd19ddd3..35b4481bfee 100644 --- a/clippy_lints/src/incompatible_msrv.rs +++ b/clippy_lints/src/incompatible_msrv.rs @@ -104,7 +104,7 @@ impl IncompatibleMsrv { cx, INCOMPATIBLE_MSRV, span, - &format!( + format!( "current MSRV (Minimum Supported Rust Version) is `{}` but this item is stable since `{version}`", self.msrv ), diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index ca2ac60306b..157f6105984 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -132,20 +132,20 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) { cx, INHERENT_TO_STRING_SHADOW_DISPLAY, item.span, - &format!( + format!( "type `{self_type}` implements inherent method `to_string(&self) -> String` which shadows the implementation of `Display`" ), None, - &format!("remove the inherent method from type `{self_type}`"), + format!("remove the inherent method from type `{self_type}`"), ); } else { span_lint_and_help( cx, INHERENT_TO_STRING, item.span, - &format!("implementation of inherent method `to_string(&self) -> String` for type `{self_type}`"), + format!("implementation of inherent method `to_string(&self) -> String` for type `{self_type}`"), None, - &format!("implement trait `Display` for type `{self_type}` instead"), + format!("implement trait `Display` for type `{self_type}` instead"), ); } } diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index 83ecaeef982..860258fd030 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -51,7 +51,7 @@ fn check_attrs(cx: &LateContext<'_>, name: Symbol, attrs: &[Attribute]) { cx, INLINE_FN_WITHOUT_BODY, attr.span, - &format!("use of `#[inline]` on trait method `{name}` which has no body"), + format!("use of `#[inline]` on trait method `{name}` which has no body"), |diag| { diag.suggest_remove_item(cx, attr.span, "remove", Applicability::MachineApplicable); }, diff --git a/clippy_lints/src/integer_division_remainder_used.rs b/clippy_lints/src/integer_division_remainder_used.rs index 36dc45ca788..a3577b765c0 100644 --- a/clippy_lints/src/integer_division_remainder_used.rs +++ b/clippy_lints/src/integer_division_remainder_used.rs @@ -43,7 +43,7 @@ impl LateLintPass<'_> for IntegerDivisionRemainderUsed { cx, INTEGER_DIVISION_REMAINDER_USED, expr.span.source_callsite(), - &format!("use of {} has been disallowed in this context", op.node.as_str()), + format!("use of {} has been disallowed in this context", op.node.as_str()), ); } } diff --git a/clippy_lints/src/invalid_upcast_comparisons.rs b/clippy_lints/src/invalid_upcast_comparisons.rs index 7dcb80ac274..30f2285bdd2 100644 --- a/clippy_lints/src/invalid_upcast_comparisons.rs +++ b/clippy_lints/src/invalid_upcast_comparisons.rs @@ -76,7 +76,7 @@ fn err_upcast_comparison(cx: &LateContext<'_>, span: Span, expr: &Expr<'_>, alwa cx, INVALID_UPCAST_COMPARISONS, span, - &format!( + format!( "because of the numeric bounds on `{}` prior to casting, this expression is always {}", snippet(cx, cast_val.span, "the expression"), if always { "true" } else { "false" }, diff --git a/clippy_lints/src/item_name_repetitions.rs b/clippy_lints/src/item_name_repetitions.rs index 0b4c416d94d..6615122567d 100644 --- a/clippy_lints/src/item_name_repetitions.rs +++ b/clippy_lints/src/item_name_repetitions.rs @@ -240,9 +240,9 @@ fn check_fields(cx: &LateContext<'_>, threshold: u64, item: &Item<'_>, fields: & cx, STRUCT_FIELD_NAMES, item.span, - &format!("all fields have the same {what}fix: `{value}`"), + format!("all fields have the same {what}fix: `{value}`"), None, - &format!("remove the {what}fixes"), + format!("remove the {what}fixes"), ); } } @@ -370,9 +370,9 @@ fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_n cx, ENUM_VARIANT_NAMES, span, - &format!("all variants have the same {what}fix: `{value}`"), + format!("all variants have the same {what}fix: `{value}`"), None, - &format!( + format!( "remove the {what}fixes and use full paths to \ the variants instead of glob imports" ), diff --git a/clippy_lints/src/iter_not_returning_iterator.rs b/clippy_lints/src/iter_not_returning_iterator.rs index 32ae6be5687..1b5f1b49947 100644 --- a/clippy_lints/src/iter_not_returning_iterator.rs +++ b/clippy_lints/src/iter_not_returning_iterator.rs @@ -84,7 +84,7 @@ fn check_sig(cx: &LateContext<'_>, name: &str, sig: &FnSig<'_>, fn_id: LocalDefI cx, ITER_NOT_RETURNING_ITERATOR, sig.span, - &format!("this method is named `{name}` but its return type does not implement `Iterator`"), + format!("this method is named `{name}` but its return type does not implement `Iterator`"), ); } } diff --git a/clippy_lints/src/iter_without_into_iter.rs b/clippy_lints/src/iter_without_into_iter.rs index b5821d909f8..1dd9b1515a9 100644 --- a/clippy_lints/src/iter_without_into_iter.rs +++ b/clippy_lints/src/iter_without_into_iter.rs @@ -182,7 +182,7 @@ impl LateLintPass<'_> for IterWithoutIntoIter { cx, INTO_ITER_WITHOUT_ITER, item.span, - &format!("`IntoIterator` implemented for a reference type without an `{expected_method_name}` method"), + format!("`IntoIterator` implemented for a reference type without an `{expected_method_name}` method"), |diag| { // The suggestion forwards to the `IntoIterator` impl and uses a form of UFCS // to avoid name ambiguities, as there might be an inherent into_iter method @@ -258,7 +258,7 @@ impl {self_ty_without_ref} {{ cx, ITER_WITHOUT_INTO_ITER, item.span, - &format!( + format!( "`{}` method without an `IntoIterator` impl for `{self_ty_snippet}`", item.ident ), diff --git a/clippy_lints/src/large_futures.rs b/clippy_lints/src/large_futures.rs index eb7570e9b44..07488a512a3 100644 --- a/clippy_lints/src/large_futures.rs +++ b/clippy_lints/src/large_futures.rs @@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeFuture { cx, LARGE_FUTURES, expr.span, - &format!("large future with a size of {} bytes", size.bytes()), + format!("large future with a size of {} bytes", size.bytes()), "consider `Box::pin` on it", format!("Box::pin({})", snippet(cx, expr.span, "..")), Applicability::Unspecified, diff --git a/clippy_lints/src/large_include_file.rs b/clippy_lints/src/large_include_file.rs index 1b5981ecc28..0599afca09f 100644 --- a/clippy_lints/src/large_include_file.rs +++ b/clippy_lints/src/large_include_file.rs @@ -74,7 +74,7 @@ impl LateLintPass<'_> for LargeIncludeFile { expr.span, "attempted to include a large file", None, - &format!( + format!( "the configuration allows a maximum size of {} bytes", self.max_file_size ), diff --git a/clippy_lints/src/large_stack_arrays.rs b/clippy_lints/src/large_stack_arrays.rs index fd33ba91bfd..afcb6745947 100644 --- a/clippy_lints/src/large_stack_arrays.rs +++ b/clippy_lints/src/large_stack_arrays.rs @@ -58,12 +58,12 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays { cx, LARGE_STACK_ARRAYS, expr.span, - &format!( + format!( "allocating a local array larger than {} bytes", self.maximum_allowed_size ), None, - &format!( + format!( "consider allocating on the heap with `vec!{}.into_boxed_slice()`", snippet(cx, expr.span, "[...]") ), diff --git a/clippy_lints/src/large_stack_frames.rs b/clippy_lints/src/large_stack_frames.rs index 059ba981ef3..49408d7e243 100644 --- a/clippy_lints/src/large_stack_frames.rs +++ b/clippy_lints/src/large_stack_frames.rs @@ -174,7 +174,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackFrames { cx, LARGE_STACK_FRAMES, fn_span, - &format!("this function may allocate {frame_size} on the stack"), + format!("this function may allocate {frame_size} on the stack"), |diag| { // Point out the largest individual contribution to this size, because // it is the most likely to be unintentionally large. diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 174b775f88b..ef52121ce3e 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -266,7 +266,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items cx, LEN_WITHOUT_IS_EMPTY, visited_trait.span, - &format!( + format!( "trait `{}` has a `len` method but no (possibly inherited) `is_empty` method", visited_trait.ident.name ), @@ -484,7 +484,7 @@ fn check_for_is_empty( Some(_) => return, }; - span_lint_and_then(cx, LEN_WITHOUT_IS_EMPTY, span, &msg, |db| { + span_lint_and_then(cx, LEN_WITHOUT_IS_EMPTY, span, msg, |db| { if let Some(span) = is_empty_span { db.span_note(span, "`is_empty` defined here"); } @@ -542,8 +542,8 @@ fn check_len( cx, LEN_ZERO, span, - &format!("length comparison to {}", if compare_to == 0 { "zero" } else { "one" }), - &format!("using `{op}is_empty` is clearer and more explicit"), + format!("length comparison to {}", if compare_to == 0 { "zero" } else { "one" }), + format!("using `{op}is_empty` is clearer and more explicit"), format!( "{op}{}.is_empty()", snippet_with_context(cx, receiver.span, span.ctxt(), "_", &mut applicability).0, @@ -566,7 +566,7 @@ fn check_empty_expr(cx: &LateContext<'_>, span: Span, lit1: &Expr<'_>, lit2: &Ex COMPARISON_TO_EMPTY, span, "comparison to empty slice", - &format!("using `{op}is_empty` is clearer and more explicit"), + format!("using `{op}is_empty` is clearer and more explicit"), format!("{op}{lit_str}.is_empty()"), applicability, ); diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 2b73663d229..a60a40a2a47 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -216,7 +216,7 @@ fn check_fn_inner<'tcx>( None })) .collect_vec(), - &format!("the following explicit lifetimes could be elided: {lts}"), + format!("the following explicit lifetimes could be elided: {lts}"), |diag| { if sig.header.is_async() { // async functions have usages whose spans point at the lifetime declaration which messes up diff --git a/clippy_lints/src/lines_filter_map_ok.rs b/clippy_lints/src/lines_filter_map_ok.rs index 29957e423b0..3d1c666dfea 100644 --- a/clippy_lints/src/lines_filter_map_ok.rs +++ b/clippy_lints/src/lines_filter_map_ok.rs @@ -70,7 +70,7 @@ impl LateLintPass<'_> for LinesFilterMapOk { cx, LINES_FILTER_MAP_OK, fm_span, - &format!("`{fm_method_str}()` will run forever if the iterator repeatedly produces an `Err`",), + format!("`{fm_method_str}()` will run forever if the iterator repeatedly produces an `Err`",), |diag| { diag.span_note( fm_receiver.span, diff --git a/clippy_lints/src/loops/explicit_counter_loop.rs b/clippy_lints/src/loops/explicit_counter_loop.rs index 277062a8490..f0ee64d714e 100644 --- a/clippy_lints/src/loops/explicit_counter_loop.rs +++ b/clippy_lints/src/loops/explicit_counter_loop.rs @@ -42,7 +42,7 @@ pub(super) fn check<'tcx>( cx, EXPLICIT_COUNTER_LOOP, span, - &format!("the variable `{name}` is used as a loop counter"), + format!("the variable `{name}` is used as a loop counter"), "consider using", format!( "for ({name}, {}) in {}.enumerate()", @@ -62,7 +62,7 @@ pub(super) fn check<'tcx>( cx, EXPLICIT_COUNTER_LOOP, span, - &format!("the variable `{name}` is used as a loop counter"), + format!("the variable `{name}` is used as a loop counter"), |diag| { diag.span_suggestion( span, diff --git a/clippy_lints/src/loops/for_kv_map.rs b/clippy_lints/src/loops/for_kv_map.rs index 94c951fc10a..6922533fbe9 100644 --- a/clippy_lints/src/loops/for_kv_map.rs +++ b/clippy_lints/src/loops/for_kv_map.rs @@ -37,7 +37,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx cx, FOR_KV_MAP, arg_span, - &format!("you seem to want to iterate on a map's {kind}s"), + format!("you seem to want to iterate on a map's {kind}s"), |diag| { let map = sugg::Sugg::hir(cx, arg, "map"); multispan_sugg( diff --git a/clippy_lints/src/loops/manual_flatten.rs b/clippy_lints/src/loops/manual_flatten.rs index 36de9021f49..dbc094a6d73 100644 --- a/clippy_lints/src/loops/manual_flatten.rs +++ b/clippy_lints/src/loops/manual_flatten.rs @@ -62,7 +62,7 @@ pub(super) fn check<'tcx>( "...and remove the `if let` statement in the for loop" }; - span_lint_and_then(cx, MANUAL_FLATTEN, span, &msg, |diag| { + span_lint_and_then(cx, MANUAL_FLATTEN, span, msg, |diag| { diag.span_suggestion(arg.span, "try", sugg, applicability); diag.span_help(inner_expr.span, help_msg); }); diff --git a/clippy_lints/src/loops/needless_range_loop.rs b/clippy_lints/src/loops/needless_range_loop.rs index 04340d33330..de7ec81bc01 100644 --- a/clippy_lints/src/loops/needless_range_loop.rs +++ b/clippy_lints/src/loops/needless_range_loop.rs @@ -143,7 +143,7 @@ pub(super) fn check<'tcx>( cx, NEEDLESS_RANGE_LOOP, arg.span, - &format!("the loop variable `{}` is used to index `{indexed}`", ident.name), + format!("the loop variable `{}` is used to index `{indexed}`", ident.name), |diag| { multispan_sugg( diag, @@ -169,7 +169,7 @@ pub(super) fn check<'tcx>( cx, NEEDLESS_RANGE_LOOP, arg.span, - &format!("the loop variable `{}` is only used to index `{indexed}`", ident.name), + format!("the loop variable `{}` is only used to index `{indexed}`", ident.name), |diag| { multispan_sugg( diag, diff --git a/clippy_lints/src/loops/same_item_push.rs b/clippy_lints/src/loops/same_item_push.rs index 0f35514b8ad..dd400a661a5 100644 --- a/clippy_lints/src/loops/same_item_push.rs +++ b/clippy_lints/src/loops/same_item_push.rs @@ -31,7 +31,7 @@ pub(super) fn check<'tcx>( vec.span, "it looks like the same item is being pushed into this Vec", None, - &format!("consider using vec![{item_str};SIZE] or {vec_str}.resize(NEW_SIZE, {item_str})"), + format!("consider using vec![{item_str};SIZE] or {vec_str}.resize(NEW_SIZE, {item_str})"), ); } diff --git a/clippy_lints/src/loops/single_element_loop.rs b/clippy_lints/src/loops/single_element_loop.rs index a1ff787ebb5..108fdb69775 100644 --- a/clippy_lints/src/loops/single_element_loop.rs +++ b/clippy_lints/src/loops/single_element_loop.rs @@ -95,7 +95,7 @@ pub(super) fn check<'tcx>( cx, SINGLE_ELEMENT_LOOP, arg.span, - format!("this loops only once with `{pat_snip}` being `{range_expr}`").as_str(), + format!("this loops only once with `{pat_snip}` being `{range_expr}`"), "did you mean to iterate over the range instead?", sugg.to_string(), Applicability::Unspecified, diff --git a/clippy_lints/src/main_recursion.rs b/clippy_lints/src/main_recursion.rs index a381b35cf2e..72807b4b284 100644 --- a/clippy_lints/src/main_recursion.rs +++ b/clippy_lints/src/main_recursion.rs @@ -51,7 +51,7 @@ impl LateLintPass<'_> for MainRecursion { cx, MAIN_RECURSION, func.span, - &format!("recursing into entrypoint `{}`", snippet(cx, func.span, "main")), + format!("recursing into entrypoint `{}`", snippet(cx, func.span, "main")), None, "consider using another function for this recursion", ); diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index bcd02436002..45af9f07718 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -106,12 +106,12 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip { cx, MANUAL_STRIP, strippings[0], - &format!("stripping a {kind_word} manually"), + format!("stripping a {kind_word} manually"), |diag| { diag.span_note(test_span, format!("the {kind_word} was tested here")); multispan_sugg( diag, - &format!("try using the `strip_{kind_word}` method"), + format!("try using the `strip_{kind_word}` method"), vec![( test_span, format!( diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index c9eab7109eb..9db04b615be 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -221,13 +221,13 @@ fn lint_map_unit_fn( binding = let_binding_name(cx, var_arg) ); - span_lint_and_then(cx, lint, expr.span, &msg, |diag| { + span_lint_and_then(cx, lint, expr.span, msg, |diag| { diag.span_suggestion(stmt.span, "try", suggestion, applicability); }); } else if let Some((binding, closure_expr)) = unit_closure(cx, fn_arg) { let msg = suggestion_msg("closure", map_type); - span_lint_and_then(cx, lint, expr.span, &msg, |diag| { + span_lint_and_then(cx, lint, expr.span, msg, |diag| { if let Some(reduced_expr_span) = reduce_unit_expression(cx, closure_expr) { let mut applicability = Applicability::MachineApplicable; let suggestion = format!( diff --git a/clippy_lints/src/match_result_ok.rs b/clippy_lints/src/match_result_ok.rs index 62cedc8847b..2a5fc8b6609 100644 --- a/clippy_lints/src/match_result_ok.rs +++ b/clippy_lints/src/match_result_ok.rs @@ -76,7 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for MatchResultOk { MATCH_RESULT_OK, expr.span.with_hi(let_expr.span.hi()), "matching on `Some` with `ok()` is redundant", - &format!("consider matching on `Ok({some_expr_string})` and removing the call to `ok` instead"), + format!("consider matching on `Ok({some_expr_string})` and removing the call to `ok` instead"), sugg, applicability, ); diff --git a/clippy_lints/src/matches/collapsible_match.rs b/clippy_lints/src/matches/collapsible_match.rs index 5fef5930fab..6746920edc5 100644 --- a/clippy_lints/src/matches/collapsible_match.rs +++ b/clippy_lints/src/matches/collapsible_match.rs @@ -97,7 +97,7 @@ fn check_arm<'tcx>( } else { String::new() }; - span_lint_and_then(cx, COLLAPSIBLE_MATCH, inner_expr.span, &msg, |diag| { + span_lint_and_then(cx, COLLAPSIBLE_MATCH, inner_expr.span, msg, |diag| { let mut help_span = MultiSpan::from_spans(vec![binding_span, inner_then_pat.span]); help_span.push_span_label(binding_span, "replace this binding"); help_span.push_span_label(inner_then_pat.span, format!("with this pattern{replace_msg}")); diff --git a/clippy_lints/src/matches/manual_unwrap_or.rs b/clippy_lints/src/matches/manual_unwrap_or.rs index 3e79cabd795..9edd6c95404 100644 --- a/clippy_lints/src/matches/manual_unwrap_or.rs +++ b/clippy_lints/src/matches/manual_unwrap_or.rs @@ -34,7 +34,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, scrutinee: cx, MANUAL_UNWRAP_OR, expr.span, - &format!("this pattern reimplements `{ty_name}::unwrap_or`"), + format!("this pattern reimplements `{ty_name}::unwrap_or`"), "replace with", format!("{suggestion}.unwrap_or({reindented_or_body})",), app, diff --git a/clippy_lints/src/matches/match_as_ref.rs b/clippy_lints/src/matches/match_as_ref.rs index 3f737da92c0..a5079f46f5e 100644 --- a/clippy_lints/src/matches/match_as_ref.rs +++ b/clippy_lints/src/matches/match_as_ref.rs @@ -43,7 +43,7 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: cx, MATCH_AS_REF, expr.span, - &format!("use `{suggestion}()` instead"), + format!("use `{suggestion}()` instead"), "try", format!( "{}.{suggestion}(){cast}", diff --git a/clippy_lints/src/matches/match_like_matches.rs b/clippy_lints/src/matches/match_like_matches.rs index b062e81cefd..64cb7a06ce9 100644 --- a/clippy_lints/src/matches/match_like_matches.rs +++ b/clippy_lints/src/matches/match_like_matches.rs @@ -122,7 +122,7 @@ where cx, MATCH_LIKE_MATCHES_MACRO, expr.span, - &format!( + format!( "{} expression looks like `matches!` macro", if is_if_let { "if let .. else" } else { "match" } ), diff --git a/clippy_lints/src/matches/match_str_case_mismatch.rs b/clippy_lints/src/matches/match_str_case_mismatch.rs index bd38648bcf1..322e9c3ebe5 100644 --- a/clippy_lints/src/matches/match_str_case_mismatch.rs +++ b/clippy_lints/src/matches/match_str_case_mismatch.rs @@ -111,7 +111,7 @@ fn lint(cx: &LateContext<'_>, case_method: &CaseMethod, bad_case_span: Span, bad MATCH_STR_CASE_MISMATCH, bad_case_span, "this `match` arm has a differing case than its expression", - &format!("consider changing the case of this arm to respect `{method_str}`"), + format!("consider changing the case of this arm to respect `{method_str}`"), format!("\"{suggestion}\""), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/matches/match_wild_err_arm.rs b/clippy_lints/src/matches/match_wild_err_arm.rs index 8a4c0ab9062..d1f637ec78c 100644 --- a/clippy_lints/src/matches/match_wild_err_arm.rs +++ b/clippy_lints/src/matches/match_wild_err_arm.rs @@ -43,7 +43,7 @@ pub(crate) fn check<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm<' cx, MATCH_WILD_ERR_ARM, arm.pat.span, - &format!("`Err({ident_bind_name})` matches all errors"), + format!("`Err({ident_bind_name})` matches all errors"), None, "match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable", ); diff --git a/clippy_lints/src/matches/redundant_pattern_match.rs b/clippy_lints/src/matches/redundant_pattern_match.rs index b5870d94d99..78973984fb0 100644 --- a/clippy_lints/src/matches/redundant_pattern_match.rs +++ b/clippy_lints/src/matches/redundant_pattern_match.rs @@ -72,7 +72,7 @@ fn find_match_true<'tcx>( pat: &'tcx Pat<'_>, scrutinee: &'tcx Expr<'_>, span: Span, - message: &str, + message: &'static str, ) { if let PatKind::Lit(lit) = pat.kind && let ExprKind::Lit(lit) = lit.kind @@ -98,7 +98,7 @@ fn find_match_true<'tcx>( span, message, "consider using the condition directly", - sugg.to_string(), + sugg.into_string(), applicability, ); } @@ -227,7 +227,7 @@ fn find_method_sugg_for_if_let<'tcx>( cx, REDUNDANT_PATTERN_MATCHING, let_pat.span, - &format!("redundant pattern matching, consider using `{good_method}`"), + format!("redundant pattern matching, consider using `{good_method}`"), |diag| { // if/while let ... = ... { ... } // ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -304,7 +304,7 @@ pub(super) fn check_match<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, op cx, REDUNDANT_PATTERN_MATCHING, span, - &format!("redundant pattern matching, consider using `{good_method}`"), + format!("redundant pattern matching, consider using `{good_method}`"), "try", sugg, Applicability::MachineApplicable, diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index 1cdb7921f81..578aa7989e7 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -193,7 +193,7 @@ fn check_replace_with_default(cx: &LateContext<'_>, src: &Expr<'_>, dest: &Expr< cx, MEM_REPLACE_WITH_DEFAULT, expr_span, - &format!( + format!( "replacing a value of type `T` with `T::default()` is better expressed using `{top_crate}::mem::take`" ), |diag| { diff --git a/clippy_lints/src/methods/bind_instead_of_map.rs b/clippy_lints/src/methods/bind_instead_of_map.rs index 08bfa2e009b..fb440ce656e 100644 --- a/clippy_lints/src/methods/bind_instead_of_map.rs +++ b/clippy_lints/src/methods/bind_instead_of_map.rs @@ -84,7 +84,7 @@ pub(crate) trait BindInsteadOfMap { "{option_snip}.{}({closure_args_snip} {some_inner_snip})", Self::GOOD_METHOD_NAME ); - span_lint_and_sugg(cx, BIND_INSTEAD_OF_MAP, expr.span, &msg, "try", note, app); + span_lint_and_sugg(cx, BIND_INSTEAD_OF_MAP, expr.span, msg, "try", note, app); true } else { false @@ -114,7 +114,7 @@ pub(crate) trait BindInsteadOfMap { } else { return false; }; - span_lint_and_then(cx, BIND_INSTEAD_OF_MAP, expr.span, &msg, |diag| { + span_lint_and_then(cx, BIND_INSTEAD_OF_MAP, expr.span, msg, |diag| { multispan_sugg_with_applicability( diag, "try", @@ -157,7 +157,7 @@ pub(crate) trait BindInsteadOfMap { cx, BIND_INSTEAD_OF_MAP, expr.span, - &msg, + msg, "use the expression directly", snippet(cx, recv.span, "..").into(), Applicability::MachineApplicable, diff --git a/clippy_lints/src/methods/bytes_nth.rs b/clippy_lints/src/methods/bytes_nth.rs index baafb7030aa..a82abc79f2a 100644 --- a/clippy_lints/src/methods/bytes_nth.rs +++ b/clippy_lints/src/methods/bytes_nth.rs @@ -31,7 +31,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx E cx, BYTES_NTH, parent.span, - &format!("called `.bytes().nth().unwrap()` on a `{caller_type}`"), + format!("called `.bytes().nth().unwrap()` on a `{caller_type}`"), "try", format!("{receiver}.as_bytes()[{n}]",), applicability, @@ -41,7 +41,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx E cx, BYTES_NTH, expr.span, - &format!("called `.bytes().nth()` on a `{caller_type}`"), + format!("called `.bytes().nth()` on a `{caller_type}`"), "try", format!("{receiver}.as_bytes().get({n}).copied()"), applicability, diff --git a/clippy_lints/src/methods/chars_cmp.rs b/clippy_lints/src/methods/chars_cmp.rs index c99cec067bf..4ae0aeea2d1 100644 --- a/clippy_lints/src/methods/chars_cmp.rs +++ b/clippy_lints/src/methods/chars_cmp.rs @@ -30,7 +30,7 @@ pub(super) fn check( cx, lint, info.expr.span, - &format!("you should use the `{suggest}` method"), + format!("you should use the `{suggest}` method"), "like this", format!( "{}{}.{suggest}({})", diff --git a/clippy_lints/src/methods/chars_cmp_with_unwrap.rs b/clippy_lints/src/methods/chars_cmp_with_unwrap.rs index d07e45434a7..9c45ec2e56c 100644 --- a/clippy_lints/src/methods/chars_cmp_with_unwrap.rs +++ b/clippy_lints/src/methods/chars_cmp_with_unwrap.rs @@ -23,7 +23,7 @@ pub(super) fn check( cx, lint, info.expr.span, - &format!("you should use the `{suggest}` method"), + format!("you should use the `{suggest}` method"), "like this", format!( "{}{}.{suggest}('{}')", diff --git a/clippy_lints/src/methods/clear_with_drain.rs b/clippy_lints/src/methods/clear_with_drain.rs index 506ec6ba1c9..5389861245a 100644 --- a/clippy_lints/src/methods/clear_with_drain.rs +++ b/clippy_lints/src/methods/clear_with_drain.rs @@ -43,7 +43,7 @@ fn suggest(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, span: Span) { cx, CLEAR_WITH_DRAIN, span.with_hi(expr.span.hi()), - &format!("`drain` used to clear a `{ty_name}`"), + format!("`drain` used to clear a `{ty_name}`"), "try", "clear()".to_string(), Applicability::MachineApplicable, diff --git a/clippy_lints/src/methods/clone_on_copy.rs b/clippy_lints/src/methods/clone_on_copy.rs index fb5c0c544a9..4965b396b8c 100644 --- a/clippy_lints/src/methods/clone_on_copy.rs +++ b/clippy_lints/src/methods/clone_on_copy.rs @@ -94,7 +94,7 @@ pub(super) fn check( cx, CLONE_ON_COPY, expr.span, - &with_forced_trimmed_paths!(format!( + with_forced_trimmed_paths!(format!( "using `clone` on type `{ty}` which implements the `Copy` trait" )), help, diff --git a/clippy_lints/src/methods/drain_collect.rs b/clippy_lints/src/methods/drain_collect.rs index 3a8ca37610a..56171a13452 100644 --- a/clippy_lints/src/methods/drain_collect.rs +++ b/clippy_lints/src/methods/drain_collect.rs @@ -70,7 +70,7 @@ pub(super) fn check(cx: &LateContext<'_>, args: &[Expr<'_>], expr: &Expr<'_>, re cx, DRAIN_COLLECT, expr.span, - &format!("you seem to be trying to move all elements into a new `{typename}`"), + format!("you seem to be trying to move all elements into a new `{typename}`"), "consider using `mem::take`", sugg, Applicability::MachineApplicable, diff --git a/clippy_lints/src/methods/expect_fun_call.rs b/clippy_lints/src/methods/expect_fun_call.rs index 4d8fb217f7f..fba76852344 100644 --- a/clippy_lints/src/methods/expect_fun_call.rs +++ b/clippy_lints/src/methods/expect_fun_call.rs @@ -142,7 +142,7 @@ pub(super) fn check<'tcx>( cx, EXPECT_FUN_CALL, span_replace_word, - &format!("use of `{name}` followed by a function call"), + format!("use of `{name}` followed by a function call"), "try", format!("unwrap_or_else({closure_args} panic!({sugg}))"), applicability, @@ -160,7 +160,7 @@ pub(super) fn check<'tcx>( cx, EXPECT_FUN_CALL, span_replace_word, - &format!("use of `{name}` followed by a function call"), + format!("use of `{name}` followed by a function call"), "try", format!("unwrap_or_else({closure_args} {{ panic!(\"{{}}\", {arg_root_snippet}) }})"), applicability, diff --git a/clippy_lints/src/methods/filetype_is_file.rs b/clippy_lints/src/methods/filetype_is_file.rs index b05361ab212..eab536b88a5 100644 --- a/clippy_lints/src/methods/filetype_is_file.rs +++ b/clippy_lints/src/methods/filetype_is_file.rs @@ -34,5 +34,5 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr } let lint_msg = format!("`{lint_unary}FileType::is_file()` only {verb} regular files"); let help_msg = format!("use `{help_unary}FileType::is_dir()` instead"); - span_lint_and_help(cx, FILETYPE_IS_FILE, span, &lint_msg, None, &help_msg); + span_lint_and_help(cx, FILETYPE_IS_FILE, span, lint_msg, None, help_msg); } diff --git a/clippy_lints/src/methods/filter_map.rs b/clippy_lints/src/methods/filter_map.rs index 83dcc90637e..581e3b308c3 100644 --- a/clippy_lints/src/methods/filter_map.rs +++ b/clippy_lints/src/methods/filter_map.rs @@ -386,7 +386,7 @@ pub(super) fn check( ) }, }; - span_lint_and_then(cx, lint, span, &msg, |diag| { + span_lint_and_then(cx, lint, span, msg, |diag| { diag.span_suggestion(span, "try", sugg, applicability); if let Some((note, span)) = note_and_span { diff --git a/clippy_lints/src/methods/get_first.rs b/clippy_lints/src/methods/get_first.rs index 55fcf372894..f4465e654c2 100644 --- a/clippy_lints/src/methods/get_first.rs +++ b/clippy_lints/src/methods/get_first.rs @@ -32,7 +32,7 @@ pub(super) fn check<'tcx>( cx, GET_FIRST, expr.span, - &format!("accessing first element with `{slice_name}.get(0)`"), + format!("accessing first element with `{slice_name}.get(0)`"), "try", format!("{slice_name}.first()"), app, @@ -44,7 +44,7 @@ pub(super) fn check<'tcx>( cx, GET_FIRST, expr.span, - &format!("accessing first element with `{slice_name}.get(0)`"), + format!("accessing first element with `{slice_name}.get(0)`"), "try", format!("{slice_name}.front()"), app, diff --git a/clippy_lints/src/methods/get_last_with_len.rs b/clippy_lints/src/methods/get_last_with_len.rs index 3bdc154df04..62037651134 100644 --- a/clippy_lints/src/methods/get_last_with_len.rs +++ b/clippy_lints/src/methods/get_last_with_len.rs @@ -44,7 +44,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg: cx, GET_LAST_WITH_LEN, expr.span, - &format!("accessing last element with `{recv_snippet}.get({recv_snippet}.len() - 1)`"), + format!("accessing last element with `{recv_snippet}.get({recv_snippet}.len() - 1)`"), "try", format!("{recv_snippet}.{method}()"), applicability, diff --git a/clippy_lints/src/methods/get_unwrap.rs b/clippy_lints/src/methods/get_unwrap.rs index afdcb3b6549..455274a4428 100644 --- a/clippy_lints/src/methods/get_unwrap.rs +++ b/clippy_lints/src/methods/get_unwrap.rs @@ -70,7 +70,7 @@ pub(super) fn check<'tcx>( cx, GET_UNWRAP, span, - &format!("called `.get{mut_str}().unwrap()` on a {caller_type}. Using `[]` is more clear and more concise"), + format!("called `.get{mut_str}().unwrap()` on a {caller_type}. Using `[]` is more clear and more concise"), "try", format!( "{borrow_str}{}[{get_args_str}]", diff --git a/clippy_lints/src/methods/implicit_clone.rs b/clippy_lints/src/methods/implicit_clone.rs index 78a553eb8c0..c510cd915d0 100644 --- a/clippy_lints/src/methods/implicit_clone.rs +++ b/clippy_lints/src/methods/implicit_clone.rs @@ -27,7 +27,7 @@ pub fn check(cx: &LateContext<'_>, method_name: &str, expr: &hir::Expr<'_>, recv cx, IMPLICIT_CLONE, expr.span, - &format!("implicitly cloning a `{ty_name}` by calling `{method_name}` on its dereferenced type"), + format!("implicitly cloning a `{ty_name}` by calling `{method_name}` on its dereferenced type"), "consider using", if ref_count > 1 { format!("({}{recv_snip}).clone()", "*".repeat(ref_count - 1)) diff --git a/clippy_lints/src/methods/inefficient_to_string.rs b/clippy_lints/src/methods/inefficient_to_string.rs index efc3ddd20b4..230a8eb2ec4 100644 --- a/clippy_lints/src/methods/inefficient_to_string.rs +++ b/clippy_lints/src/methods/inefficient_to_string.rs @@ -32,7 +32,7 @@ pub fn check( cx, INEFFICIENT_TO_STRING, expr.span, - &format!("calling `to_string` on `{arg_ty}`"), + format!("calling `to_string` on `{arg_ty}`"), |diag| { diag.help(format!( "`{self_ty}` implements `ToString` through a slower blanket impl, but `{deref_self_ty}` has a fast specialization of `ToString`" diff --git a/clippy_lints/src/methods/into_iter_on_ref.rs b/clippy_lints/src/methods/into_iter_on_ref.rs index 80160d17c82..bbc7ce8d78a 100644 --- a/clippy_lints/src/methods/into_iter_on_ref.rs +++ b/clippy_lints/src/methods/into_iter_on_ref.rs @@ -27,7 +27,7 @@ pub(super) fn check( cx, INTO_ITER_ON_REF, method_span, - &format!("this `.into_iter()` call is equivalent to `.{method_name}()` and will not consume the `{kind}`",), + format!("this `.into_iter()` call is equivalent to `.{method_name}()` and will not consume the `{kind}`",), "call directly", method_name.to_string(), Applicability::MachineApplicable, diff --git a/clippy_lints/src/methods/is_digit_ascii_radix.rs b/clippy_lints/src/methods/is_digit_ascii_radix.rs index e963950960a..210e4ae0a7b 100644 --- a/clippy_lints/src/methods/is_digit_ascii_radix.rs +++ b/clippy_lints/src/methods/is_digit_ascii_radix.rs @@ -36,7 +36,7 @@ pub(super) fn check<'tcx>( cx, IS_DIGIT_ASCII_RADIX, expr.span, - &format!("use of `char::is_digit` with literal radix of {num}"), + format!("use of `char::is_digit` with literal radix of {num}"), "try", format!( "{}.{replacement}()", diff --git a/clippy_lints/src/methods/is_empty.rs b/clippy_lints/src/methods/is_empty.rs index 7fe66062251..d921b7ea14f 100644 --- a/clippy_lints/src/methods/is_empty.rs +++ b/clippy_lints/src/methods/is_empty.rs @@ -23,7 +23,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, receiver: &Expr<'_ cx, CONST_IS_EMPTY, expr.span, - &format!("this expression always evaluates to {init_is_empty:?}"), + format!("this expression always evaluates to {init_is_empty:?}"), ); } } diff --git a/clippy_lints/src/methods/iter_cloned_collect.rs b/clippy_lints/src/methods/iter_cloned_collect.rs index dd741cd43f9..49de83885a1 100644 --- a/clippy_lints/src/methods/iter_cloned_collect.rs +++ b/clippy_lints/src/methods/iter_cloned_collect.rs @@ -17,7 +17,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, method_name: &str, expr: &hir: cx, ITER_CLONED_COLLECT, to_replace, - &format!( + format!( "called `iter().{method_name}().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and \ more readable" ), diff --git a/clippy_lints/src/methods/iter_count.rs b/clippy_lints/src/methods/iter_count.rs index bcddc7c786a..209cf2fcc0a 100644 --- a/clippy_lints/src/methods/iter_count.rs +++ b/clippy_lints/src/methods/iter_count.rs @@ -37,7 +37,7 @@ pub(crate) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, recv: &'tcx E cx, ITER_COUNT, expr.span, - &format!("called `.{iter_method}().count()` on a `{caller_type}`"), + format!("called `.{iter_method}().count()` on a `{caller_type}`"), "try", format!( "{}.len()", diff --git a/clippy_lints/src/methods/iter_kv_map.rs b/clippy_lints/src/methods/iter_kv_map.rs index 6394f35f860..84fa4c03757 100644 --- a/clippy_lints/src/methods/iter_kv_map.rs +++ b/clippy_lints/src/methods/iter_kv_map.rs @@ -54,7 +54,7 @@ pub(super) fn check<'tcx>( cx, ITER_KV_MAP, expr.span, - &format!("iterating on a map's {replacement_kind}s"), + format!("iterating on a map's {replacement_kind}s"), "try", format!("{recv_snippet}.{into_prefix}{replacement_kind}s()"), applicability, @@ -66,7 +66,7 @@ pub(super) fn check<'tcx>( cx, ITER_KV_MAP, expr.span, - &format!("iterating on a map's {replacement_kind}s"), + format!("iterating on a map's {replacement_kind}s"), "try", format!( "{recv_snippet}.{into_prefix}{replacement_kind}s().map(|{ref_annotation}{mut_annotation}{bound_ident}| {})", diff --git a/clippy_lints/src/methods/iter_nth.rs b/clippy_lints/src/methods/iter_nth.rs index 5b0b70b4b96..e31fa2f777d 100644 --- a/clippy_lints/src/methods/iter_nth.rs +++ b/clippy_lints/src/methods/iter_nth.rs @@ -28,7 +28,7 @@ pub(super) fn check<'tcx>( cx, ITER_NTH, expr.span, - &format!("called `.{iter_method}().nth()` on a {caller_type}"), + format!("called `.{iter_method}().nth()` on a {caller_type}"), |diag| { let get_method = if iter_method == "iter_mut" { "get_mut" } else { "get" }; diag.span_suggestion_verbose( diff --git a/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs b/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs index 4c7c56e7174..2c789827f80 100644 --- a/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs +++ b/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs @@ -69,7 +69,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: &str, re cx, ITER_ON_SINGLE_ITEMS, expr.span, - &format!("`{method_name}` call on a collection with only one item"), + format!("`{method_name}` call on a collection with only one item"), "try", sugg, Applicability::MaybeIncorrect, @@ -79,7 +79,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: &str, re cx, ITER_ON_EMPTY_COLLECTIONS, expr.span, - &format!("`{method_name}` call on an empty collection"), + format!("`{method_name}` call on an empty collection"), "try", format!("{top_crate}::iter::empty()"), Applicability::MaybeIncorrect, diff --git a/clippy_lints/src/methods/iter_with_drain.rs b/clippy_lints/src/methods/iter_with_drain.rs index 2ab721ace84..1378a07cbc4 100644 --- a/clippy_lints/src/methods/iter_with_drain.rs +++ b/clippy_lints/src/methods/iter_with_drain.rs @@ -20,7 +20,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, span cx, ITER_WITH_DRAIN, span.with_hi(expr.span.hi()), - &format!("`drain(..)` used on a `{ty_name}`"), + format!("`drain(..)` used on a `{ty_name}`"), "try", "into_iter()".to_string(), Applicability::MaybeIncorrect, diff --git a/clippy_lints/src/methods/manual_saturating_arithmetic.rs b/clippy_lints/src/methods/manual_saturating_arithmetic.rs index bf437db7e72..9e3b313156e 100644 --- a/clippy_lints/src/methods/manual_saturating_arithmetic.rs +++ b/clippy_lints/src/methods/manual_saturating_arithmetic.rs @@ -50,7 +50,7 @@ pub fn check( super::MANUAL_SATURATING_ARITHMETIC, expr.span, "manual saturating arithmetic", - &format!("consider using `saturating_{arith}`"), + format!("consider using `saturating_{arith}`"), format!( "{}.saturating_{arith}({})", snippet_with_applicability(cx, arith_lhs.span, "..", &mut applicability), diff --git a/clippy_lints/src/methods/map_clone.rs b/clippy_lints/src/methods/map_clone.rs index 9d020092ccb..0901268e9bd 100644 --- a/clippy_lints/src/methods/map_clone.rs +++ b/clippy_lints/src/methods/map_clone.rs @@ -161,7 +161,7 @@ fn lint_path(cx: &LateContext<'_>, replace: Span, root: Span, is_copy: bool) { MAP_CLONE, replace, "you are explicitly cloning with `.map()`", - &format!("consider calling the dedicated `{replacement}` method"), + format!("consider calling the dedicated `{replacement}` method"), format!( "{}.{replacement}()", snippet_with_applicability(cx, root, "..", &mut applicability), @@ -184,7 +184,7 @@ fn lint_explicit_closure(cx: &LateContext<'_>, replace: Span, root: Span, is_cop MAP_CLONE, replace, message, - &format!("consider calling the dedicated `{sugg_method}` method"), + format!("consider calling the dedicated `{sugg_method}` method"), format!( "{}.{sugg_method}()", snippet_with_applicability(cx, root, "..", &mut applicability), diff --git a/clippy_lints/src/methods/map_flatten.rs b/clippy_lints/src/methods/map_flatten.rs index 26ef0d10fed..def8be2ef73 100644 --- a/clippy_lints/src/methods/map_flatten.rs +++ b/clippy_lints/src/methods/map_flatten.rs @@ -21,8 +21,8 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, map_ cx, MAP_FLATTEN, expr.span.with_lo(map_span.lo()), - &format!("called `map(..).flatten()` on `{caller_ty_name}`"), - &format!("try replacing `map` with `{method_to_use}` and remove the `.flatten()`"), + format!("called `map(..).flatten()` on `{caller_ty_name}`"), + format!("try replacing `map` with `{method_to_use}` and remove the `.flatten()`"), format!("{method_to_use}({closure_snippet})"), applicability, ); diff --git a/clippy_lints/src/methods/map_identity.rs b/clippy_lints/src/methods/map_identity.rs index 6da9a87f5ee..5dd7b1b02ad 100644 --- a/clippy_lints/src/methods/map_identity.rs +++ b/clippy_lints/src/methods/map_identity.rs @@ -29,7 +29,7 @@ pub(super) fn check( MAP_IDENTITY, sugg_span, "unnecessary map of the identity function", - &format!("remove the call to `{name}`"), + format!("remove the call to `{name}`"), String::new(), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 3ad92a91ea7..2fb317c8c68 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -4333,12 +4333,12 @@ impl<'tcx> LateLintPass<'tcx> for Methods { cx, SHOULD_IMPLEMENT_TRAIT, impl_item.span, - &format!( + format!( "method `{}` can be confused for the standard trait method `{}::{}`", method_config.method_name, method_config.trait_name, method_config.method_name ), None, - &format!( + format!( "consider implementing the trait `{}` or choosing a less ambiguous method name", method_config.trait_name ), diff --git a/clippy_lints/src/methods/open_options.rs b/clippy_lints/src/methods/open_options.rs index 77484ab91a9..d425b505a76 100644 --- a/clippy_lints/src/methods/open_options.rs +++ b/clippy_lints/src/methods/open_options.rs @@ -151,7 +151,7 @@ fn check_open_options(cx: &LateContext<'_>, settings: &[(OpenOption, Argument, S cx, NONSENSICAL_OPEN_OPTIONS, prev_span, - &format!("the method `{}` is called more than once", &option), + format!("the method `{}` is called more than once", &option), ); } } diff --git a/clippy_lints/src/methods/option_as_ref_cloned.rs b/clippy_lints/src/methods/option_as_ref_cloned.rs index d7fec360fa2..ba167f9d9c2 100644 --- a/clippy_lints/src/methods/option_as_ref_cloned.rs +++ b/clippy_lints/src/methods/option_as_ref_cloned.rs @@ -15,7 +15,7 @@ pub(super) fn check(cx: &LateContext<'_>, cloned_recv: &Expr<'_>, cloned_ident_s cx, OPTION_AS_REF_CLONED, as_ref_ident_span.to(cloned_ident_span), - &format!("cloning an `Option<_>` using `.{method}().cloned()`"), + format!("cloning an `Option<_>` using `.{method}().cloned()`"), "this can be written more concisely by cloning the `Option<_>` directly", "clone".into(), Applicability::MachineApplicable, diff --git a/clippy_lints/src/methods/option_as_ref_deref.rs b/clippy_lints/src/methods/option_as_ref_deref.rs index 88e2af15658..cb57689b0c4 100644 --- a/clippy_lints/src/methods/option_as_ref_deref.rs +++ b/clippy_lints/src/methods/option_as_ref_deref.rs @@ -104,8 +104,8 @@ pub(super) fn check( cx, OPTION_AS_REF_DEREF, expr.span, - &msg, - &suggestion, + msg, + suggestion, hint, Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs index ab36f854fcb..efec9dd716d 100644 --- a/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -97,7 +97,7 @@ pub(super) fn check<'tcx>( } else { "map_or(, )" }; - let msg = &format!("called `map().unwrap_or({arg})` on an `Option` value"); + let msg = format!("called `map().unwrap_or({arg})` on an `Option` value"); span_lint_and_then(cx, MAP_UNWRAP_OR, expr.span, msg, |diag| { let map_arg_span = map_arg.span; diff --git a/clippy_lints/src/methods/or_fun_call.rs b/clippy_lints/src/methods/or_fun_call.rs index 0602eeaa704..583e04fb4b1 100644 --- a/clippy_lints/src/methods/or_fun_call.rs +++ b/clippy_lints/src/methods/or_fun_call.rs @@ -97,7 +97,7 @@ pub(super) fn check<'tcx>( cx, UNWRAP_OR_DEFAULT, method_span.with_hi(span.hi()), - &format!("use of `{name}` to construct default value"), + format!("use of `{name}` to construct default value"), "try", format!("{sugg}()"), Applicability::MachineApplicable, @@ -167,7 +167,7 @@ pub(super) fn check<'tcx>( cx, OR_FUN_CALL, span_replace_word, - &format!("use of `{name}` followed by a function call"), + format!("use of `{name}` followed by a function call"), "try", format!("{name}_{suffix}({sugg})"), app, diff --git a/clippy_lints/src/methods/range_zip_with_len.rs b/clippy_lints/src/methods/range_zip_with_len.rs index 1148628b084..28ca76832eb 100644 --- a/clippy_lints/src/methods/range_zip_with_len.rs +++ b/clippy_lints/src/methods/range_zip_with_len.rs @@ -24,7 +24,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, recv: &' cx, RANGE_ZIP_WITH_LEN, expr.span, - &format!( + format!( "it is more idiomatic to use `{}.iter().enumerate()`", snippet(cx, recv.span, "_") ), diff --git a/clippy_lints/src/methods/search_is_some.rs b/clippy_lints/src/methods/search_is_some.rs index 0c3b881b086..ac5cc2f01e5 100644 --- a/clippy_lints/src/methods/search_is_some.rs +++ b/clippy_lints/src/methods/search_is_some.rs @@ -62,7 +62,7 @@ pub(super) fn check<'tcx>( cx, SEARCH_IS_SOME, method_span.with_hi(expr.span.hi()), - &msg, + msg, "consider using", format!( "any({})", @@ -76,7 +76,7 @@ pub(super) fn check<'tcx>( cx, SEARCH_IS_SOME, expr.span, - &msg, + msg, "consider using", format!( "!{iter}.any({})", @@ -94,7 +94,7 @@ pub(super) fn check<'tcx>( "" } ); - span_lint_and_help(cx, SEARCH_IS_SOME, expr.span, &msg, None, &hint); + span_lint_and_help(cx, SEARCH_IS_SOME, expr.span, msg, None, hint); } } // lint if `find()` is called by `String` or `&str` @@ -117,7 +117,7 @@ pub(super) fn check<'tcx>( cx, SEARCH_IS_SOME, method_span.with_hi(expr.span.hi()), - &msg, + msg, "consider using", format!("contains({find_arg})"), applicability, @@ -131,7 +131,7 @@ pub(super) fn check<'tcx>( cx, SEARCH_IS_SOME, expr.span, - &msg, + msg, "consider using", format!("!{string}.contains({find_arg})"), applicability, diff --git a/clippy_lints/src/methods/stable_sort_primitive.rs b/clippy_lints/src/methods/stable_sort_primitive.rs index 0f4c97022db..aef14435d8a 100644 --- a/clippy_lints/src/methods/stable_sort_primitive.rs +++ b/clippy_lints/src/methods/stable_sort_primitive.rs @@ -17,7 +17,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, recv: &'tcx cx, STABLE_SORT_PRIMITIVE, e.span, - &format!("used `sort` on primitive type `{slice_type}`"), + format!("used `sort` on primitive type `{slice_type}`"), |diag| { let mut app = Applicability::MachineApplicable; let recv_snip = snippet_with_context(cx, recv.span, e.span.ctxt(), "..", &mut app).0; diff --git a/clippy_lints/src/methods/str_splitn.rs b/clippy_lints/src/methods/str_splitn.rs index 55cd1a38ec9..955330237bf 100644 --- a/clippy_lints/src/methods/str_splitn.rs +++ b/clippy_lints/src/methods/str_splitn.rs @@ -53,7 +53,7 @@ fn lint_needless(cx: &LateContext<'_>, method_name: &str, expr: &Expr<'_>, self_ cx, NEEDLESS_SPLITN, expr.span, - &format!("unnecessary use of `{r}splitn`"), + format!("unnecessary use of `{r}splitn`"), "try", format!( "{}.{r}split({})", @@ -154,7 +154,7 @@ fn check_manual_split_once_indirect( let self_snip = snippet_with_context(cx, self_arg.span, ctxt, "..", &mut app).0; let pat_snip = snippet_with_context(cx, pat_arg.span, ctxt, "..", &mut app).0; - span_lint_and_then(cx, MANUAL_SPLIT_ONCE, local.span, &msg, |diag| { + span_lint_and_then(cx, MANUAL_SPLIT_ONCE, local.span, msg, |diag| { diag.span_label(first.span, "first usage here"); diag.span_label(second.span, "second usage here"); diff --git a/clippy_lints/src/methods/suspicious_splitn.rs b/clippy_lints/src/methods/suspicious_splitn.rs index c45212581ee..ff5c1d1a401 100644 --- a/clippy_lints/src/methods/suspicious_splitn.rs +++ b/clippy_lints/src/methods/suspicious_splitn.rs @@ -37,6 +37,6 @@ pub(super) fn check(cx: &LateContext<'_>, method_name: &str, expr: &Expr<'_>, se ) }; - span_lint_and_note(cx, SUSPICIOUS_SPLITN, expr.span, &msg, None, note_msg); + span_lint_and_note(cx, SUSPICIOUS_SPLITN, expr.span, msg, None, note_msg); } } diff --git a/clippy_lints/src/methods/suspicious_to_owned.rs b/clippy_lints/src/methods/suspicious_to_owned.rs index 60864902a48..ce7aefed01f 100644 --- a/clippy_lints/src/methods/suspicious_to_owned.rs +++ b/clippy_lints/src/methods/suspicious_to_owned.rs @@ -23,7 +23,7 @@ pub fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>) - cx, SUSPICIOUS_TO_OWNED, expr.span, - &with_forced_trimmed_paths!(format!( + with_forced_trimmed_paths!(format!( "this `to_owned` call clones the {input_type} itself and does not cause the {input_type} contents to become owned" )), |diag| { diff --git a/clippy_lints/src/methods/type_id_on_box.rs b/clippy_lints/src/methods/type_id_on_box.rs index 31e6ccb950a..6f9b38fcf83 100644 --- a/clippy_lints/src/methods/type_id_on_box.rs +++ b/clippy_lints/src/methods/type_id_on_box.rs @@ -55,7 +55,7 @@ pub(super) fn check(cx: &LateContext<'_>, receiver: &Expr<'_>, call_span: Span) cx, TYPE_ID_ON_BOX, call_span, - &format!("calling `.type_id()` on `{ty_name}`"), + format!("calling `.type_id()` on `{ty_name}`"), |diag| { let derefs = recv_adjusts .iter() diff --git a/clippy_lints/src/methods/unnecessary_filter_map.rs b/clippy_lints/src/methods/unnecessary_filter_map.rs index fabf3fa0c0c..daf99d98614 100644 --- a/clippy_lints/src/methods/unnecessary_filter_map.rs +++ b/clippy_lints/src/methods/unnecessary_filter_map.rs @@ -60,7 +60,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>, a UNNECESSARY_FIND_MAP }, expr.span, - &format!("this `.{name}` can be written more simply using `.{sugg}`"), + format!("this `.{name}` can be written more simply using `.{sugg}`"), ); } } diff --git a/clippy_lints/src/methods/unnecessary_get_then_check.rs b/clippy_lints/src/methods/unnecessary_get_then_check.rs index cc8053ef507..f6184222d8e 100644 --- a/clippy_lints/src/methods/unnecessary_get_then_check.rs +++ b/clippy_lints/src/methods/unnecessary_get_then_check.rs @@ -58,7 +58,7 @@ pub(super) fn check( cx, UNNECESSARY_GET_THEN_CHECK, both_calls_span, - &format!("unnecessary use of `{snippet}`"), + format!("unnecessary use of `{snippet}`"), "replace it with", suggestion, Applicability::MaybeIncorrect, @@ -70,7 +70,7 @@ pub(super) fn check( cx, UNNECESSARY_GET_THEN_CHECK, both_calls_span, - &format!("unnecessary use of `{snippet}`"), + format!("unnecessary use of `{snippet}`"), |diag| { diag.span_suggestion( full_span, diff --git a/clippy_lints/src/methods/unnecessary_iter_cloned.rs b/clippy_lints/src/methods/unnecessary_iter_cloned.rs index 36497d59a5a..520dcb2d52d 100644 --- a/clippy_lints/src/methods/unnecessary_iter_cloned.rs +++ b/clippy_lints/src/methods/unnecessary_iter_cloned.rs @@ -61,7 +61,7 @@ pub fn check_for_loop_iter( cx, UNNECESSARY_TO_OWNED, expr.span, - &format!("unnecessary use of `{method_name}`"), + format!("unnecessary use of `{method_name}`"), |diag| { // If `check_into_iter_call_arg` called `check_for_loop_iter` because a call to // a `to_owned`-like function was removed, then the next suggestion may be diff --git a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs index 1b2bfbf4090..494d71fc053 100644 --- a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs +++ b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs @@ -63,7 +63,7 @@ pub(super) fn check( let help_message = format!("used `{method}()` on `{constructor}` value"); let suggestion_message = format!("remove the `{constructor}` and `{method}()`"); - span_lint_and_then(cx, UNNECESSARY_LITERAL_UNWRAP, expr.span, &help_message, |diag| { + span_lint_and_then(cx, UNNECESSARY_LITERAL_UNWRAP, expr.span, help_message, |diag| { let suggestions = match (constructor, method, ty) { ("None", "unwrap", _) => Some(vec![(expr.span, "panic!()".to_string())]), ("None", "expect", _) => Some(vec![ diff --git a/clippy_lints/src/methods/unnecessary_to_owned.rs b/clippy_lints/src/methods/unnecessary_to_owned.rs index c234e4f9b11..0762115d212 100644 --- a/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -138,7 +138,7 @@ fn check_addr_of_expr( cx, UNNECESSARY_TO_OWNED, parent.span, - &format!("unnecessary use of `{method_name}`"), + format!("unnecessary use of `{method_name}`"), "use", format!( "{:&>width$}{receiver_snippet}", @@ -163,7 +163,7 @@ fn check_addr_of_expr( cx, UNNECESSARY_TO_OWNED, parent.span, - &format!("unnecessary use of `{method_name}`"), + format!("unnecessary use of `{method_name}`"), "use", receiver_snippet, Applicability::MachineApplicable, @@ -173,7 +173,7 @@ fn check_addr_of_expr( cx, UNNECESSARY_TO_OWNED, expr.span.with_lo(receiver.span.hi()), - &format!("unnecessary use of `{method_name}`"), + format!("unnecessary use of `{method_name}`"), "remove this", String::new(), Applicability::MachineApplicable, @@ -188,7 +188,7 @@ fn check_addr_of_expr( cx, UNNECESSARY_TO_OWNED, parent.span, - &format!("unnecessary use of `{method_name}`"), + format!("unnecessary use of `{method_name}`"), "use", format!("{receiver_snippet}.as_ref()"), Applicability::MachineApplicable, @@ -232,7 +232,7 @@ fn check_into_iter_call_arg( cx, UNNECESSARY_TO_OWNED, parent.span, - &format!("unnecessary use of `{method_name}`"), + format!("unnecessary use of `{method_name}`"), "use", format!("{receiver_snippet}.iter().{cloned_or_copied}()"), Applicability::MaybeIncorrect, @@ -271,7 +271,7 @@ fn check_split_call_arg(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: Symb cx, UNNECESSARY_TO_OWNED, parent.span, - &format!("unnecessary use of `{method_name}`"), + format!("unnecessary use of `{method_name}`"), "use", format!("{receiver_snippet}{as_ref}.split({arg_snippet})"), Applicability::MaybeIncorrect, @@ -353,7 +353,7 @@ fn check_other_call_arg<'tcx>( cx, UNNECESSARY_TO_OWNED, maybe_arg.span, - &format!("unnecessary use of `{method_name}`"), + format!("unnecessary use of `{method_name}`"), "use", format!("{:&>n_refs$}{receiver_snippet}", ""), Applicability::MachineApplicable, @@ -645,7 +645,7 @@ fn check_if_applicable_to_argument<'tcx>(cx: &LateContext<'tcx>, arg: &Expr<'tcx cx, UNNECESSARY_TO_OWNED, arg.span, - &format!("unnecessary use of `{method_name}`"), + format!("unnecessary use of `{method_name}`"), "replace it with", if original_arg_ty.is_array() { format!("{snippet}.as_slice()") diff --git a/clippy_lints/src/methods/unwrap_expect_used.rs b/clippy_lints/src/methods/unwrap_expect_used.rs index 7bd16b473ce..516b8984ad7 100644 --- a/clippy_lints/src/methods/unwrap_expect_used.rs +++ b/clippy_lints/src/methods/unwrap_expect_used.rs @@ -69,7 +69,7 @@ pub(super) fn check( cx, variant.lint(), expr.span, - &format!("used `{}()` on {kind} value", variant.method_name(is_err)), + format!("used `{}()` on {kind} value", variant.method_name(is_err)), |diag| { diag.note(format!("if this value is {none_prefix}`{none_value}`, it will panic")); diff --git a/clippy_lints/src/methods/useless_asref.rs b/clippy_lints/src/methods/useless_asref.rs index 474103fccd2..ae2b6e6347e 100644 --- a/clippy_lints/src/methods/useless_asref.rs +++ b/clippy_lints/src/methods/useless_asref.rs @@ -68,7 +68,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, call_name: &str, cx, USELESS_ASREF, expr.span, - &format!("this call to `{call_name}` does nothing"), + format!("this call to `{call_name}` does nothing"), "try", snippet_with_applicability(cx, recvr.span, "..", &mut applicability).to_string(), applicability, @@ -159,7 +159,7 @@ fn lint_as_ref_clone(cx: &LateContext<'_>, span: Span, recvr: &hir::Expr<'_>, ca cx, USELESS_ASREF, span, - &format!("this call to `{call_name}.map(...)` does nothing"), + format!("this call to `{call_name}.map(...)` does nothing"), "try", format!( "{}.clone()", diff --git a/clippy_lints/src/methods/verbose_file_reads.rs b/clippy_lints/src/methods/verbose_file_reads.rs index 2fe5ae9a9ad..181b413a182 100644 --- a/clippy_lints/src/methods/verbose_file_reads.rs +++ b/clippy_lints/src/methods/verbose_file_reads.rs @@ -17,7 +17,7 @@ pub(super) fn check<'tcx>( cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, recv: &'tcx Expr<'_>, - (msg, help): (&str, &str), + (msg, help): (&'static str, &'static str), ) { if is_trait_method(cx, expr, sym::IoRead) && matches!(recv.kind, ExprKind::Path(QPath::Resolved(None, _))) diff --git a/clippy_lints/src/methods/wrong_self_convention.rs b/clippy_lints/src/methods/wrong_self_convention.rs index 0a810a13f3f..28068c63473 100644 --- a/clippy_lints/src/methods/wrong_self_convention.rs +++ b/clippy_lints/src/methods/wrong_self_convention.rs @@ -137,7 +137,7 @@ pub(super) fn check<'tcx>( cx, WRONG_SELF_CONVENTION, first_arg_span, - &format!( + format!( "{suggestion} usually take {}", &self_kinds .iter() diff --git a/clippy_lints/src/min_ident_chars.rs b/clippy_lints/src/min_ident_chars.rs index 0016fb33517..c6b7f5b0ce2 100644 --- a/clippy_lints/src/min_ident_chars.rs +++ b/clippy_lints/src/min_ident_chars.rs @@ -181,7 +181,7 @@ fn emit_min_ident_chars(conf: &MinIdentChars, cx: &impl LintContext, ident: &str conf.min_ident_chars_threshold, )) }; - span_lint(cx, MIN_IDENT_CHARS, span, &help); + span_lint(cx, MIN_IDENT_CHARS, span, help); } /// Attempt to convert the node to an [`ItemKind::Use`] node. diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index ea6e662b4be..0c0d440a81b 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -246,7 +246,7 @@ impl<'tcx> LateLintPass<'tcx> for LintPass { cx, USED_UNDERSCORE_BINDING, expr.span, - &format!( + format!( "used binding `{name}` which is prefixed with an underscore. A leading \ underscore signals that a binding will not be used" ), diff --git a/clippy_lints/src/misc_early/builtin_type_shadow.rs b/clippy_lints/src/misc_early/builtin_type_shadow.rs index 9f6b0bdc7a4..662f7cd8500 100644 --- a/clippy_lints/src/misc_early/builtin_type_shadow.rs +++ b/clippy_lints/src/misc_early/builtin_type_shadow.rs @@ -12,7 +12,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, param: &GenericParam) { cx, BUILTIN_TYPE_SHADOW, param.ident.span, - &format!("this generic shadows the built-in type `{}`", prim_ty.name()), + format!("this generic shadows the built-in type `{}`", prim_ty.name()), ); } } diff --git a/clippy_lints/src/misc_early/literal_suffix.rs b/clippy_lints/src/misc_early/literal_suffix.rs index eda4376f200..e0a5e401a50 100644 --- a/clippy_lints/src/misc_early/literal_suffix.rs +++ b/clippy_lints/src/misc_early/literal_suffix.rs @@ -16,7 +16,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, lit_span: Span, lit_snip: &str, suffi cx, SEPARATED_LITERAL_SUFFIX, lit_span, - &format!("{sugg_type} type suffix should not be separated by an underscore"), + format!("{sugg_type} type suffix should not be separated by an underscore"), "remove the underscore", format!("{}{suffix}", &lit_snip[..maybe_last_sep_idx]), Applicability::MachineApplicable, @@ -26,7 +26,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, lit_span: Span, lit_snip: &str, suffi cx, UNSEPARATED_LITERAL_SUFFIX, lit_span, - &format!("{sugg_type} type suffix should be separated by an underscore"), + format!("{sugg_type} type suffix should be separated by an underscore"), "add an underscore", format!("{}_{suffix}", &lit_snip[..=maybe_last_sep_idx]), Applicability::MachineApplicable, diff --git a/clippy_lints/src/misc_early/mod.rs b/clippy_lints/src/misc_early/mod.rs index abe5b00e888..2f5499d7656 100644 --- a/clippy_lints/src/misc_early/mod.rs +++ b/clippy_lints/src/misc_early/mod.rs @@ -394,7 +394,7 @@ impl EarlyLintPass for MiscEarlyLints { cx, DUPLICATE_UNDERSCORE_ARGUMENT, *correspondence, - &format!( + format!( "`{arg_name}` already exists, having another argument having almost the same \ name makes code comprehension and documentation more difficult" ), diff --git a/clippy_lints/src/misc_early/redundant_pattern.rs b/clippy_lints/src/misc_early/redundant_pattern.rs index d7bb0616acb..d5b5b2bf2dd 100644 --- a/clippy_lints/src/misc_early/redundant_pattern.rs +++ b/clippy_lints/src/misc_early/redundant_pattern.rs @@ -12,7 +12,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, pat: &Pat) { cx, REDUNDANT_PATTERN, pat.span, - &format!( + format!( "the `{} @ _` pattern can be written as just `{}`", ident.name, ident.name, ), diff --git a/clippy_lints/src/misc_early/unneeded_field_pattern.rs b/clippy_lints/src/misc_early/unneeded_field_pattern.rs index 676e5d40bb7..cb305cf5582 100644 --- a/clippy_lints/src/misc_early/unneeded_field_pattern.rs +++ b/clippy_lints/src/misc_early/unneeded_field_pattern.rs @@ -27,7 +27,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, pat: &Pat) { pat.span, "all the struct fields are matched to a wildcard pattern, consider using `..`", None, - &format!("try with `{type_name} {{ .. }}` instead"), + format!("try with `{type_name} {{ .. }}` instead"), ); return; } @@ -63,7 +63,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, pat: &Pat) { "you matched a field with a wildcard pattern, consider using `..` \ instead", None, - &format!("try with `{type_name} {{ {}, .. }}`", normal[..].join(", ")), + format!("try with `{type_name} {{ {}, .. }}`", normal[..].join(", ")), ); } } diff --git a/clippy_lints/src/mismatching_type_param_order.rs b/clippy_lints/src/mismatching_type_param_order.rs index 0739b49fe19..0842a872824 100644 --- a/clippy_lints/src/mismatching_type_param_order.rs +++ b/clippy_lints/src/mismatching_type_param_order.rs @@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeParamMismatch { "try `{}`, or a name that does not conflict with `{type_name}`'s generic params", type_param_names[i] ); - span_lint_and_help(cx, MISMATCHING_TYPE_PARAM_ORDER, *impl_param_span, &msg, None, &help); + span_lint_and_help(cx, MISMATCHING_TYPE_PARAM_ORDER, *impl_param_span, msg, None, help); } } } diff --git a/clippy_lints/src/missing_asserts_for_indexing.rs b/clippy_lints/src/missing_asserts_for_indexing.rs index 39d4ea74b31..c29e46b941c 100644 --- a/clippy_lints/src/missing_asserts_for_indexing.rs +++ b/clippy_lints/src/missing_asserts_for_indexing.rs @@ -65,7 +65,7 @@ declare_clippy_lint! { } declare_lint_pass!(MissingAssertsForIndexing => [MISSING_ASSERTS_FOR_INDEXING]); -fn report_lint(cx: &LateContext<'_>, full_span: Span, msg: &str, indexes: &[Span], f: F) +fn report_lint(cx: &LateContext<'_>, full_span: Span, msg: &'static str, indexes: &[Span], f: F) where F: FnOnce(&mut Diag<'_, ()>), { diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 6878fb3349d..d9379ec89df 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -127,7 +127,7 @@ impl MissingDoc { cx, MISSING_DOCS_IN_PRIVATE_ITEMS, sp, - &format!("missing documentation for {article} {desc}"), + format!("missing documentation for {article} {desc}"), ); } } diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 7393b39c8f6..c6a76478806 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -64,7 +64,7 @@ fn check_missing_inline_attrs(cx: &LateContext<'_>, attrs: &[ast::Attribute], sp cx, MISSING_INLINE_IN_PUBLIC_ITEMS, sp, - &format!("missing `#[inline]` for {desc}"), + format!("missing `#[inline]` for {desc}"), ); } } diff --git a/clippy_lints/src/missing_trait_methods.rs b/clippy_lints/src/missing_trait_methods.rs index 6bbf18d52d1..6f844bc646a 100644 --- a/clippy_lints/src/missing_trait_methods.rs +++ b/clippy_lints/src/missing_trait_methods.rs @@ -89,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingTraitMethods { cx, MISSING_TRAIT_METHODS, source_map.guess_head_span(item.span), - &format!("missing trait method provided by default: `{}`", assoc.name), + format!("missing trait method provided by default: `{}`", assoc.name), Some(definition_span), "implement the method", ); diff --git a/clippy_lints/src/mixed_read_write_in_expression.rs b/clippy_lints/src/mixed_read_write_in_expression.rs index 12c7c18afde..0a65c768c66 100644 --- a/clippy_lints/src/mixed_read_write_in_expression.rs +++ b/clippy_lints/src/mixed_read_write_in_expression.rs @@ -325,7 +325,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> { self.cx, MIXED_READ_WRITE_IN_EXPRESSION, expr.span, - &format!("unsequenced read of `{}`", self.cx.tcx.hir().name(self.var)), + format!("unsequenced read of `{}`", self.cx.tcx.hir().name(self.var)), Some(self.write_expr.span), "whether read occurs before this write depends on evaluation order", ); diff --git a/clippy_lints/src/module_style.rs b/clippy_lints/src/module_style.rs index 0226b31dd19..6c031c08175 100644 --- a/clippy_lints/src/module_style.rs +++ b/clippy_lints/src/module_style.rs @@ -129,9 +129,9 @@ impl EarlyLintPass for ModStyle { cx, SELF_NAMED_MODULE_FILES, Span::new(file.start_pos, file.start_pos, SyntaxContext::root(), None), - &format!("`mod.rs` files are required, found `{}`", path.display()), + format!("`mod.rs` files are required, found `{}`", path.display()), None, - &format!("move `{}` to `{}`", path.display(), correct.display(),), + format!("move `{}` to `{}`", path.display(), correct.display(),), ); } } @@ -169,9 +169,9 @@ fn check_self_named_mod_exists(cx: &EarlyContext<'_>, path: &Path, file: &Source cx, MOD_MODULE_FILES, Span::new(file.start_pos, file.start_pos, SyntaxContext::root(), None), - &format!("`mod.rs` files are not allowed, found `{}`", path.display()), + format!("`mod.rs` files are not allowed, found `{}`", path.display()), None, - &format!("move `{}` to `{}`", path.display(), mod_file.display()), + format!("move `{}` to `{}`", path.display(), mod_file.display()), ); } } diff --git a/clippy_lints/src/multiple_unsafe_ops_per_block.rs b/clippy_lints/src/multiple_unsafe_ops_per_block.rs index 648d780ac09..0e138066780 100644 --- a/clippy_lints/src/multiple_unsafe_ops_per_block.rs +++ b/clippy_lints/src/multiple_unsafe_ops_per_block.rs @@ -77,7 +77,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleUnsafeOpsPerBlock { cx, MULTIPLE_UNSAFE_OPS_PER_BLOCK, block.span, - &format!( + format!( "this `unsafe` block contains {} unsafe operations, expected only one", unsafe_ops.len() ), diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 7447a2287d3..11ab36bb056 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -92,7 +92,7 @@ fn check_arguments<'tcx>( cx, UNNECESSARY_MUT_PASSED, argument.span, - &format!("the {fn_kind} `{name}` doesn't need a mutable reference"), + format!("the {fn_kind} `{name}` doesn't need a mutable reference"), ); } }, diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 2d7ce7b52ae..563ce2d82ea 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -60,7 +60,7 @@ impl<'tcx> LateLintPass<'tcx> for DebugAssertWithMutCall { cx, DEBUG_ASSERT_WITH_MUT_CALL, span, - &format!("do not call a function with mutable arguments inside of `{macro_name}!`"), + format!("do not call a function with mutable arguments inside of `{macro_name}!`"), ); } } diff --git a/clippy_lints/src/mutex_atomic.rs b/clippy_lints/src/mutex_atomic.rs index b882e00dbdf..0c7f7e44edf 100644 --- a/clippy_lints/src/mutex_atomic.rs +++ b/clippy_lints/src/mutex_atomic.rs @@ -92,9 +92,9 @@ impl<'tcx> LateLintPass<'tcx> for Mutex { behavior and not the internal type, consider using `Mutex<()>`" ); match *mutex_param.kind() { - ty::Uint(t) if t != UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), - ty::Int(t) if t != IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, &msg), - _ => span_lint(cx, MUTEX_ATOMIC, expr.span, &msg), + ty::Uint(t) if t != UintTy::Usize => span_lint(cx, MUTEX_INTEGER, expr.span, msg), + ty::Int(t) if t != IntTy::Isize => span_lint(cx, MUTEX_INTEGER, expr.span, msg), + _ => span_lint(cx, MUTEX_ATOMIC, expr.span, msg), }; } } diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 081d14c043c..f9ee4a3dc93 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -317,11 +317,11 @@ fn one_side_is_unary_not<'tcx>(left_side: &'tcx Expr<'_>, right_side: &'tcx Expr fn check_comparison<'a, 'tcx>( cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, - left_true: Option<(impl FnOnce(Sugg<'a>) -> Sugg<'a>, &str)>, - left_false: Option<(impl FnOnce(Sugg<'a>) -> Sugg<'a>, &str)>, - right_true: Option<(impl FnOnce(Sugg<'a>) -> Sugg<'a>, &str)>, - right_false: Option<(impl FnOnce(Sugg<'a>) -> Sugg<'a>, &str)>, - no_literal: Option<(impl FnOnce(Sugg<'a>, Sugg<'a>) -> Sugg<'a>, &str)>, + left_true: Option<(impl FnOnce(Sugg<'a>) -> Sugg<'a>, &'static str)>, + left_false: Option<(impl FnOnce(Sugg<'a>) -> Sugg<'a>, &'static str)>, + right_true: Option<(impl FnOnce(Sugg<'a>) -> Sugg<'a>, &'static str)>, + right_false: Option<(impl FnOnce(Sugg<'a>) -> Sugg<'a>, &'static str)>, + no_literal: Option<(impl FnOnce(Sugg<'a>, Sugg<'a>) -> Sugg<'a>, &'static str)>, ) { if let ExprKind::Binary(op, left_side, right_side) = e.kind { let (l_ty, r_ty) = ( @@ -391,7 +391,7 @@ fn check_comparison<'a, 'tcx>( binop_span, m, "try simplifying it as shown", - h(left_side, right_side).to_string(), + h(left_side, right_side).into_string(), applicability, ); }), @@ -406,7 +406,7 @@ fn suggest_bool_comparison<'a, 'tcx>( span: Span, expr: &Expr<'_>, mut app: Applicability, - message: &str, + message: &'static str, conv_hint: impl FnOnce(Sugg<'a>) -> Sugg<'a>, ) { let hint = Sugg::hir_with_context(cx, expr, span.ctxt(), "..", &mut app); @@ -416,7 +416,7 @@ fn suggest_bool_comparison<'a, 'tcx>( span, message, "try simplifying it as shown", - conv_hint(hint).to_string(), + conv_hint(hint).into_string(), app, ); } diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index 4710a69443b..d91329eadcb 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -119,7 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowedRef { fn check_subpatterns<'tcx>( cx: &LateContext<'tcx>, - message: &str, + message: &'static str, ref_pat: &Pat<'_>, pat: &Pat<'_>, subpatterns: impl IntoIterator>, diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index ff72b5e69ef..8b4a12bb766 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -313,7 +313,7 @@ fn emit_warning(cx: &EarlyContext<'_>, data: &LintData<'_>, header: &str, typ: L expr.span, message, None, - &format!("{header}\n{snip}"), + format!("{header}\n{snip}"), ); } diff --git a/clippy_lints/src/needless_question_mark.rs b/clippy_lints/src/needless_question_mark.rs index d7adf22ff32..37463cfec9a 100644 --- a/clippy_lints/src/needless_question_mark.rs +++ b/clippy_lints/src/needless_question_mark.rs @@ -131,7 +131,7 @@ fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { NEEDLESS_QUESTION_MARK, expr.span, "question mark operator is useless here", - &format!("try removing question mark and `{sugg_remove}`"), + format!("try removing question mark and `{sugg_remove}`"), format!("{}", snippet(cx, inner_expr.span, r#""...""#)), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 627b4968d9f..78dd1e05162 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -134,9 +134,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault { NEW_WITHOUT_DEFAULT, id.into(), impl_item.span, - &format!( - "you should consider adding a `Default` implementation for `{self_type_snip}`" - ), + format!("you should consider adding a `Default` implementation for `{self_type_snip}`"), |diag| { diag.suggest_prepend_item( cx, diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index b8c3c7fa65a..7b26235291a 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -111,7 +111,7 @@ impl<'a, 'tcx> SimilarNamesLocalVisitor<'a, 'tcx> { self.cx, MANY_SINGLE_CHAR_NAMES, span, - &format!("{num_single_char_names} bindings with single-character names in scope"), + format!("{num_single_char_names} bindings with single-character names in scope"), ); } } diff --git a/clippy_lints/src/non_send_fields_in_send_ty.rs b/clippy_lints/src/non_send_fields_in_send_ty.rs index 793a3a9545c..d64190daecb 100644 --- a/clippy_lints/src/non_send_fields_in_send_ty.rs +++ b/clippy_lints/src/non_send_fields_in_send_ty.rs @@ -119,7 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy { cx, NON_SEND_FIELDS_IN_SEND_TY, item.span, - &format!( + format!( "some fields in `{}` are not safe to be sent to another thread", snippet(cx, hir_impl.self_ty.span, "Unknown") ), diff --git a/clippy_lints/src/nonstandard_macro_braces.rs b/clippy_lints/src/nonstandard_macro_braces.rs index 1c6069e9c65..88f2eabaccb 100644 --- a/clippy_lints/src/nonstandard_macro_braces.rs +++ b/clippy_lints/src/nonstandard_macro_braces.rs @@ -121,7 +121,7 @@ fn emit_help(cx: &EarlyContext<'_>, snip: &str, (open, close): (char, char), spa cx, NONSTANDARD_MACRO_BRACES, span, - &format!("use of irregular braces for `{macro_name}!` macro"), + format!("use of irregular braces for `{macro_name}!` macro"), "consider writing", format!("{macro_name}!{open}{macro_args}{close}"), Applicability::MachineApplicable, diff --git a/clippy_lints/src/octal_escapes.rs b/clippy_lints/src/octal_escapes.rs index 8822dfeeddd..2fc039ae886 100644 --- a/clippy_lints/src/octal_escapes.rs +++ b/clippy_lints/src/octal_escapes.rs @@ -94,7 +94,7 @@ fn check_lit(cx: &EarlyContext<'_>, lit: &Lit, span: Span, is_string: bool) { cx, OCTAL_ESCAPES, span, - &format!( + format!( "octal-looking escape in {} literal", if is_string { "string" } else { "byte string" } ), diff --git a/clippy_lints/src/operators/absurd_extreme_comparisons.rs b/clippy_lints/src/operators/absurd_extreme_comparisons.rs index f4863600ccc..9769da6d3e9 100644 --- a/clippy_lints/src/operators/absurd_extreme_comparisons.rs +++ b/clippy_lints/src/operators/absurd_extreme_comparisons.rs @@ -42,7 +42,7 @@ pub(super) fn check<'tcx>( } ); - span_lint_and_help(cx, ABSURD_EXTREME_COMPARISONS, expr.span, msg, None, &help); + span_lint_and_help(cx, ABSURD_EXTREME_COMPARISONS, expr.span, msg, None, help); } } diff --git a/clippy_lints/src/operators/bit_mask.rs b/clippy_lints/src/operators/bit_mask.rs index 2e026c369ee..545e680ce0d 100644 --- a/clippy_lints/src/operators/bit_mask.rs +++ b/clippy_lints/src/operators/bit_mask.rs @@ -64,7 +64,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!("incompatible bit mask: `_ & {mask_value}` can never be equal to `{cmp_value}`"), + format!("incompatible bit mask: `_ & {mask_value}` can never be equal to `{cmp_value}`"), ); } } else if mask_value == 0 { @@ -77,7 +77,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!("incompatible bit mask: `_ | {mask_value}` can never be equal to `{cmp_value}`"), + format!("incompatible bit mask: `_ | {mask_value}` can never be equal to `{cmp_value}`"), ); } }, @@ -90,7 +90,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!("incompatible bit mask: `_ & {mask_value}` will always be lower than `{cmp_value}`"), + format!("incompatible bit mask: `_ & {mask_value}` will always be lower than `{cmp_value}`"), ); } else if mask_value == 0 { span_lint(cx, BAD_BIT_MASK, span, "&-masking with zero"); @@ -102,7 +102,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!("incompatible bit mask: `_ | {mask_value}` will never be lower than `{cmp_value}`"), + format!("incompatible bit mask: `_ | {mask_value}` will never be lower than `{cmp_value}`"), ); } else { check_ineffective_lt(cx, span, mask_value, cmp_value, "|"); @@ -118,7 +118,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!("incompatible bit mask: `_ & {mask_value}` will never be higher than `{cmp_value}`"), + format!("incompatible bit mask: `_ & {mask_value}` will never be higher than `{cmp_value}`"), ); } else if mask_value == 0 { span_lint(cx, BAD_BIT_MASK, span, "&-masking with zero"); @@ -130,7 +130,7 @@ fn check_bit_mask( cx, BAD_BIT_MASK, span, - &format!("incompatible bit mask: `_ | {mask_value}` will always be higher than `{cmp_value}`"), + format!("incompatible bit mask: `_ | {mask_value}` will always be higher than `{cmp_value}`"), ); } else { check_ineffective_gt(cx, span, mask_value, cmp_value, "|"); @@ -149,7 +149,7 @@ fn check_ineffective_lt(cx: &LateContext<'_>, span: Span, m: u128, c: u128, op: cx, INEFFECTIVE_BIT_MASK, span, - &format!("ineffective bit mask: `x {op} {m}` compared to `{c}`, is the same as x compared directly"), + format!("ineffective bit mask: `x {op} {m}` compared to `{c}`, is the same as x compared directly"), ); } } @@ -160,7 +160,7 @@ fn check_ineffective_gt(cx: &LateContext<'_>, span: Span, m: u128, c: u128, op: cx, INEFFECTIVE_BIT_MASK, span, - &format!("ineffective bit mask: `x {op} {m}` compared to `{c}`, is the same as x compared directly"), + format!("ineffective bit mask: `x {op} {m}` compared to `{c}`, is the same as x compared directly"), ); } } diff --git a/clippy_lints/src/operators/const_comparisons.rs b/clippy_lints/src/operators/const_comparisons.rs index e278cf9835a..7bf9b8ef866 100644 --- a/clippy_lints/src/operators/const_comparisons.rs +++ b/clippy_lints/src/operators/const_comparisons.rs @@ -89,7 +89,7 @@ pub(super) fn check<'tcx>( span, "left-hand side of `&&` operator has no effect", Some(left_cond.span.until(right_cond.span)), - &format!("`if `{rhs_str}` evaluates to true, {lhs_str}` will always evaluate to true as well"), + format!("`if `{rhs_str}` evaluates to true, {lhs_str}` will always evaluate to true as well"), ); } else { span_lint_and_note( @@ -98,7 +98,7 @@ pub(super) fn check<'tcx>( span, "right-hand side of `&&` operator has no effect", Some(and_op.span.to(right_cond.span)), - &format!("`if `{lhs_str}` evaluates to true, {rhs_str}` will always evaluate to true as well"), + format!("`if `{lhs_str}` evaluates to true, {rhs_str}` will always evaluate to true as well"), ); } // We could autofix this error but choose not to, @@ -124,7 +124,7 @@ pub(super) fn check<'tcx>( span, "boolean expression will never evaluate to 'true'", None, - ¬e, + note, ); }; } diff --git a/clippy_lints/src/operators/duration_subsec.rs b/clippy_lints/src/operators/duration_subsec.rs index f120be13836..ca3112ce5c4 100644 --- a/clippy_lints/src/operators/duration_subsec.rs +++ b/clippy_lints/src/operators/duration_subsec.rs @@ -31,7 +31,7 @@ pub(crate) fn check<'tcx>( cx, DURATION_SUBSEC, expr.span, - &format!("calling `{suggested_fn}()` is more concise than this calculation"), + format!("calling `{suggested_fn}()` is more concise than this calculation"), "try", format!( "{}.{suggested_fn}()", diff --git a/clippy_lints/src/operators/eq_op.rs b/clippy_lints/src/operators/eq_op.rs index 01dd418c38b..1421893274f 100644 --- a/clippy_lints/src/operators/eq_op.rs +++ b/clippy_lints/src/operators/eq_op.rs @@ -24,7 +24,7 @@ pub(crate) fn check_assert<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { cx, EQ_OP, lhs.span.to(rhs.span), - &format!("identical args used in this `{macro_name}!` macro call"), + format!("identical args used in this `{macro_name}!` macro call"), ); } } @@ -41,7 +41,7 @@ pub(crate) fn check<'tcx>( cx, EQ_OP, e.span, - &format!("equal expressions as operands to `{}`", op.as_str()), + format!("equal expressions as operands to `{}`", op.as_str()), |diag| { if let BinOpKind::Ne = op && cx.typeck_results().expr_ty(left).is_floating_point() diff --git a/clippy_lints/src/operators/modulo_arithmetic.rs b/clippy_lints/src/operators/modulo_arithmetic.rs index 2a933a11e12..c56518ac72a 100644 --- a/clippy_lints/src/operators/modulo_arithmetic.rs +++ b/clippy_lints/src/operators/modulo_arithmetic.rs @@ -113,7 +113,7 @@ fn check_const_operands<'tcx>( cx, MODULO_ARITHMETIC, expr.span, - &format!( + format!( "you are using modulo operator on constants with different signs: `{} % {}`", lhs_operand.string_representation.as_ref().unwrap(), rhs_operand.string_representation.as_ref().unwrap() diff --git a/clippy_lints/src/operators/ptr_eq.rs b/clippy_lints/src/operators/ptr_eq.rs index a69989e400b..607930561e0 100644 --- a/clippy_lints/src/operators/ptr_eq.rs +++ b/clippy_lints/src/operators/ptr_eq.rs @@ -30,7 +30,7 @@ pub(super) fn check<'tcx>( cx, PTR_EQ, expr.span, - &format!("use `{top_crate}::ptr::eq` when comparing raw pointers"), + format!("use `{top_crate}::ptr::eq` when comparing raw pointers"), "try", format!("{top_crate}::ptr::eq({left_snip}, {right_snip})"), Applicability::MachineApplicable, diff --git a/clippy_lints/src/operators/self_assignment.rs b/clippy_lints/src/operators/self_assignment.rs index 7c9d5320a3a..a932378fbb5 100644 --- a/clippy_lints/src/operators/self_assignment.rs +++ b/clippy_lints/src/operators/self_assignment.rs @@ -14,7 +14,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, lhs: &'tcx cx, SELF_ASSIGNMENT, e.span, - &format!("self-assignment of `{rhs}` to `{lhs}`"), + format!("self-assignment of `{rhs}` to `{lhs}`"), ); } } diff --git a/clippy_lints/src/option_if_let_else.rs b/clippy_lints/src/option_if_let_else.rs index 556c493d36c..3cbd03a58c5 100644 --- a/clippy_lints/src/option_if_let_else.rs +++ b/clippy_lints/src/option_if_let_else.rs @@ -304,7 +304,7 @@ impl<'tcx> LateLintPass<'tcx> for OptionIfLetElse { cx, OPTION_IF_LET_ELSE, expr.span, - format!("use Option::{} instead of an if let/else", det.method_sugg).as_str(), + format!("use Option::{} instead of an if let/else", det.method_sugg), "try", format!( "{}.{}({}, {})", diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index ec03ab0e41a..bb4a1de9f77 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -206,7 +206,7 @@ impl<'tcx> PassByRefOrValue { cx, TRIVIALLY_COPY_PASS_BY_REF, input.span, - &format!( + format!( "this argument ({size} byte) is passed by reference, but would be more efficient if passed by value (limit: {} byte)", self.ref_min_size ), @@ -236,7 +236,7 @@ impl<'tcx> PassByRefOrValue { cx, LARGE_TYPES_PASSED_BY_VALUE, input.span, - &format!( + format!( "this argument ({size} byte) is passed by value, but might be more efficient if passed by reference (limit: {} byte)", self.value_max_size ), diff --git a/clippy_lints/src/pattern_type_mismatch.rs b/clippy_lints/src/pattern_type_mismatch.rs index fbca4329342..582b9de43ae 100644 --- a/clippy_lints/src/pattern_type_mismatch.rs +++ b/clippy_lints/src/pattern_type_mismatch.rs @@ -138,7 +138,7 @@ fn apply_lint(cx: &LateContext<'_>, pat: &Pat<'_>, deref_possible: DerefPossible span, "type of pattern does not match the expression type", None, - &format!( + format!( "{}explicitly match against a `{}` pattern and adjust the enclosed variable bindings", match (deref_possible, level) { (DerefPossible::Possible, Level::Top) => "use `*` to dereference the match expression or ", diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index 6f20b5ec150..d180d4fe327 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -177,7 +177,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr { ) .filter(|arg| arg.mutability() == Mutability::Not) { - span_lint_hir_and_then(cx, PTR_ARG, arg.emission_id, arg.span, &arg.build_msg(), |diag| { + span_lint_hir_and_then(cx, PTR_ARG, arg.emission_id, arg.span, arg.build_msg(), |diag| { diag.span_suggestion( arg.span, "change this to", @@ -237,7 +237,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr { let results = check_ptr_arg_usage(cx, body, &lint_args); for (result, args) in results.iter().zip(lint_args.iter()).filter(|(r, _)| !r.skip) { - span_lint_hir_and_then(cx, PTR_ARG, args.emission_id, args.span, &args.build_msg(), |diag| { + span_lint_hir_and_then(cx, PTR_ARG, args.emission_id, args.span, args.build_msg(), |diag| { diag.multipart_suggestion( "change this to", iter::once((args.span, format!("{}{}", args.ref_prefix, args.deref_ty.display(cx)))) diff --git a/clippy_lints/src/ptr_offset_with_cast.rs b/clippy_lints/src/ptr_offset_with_cast.rs index ff8ec2ad57c..7c82895d609 100644 --- a/clippy_lints/src/ptr_offset_with_cast.rs +++ b/clippy_lints/src/ptr_offset_with_cast.rs @@ -64,13 +64,13 @@ impl<'tcx> LateLintPass<'tcx> for PtrOffsetWithCast { cx, PTR_OFFSET_WITH_CAST, expr.span, - &msg, + msg, "try", sugg, Applicability::MachineApplicable, ); } else { - span_lint(cx, PTR_OFFSET_WITH_CAST, expr.span, &msg); + span_lint(cx, PTR_OFFSET_WITH_CAST, expr.span, msg); } } } diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 6b54258dd61..186e548d373 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -242,7 +242,7 @@ fn check_possible_range_contains( cx, MANUAL_RANGE_CONTAINS, span, - &format!("manual `{range_type}::contains` implementation"), + format!("manual `{range_type}::contains` implementation"), "use", format!("({lo}{space}{range_op}{hi}).contains(&{name})"), applicability, @@ -272,7 +272,7 @@ fn check_possible_range_contains( cx, MANUAL_RANGE_CONTAINS, span, - &format!("manual `!{range_type}::contains` implementation"), + format!("manual `!{range_type}::contains` implementation"), "use", format!("!({lo}{space}{range_op}{hi}).contains(&{name})"), applicability, diff --git a/clippy_lints/src/redundant_locals.rs b/clippy_lints/src/redundant_locals.rs index 6528a7b369f..8bc5d081a20 100644 --- a/clippy_lints/src/redundant_locals.rs +++ b/clippy_lints/src/redundant_locals.rs @@ -77,9 +77,9 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals { cx, REDUNDANT_LOCALS, local.span, - &format!("redundant redefinition of a binding `{ident}`"), + format!("redundant redefinition of a binding `{ident}`"), Some(binding_pat.span), - &format!("`{ident}` is initially defined here"), + format!("`{ident}` is initially defined here"), ); } } diff --git a/clippy_lints/src/redundant_pub_crate.rs b/clippy_lints/src/redundant_pub_crate.rs index 0e43e4a7ee5..1b557730eca 100644 --- a/clippy_lints/src/redundant_pub_crate.rs +++ b/clippy_lints/src/redundant_pub_crate.rs @@ -56,7 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate { cx, REDUNDANT_PUB_CRATE, span, - &format!("pub(crate) {descr} inside private module"), + format!("pub(crate) {descr} inside private module"), |diag| { diag.span_suggestion( item.vis_span, diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index 07b604f2326..136e7db83bd 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -48,7 +48,7 @@ impl_lint_pass!(RedundantStaticLifetimes => [REDUNDANT_STATIC_LIFETIMES]); impl RedundantStaticLifetimes { // Recursively visit types - fn visit_type(ty: &Ty, cx: &EarlyContext<'_>, reason: &str) { + fn visit_type(ty: &Ty, cx: &EarlyContext<'_>, reason: &'static str) { match ty.kind { // Be careful of nested structures (arrays and tuples) TyKind::Array(ref ty, _) | TyKind::Slice(ref ty) => { diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index 687bad35a36..e925ec0271c 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -134,13 +134,13 @@ fn lint_syntax_error(cx: &LateContext<'_>, error: ®ex_syntax::Error, unescape vec![convert_span(primary)] }; - span_lint(cx, INVALID_REGEX, spans, &format!("regex syntax error: {kind}")); + span_lint(cx, INVALID_REGEX, spans, format!("regex syntax error: {kind}")); } else { span_lint_and_help( cx, INVALID_REGEX, base, - &error.to_string(), + error.to_string(), None, "consider using a raw string literal: `r\"..\"`", ); @@ -223,7 +223,7 @@ fn check_regex<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, utf8: bool) { span_lint_and_help(cx, TRIVIAL_REGEX, expr.span, "trivial regex", None, repl); } }, - Err(e) => span_lint(cx, INVALID_REGEX, expr.span, &e.to_string()), + Err(e) => span_lint(cx, INVALID_REGEX, expr.span, e.to_string()), } } } diff --git a/clippy_lints/src/repeat_vec_with_capacity.rs b/clippy_lints/src/repeat_vec_with_capacity.rs index fcb79f6d694..a358881bf80 100644 --- a/clippy_lints/src/repeat_vec_with_capacity.rs +++ b/clippy_lints/src/repeat_vec_with_capacity.rs @@ -55,7 +55,7 @@ fn emit_lint(cx: &LateContext<'_>, span: Span, kind: &str, note: &'static str, s cx, REPEAT_VEC_WITH_CAPACITY, span, - &format!("repeating `Vec::with_capacity` using `{kind}`, which does not retain capacity"), + format!("repeating `Vec::with_capacity` using `{kind}`, which does not retain capacity"), |diag| { diag.note(note); diag.span_suggestion_verbose(span, sugg_msg, sugg, Applicability::MaybeIncorrect); diff --git a/clippy_lints/src/self_named_constructors.rs b/clippy_lints/src/self_named_constructors.rs index 85a2b1a6735..23b47606f8a 100644 --- a/clippy_lints/src/self_named_constructors.rs +++ b/clippy_lints/src/self_named_constructors.rs @@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructors { cx, SELF_NAMED_CONSTRUCTORS, impl_item.span, - &format!("constructor `{}` has the same name as the type", impl_item.ident.name), + format!("constructor `{}` has the same name as the type", impl_item.ident.name), ); } } diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index c74364d89d6..0fb7666dd9c 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -194,7 +194,7 @@ fn lint_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, shadowed: HirId, span: Span) cx, lint, span, - &msg, + msg, Some(cx.tcx.hir().span(shadowed)), "previous binding is here", ); diff --git a/clippy_lints/src/single_range_in_vec_init.rs b/clippy_lints/src/single_range_in_vec_init.rs index 95b4a11a783..0a9a3c6307a 100644 --- a/clippy_lints/src/single_range_in_vec_init.rs +++ b/clippy_lints/src/single_range_in_vec_init.rs @@ -122,7 +122,7 @@ impl LateLintPass<'_> for SingleRangeInVecInit { cx, SINGLE_RANGE_IN_VEC_INIT, span, - &format!("{suggested_type} of `Range` that is only one element"), + format!("{suggested_type} of `Range` that is only one element"), |diag| { if should_emit_every_value { diag.span_suggestion( diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index ff8e8fe7021..8a9f02b6dcb 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -196,7 +196,7 @@ impl SlowVectorInit { }; } - fn emit_lint(cx: &LateContext<'_>, slow_fill: &Expr<'_>, vec_alloc: &VecAllocation<'_>, msg: &str) { + fn emit_lint(cx: &LateContext<'_>, slow_fill: &Expr<'_>, vec_alloc: &VecAllocation<'_>, msg: &'static str) { let len_expr = Sugg::hir( cx, match vec_alloc.size_expr { diff --git a/clippy_lints/src/std_instead_of_core.rs b/clippy_lints/src/std_instead_of_core.rs index cf839941123..926c56332cc 100644 --- a/clippy_lints/src/std_instead_of_core.rs +++ b/clippy_lints/src/std_instead_of_core.rs @@ -128,8 +128,8 @@ impl<'tcx> LateLintPass<'tcx> for StdReexports { cx, lint, first_segment.ident.span, - &format!("used import from `{used_mod}` instead of `{replace_with}`"), - &format!("consider importing the item from `{replace_with}`"), + format!("used import from `{used_mod}` instead of `{replace_with}`"), + format!("consider importing the item from `{replace_with}`"), replace_with.to_string(), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 13ae1ff52dd..b3c729dacdd 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -495,8 +495,8 @@ impl<'tcx> LateLintPass<'tcx> for TrimSplitWhitespace { cx, TRIM_SPLIT_WHITESPACE, trim_span.with_hi(split_ws_span.lo()), - &format!("found call to `str::{trim_fn_name}` before `str::split_whitespace`"), - &format!("remove `{trim_fn_name}()`"), + format!("found call to `str::{trim_fn_name}` before `str::split_whitespace`"), + format!("remove `{trim_fn_name}()`"), String::new(), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index 8eab3f5874e..3f030b80331 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for SuspiciousImpl { cx, lint, binop.span, - &format!( + format!( "suspicious use of `{}` in `{}` impl", binop.node.as_str(), cx.tcx.item_name(trait_id) diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index be590aede15..78c99e0c0a3 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -103,7 +103,7 @@ fn generate_swap_warning(cx: &LateContext<'_>, e1: &Expr<'_>, e2: &Expr<'_>, spa cx, MANUAL_SWAP, span, - &format!("this looks like you are swapping elements of `{slice}` manually"), + format!("this looks like you are swapping elements of `{slice}` manually"), "try", format!( "{}.swap({}, {});", @@ -126,7 +126,7 @@ fn generate_swap_warning(cx: &LateContext<'_>, e1: &Expr<'_>, e2: &Expr<'_>, spa cx, MANUAL_SWAP, span, - &format!("this looks like you are swapping `{first}` and `{second}` manually"), + format!("this looks like you are swapping `{first}` and `{second}` manually"), |diag| { diag.span_suggestion( span, @@ -201,7 +201,7 @@ fn check_suspicious_swap(cx: &LateContext<'_>, block: &Block<'_>) { cx, ALMOST_SWAPPED, span, - &format!("this looks like you are trying to swap `{lhs_sugg}` and `{rhs_sugg}`"), + format!("this looks like you are trying to swap `{lhs_sugg}` and `{rhs_sugg}`"), |diag| { diag.span_suggestion( span, diff --git a/clippy_lints/src/trailing_empty_array.rs b/clippy_lints/src/trailing_empty_array.rs index cbdf31c9336..462084e96a8 100644 --- a/clippy_lints/src/trailing_empty_array.rs +++ b/clippy_lints/src/trailing_empty_array.rs @@ -44,7 +44,7 @@ impl<'tcx> LateLintPass<'tcx> for TrailingEmptyArray { item.span, "trailing zero-sized array in a struct which is not marked with a `repr` attribute", None, - &format!( + format!( "consider annotating `{}` with `#[repr(C)]` or another `repr` attribute", cx.tcx.def_path_str(item.owner_id) ), diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index 768623b5d03..9468d367a92 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -293,7 +293,7 @@ impl TraitBounds { p.span, "this type has already been used as a bound predicate", None, - &hint_string, + hint_string, ); } } @@ -420,7 +420,11 @@ fn into_comparable_trait_ref(trait_ref: &TraitRef<'_>) -> ComparableTraitRef { ) } -fn rollup_traits(cx: &LateContext<'_>, bounds: &[GenericBound<'_>], msg: &str) -> Vec<(ComparableTraitRef, Span)> { +fn rollup_traits( + cx: &LateContext<'_>, + bounds: &[GenericBound<'_>], + msg: &'static str, +) -> Vec<(ComparableTraitRef, Span)> { let mut map = FxHashMap::default(); let mut repeated_res = false; diff --git a/clippy_lints/src/transmute/crosspointer_transmute.rs b/clippy_lints/src/transmute/crosspointer_transmute.rs index c4b9d82fc73..72f1529eb00 100644 --- a/clippy_lints/src/transmute/crosspointer_transmute.rs +++ b/clippy_lints/src/transmute/crosspointer_transmute.rs @@ -13,7 +13,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty cx, CROSSPOINTER_TRANSMUTE, e.span, - &format!("transmute from a type (`{from_ty}`) to the type that it points to (`{to_ty}`)"), + format!("transmute from a type (`{from_ty}`) to the type that it points to (`{to_ty}`)"), ); true }, @@ -22,7 +22,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty cx, CROSSPOINTER_TRANSMUTE, e.span, - &format!("transmute from a type (`{from_ty}`) to a pointer to that type (`{to_ty}`)"), + format!("transmute from a type (`{from_ty}`) to a pointer to that type (`{to_ty}`)"), ); true }, diff --git a/clippy_lints/src/transmute/transmute_float_to_int.rs b/clippy_lints/src/transmute/transmute_float_to_int.rs index aef520923e4..ab3bb5e1062 100644 --- a/clippy_lints/src/transmute/transmute_float_to_int.rs +++ b/clippy_lints/src/transmute/transmute_float_to_int.rs @@ -23,7 +23,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_FLOAT_TO_INT, e.span, - &format!("transmute from a `{from_ty}` to a `{to_ty}`"), + format!("transmute from a `{from_ty}` to a `{to_ty}`"), |diag| { let mut sugg = sugg::Sugg::hir(cx, arg, ".."); diff --git a/clippy_lints/src/transmute/transmute_int_to_bool.rs b/clippy_lints/src/transmute/transmute_int_to_bool.rs index 58227c53de2..a7192809077 100644 --- a/clippy_lints/src/transmute/transmute_int_to_bool.rs +++ b/clippy_lints/src/transmute/transmute_int_to_bool.rs @@ -23,7 +23,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_INT_TO_BOOL, e.span, - &format!("transmute from a `{from_ty}` to a `bool`"), + format!("transmute from a `{from_ty}` to a `bool`"), |diag| { let arg = sugg::Sugg::hir(cx, arg, ".."); let zero = sugg::Sugg::NonParen(Cow::from("0")); diff --git a/clippy_lints/src/transmute/transmute_int_to_char.rs b/clippy_lints/src/transmute/transmute_int_to_char.rs index 2a6c2481254..81d10a7d5bd 100644 --- a/clippy_lints/src/transmute/transmute_int_to_char.rs +++ b/clippy_lints/src/transmute/transmute_int_to_char.rs @@ -23,7 +23,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_INT_TO_CHAR, e.span, - &format!("transmute from a `{from_ty}` to a `char`"), + format!("transmute from a `{from_ty}` to a `char`"), |diag| { let Some(top_crate) = std_or_core(cx) else { return }; let arg = sugg::Sugg::hir(cx, arg, ".."); diff --git a/clippy_lints/src/transmute/transmute_int_to_float.rs b/clippy_lints/src/transmute/transmute_int_to_float.rs index cc3422edbbf..d51888e3097 100644 --- a/clippy_lints/src/transmute/transmute_int_to_float.rs +++ b/clippy_lints/src/transmute/transmute_int_to_float.rs @@ -22,7 +22,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_INT_TO_FLOAT, e.span, - &format!("transmute from a `{from_ty}` to a `{to_ty}`"), + format!("transmute from a `{from_ty}` to a `{to_ty}`"), |diag| { let arg = sugg::Sugg::hir(cx, arg, ".."); let arg = if let ty::Int(int_ty) = from_ty.kind() { diff --git a/clippy_lints/src/transmute/transmute_int_to_non_zero.rs b/clippy_lints/src/transmute/transmute_int_to_non_zero.rs index 97068efd43c..234021f0f47 100644 --- a/clippy_lints/src/transmute/transmute_int_to_non_zero.rs +++ b/clippy_lints/src/transmute/transmute_int_to_non_zero.rs @@ -58,7 +58,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_INT_TO_NON_ZERO, e.span, - &format!("transmute from a `{from_ty}` to a `{nonzero_alias}`"), + format!("transmute from a `{from_ty}` to a `{nonzero_alias}`"), |diag| { let arg = sugg::Sugg::hir(cx, arg, ".."); diag.span_suggestion( diff --git a/clippy_lints/src/transmute/transmute_num_to_bytes.rs b/clippy_lints/src/transmute/transmute_num_to_bytes.rs index 009d5a7c8ae..88b0ac5a368 100644 --- a/clippy_lints/src/transmute/transmute_num_to_bytes.rs +++ b/clippy_lints/src/transmute/transmute_num_to_bytes.rs @@ -31,7 +31,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_NUM_TO_BYTES, e.span, - &format!("transmute from a `{from_ty}` to a `{to_ty}`"), + format!("transmute from a `{from_ty}` to a `{to_ty}`"), |diag| { let arg = sugg::Sugg::hir(cx, arg, ".."); diag.span_suggestion( diff --git a/clippy_lints/src/transmute/transmute_ptr_to_ref.rs b/clippy_lints/src/transmute/transmute_ptr_to_ref.rs index 4ab3afbe714..65d89c1fe43 100644 --- a/clippy_lints/src/transmute/transmute_ptr_to_ref.rs +++ b/clippy_lints/src/transmute/transmute_ptr_to_ref.rs @@ -25,7 +25,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_PTR_TO_REF, e.span, - &format!("transmute from a pointer type (`{from_ty}`) to a reference type (`{to_ty}`)"), + format!("transmute from a pointer type (`{from_ty}`) to a reference type (`{to_ty}`)"), |diag| { let arg = sugg::Sugg::hir(cx, arg, ".."); let (deref, cast) = if *mutbl == Mutability::Mut { diff --git a/clippy_lints/src/transmute/transmute_ref_to_ref.rs b/clippy_lints/src/transmute/transmute_ref_to_ref.rs index 6c885ebdea1..5de2d7fc2e5 100644 --- a/clippy_lints/src/transmute/transmute_ref_to_ref.rs +++ b/clippy_lints/src/transmute/transmute_ref_to_ref.rs @@ -35,7 +35,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_BYTES_TO_STR, e.span, - &format!("transmute from a `{from_ty}` to a `{to_ty}`"), + format!("transmute from a `{from_ty}` to a `{to_ty}`"), "consider using", if const_context { format!("{top_crate}::str::from_utf8_unchecked{postfix}({snippet})") diff --git a/clippy_lints/src/transmute/transmute_undefined_repr.rs b/clippy_lints/src/transmute/transmute_undefined_repr.rs index a6f03c85b4f..275cab2af9b 100644 --- a/clippy_lints/src/transmute/transmute_undefined_repr.rs +++ b/clippy_lints/src/transmute/transmute_undefined_repr.rs @@ -71,7 +71,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_UNDEFINED_REPR, e.span, - &format!("transmute from `{from_ty_orig}` which has an undefined layout"), + format!("transmute from `{from_ty_orig}` which has an undefined layout"), |diag| { if from_ty_orig.peel_refs() != from_ty.peel_refs() { diag.note(format!("the contained type `{from_ty}` has an undefined layout")); @@ -85,7 +85,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_UNDEFINED_REPR, e.span, - &format!("transmute to `{to_ty_orig}` which has an undefined layout"), + format!("transmute to `{to_ty_orig}` which has an undefined layout"), |diag| { if to_ty_orig.peel_refs() != to_ty.peel_refs() { diag.note(format!("the contained type `{to_ty}` has an undefined layout")); @@ -111,7 +111,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_UNDEFINED_REPR, e.span, - &format!( + format!( "transmute from `{from_ty_orig}` to `{to_ty_orig}`, both of which have an undefined layout" ), |diag| { @@ -140,7 +140,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_UNDEFINED_REPR, e.span, - &format!("transmute from `{from_ty_orig}` which has an undefined layout"), + format!("transmute from `{from_ty_orig}` which has an undefined layout"), |diag| { if from_ty_orig.peel_refs() != from_ty { diag.note(format!("the contained type `{from_ty}` has an undefined layout")); @@ -157,7 +157,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTE_UNDEFINED_REPR, e.span, - &format!("transmute into `{to_ty_orig}` which has an undefined layout"), + format!("transmute into `{to_ty_orig}` which has an undefined layout"), |diag| { if to_ty_orig.peel_refs() != to_ty { diag.note(format!("the contained type `{to_ty}` has an undefined layout")); diff --git a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs index 043c9c88601..6f5ac625e35 100644 --- a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs +++ b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs @@ -53,7 +53,7 @@ pub(super) fn check<'tcx>( cx, TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS, e.span, - &format!("transmute from `{from_ty}` to `{to_ty}` which could be expressed as a pointer cast instead"), + format!("transmute from `{from_ty}` to `{to_ty}` which could be expressed as a pointer cast instead"), "try", sugg, app, diff --git a/clippy_lints/src/transmute/unsound_collection_transmute.rs b/clippy_lints/src/transmute/unsound_collection_transmute.rs index 891fefc17a6..35e93830766 100644 --- a/clippy_lints/src/transmute/unsound_collection_transmute.rs +++ b/clippy_lints/src/transmute/unsound_collection_transmute.rs @@ -37,7 +37,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty cx, UNSOUND_COLLECTION_TRANSMUTE, e.span, - &format!("transmute from `{from_ty}` to `{to_ty}` with mismatched layout is unsound"), + format!("transmute from `{from_ty}` to `{to_ty}` with mismatched layout is unsound"), ); true } else { diff --git a/clippy_lints/src/transmute/useless_transmute.rs b/clippy_lints/src/transmute/useless_transmute.rs index 088c8fda87a..0d5fbff0605 100644 --- a/clippy_lints/src/transmute/useless_transmute.rs +++ b/clippy_lints/src/transmute/useless_transmute.rs @@ -21,7 +21,7 @@ pub(super) fn check<'tcx>( cx, USELESS_TRANSMUTE, e.span, - &format!("transmute from a type (`{from_ty}`) to itself"), + format!("transmute from a type (`{from_ty}`) to itself"), ); true }, diff --git a/clippy_lints/src/transmute/wrong_transmute.rs b/clippy_lints/src/transmute/wrong_transmute.rs index d1965565b92..53c479b54d5 100644 --- a/clippy_lints/src/transmute/wrong_transmute.rs +++ b/clippy_lints/src/transmute/wrong_transmute.rs @@ -13,7 +13,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty cx, WRONG_TRANSMUTE, e.span, - &format!("transmute from a `{from_ty}` to a pointer"), + format!("transmute from a `{from_ty}` to a pointer"), ); true }, diff --git a/clippy_lints/src/types/box_collection.rs b/clippy_lints/src/types/box_collection.rs index fc3420af020..9ac73394548 100644 --- a/clippy_lints/src/types/box_collection.rs +++ b/clippy_lints/src/types/box_collection.rs @@ -21,9 +21,9 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_ cx, BOX_COLLECTION, hir_ty.span, - &format!("you seem to be trying to use `Box<{box_content}>`. Consider using just `{box_content}`"), + format!("you seem to be trying to use `Box<{box_content}>`. Consider using just `{box_content}`"), None, - &format!("`{box_content}` is already on the heap, `Box<{box_content}>` makes an extra allocation"), + format!("`{box_content}` is already on the heap, `Box<{box_content}>` makes an extra allocation"), ); true } else { diff --git a/clippy_lints/src/types/redundant_allocation.rs b/clippy_lints/src/types/redundant_allocation.rs index a0d609501a0..893faafc2c0 100644 --- a/clippy_lints/src/types/redundant_allocation.rs +++ b/clippy_lints/src/types/redundant_allocation.rs @@ -29,7 +29,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, hir_ty: &hir::Ty<'tcx>, qpath: cx, REDUNDANT_ALLOCATION, hir_ty.span, - &format!("usage of `{outer_sym}<{generic_snippet}>`"), + format!("usage of `{outer_sym}<{generic_snippet}>`"), |diag| { diag.span_suggestion(hir_ty.span, "try", format!("{generic_snippet}"), applicability); diag.note(format!( @@ -73,7 +73,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, hir_ty: &hir::Ty<'tcx>, qpath: cx, REDUNDANT_ALLOCATION, hir_ty.span, - &format!("usage of `{outer_sym}<{inner_sym}<{generic_snippet}>>`"), + format!("usage of `{outer_sym}<{inner_sym}<{generic_snippet}>>`"), |diag| { diag.span_suggestion( hir_ty.span, @@ -92,7 +92,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, hir_ty: &hir::Ty<'tcx>, qpath: cx, REDUNDANT_ALLOCATION, hir_ty.span, - &format!("usage of `{outer_sym}<{inner_sym}<{generic_snippet}>>`"), + format!("usage of `{outer_sym}<{inner_sym}<{generic_snippet}>>`"), |diag| { diag.note(format!( "`{inner_sym}<{generic_snippet}>` is already on the heap, `{outer_sym}<{inner_sym}<{generic_snippet}>>` makes an extra allocation" diff --git a/clippy_lints/src/undocumented_unsafe_blocks.rs b/clippy_lints/src/undocumented_unsafe_blocks.rs index 1dedb4510bd..8106694c43b 100644 --- a/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -251,7 +251,7 @@ impl<'tcx> LateLintPass<'tcx> for UndocumentedUnsafeBlocks { cx, UNNECESSARY_SAFETY_COMMENT, span, - &format!("{} has unnecessary safety comment", item.kind.descr()), + format!("{} has unnecessary safety comment", item.kind.descr()), Some(help_span), "consider removing the safety comment", ); @@ -268,7 +268,7 @@ impl<'tcx> LateLintPass<'tcx> for UndocumentedUnsafeBlocks { cx, UNNECESSARY_SAFETY_COMMENT, span, - &format!("{} has unnecessary safety comment", item.kind.descr()), + format!("{} has unnecessary safety comment", item.kind.descr()), Some(help_span), "consider removing the safety comment", ); diff --git a/clippy_lints/src/unit_return_expecting_ord.rs b/clippy_lints/src/unit_return_expecting_ord.rs index 729972de6e6..214b69dc925 100644 --- a/clippy_lints/src/unit_return_expecting_ord.rs +++ b/clippy_lints/src/unit_return_expecting_ord.rs @@ -153,7 +153,7 @@ impl<'tcx> LateLintPass<'tcx> for UnitReturnExpectingOrd { cx, UNIT_RETURN_EXPECTING_ORD, span, - &format!( + format!( "this closure returns \ the unit type which also implements {trait_name}" ), @@ -164,7 +164,7 @@ impl<'tcx> LateLintPass<'tcx> for UnitReturnExpectingOrd { cx, UNIT_RETURN_EXPECTING_ORD, span, - &format!( + format!( "this closure returns \ the unit type which also implements {trait_name}" ), diff --git a/clippy_lints/src/unit_types/unit_arg.rs b/clippy_lints/src/unit_types/unit_arg.rs index 7fd17e332e4..afc53e6f32d 100644 --- a/clippy_lints/src/unit_types/unit_arg.rs +++ b/clippy_lints/src/unit_types/unit_arg.rs @@ -69,7 +69,7 @@ fn lint_unit_args(cx: &LateContext<'_>, expr: &Expr<'_>, args_to_recover: &[&Exp cx, UNIT_ARG, expr.span, - &format!("passing {singular}unit value{plural} to a function"), + format!("passing {singular}unit value{plural} to a function"), |db| { let mut or = ""; args_to_recover diff --git a/clippy_lints/src/unit_types/unit_cmp.rs b/clippy_lints/src/unit_types/unit_cmp.rs index d4342ec5169..6dcc1195a70 100644 --- a/clippy_lints/src/unit_types/unit_cmp.rs +++ b/clippy_lints/src/unit_types/unit_cmp.rs @@ -24,7 +24,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { cx, UNIT_CMP, macro_call.span, - &format!("`{macro_name}` of unit values detected. This will always {result}"), + format!("`{macro_name}` of unit values detected. This will always {result}"), ); } return; @@ -41,7 +41,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) { cx, UNIT_CMP, expr.span, - &format!( + format!( "{}-comparison of unit values detected. This will always be {result}", op.as_str() ), diff --git a/clippy_lints/src/unnecessary_box_returns.rs b/clippy_lints/src/unnecessary_box_returns.rs index c332cf076ae..bfcefb26153 100644 --- a/clippy_lints/src/unnecessary_box_returns.rs +++ b/clippy_lints/src/unnecessary_box_returns.rs @@ -88,7 +88,7 @@ impl UnnecessaryBoxReturns { cx, UNNECESSARY_BOX_RETURNS, return_ty_hir.span, - format!("boxed return of the sized type `{boxed_ty}`").as_str(), + format!("boxed return of the sized type `{boxed_ty}`"), |diagnostic| { diagnostic.span_suggestion( return_ty_hir.span, diff --git a/clippy_lints/src/unnecessary_map_on_constructor.rs b/clippy_lints/src/unnecessary_map_on_constructor.rs index 252e5e4dd7c..8f1eb5019f0 100644 --- a/clippy_lints/src/unnecessary_map_on_constructor.rs +++ b/clippy_lints/src/unnecessary_map_on_constructor.rs @@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor { cx, UNNECESSARY_MAP_ON_CONSTRUCTOR, expr.span, - &format!( + format!( "unnecessary {} on constructor {constructor_snippet}(_)", path.ident.name ), diff --git a/clippy_lints/src/unnecessary_wraps.rs b/clippy_lints/src/unnecessary_wraps.rs index 9c8b0ae1727..5c7fbbab988 100644 --- a/clippy_lints/src/unnecessary_wraps.rs +++ b/clippy_lints/src/unnecessary_wraps.rs @@ -156,7 +156,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps { ) }; - span_lint_and_then(cx, UNNECESSARY_WRAPS, span, lint_msg.as_str(), |diag| { + span_lint_and_then(cx, UNNECESSARY_WRAPS, span, lint_msg, |diag| { diag.span_suggestion( fn_decl.output.span(), return_type_sugg_msg, diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index 3f2f765f751..51b3ea93b6d 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -65,7 +65,7 @@ fn unsafe_to_safe_check(old_name: Ident, new_name: Ident, cx: &EarlyContext<'_>, cx, UNSAFE_REMOVED_FROM_NAME, span, - &format!("removed `unsafe` from the name of `{old_str}` in use as `{new_str}`"), + format!("removed `unsafe` from the name of `{old_str}` in use as `{new_str}`"), ); } } diff --git a/clippy_lints/src/unused_rounding.rs b/clippy_lints/src/unused_rounding.rs index d5ca844b9e2..3e5afec541c 100644 --- a/clippy_lints/src/unused_rounding.rs +++ b/clippy_lints/src/unused_rounding.rs @@ -55,8 +55,8 @@ impl EarlyLintPass for UnusedRounding { cx, UNUSED_ROUNDING, expr.span, - &format!("used the `{method_name}` method with a whole number float"), - &format!("remove the `{method_name}` method call"), + format!("used the `{method_name}` method with a whole number float"), + format!("remove the `{method_name}` method call"), float, Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index f2eb774b5cb..2622abd59cb 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -338,7 +338,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> { UNNECESSARY_UNWRAP, expr.hir_id, expr.span, - &format!( + format!( "called `{}` on `{unwrappable_variable_name}` after checking its variant with `{}`", method_name.ident.name, unwrappable.check_name.ident.as_str(), @@ -373,7 +373,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> { PANICKING_UNWRAP, expr.hir_id, expr.span, - &format!("this call to `{}()` will always panic", method_name.ident.name), + format!("this call to `{}()` will always panic", method_name.ident.name), |diag| { diag.span_label(unwrappable.check.span, "because of this check"); }, diff --git a/clippy_lints/src/upper_case_acronyms.rs b/clippy_lints/src/upper_case_acronyms.rs index d2a1d42f279..f376d349646 100644 --- a/clippy_lints/src/upper_case_acronyms.rs +++ b/clippy_lints/src/upper_case_acronyms.rs @@ -94,7 +94,7 @@ fn check_ident(cx: &LateContext<'_>, ident: &Ident, hir_id: HirId, be_aggressive UPPER_CASE_ACRONYMS, hir_id, span, - &format!("name `{ident}` contains a capitalized acronym"), + format!("name `{ident}` contains a capitalized acronym"), |diag| { diag.span_suggestion( span, diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index f7a455977fa..75541766156 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -184,7 +184,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { cx, USELESS_CONVERSION, e.span, - &format!("useless conversion to the same type: `{b}`"), + format!("useless conversion to the same type: `{b}`"), "consider removing `.into()`", sugg.into_owned(), app, @@ -301,7 +301,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { cx, USELESS_CONVERSION, e.span, - &format!("useless conversion to the same type: `{b}`"), + format!("useless conversion to the same type: `{b}`"), "consider removing `.into_iter()`", sugg, Applicability::MachineApplicable, // snippet @@ -321,7 +321,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { cx, USELESS_CONVERSION, e.span, - &format!("useless conversion to the same type: `{b}`"), + format!("useless conversion to the same type: `{b}`"), None, "consider removing `.try_into()`", ); @@ -346,9 +346,9 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { cx, USELESS_CONVERSION, e.span, - &format!("useless conversion to the same type: `{b}`"), + format!("useless conversion to the same type: `{b}`"), None, - &hint, + hint, ); } @@ -360,8 +360,8 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { cx, USELESS_CONVERSION, e.span, - &format!("useless conversion to the same type: `{b}`"), - &sugg_msg, + format!("useless conversion to the same type: `{b}`"), + sugg_msg, sugg.to_string(), app, ); diff --git a/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs b/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs index 4822970e47e..5483e80f932 100644 --- a/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs +++ b/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for AlmostStandardFormulation { ident.span, "non-standard lint formulation", None, - &format!("consider using `{}`", formulation.correction), + format!("consider using `{}`", formulation.correction), ); } return; diff --git a/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs b/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs index df37619227c..9b6b6871818 100644 --- a/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs +++ b/clippy_lints/src/utils/internal_lints/compiler_lint_functions.rs @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for CompilerLintFunctions { path.ident.span, "usage of a compiler lint function", None, - &format!("please use the Clippy variant of this function: `{sugg}`"), + format!("please use the Clippy variant of this function: `{sugg}`"), ); } } diff --git a/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs b/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs index 370ed430bcf..9be225759df 100644 --- a/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs +++ b/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs @@ -181,7 +181,7 @@ impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass { cx, DEFAULT_LINT, item.span, - &format!("the lint `{}` has the default lint description", item.ident.name), + format!("the lint `{}` has the default lint description", item.ident.name), ); } @@ -191,7 +191,7 @@ impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass { cx, DEFAULT_DEPRECATION_REASON, item.span, - &format!("the lint `{}` has the default deprecation reason", item.ident.name), + format!("the lint `{}` has the default deprecation reason", item.ident.name), ); } } @@ -247,7 +247,7 @@ impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass { cx, LINT_WITHOUT_LINT_PASS, lint_span, - &format!("the lint `{lint_name}` is not added to any `LintPass`"), + format!("the lint `{lint_name}` is not added to any `LintPass`"), ); } } diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index d6a541a1eff..5fb80059e03 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -822,7 +822,7 @@ fn lint_collection_error_item(cx: &LateContext<'_>, item: &Item<'_>, message: &s cx, METADATA_COLLECTOR, item.ident.span, - &format!("metadata collection error for `{}`: {message}", item.ident.name), + format!("metadata collection error for `{}`: {message}", item.ident.name), ); } diff --git a/clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs b/clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs index 6d5240db832..777fe544b24 100644 --- a/clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs +++ b/clippy_lints/src/utils/internal_lints/msrv_attr_impl.rs @@ -51,8 +51,8 @@ impl LateLintPass<'_> for MsrvAttrImpl { cx, MISSING_MSRV_ATTR_IMPL, span, - &format!("`extract_msrv_attr!` macro missing from `{lint_pass}` implementation"), - &format!("add `extract_msrv_attr!({context})` to the `{lint_pass}` implementation"), + format!("`extract_msrv_attr!` macro missing from `{lint_pass}` implementation"), + format!("add `extract_msrv_attr!({context})` to the `{lint_pass}` implementation"), format!("{}\n extract_msrv_attr!({context});", snippet(cx, span, "..")), Applicability::MachineApplicable, ); diff --git a/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs b/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs index 5fb643854dc..2fa55c5ff52 100644 --- a/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs +++ b/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs @@ -78,9 +78,9 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryDefPath { cx, UNNECESSARY_DEF_PATH, span, - &format!("hardcoded path to a {msg}"), + format!("hardcoded path to a {msg}"), None, - &format!("convert all references to use `{sugg}`"), + format!("convert all references to use `{sugg}`"), ); } } diff --git a/clippy_lints/src/visibility.rs b/clippy_lints/src/visibility.rs index 83369c66367..9818b98dd5b 100644 --- a/clippy_lints/src/visibility.rs +++ b/clippy_lints/src/visibility.rs @@ -89,7 +89,7 @@ impl EarlyLintPass for Visibility { cx, NEEDLESS_PUB_SELF, item.vis.span, - &format!("unnecessary `pub({}self)`", if *shorthand { "" } else { "in " }), + format!("unnecessary `pub({}self)`", if *shorthand { "" } else { "in " }), "remove it", String::new(), Applicability::MachineApplicable, diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index be16d2e5cc3..26c6859233d 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -297,11 +297,11 @@ impl<'tcx> LateLintPass<'tcx> for Write { match diag_name { sym::print_macro | sym::println_macro if !allowed_in_tests => { if !is_build_script { - span_lint(cx, PRINT_STDOUT, macro_call.span, &format!("use of `{name}!`")); + span_lint(cx, PRINT_STDOUT, macro_call.span, format!("use of `{name}!`")); } }, sym::eprint_macro | sym::eprintln_macro if !allowed_in_tests => { - span_lint(cx, PRINT_STDERR, macro_call.span, &format!("use of `{name}!`")); + span_lint(cx, PRINT_STDERR, macro_call.span, format!("use of `{name}!`")); }, sym::write_macro | sym::writeln_macro => {}, _ => return, @@ -390,7 +390,7 @@ fn check_newline(cx: &LateContext<'_>, format_args: &FormatArgs, macro_call: &Ma cx, lint, macro_call.span, - &format!("using `{name}!()` with a format string that ends in a single newline"), + format!("using `{name}!()` with a format string that ends in a single newline"), |diag| { let name_span = cx.sess().source_map().span_until_char(macro_call.span, '!'); let Some(format_snippet) = snippet_opt(cx, format_string_span) else { @@ -440,7 +440,7 @@ fn check_empty_string(cx: &LateContext<'_>, format_args: &FormatArgs, macro_call cx, lint, macro_call.span, - &format!("empty string literal in `{name}!`"), + format!("empty string literal in `{name}!`"), |diag| { diag.span_suggestion( span, diff --git a/clippy_lints/src/zero_div_zero.rs b/clippy_lints/src/zero_div_zero.rs index d3623d6fda4..662242f6196 100644 --- a/clippy_lints/src/zero_div_zero.rs +++ b/clippy_lints/src/zero_div_zero.rs @@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for ZeroDiv { expr.span, "constant division of `0.0` with `0.0` will always result in NaN", None, - &format!("consider using `{float_type}::NAN` if you would like a constant representing NaN",), + format!("consider using `{float_type}::NAN` if you would like a constant representing NaN",), ); } } -- cgit 1.4.1-3-g733a5 From 3ab1da8bab0779888975b62c934160da6b8aa6e7 Mon Sep 17 00:00:00 2001 From: Philipp Krones Date: Sun, 22 Sep 2024 20:42:10 +0200 Subject: Formatting --- clippy_config/src/conf.rs | 2 +- clippy_config/src/lib.rs | 2 +- clippy_config/src/msrvs.rs | 2 +- clippy_config/src/types.rs | 2 +- clippy_dev/src/fmt.rs | 2 +- clippy_dev/src/new_lint.rs | 2 +- clippy_dev/src/update_lints.rs | 30 +-- clippy_lints/src/absolute_paths.rs | 4 +- clippy_lints/src/almost_complete_range.rs | 2 +- clippy_lints/src/approx_const.rs | 4 +- clippy_lints/src/arc_with_non_send_sync.rs | 2 +- clippy_lints/src/assertions_on_constants.rs | 2 +- clippy_lints/src/assertions_on_result_states.rs | 2 +- clippy_lints/src/assigning_clones.rs | 4 +- .../src/attrs/allow_attributes_without_reason.rs | 2 +- .../src/attrs/blanket_clippy_restriction_lints.rs | 4 +- clippy_lints/src/attrs/deprecated_cfg_attr.rs | 2 +- clippy_lints/src/attrs/duplicated_attributes.rs | 2 +- clippy_lints/src/attrs/inline_always.rs | 4 +- clippy_lints/src/attrs/mod.rs | 2 +- clippy_lints/src/attrs/useless_attribute.rs | 2 +- clippy_lints/src/await_holding_invalid.rs | 2 +- clippy_lints/src/booleans.rs | 4 +- clippy_lints/src/box_default.rs | 2 +- clippy_lints/src/cargo/lint_groups_priority.rs | 2 +- clippy_lints/src/casts/cast_lossless.rs | 2 +- clippy_lints/src/casts/cast_possible_truncation.rs | 2 +- clippy_lints/src/casts/cast_possible_wrap.rs | 2 +- clippy_lints/src/casts/cast_precision_loss.rs | 2 +- clippy_lints/src/casts/cast_sign_loss.rs | 2 +- clippy_lints/src/casts/fn_to_numeric_cast.rs | 2 +- .../casts/fn_to_numeric_cast_with_truncation.rs | 2 +- clippy_lints/src/casts/mod.rs | 2 +- clippy_lints/src/casts/ref_as_ptr.rs | 2 +- clippy_lints/src/casts/unnecessary_cast.rs | 4 +- clippy_lints/src/casts/utils.rs | 2 +- clippy_lints/src/checked_conversions.rs | 4 +- clippy_lints/src/cognitive_complexity.rs | 4 +- clippy_lints/src/collection_is_never_read.rs | 2 +- clippy_lints/src/comparison_chain.rs | 2 +- clippy_lints/src/copies.rs | 11 +- clippy_lints/src/crate_in_macro_def.rs | 2 +- clippy_lints/src/dbg_macro.rs | 4 +- clippy_lints/src/default.rs | 2 +- .../src/default_constructed_unit_structs.rs | 2 +- clippy_lints/src/default_instead_of_iter_empty.rs | 4 +- clippy_lints/src/default_numeric_fallback.rs | 2 +- clippy_lints/src/dereference.rs | 73 +++--- clippy_lints/src/derivable_impls.rs | 2 +- clippy_lints/src/derive.rs | 4 +- clippy_lints/src/doc/empty_line_after.rs | 13 +- clippy_lints/src/doc/link_with_quotes.rs | 2 +- clippy_lints/src/doc/missing_headers.rs | 2 +- clippy_lints/src/doc/mod.rs | 6 +- clippy_lints/src/doc/needless_doctest_main.rs | 2 +- clippy_lints/src/entry.rs | 8 +- clippy_lints/src/enum_clike.rs | 2 +- clippy_lints/src/escape.rs | 4 +- clippy_lints/src/excessive_bools.rs | 2 +- clippy_lints/src/excessive_nesting.rs | 2 +- clippy_lints/src/explicit_write.rs | 4 +- clippy_lints/src/extra_unused_type_parameters.rs | 4 +- clippy_lints/src/fallible_impl_from.rs | 2 +- clippy_lints/src/floating_point_arithmetic.rs | 2 +- clippy_lints/src/format.rs | 6 +- clippy_lints/src/format_args.rs | 11 +- clippy_lints/src/format_impl.rs | 4 +- clippy_lints/src/format_push_string.rs | 2 +- clippy_lints/src/from_over_into.rs | 4 +- clippy_lints/src/from_str_radix_10.rs | 2 +- clippy_lints/src/functions/mod.rs | 2 +- clippy_lints/src/functions/must_use.rs | 2 +- .../src/functions/not_unsafe_ptr_arg_deref.rs | 2 +- .../src/functions/renamed_function_params.rs | 2 +- clippy_lints/src/functions/result.rs | 4 +- clippy_lints/src/future_not_send.rs | 2 +- clippy_lints/src/if_then_some_else_none.rs | 2 +- clippy_lints/src/implicit_hasher.rs | 6 +- clippy_lints/src/implicit_saturating_sub.rs | 4 +- clippy_lints/src/incompatible_msrv.rs | 4 +- clippy_lints/src/index_refutable_slice.rs | 6 +- clippy_lints/src/ineffective_open_options.rs | 2 +- clippy_lints/src/instant_subtraction.rs | 2 +- clippy_lints/src/item_name_repetitions.rs | 2 +- clippy_lints/src/items_after_test_module.rs | 2 +- clippy_lints/src/iter_not_returning_iterator.rs | 2 +- clippy_lints/src/iter_over_hash_type.rs | 4 +- clippy_lints/src/large_enum_variant.rs | 2 +- clippy_lints/src/large_stack_arrays.rs | 2 +- clippy_lints/src/legacy_numeric_constants.rs | 4 +- clippy_lints/src/len_zero.rs | 4 +- clippy_lints/src/lib.rs | 2 +- clippy_lints/src/lifetimes.rs | 16 +- clippy_lints/src/loops/explicit_counter_loop.rs | 2 +- clippy_lints/src/loops/infinite_loop.rs | 2 +- clippy_lints/src/loops/manual_find.rs | 2 +- clippy_lints/src/loops/manual_flatten.rs | 2 +- clippy_lints/src/loops/manual_while_let_some.rs | 4 +- clippy_lints/src/loops/mod.rs | 4 +- clippy_lints/src/loops/needless_range_loop.rs | 6 +- clippy_lints/src/loops/never_loop.rs | 4 +- clippy_lints/src/loops/same_item_push.rs | 4 +- clippy_lints/src/loops/single_element_loop.rs | 4 +- clippy_lints/src/loops/utils.rs | 4 +- .../src/loops/while_immutable_condition.rs | 2 +- clippy_lints/src/loops/while_let_on_iterator.rs | 4 +- clippy_lints/src/macro_metavars_in_unsafe.rs | 6 +- clippy_lints/src/macro_use.rs | 2 +- clippy_lints/src/manual_async_fn.rs | 4 +- clippy_lints/src/manual_bits.rs | 2 +- clippy_lints/src/manual_clamp.rs | 8 +- clippy_lints/src/manual_div_ceil.rs | 2 +- clippy_lints/src/manual_hash_one.rs | 2 +- clippy_lints/src/manual_is_ascii_check.rs | 6 +- clippy_lints/src/manual_is_power_of_two.rs | 2 +- clippy_lints/src/manual_let_else.rs | 4 +- clippy_lints/src/manual_main_separator_str.rs | 2 +- clippy_lints/src/manual_non_exhaustive.rs | 4 +- clippy_lints/src/manual_range_patterns.rs | 2 +- clippy_lints/src/manual_rem_euclid.rs | 2 +- clippy_lints/src/manual_retain.rs | 8 +- clippy_lints/src/manual_string_new.rs | 2 +- clippy_lints/src/manual_strip.rs | 6 +- clippy_lints/src/map_unit_fn.rs | 2 +- clippy_lints/src/matches/collapsible_match.rs | 4 +- clippy_lints/src/matches/manual_filter.rs | 4 +- clippy_lints/src/matches/manual_map.rs | 2 +- clippy_lints/src/matches/manual_unwrap_or.rs | 4 +- clippy_lints/src/matches/manual_utils.rs | 8 +- clippy_lints/src/matches/match_same_arms.rs | 2 +- .../src/matches/match_str_case_mismatch.rs | 4 +- clippy_lints/src/matches/mod.rs | 2 +- clippy_lints/src/matches/overlapping_arms.rs | 2 +- clippy_lints/src/matches/redundant_guards.rs | 4 +- .../src/matches/redundant_pattern_match.rs | 6 +- .../src/matches/significant_drop_in_scrutinee.rs | 2 +- clippy_lints/src/matches/single_match.rs | 6 +- clippy_lints/src/mem_replace.rs | 4 +- clippy_lints/src/methods/bind_instead_of_map.rs | 2 +- .../case_sensitive_file_extension_comparisons.rs | 4 +- clippy_lints/src/methods/clear_with_drain.rs | 2 +- clippy_lints/src/methods/clone_on_copy.rs | 2 +- clippy_lints/src/methods/clone_on_ref_ptr.rs | 2 +- .../src/methods/cloned_instead_of_copied.rs | 2 +- .../src/methods/collapsible_str_replace.rs | 2 +- clippy_lints/src/methods/drain_collect.rs | 2 +- clippy_lints/src/methods/err_expect.rs | 2 +- clippy_lints/src/methods/expect_fun_call.rs | 4 +- clippy_lints/src/methods/filetype_is_file.rs | 2 +- clippy_lints/src/methods/filter_map.rs | 4 +- clippy_lints/src/methods/filter_map_bool_then.rs | 4 +- clippy_lints/src/methods/filter_map_identity.rs | 2 +- clippy_lints/src/methods/flat_map_identity.rs | 2 +- clippy_lints/src/methods/flat_map_option.rs | 2 +- clippy_lints/src/methods/get_last_with_len.rs | 2 +- clippy_lints/src/methods/inefficient_to_string.rs | 2 +- clippy_lints/src/methods/inspect_for_each.rs | 2 +- clippy_lints/src/methods/into_iter_on_ref.rs | 2 +- clippy_lints/src/methods/iter_filter.rs | 2 +- clippy_lints/src/methods/iter_nth.rs | 2 +- .../methods/iter_on_single_or_empty_collections.rs | 2 +- clippy_lints/src/methods/iter_with_drain.rs | 2 +- clippy_lints/src/methods/join_absolute_paths.rs | 2 +- clippy_lints/src/methods/manual_c_str_literals.rs | 2 +- clippy_lints/src/methods/manual_inspect.rs | 4 +- clippy_lints/src/methods/manual_is_variant_and.rs | 2 +- clippy_lints/src/methods/manual_ok_or.rs | 2 +- clippy_lints/src/methods/manual_try_fold.rs | 2 +- clippy_lints/src/methods/map_clone.rs | 2 +- clippy_lints/src/methods/map_flatten.rs | 2 +- clippy_lints/src/methods/map_identity.rs | 2 +- clippy_lints/src/methods/mod.rs | 13 +- clippy_lints/src/methods/mut_mutex_lock.rs | 2 +- .../src/methods/needless_character_iteration.rs | 2 +- clippy_lints/src/methods/needless_collect.rs | 8 +- .../src/methods/needless_option_as_deref.rs | 2 +- clippy_lints/src/methods/no_effect_replace.rs | 2 +- clippy_lints/src/methods/open_options.rs | 16 +- clippy_lints/src/methods/option_as_ref_cloned.rs | 4 +- clippy_lints/src/methods/option_as_ref_deref.rs | 10 +- clippy_lints/src/methods/option_map_unwrap_or.rs | 4 +- clippy_lints/src/methods/or_fun_call.rs | 2 +- clippy_lints/src/methods/or_then_unwrap.rs | 2 +- clippy_lints/src/methods/range_zip_with_len.rs | 2 +- clippy_lints/src/methods/search_is_some.rs | 2 +- clippy_lints/src/methods/seek_from_current.rs | 2 +- .../src/methods/seek_to_start_instead_of_rewind.rs | 4 +- clippy_lints/src/methods/str_splitn.rs | 4 +- .../src/methods/suspicious_command_arg_space.rs | 2 +- clippy_lints/src/methods/type_id_on_box.rs | 2 +- .../methods/unnecessary_fallible_conversions.rs | 2 +- clippy_lints/src/methods/unnecessary_filter_map.rs | 2 +- clippy_lints/src/methods/unnecessary_fold.rs | 70 ++---- .../src/methods/unnecessary_get_then_check.rs | 2 +- .../src/methods/unnecessary_iter_cloned.rs | 2 +- .../src/methods/unnecessary_literal_unwrap.rs | 2 +- clippy_lints/src/methods/unnecessary_min_or_max.rs | 2 +- .../src/methods/unnecessary_result_map_or_else.rs | 2 +- clippy_lints/src/methods/unnecessary_to_owned.rs | 7 +- clippy_lints/src/methods/unused_enumerate_index.rs | 4 +- clippy_lints/src/methods/useless_asref.rs | 2 +- clippy_lints/src/methods/utils.rs | 4 +- clippy_lints/src/methods/vec_resize_to_zero.rs | 2 +- clippy_lints/src/methods/waker_clone_wake.rs | 2 +- clippy_lints/src/min_ident_chars.rs | 2 +- clippy_lints/src/misc.rs | 6 +- clippy_lints/src/missing_assert_message.rs | 2 +- clippy_lints/src/missing_asserts_for_indexing.rs | 4 +- clippy_lints/src/missing_const_for_fn.rs | 4 +- clippy_lints/src/missing_const_for_thread_local.rs | 4 +- clippy_lints/src/missing_doc.rs | 2 +- clippy_lints/src/missing_fields_in_debug.rs | 4 +- clippy_lints/src/missing_inline.rs | 2 +- clippy_lints/src/mixed_read_write_in_expression.rs | 2 +- clippy_lints/src/multiple_unsafe_ops_per_block.rs | 25 +-- clippy_lints/src/mut_key.rs | 2 +- clippy_lints/src/mutable_debug_assertion.rs | 2 +- clippy_lints/src/needless_arbitrary_self_type.rs | 2 +- clippy_lints/src/needless_bool.rs | 6 +- .../src/needless_borrows_for_generic_args.rs | 6 +- clippy_lints/src/needless_for_each.rs | 4 +- clippy_lints/src/needless_pass_by_ref_mut.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 15 +- clippy_lints/src/no_effect.rs | 4 +- clippy_lints/src/non_copy_const.rs | 4 +- clippy_lints/src/non_expressive_names.rs | 4 +- clippy_lints/src/non_octal_unix_permissions.rs | 2 +- clippy_lints/src/nonstandard_macro_braces.rs | 4 +- clippy_lints/src/only_used_in_recursion.rs | 2 +- .../src/operators/absurd_extreme_comparisons.rs | 2 +- clippy_lints/src/operators/const_comparisons.rs | 4 +- .../src/operators/float_equality_without_abs.rs | 3 +- clippy_lints/src/option_if_let_else.rs | 6 +- clippy_lints/src/panic_in_result_fn.rs | 4 +- clippy_lints/src/pass_by_ref_or_value.rs | 2 +- clippy_lints/src/pathbuf_init_then_push.rs | 4 +- clippy_lints/src/pattern_type_mismatch.rs | 4 +- clippy_lints/src/ptr.rs | 4 +- clippy_lints/src/pub_underscore_fields.rs | 2 +- clippy_lints/src/question_mark.rs | 4 +- clippy_lints/src/ranges.rs | 6 +- clippy_lints/src/rc_clone_in_vec_init.rs | 2 +- clippy_lints/src/read_zero_byte_vec.rs | 4 +- clippy_lints/src/redundant_clone.rs | 20 +- clippy_lints/src/redundant_closure_call.rs | 2 +- clippy_lints/src/redundant_else.rs | 2 +- clippy_lints/src/redundant_field_names.rs | 2 +- clippy_lints/src/redundant_locals.rs | 2 +- clippy_lints/src/redundant_static_lifetimes.rs | 2 +- clippy_lints/src/reference.rs | 2 +- clippy_lints/src/repeat_vec_with_capacity.rs | 2 +- clippy_lints/src/reserve_after_initialization.rs | 2 +- clippy_lints/src/return_self_not_must_use.rs | 2 +- clippy_lints/src/returns.rs | 8 +- clippy_lints/src/same_name_method.rs | 13 +- clippy_lints/src/set_contains_or_insert.rs | 4 +- clippy_lints/src/significant_drop_tightening.rs | 4 +- clippy_lints/src/single_component_path_imports.rs | 2 +- clippy_lints/src/slow_vector_initialization.rs | 5 +- clippy_lints/src/std_instead_of_core.rs | 4 +- clippy_lints/src/string_patterns.rs | 6 +- clippy_lints/src/strings.rs | 4 +- clippy_lints/src/suspicious_operation_groupings.rs | 4 +- clippy_lints/src/suspicious_trait_impl.rs | 2 +- clippy_lints/src/swap.rs | 4 +- clippy_lints/src/swap_ptr_to_ref.rs | 2 +- clippy_lints/src/tests_outside_test_module.rs | 2 +- clippy_lints/src/to_digit_is_some.rs | 12 +- clippy_lints/src/trait_bounds.rs | 6 +- clippy_lints/src/transmute/mod.rs | 2 +- .../transmutes_expressible_as_ptr_casts.rs | 2 +- .../src/transmute/unsound_collection_transmute.rs | 2 +- clippy_lints/src/tuple_array_conversions.rs | 2 +- clippy_lints/src/types/box_collection.rs | 2 +- clippy_lints/src/types/mod.rs | 66 ++---- clippy_lints/src/types/redundant_allocation.rs | 2 +- clippy_lints/src/types/type_complexity.rs | 2 +- clippy_lints/src/types/vec_box.rs | 2 +- clippy_lints/src/unconditional_recursion.rs | 17 +- clippy_lints/src/undocumented_unsafe_blocks.rs | 4 +- clippy_lints/src/uninhabited_references.rs | 2 +- clippy_lints/src/uninit_vec.rs | 6 +- clippy_lints/src/unit_return_expecting_ord.rs | 2 +- clippy_lints/src/unit_types/let_unit_value.rs | 2 +- clippy_lints/src/unit_types/unit_arg.rs | 4 +- clippy_lints/src/unnecessary_wraps.rs | 4 +- clippy_lints/src/unnested_or_patterns.rs | 8 +- clippy_lints/src/unsafe_removed_from_name.rs | 2 +- clippy_lints/src/unused_async.rs | 4 +- clippy_lints/src/unused_io_amount.rs | 2 +- clippy_lints/src/unused_peekable.rs | 2 +- clippy_lints/src/unused_trait_names.rs | 2 +- clippy_lints/src/unused_unit.rs | 4 +- clippy_lints/src/unwrap.rs | 4 +- clippy_lints/src/unwrap_in_result.rs | 2 +- clippy_lints/src/use_self.rs | 4 +- clippy_lints/src/useless_conversion.rs | 2 +- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/format_args_collector.rs | 4 +- .../src/utils/internal_lints/collapsible_calls.rs | 2 +- .../src/utils/internal_lints/invalid_paths.rs | 4 +- .../utils/internal_lints/lint_without_lint_pass.rs | 2 +- .../utils/internal_lints/unnecessary_def_path.rs | 4 +- clippy_lints/src/vec.rs | 4 +- clippy_lints/src/vec_init_then_push.rs | 2 +- clippy_lints/src/visibility.rs | 2 +- clippy_lints/src/wildcard_imports.rs | 2 +- clippy_lints/src/write.rs | 6 +- clippy_lints/src/zombie_processes.rs | 4 +- clippy_utils/src/ast_utils/ident_iter.rs | 2 +- clippy_utils/src/attrs.rs | 2 +- clippy_utils/src/check_proc_macro.rs | 4 +- clippy_utils/src/consts.rs | 10 +- clippy_utils/src/eager_or_lazy.rs | 4 +- clippy_utils/src/higher.rs | 4 +- clippy_utils/src/hir_utils.rs | 8 +- clippy_utils/src/lib.rs | 34 +-- clippy_utils/src/macros.rs | 4 +- clippy_utils/src/mir/mod.rs | 14 +- clippy_utils/src/ptr.rs | 2 +- clippy_utils/src/qualify_min_const_fn.rs | 2 +- clippy_utils/src/source.rs | 21 +- clippy_utils/src/str_utils.rs | 10 +- clippy_utils/src/ty.rs | 4 +- clippy_utils/src/ty/type_certainty/mod.rs | 4 +- clippy_utils/src/usage.rs | 2 +- clippy_utils/src/visitors.rs | 4 +- declare_clippy_lint/src/lib.rs | 17 +- lintcheck/src/driver.rs | 2 +- lintcheck/src/recursive.rs | 2 +- src/driver.rs | 2 +- tests/compile-test.rs | 10 +- tests/config-metadata.rs | 2 +- tests/ui-internal/unnecessary_def_path.fixed | 2 +- tests/ui-internal/unnecessary_def_path.rs | 2 +- .../conf_missing_enforced_import_rename.fixed | 2 +- .../conf_missing_enforced_import_rename.rs | 2 +- .../conf_missing_enforced_import_rename.stderr | 6 +- tests/ui/arithmetic_side_effects.rs | 1 - tests/ui/arithmetic_side_effects.stderr | 246 ++++++++++----------- tests/ui/auxiliary/proc_macro_attr.rs | 4 +- tests/ui/auxiliary/proc_macro_derive.rs | 2 +- .../proc_macro_suspicious_else_formatting.rs | 2 +- tests/ui/auxiliary/proc_macros.rs | 2 +- tests/ui/borrow_interior_mutable_const/others.rs | 2 +- tests/ui/declare_interior_mutable_const/others.rs | 2 +- tests/ui/field_reassign_with_default.rs | 2 +- tests/ui/format_args.fixed | 2 +- tests/ui/format_args.rs | 2 +- tests/ui/format_args_unfixable.rs | 2 +- tests/ui/ignored_unit_patterns.fixed | 15 +- tests/ui/ignored_unit_patterns.rs | 15 +- tests/ui/ignored_unit_patterns.stderr | 18 +- tests/ui/incompatible_msrv.rs | 2 +- tests/ui/legacy_numeric_constants.fixed | 4 +- tests/ui/legacy_numeric_constants.rs | 4 +- tests/ui/manual_saturating_arithmetic.fixed | 2 +- tests/ui/manual_saturating_arithmetic.rs | 2 +- tests/ui/must_use_candidates.fixed | 2 +- tests/ui/must_use_candidates.rs | 2 +- tests/ui/mut_key.rs | 2 +- tests/ui/non_zero_suggestions.fixed | 2 +- tests/ui/non_zero_suggestions.rs | 2 +- tests/ui/non_zero_suggestions_unfixable.rs | 2 +- tests/ui/single_match.fixed | 2 +- tests/ui/single_match.rs | 2 +- tests/ui/suspicious_to_owned.rs | 2 +- tests/ui/transmute_collection.rs | 2 +- tests/ui/transmute_undefined_repr.rs | 2 +- 369 files changed, 874 insertions(+), 973 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_config/src/conf.rs b/clippy_config/src/conf.rs index 1765cf87d48..757620341cc 100644 --- a/clippy_config/src/conf.rs +++ b/clippy_config/src/conf.rs @@ -1,6 +1,6 @@ +use crate::ClippyConfiguration; use crate::msrvs::Msrv; use crate::types::{DisallowedPath, MacroMatcher, MatchLintBehaviour, PubUnderscoreFieldsBehaviour, Rename}; -use crate::ClippyConfiguration; use rustc_errors::Applicability; use rustc_session::Session; use rustc_span::edit_distance::edit_distance; diff --git a/clippy_config/src/lib.rs b/clippy_config/src/lib.rs index ac838cc81d2..c63d98a0a13 100644 --- a/clippy_config/src/lib.rs +++ b/clippy_config/src/lib.rs @@ -26,5 +26,5 @@ mod metadata; pub mod msrvs; pub mod types; -pub use conf::{get_configuration_metadata, lookup_conf_file, Conf}; +pub use conf::{Conf, get_configuration_metadata, lookup_conf_file}; pub use metadata::ClippyConfiguration; diff --git a/clippy_config/src/msrvs.rs b/clippy_config/src/msrvs.rs index 5f163cbe8e1..e30df3d3234 100644 --- a/clippy_config/src/msrvs.rs +++ b/clippy_config/src/msrvs.rs @@ -1,7 +1,7 @@ use rustc_ast::Attribute; use rustc_attr::parse_version; use rustc_session::{RustcVersion, Session}; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; use serde::Deserialize; use std::fmt; diff --git a/clippy_config/src/types.rs b/clippy_config/src/types.rs index d47e34bb5bc..bab63911182 100644 --- a/clippy_config/src/types.rs +++ b/clippy_config/src/types.rs @@ -1,5 +1,5 @@ use serde::de::{self, Deserializer, Visitor}; -use serde::{ser, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, ser}; use std::fmt; #[derive(Debug, Deserialize)] diff --git a/clippy_dev/src/fmt.rs b/clippy_dev/src/fmt.rs index 5fc4365c6e7..8c61c35533c 100644 --- a/clippy_dev/src/fmt.rs +++ b/clippy_dev/src/fmt.rs @@ -1,6 +1,6 @@ use crate::clippy_project_root; use itertools::Itertools; -use rustc_lexer::{tokenize, TokenKind}; +use rustc_lexer::{TokenKind, tokenize}; use shell_escape::escape; use std::ffi::{OsStr, OsString}; use std::ops::ControlFlow; diff --git a/clippy_dev/src/new_lint.rs b/clippy_dev/src/new_lint.rs index de91233d196..c4d9c52a1cc 100644 --- a/clippy_dev/src/new_lint.rs +++ b/clippy_dev/src/new_lint.rs @@ -441,7 +441,7 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R #[allow(clippy::too_many_lines)] fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str> { - use super::update_lints::{match_tokens, LintDeclSearchResult}; + use super::update_lints::{LintDeclSearchResult, match_tokens}; use rustc_lexer::TokenKind; let lint_name_upper = lint.name.to_uppercase(); diff --git a/clippy_dev/src/update_lints.rs b/clippy_dev/src/update_lints.rs index 8dbda1c634c..d6ed36d52f4 100644 --- a/clippy_dev/src/update_lints.rs +++ b/clippy_dev/src/update_lints.rs @@ -1,7 +1,7 @@ use crate::clippy_project_root; use aho_corasick::AhoCorasickBuilder; use itertools::Itertools; -use rustc_lexer::{tokenize, unescape, LiteralKind, TokenKind}; +use rustc_lexer::{LiteralKind, TokenKind, tokenize, unescape}; use std::collections::{HashMap, HashSet}; use std::ffi::OsStr; use std::fmt::{self, Write}; @@ -1048,23 +1048,17 @@ mod tests { Lint::new("incorrect_match", "group1", "\"abc\"", "module_name", Range::default()), ]; let mut expected: HashMap> = HashMap::new(); - expected.insert( - "group1".to_string(), - vec![ - Lint::new("should_assert_eq", "group1", "\"abc\"", "module_name", Range::default()), - Lint::new("incorrect_match", "group1", "\"abc\"", "module_name", Range::default()), - ], - ); - expected.insert( - "group2".to_string(), - vec![Lint::new( - "should_assert_eq2", - "group2", - "\"abc\"", - "module_name", - Range::default(), - )], - ); + expected.insert("group1".to_string(), vec![ + Lint::new("should_assert_eq", "group1", "\"abc\"", "module_name", Range::default()), + Lint::new("incorrect_match", "group1", "\"abc\"", "module_name", Range::default()), + ]); + expected.insert("group2".to_string(), vec![Lint::new( + "should_assert_eq2", + "group2", + "\"abc\"", + "module_name", + Range::default(), + )]); assert_eq!(expected, Lint::by_lint_group(lints.into_iter())); } } diff --git a/clippy_lints/src/absolute_paths.rs b/clippy_lints/src/absolute_paths.rs index c72b3f1318c..1af6d448a93 100644 --- a/clippy_lints/src/absolute_paths.rs +++ b/clippy_lints/src/absolute_paths.rs @@ -3,12 +3,12 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::is_from_proc_macro; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX}; +use rustc_hir::def_id::{CRATE_DEF_INDEX, DefId}; use rustc_hir::{HirId, ItemKind, Node, Path}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::symbol::kw; use rustc_span::Symbol; +use rustc_span::symbol::kw; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/almost_complete_range.rs b/clippy_lints/src/almost_complete_range.rs index 451bae95987..370f0c482fd 100644 --- a/clippy_lints/src/almost_complete_range.rs +++ b/clippy_lints/src/almost_complete_range.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::{trim_span, walk_span_to_context}; use rustc_ast::ast::{Expr, ExprKind, LitKind, Pat, PatKind, RangeEnd, RangeLimits}; diff --git a/clippy_lints/src/approx_const.rs b/clippy_lints/src/approx_const.rs index 56f5e903dc3..4f8f091a095 100644 --- a/clippy_lints/src/approx_const.rs +++ b/clippy_lints/src/approx_const.rs @@ -1,10 +1,10 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{FloatTy, LitFloatType, LitKind}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_session::{impl_lint_pass, RustcVersion}; +use rustc_session::{RustcVersion, impl_lint_pass}; use rustc_span::symbol; use std::f64::consts as f64; diff --git a/clippy_lints/src/arc_with_non_send_sync.rs b/clippy_lints/src/arc_with_non_send_sync.rs index 4eafa330faf..2643f850879 100644 --- a/clippy_lints/src/arc_with_non_send_sync.rs +++ b/clippy_lints/src/arc_with_non_send_sync.rs @@ -4,8 +4,8 @@ use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::GenericArgKind; +use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index 7eaac80f969..b6684825835 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -1,7 +1,7 @@ use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::is_inside_always_const_context; -use clippy_utils::macros::{find_assert_args, root_macro_call_first_node, PanicExpn}; +use clippy_utils::macros::{PanicExpn, find_assert_args, root_macro_call_first_node}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; diff --git a/clippy_lints/src/assertions_on_result_states.rs b/clippy_lints/src/assertions_on_result_states.rs index f1cb4a05af8..c073dee855e 100644 --- a/clippy_lints/src/assertions_on_result_states.rs +++ b/clippy_lints/src/assertions_on_result_states.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::macros::{find_assert_args, root_macro_call_first_node, PanicExpn}; +use clippy_utils::macros::{PanicExpn, find_assert_args, root_macro_call_first_node}; use clippy_utils::source::snippet_with_context; use clippy_utils::ty::{has_debug_impl, is_copy, is_type_diagnostic_item}; use clippy_utils::usage::local_used_after_expr; diff --git a/clippy_lints/src/assigning_clones.rs b/clippy_lints/src/assigning_clones.rs index 55645d04eef..0b82c0cd04c 100644 --- a/clippy_lints/src/assigning_clones.rs +++ b/clippy_lints/src/assigning_clones.rs @@ -1,7 +1,7 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::mir::{enclosing_mir, PossibleBorrowerMap}; +use clippy_utils::mir::{PossibleBorrowerMap, enclosing_mir}; use clippy_utils::sugg::Sugg; use clippy_utils::{is_diag_trait_item, is_in_test, last_path_segment, local_is_initialized, path_to_local}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/attrs/allow_attributes_without_reason.rs b/clippy_lints/src/attrs/allow_attributes_without_reason.rs index 4c7e07478c1..40959eccd3a 100644 --- a/clippy_lints/src/attrs/allow_attributes_without_reason.rs +++ b/clippy_lints/src/attrs/allow_attributes_without_reason.rs @@ -1,4 +1,4 @@ -use super::{Attribute, ALLOW_ATTRIBUTES_WITHOUT_REASON}; +use super::{ALLOW_ATTRIBUTES_WITHOUT_REASON, Attribute}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_from_proc_macro; use rustc_ast::{MetaItemKind, NestedMetaItem}; diff --git a/clippy_lints/src/attrs/blanket_clippy_restriction_lints.rs b/clippy_lints/src/attrs/blanket_clippy_restriction_lints.rs index 9b08fd6d654..508963a20ea 100644 --- a/clippy_lints/src/attrs/blanket_clippy_restriction_lints.rs +++ b/clippy_lints/src/attrs/blanket_clippy_restriction_lints.rs @@ -1,10 +1,10 @@ -use super::utils::extract_clippy_lint; use super::BLANKET_CLIPPY_RESTRICTION_LINTS; +use super::utils::extract_clippy_lint; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then}; use rustc_ast::NestedMetaItem; use rustc_lint::{LateContext, Level, LintContext}; use rustc_span::symbol::Symbol; -use rustc_span::{sym, DUMMY_SP}; +use rustc_span::{DUMMY_SP, sym}; pub(super) fn check(cx: &LateContext<'_>, name: Symbol, items: &[NestedMetaItem]) { for lint in items { diff --git a/clippy_lints/src/attrs/deprecated_cfg_attr.rs b/clippy_lints/src/attrs/deprecated_cfg_attr.rs index e872ab6b4b5..abf924f7542 100644 --- a/clippy_lints/src/attrs/deprecated_cfg_attr.rs +++ b/clippy_lints/src/attrs/deprecated_cfg_attr.rs @@ -1,4 +1,4 @@ -use super::{unnecessary_clippy_cfg, Attribute, DEPRECATED_CFG_ATTR, DEPRECATED_CLIPPY_CFG_ATTR}; +use super::{Attribute, DEPRECATED_CFG_ATTR, DEPRECATED_CLIPPY_CFG_ATTR, unnecessary_clippy_cfg}; use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use rustc_ast::AttrStyle; diff --git a/clippy_lints/src/attrs/duplicated_attributes.rs b/clippy_lints/src/attrs/duplicated_attributes.rs index 199e07565b0..55f8e1072db 100644 --- a/clippy_lints/src/attrs/duplicated_attributes.rs +++ b/clippy_lints/src/attrs/duplicated_attributes.rs @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use rustc_ast::{Attribute, MetaItem}; use rustc_data_structures::fx::FxHashMap; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use std::collections::hash_map::Entry; fn emit_if_duplicated( diff --git a/clippy_lints/src/attrs/inline_always.rs b/clippy_lints/src/attrs/inline_always.rs index 3b5b80ffefa..d41bb580c6c 100644 --- a/clippy_lints/src/attrs/inline_always.rs +++ b/clippy_lints/src/attrs/inline_always.rs @@ -1,10 +1,10 @@ -use super::utils::is_word; use super::INLINE_ALWAYS; +use super::utils::is_word; use clippy_utils::diagnostics::span_lint; use rustc_ast::Attribute; use rustc_lint::LateContext; use rustc_span::symbol::Symbol; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; pub(super) fn check(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribute]) { if span.from_expansion() { diff --git a/clippy_lints/src/attrs/mod.rs b/clippy_lints/src/attrs/mod.rs index c8fea25c9f2..888f28fa225 100644 --- a/clippy_lints/src/attrs/mod.rs +++ b/clippy_lints/src/attrs/mod.rs @@ -12,8 +12,8 @@ mod unnecessary_clippy_cfg; mod useless_attribute; mod utils; -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use rustc_ast::{Attribute, MetaItemKind, NestedMetaItem}; use rustc_hir::{ImplItem, Item, ItemKind, TraitItem}; use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass}; diff --git a/clippy_lints/src/attrs/useless_attribute.rs b/clippy_lints/src/attrs/useless_attribute.rs index 1296b59f2e1..12668c616c1 100644 --- a/clippy_lints/src/attrs/useless_attribute.rs +++ b/clippy_lints/src/attrs/useless_attribute.rs @@ -1,7 +1,7 @@ use super::utils::{extract_clippy_lint, is_lint_level, is_word}; use super::{Attribute, USELESS_ATTRIBUTE}; use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::source::{first_line_of_span, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, first_line_of_span}; use rustc_ast::NestedMetaItem; use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind}; diff --git a/clippy_lints/src/await_holding_invalid.rs b/clippy_lints/src/await_holding_invalid.rs index d5f017b2650..9952d0af99e 100644 --- a/clippy_lints/src/await_holding_invalid.rs +++ b/clippy_lints/src/await_holding_invalid.rs @@ -7,7 +7,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::CoroutineLayout; use rustc_middle::ty::TyCtxt; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index e933fdf1d6e..3c2af72624f 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -4,12 +4,12 @@ use clippy_utils::source::SpanRangeExt; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_expr, FnKind, Visitor}; +use rustc_hir::intravisit::{FnKind, Visitor, walk_expr}; use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, UnOp}; use rustc_lint::{LateContext, LateLintPass, Level}; use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/box_default.rs b/clippy_lints/src/box_default.rs index 8459f051d3d..8261c65354f 100644 --- a/clippy_lints/src/box_default.rs +++ b/clippy_lints/src/box_default.rs @@ -4,7 +4,7 @@ use clippy_utils::ty::expr_sig; use clippy_utils::{is_default_equivalent, path_def_id}; use rustc_errors::Applicability; use rustc_hir::def::Res; -use rustc_hir::intravisit::{walk_ty, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_ty}; use rustc_hir::{Block, Expr, ExprKind, LetStmt, Node, QPath, Ty, TyKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; diff --git a/clippy_lints/src/cargo/lint_groups_priority.rs b/clippy_lints/src/cargo/lint_groups_priority.rs index e924542fea2..ffd6c520c9a 100644 --- a/clippy_lints/src/cargo/lint_groups_priority.rs +++ b/clippy_lints/src/cargo/lint_groups_priority.rs @@ -2,7 +2,7 @@ use super::LINT_GROUPS_PRIORITY; use clippy_utils::diagnostics::span_lint_and_then; use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; -use rustc_lint::{unerased_lint_store, LateContext}; +use rustc_lint::{LateContext, unerased_lint_store}; use rustc_span::{BytePos, Pos, SourceFile, Span, SyntaxContext}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; diff --git a/clippy_lints/src/casts/cast_lossless.rs b/clippy_lints/src/casts/cast_lossless.rs index 346aed7e9f1..84a44b14dde 100644 --- a/clippy_lints/src/casts/cast_lossless.rs +++ b/clippy_lints/src/casts/cast_lossless.rs @@ -10,7 +10,7 @@ use rustc_lint::LateContext; use rustc_middle::ty::{self, FloatTy, Ty}; use rustc_span::hygiene; -use super::{utils, CAST_LOSSLESS}; +use super::{CAST_LOSSLESS, utils}; pub(super) fn check( cx: &LateContext<'_>, diff --git a/clippy_lints/src/casts/cast_possible_truncation.rs b/clippy_lints/src/casts/cast_possible_truncation.rs index 5708aae3f3e..40a1a9d1ce8 100644 --- a/clippy_lints/src/casts/cast_possible_truncation.rs +++ b/clippy_lints/src/casts/cast_possible_truncation.rs @@ -12,7 +12,7 @@ use rustc_middle::ty::{self, FloatTy, Ty}; use rustc_span::Span; use rustc_target::abi::IntegerType; -use super::{utils, CAST_ENUM_TRUNCATION, CAST_POSSIBLE_TRUNCATION}; +use super::{CAST_ENUM_TRUNCATION, CAST_POSSIBLE_TRUNCATION, utils}; fn constant_int(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { if let Some(Constant::Int(c)) = ConstEvalCtxt::new(cx).eval(expr) { diff --git a/clippy_lints/src/casts/cast_possible_wrap.rs b/clippy_lints/src/casts/cast_possible_wrap.rs index 11274383595..3cf4a43b0d4 100644 --- a/clippy_lints/src/casts/cast_possible_wrap.rs +++ b/clippy_lints/src/casts/cast_possible_wrap.rs @@ -3,7 +3,7 @@ use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::Ty; -use super::{utils, CAST_POSSIBLE_WRAP}; +use super::{CAST_POSSIBLE_WRAP, utils}; // this should be kept in sync with the allowed bit widths of `usize` and `isize` const ALLOWED_POINTER_SIZES: [u64; 3] = [16, 32, 64]; diff --git a/clippy_lints/src/casts/cast_precision_loss.rs b/clippy_lints/src/casts/cast_precision_loss.rs index 035666e4d4c..1eb115ce6bd 100644 --- a/clippy_lints/src/casts/cast_precision_loss.rs +++ b/clippy_lints/src/casts/cast_precision_loss.rs @@ -4,7 +4,7 @@ use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, FloatTy, Ty}; -use super::{utils, CAST_PRECISION_LOSS}; +use super::{CAST_PRECISION_LOSS, utils}; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { if !cast_from.is_integral() || cast_to.is_integral() { diff --git a/clippy_lints/src/casts/cast_sign_loss.rs b/clippy_lints/src/casts/cast_sign_loss.rs index 9daf237344a..4be53ace687 100644 --- a/clippy_lints/src/casts/cast_sign_loss.rs +++ b/clippy_lints/src/casts/cast_sign_loss.rs @@ -3,7 +3,7 @@ use std::ops::ControlFlow; use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::span_lint; -use clippy_utils::visitors::{for_each_expr_without_closures, Descend}; +use clippy_utils::visitors::{Descend, for_each_expr_without_closures}; use clippy_utils::{method_chain_args, sext}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/casts/fn_to_numeric_cast.rs b/clippy_lints/src/casts/fn_to_numeric_cast.rs index dbe03e4ae80..ac1a355c8d9 100644 --- a/clippy_lints/src/casts/fn_to_numeric_cast.rs +++ b/clippy_lints/src/casts/fn_to_numeric_cast.rs @@ -5,7 +5,7 @@ use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty, UintTy}; -use super::{utils, FN_TO_NUMERIC_CAST}; +use super::{FN_TO_NUMERIC_CAST, utils}; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { // We only want to check casts to `ty::Uint` or `ty::Int` diff --git a/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs b/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs index dfbae1618ac..18e7798452e 100644 --- a/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs +++ b/clippy_lints/src/casts/fn_to_numeric_cast_with_truncation.rs @@ -5,7 +5,7 @@ use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; -use super::{utils, FN_TO_NUMERIC_CAST_WITH_TRUNCATION}; +use super::{FN_TO_NUMERIC_CAST_WITH_TRUNCATION, utils}; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { // We only want to check casts to `ty::Uint` or `ty::Int` diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index 39f50a347c0..3acd4eca420 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -23,8 +23,8 @@ mod unnecessary_cast; mod utils; mod zero_ptr; -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::is_hir_ty_cfg_dependant; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; diff --git a/clippy_lints/src/casts/ref_as_ptr.rs b/clippy_lints/src/casts/ref_as_ptr.rs index 5f48b8bd206..dfa240ccec6 100644 --- a/clippy_lints/src/casts/ref_as_ptr.rs +++ b/clippy_lints/src/casts/ref_as_ptr.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::sugg::Sugg; -use clippy_utils::{expr_use_ctxt, is_no_std_crate, ExprUseNode}; +use clippy_utils::{ExprUseNode, expr_use_ctxt, is_no_std_crate}; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability, Ty, TyKind}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/casts/unnecessary_cast.rs b/clippy_lints/src/casts/unnecessary_cast.rs index 566adc83d69..811d33c8bde 100644 --- a/clippy_lints/src/casts/unnecessary_cast.rs +++ b/clippy_lints/src/casts/unnecessary_cast.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::numeric_literal::NumericLiteral; -use clippy_utils::source::{snippet_opt, SpanRangeExt}; -use clippy_utils::visitors::{for_each_expr_without_closures, Visitable}; +use clippy_utils::source::{SpanRangeExt, snippet_opt}; +use clippy_utils::visitors::{Visitable, for_each_expr_without_closures}; use clippy_utils::{get_parent_expr, is_hir_ty_cfg_dependant, is_ty_alias, path_to_local}; use rustc_ast::{LitFloatType, LitIntType, LitKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/casts/utils.rs b/clippy_lints/src/casts/utils.rs index 5a4f20f0990..5ccba92a0af 100644 --- a/clippy_lints/src/casts/utils.rs +++ b/clippy_lints/src/casts/utils.rs @@ -1,4 +1,4 @@ -use clippy_utils::ty::{read_explicit_enum_value, EnumValue}; +use clippy_utils::ty::{EnumValue, read_explicit_enum_value}; use rustc_middle::ty::{self, AdtDef, IntTy, Ty, TyCtxt, UintTy, VariantDiscr}; /// Returns the size in bits of an integral type. diff --git a/clippy_lints/src/checked_conversions.rs b/clippy_lints/src/checked_conversions.rs index dd7c34d1e46..d3aa2fd1ea1 100644 --- a/clippy_lints/src/checked_conversions.rs +++ b/clippy_lints/src/checked_conversions.rs @@ -1,8 +1,8 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; -use clippy_utils::{is_in_const_context, is_integer_literal, SpanlessEq}; +use clippy_utils::{SpanlessEq, is_in_const_context, is_integer_literal}; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; diff --git a/clippy_lints/src/cognitive_complexity.rs b/clippy_lints/src/cognitive_complexity.rs index 0099eefbc8d..495d8ce3fa7 100644 --- a/clippy_lints/src/cognitive_complexity.rs +++ b/clippy_lints/src/cognitive_complexity.rs @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::{IntoSpan, SpanRangeExt}; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::visitors::for_each_expr_without_closures; -use clippy_utils::{get_async_fn_body, is_async_fn, LimitStack}; +use clippy_utils::{LimitStack, get_async_fn_body, is_async_fn}; use core::ops::ControlFlow; use rustc_ast::ast::Attribute; use rustc_hir::intravisit::FnKind; @@ -11,7 +11,7 @@ use rustc_hir::{Body, Expr, ExprKind, FnDecl}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/collection_is_never_read.rs b/clippy_lints/src/collection_is_never_read.rs index c6847411c75..8276e53648c 100644 --- a/clippy_lints/src/collection_is_never_read.rs +++ b/clippy_lints/src/collection_is_never_read.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::{get_type_diagnostic_name, is_type_lang_item}; -use clippy_utils::visitors::{for_each_expr, Visitable}; +use clippy_utils::visitors::{Visitable, for_each_expr}; use clippy_utils::{get_enclosing_block, path_to_local_id}; use core::ops::ControlFlow; use rustc_hir::{Body, ExprKind, HirId, LangItem, LetStmt, Node, PatKind}; diff --git a/clippy_lints/src/comparison_chain.rs b/clippy_lints/src/comparison_chain.rs index 5d78744e9b5..b9baf9af248 100644 --- a/clippy_lints/src/comparison_chain.rs +++ b/clippy_lints/src/comparison_chain.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::implements_trait; -use clippy_utils::{if_sequence, is_else_clause, is_in_const_context, SpanlessEq}; +use clippy_utils::{SpanlessEq, if_sequence, is_else_clause, is_in_const_context}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 86e0368c4e4..d90a22bb62a 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -1,16 +1,17 @@ use clippy_config::Conf; use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_then}; -use clippy_utils::source::{first_line_of_span, indent_of, reindent_multiline, snippet, IntoSpan, SpanRangeExt}; -use clippy_utils::ty::{needs_ordered_drop, InteriorMut}; +use clippy_utils::source::{IntoSpan, SpanRangeExt, first_line_of_span, indent_of, reindent_multiline, snippet}; +use clippy_utils::ty::{InteriorMut, needs_ordered_drop}; use clippy_utils::visitors::for_each_expr_without_closures; use clippy_utils::{ - capture_local_usage, eq_expr_value, find_binding_init, get_enclosing_block, hash_expr, hash_stmt, if_sequence, - is_else_clause, is_lint_allowed, path_to_local, search_same, ContainsName, HirEqInterExpr, SpanlessEq, + ContainsName, HirEqInterExpr, SpanlessEq, capture_local_usage, eq_expr_value, find_binding_init, + get_enclosing_block, hash_expr, hash_stmt, if_sequence, is_else_clause, is_lint_allowed, path_to_local, + search_same, }; use core::iter; use core::ops::ControlFlow; use rustc_errors::Applicability; -use rustc_hir::{intravisit, BinOpKind, Block, Expr, ExprKind, HirId, HirIdSet, Stmt, StmtKind}; +use rustc_hir::{BinOpKind, Block, Expr, ExprKind, HirId, HirIdSet, Stmt, StmtKind, intravisit}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::TyCtxt; use rustc_session::impl_lint_pass; diff --git a/clippy_lints/src/crate_in_macro_def.rs b/clippy_lints/src/crate_in_macro_def.rs index 678bdbc0ffb..c8f81413728 100644 --- a/clippy_lints/src/crate_in_macro_def.rs +++ b/clippy_lints/src/crate_in_macro_def.rs @@ -5,8 +5,8 @@ use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/dbg_macro.rs b/clippy_lints/src/dbg_macro.rs index 93c8fff05e9..a96c86f0765 100644 --- a/clippy_lints/src/dbg_macro.rs +++ b/clippy_lints/src/dbg_macro.rs @@ -1,7 +1,7 @@ use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_in_test; -use clippy_utils::macros::{macro_backtrace, MacroCall}; +use clippy_utils::macros::{MacroCall, macro_backtrace}; use clippy_utils::source::snippet_with_applicability; use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; @@ -9,7 +9,7 @@ use rustc_hir::{Expr, ExprKind, Node}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span, SyntaxContext}; +use rustc_span::{Span, SyntaxContext, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/default.rs b/clippy_lints/src/default.rs index 0b7279f2b36..dc10b64698b 100644 --- a/clippy_lints/src/default.rs +++ b/clippy_lints/src/default.rs @@ -11,7 +11,7 @@ use rustc_middle::ty; use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_session::impl_lint_pass; use rustc_span::symbol::{Ident, Symbol}; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/default_constructed_unit_structs.rs b/clippy_lints/src/default_constructed_unit_structs.rs index 13778175496..33a97222b8f 100644 --- a/clippy_lints/src/default_constructed_unit_structs.rs +++ b/clippy_lints/src/default_constructed_unit_structs.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::is_ty_alias; -use hir::def::Res; use hir::ExprKind; +use hir::def::Res; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/default_instead_of_iter_empty.rs b/clippy_lints/src/default_instead_of_iter_empty.rs index ac49e6f1a48..056e39c02af 100644 --- a/clippy_lints/src/default_instead_of_iter_empty.rs +++ b/clippy_lints/src/default_instead_of_iter_empty.rs @@ -2,10 +2,10 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_context; use clippy_utils::{last_path_segment, std_or_core}; use rustc_errors::Applicability; -use rustc_hir::{def, Expr, ExprKind, GenericArg, QPath, TyKind}; +use rustc_hir::{Expr, ExprKind, GenericArg, QPath, TyKind, def}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, SyntaxContext}; +use rustc_span::{SyntaxContext, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/default_numeric_fallback.rs b/clippy_lints/src/default_numeric_fallback.rs index 05c3cd3c814..a065dc2cf7e 100644 --- a/clippy_lints/src/default_numeric_fallback.rs +++ b/clippy_lints/src/default_numeric_fallback.rs @@ -3,7 +3,7 @@ use clippy_utils::numeric_literal; use clippy_utils::source::snippet_opt; use rustc_ast::ast::{LitFloatType, LitIntType, LitKind}; use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_expr, walk_stmt, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr, walk_stmt}; use rustc_hir::{Block, Body, ConstContext, Expr, ExprKind, FnRetTy, HirId, Lit, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index 0e55d3db469..f34f5e05606 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -3,14 +3,14 @@ use clippy_utils::source::{snippet_with_applicability, snippet_with_context}; use clippy_utils::sugg::has_enclosing_paren; use clippy_utils::ty::{implements_trait, is_manually_drop}; use clippy_utils::{ - expr_use_ctxt, get_parent_expr, is_block_like, is_lint_allowed, path_to_local, peel_middle_ty_refs, DefinedTy, - ExprUseNode, + DefinedTy, ExprUseNode, expr_use_ctxt, get_parent_expr, is_block_like, is_lint_allowed, path_to_local, + peel_middle_ty_refs, }; use core::mem; use rustc_ast::util::parser::{PREC_PREFIX, PREC_UNAMBIGUOUS}; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_ty, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_ty}; use rustc_hir::{ self as hir, BindingMode, Body, BodyId, BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, Pat, PatKind, Path, QPath, TyKind, UnOp, @@ -290,13 +290,10 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> { && let Some(ty) = use_node.defined_ty(cx) && TyCoercionStability::for_defined_ty(cx, ty, use_node.is_return()).is_deref_stable() { - self.state = Some(( - State::ExplicitDeref { mutability: None }, - StateData { - first_expr: expr, - adjusted_ty, - }, - )); + self.state = Some((State::ExplicitDeref { mutability: None }, StateData { + first_expr: expr, + adjusted_ty, + })); } }, RefOp::Method { mutbl, is_ufcs } @@ -458,13 +455,10 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> { && next_adjust.map_or(true, |a| matches!(a.kind, Adjust::Deref(_) | Adjust::Borrow(_))) && iter.all(|a| matches!(a.kind, Adjust::Deref(_) | Adjust::Borrow(_))) { - self.state = Some(( - State::Borrow { mutability }, - StateData { - first_expr: expr, - adjusted_ty, - }, - )); + self.state = Some((State::Borrow { mutability }, StateData { + first_expr: expr, + adjusted_ty, + })); } }, _ => {}, @@ -508,13 +502,10 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> { let stability = state.stability; report(cx, expr, State::DerefedBorrow(state), data, typeck); if stability.is_deref_stable() { - self.state = Some(( - State::Borrow { mutability }, - StateData { - first_expr: expr, - adjusted_ty, - }, - )); + self.state = Some((State::Borrow { mutability }, StateData { + first_expr: expr, + adjusted_ty, + })); } }, (Some((State::DerefedBorrow(state), data)), RefOp::Deref) => { @@ -539,13 +530,10 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> { } else if stability.is_deref_stable() && let Some(parent) = get_parent_expr(cx, expr) { - self.state = Some(( - State::ExplicitDeref { mutability: None }, - StateData { - first_expr: parent, - adjusted_ty, - }, - )); + self.state = Some((State::ExplicitDeref { mutability: None }, StateData { + first_expr: parent, + adjusted_ty, + })); } }, @@ -1138,20 +1126,17 @@ impl<'tcx> Dereferencing<'tcx> { if let Some(outer_pat) = self.ref_locals.get_mut(&local) { if let Some(pat) = outer_pat { // Check for auto-deref - if !matches!( - cx.typeck_results().expr_adjustments(e), - [ - Adjustment { - kind: Adjust::Deref(_), - .. - }, - Adjustment { - kind: Adjust::Deref(_), - .. - }, + if !matches!(cx.typeck_results().expr_adjustments(e), [ + Adjustment { + kind: Adjust::Deref(_), + .. + }, + Adjustment { + kind: Adjust::Deref(_), .. - ] - ) { + }, + .. + ]) { match get_parent_expr(cx, e) { // Field accesses are the same no matter the number of references. Some(Expr { diff --git a/clippy_lints/src/derivable_impls.rs b/clippy_lints/src/derivable_impls.rs index f27f68e2cbc..2920bbb4c81 100644 --- a/clippy_lints/src/derivable_impls.rs +++ b/clippy_lints/src/derivable_impls.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::indent_of; use clippy_utils::{is_default_equivalent, peel_blocks}; diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index 636698e96f6..61c151d4f9d 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -3,7 +3,7 @@ use clippy_utils::ty::{implements_trait, implements_trait_with_env, is_copy}; use clippy_utils::{has_non_exhaustive_attr, is_lint_allowed, match_def_path, paths}; use rustc_errors::Applicability; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, Visitor}; +use rustc_hir::intravisit::{FnKind, Visitor, walk_expr, walk_fn, walk_item}; use rustc_hir::{ self as hir, BlockCheckMode, BodyId, Expr, ExprKind, FnDecl, Impl, Item, ItemKind, Safety, UnsafeSource, }; @@ -15,7 +15,7 @@ use rustc_middle::ty::{ }; use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/doc/empty_line_after.rs b/clippy_lints/src/doc/empty_line_after.rs index 289debe0a6a..125b9077061 100644 --- a/clippy_lints/src/doc/empty_line_after.rs +++ b/clippy_lints/src/doc/empty_line_after.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::source::{snippet_indent, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, snippet_indent}; use clippy_utils::tokenize_with_text; use itertools::Itertools; use rustc_ast::token::CommentKind; @@ -219,13 +219,10 @@ fn check_gaps(cx: &LateContext<'_>, gaps: &[Gap<'_>]) -> bool { if let Some(owner) = cx.last_node_with_lint_attrs.as_owner() { let def_id = owner.to_def_id(); let def_descr = cx.tcx.def_descr(def_id); - diag.span_label( - cx.tcx.def_span(def_id), - match kind { - StopKind::Attr => format!("the attribute applies to this {def_descr}"), - StopKind::Doc(_) => format!("the comment documents this {def_descr}"), - }, - ); + diag.span_label(cx.tcx.def_span(def_id), match kind { + StopKind::Attr => format!("the attribute applies to this {def_descr}"), + StopKind::Doc(_) => format!("the comment documents this {def_descr}"), + }); } diag.multipart_suggestion_with_style( diff --git a/clippy_lints/src/doc/link_with_quotes.rs b/clippy_lints/src/doc/link_with_quotes.rs index 01191e811b0..1d4345e4541 100644 --- a/clippy_lints/src/doc/link_with_quotes.rs +++ b/clippy_lints/src/doc/link_with_quotes.rs @@ -3,7 +3,7 @@ use std::ops::Range; use clippy_utils::diagnostics::span_lint; use rustc_lint::LateContext; -use super::{Fragments, DOC_LINK_WITH_QUOTES}; +use super::{DOC_LINK_WITH_QUOTES, Fragments}; pub fn check(cx: &LateContext<'_>, trimmed_text: &str, range: Range, fragments: Fragments<'_>) { if ((trimmed_text.starts_with('\'') && trimmed_text.ends_with('\'')) diff --git a/clippy_lints/src/doc/missing_headers.rs b/clippy_lints/src/doc/missing_headers.rs index e3d74840726..c9173030a55 100644 --- a/clippy_lints/src/doc/missing_headers.rs +++ b/clippy_lints/src/doc/missing_headers.rs @@ -5,7 +5,7 @@ use clippy_utils::{is_doc_hidden, return_ty}; use rustc_hir::{BodyId, FnSig, OwnerId, Safety}; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; pub fn check( cx: &LateContext<'_>, diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index f2c87f0fd70..0ae1fad5692 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -23,12 +23,12 @@ use rustc_middle::hir::nested_filter; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_resolve::rustdoc::{ - add_doc_fragment, attrs_to_doc_fragments, main_body_opts, source_span_for_markdown_range, span_of_fragments, - DocFragment, + DocFragment, add_doc_fragment, attrs_to_doc_fragments, main_body_opts, source_span_for_markdown_range, + span_of_fragments, }; use rustc_session::impl_lint_pass; use rustc_span::edition::Edition; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use std::ops::Range; use url::Url; diff --git a/clippy_lints/src/doc/needless_doctest_main.rs b/clippy_lints/src/doc/needless_doctest_main.rs index c3e3c0431e6..9ba2723157a 100644 --- a/clippy_lints/src/doc/needless_doctest_main.rs +++ b/clippy_lints/src/doc/needless_doctest_main.rs @@ -13,7 +13,7 @@ use rustc_parse::parser::ForceCollect; use rustc_session::parse::ParseSess; use rustc_span::edition::Edition; use rustc_span::source_map::{FilePathMapping, SourceMap}; -use rustc_span::{sym, FileName, Pos}; +use rustc_span::{FileName, Pos, sym}; use super::Fragments; diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 9c5100a8c1a..70524e458c7 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -1,17 +1,17 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{reindent_multiline, snippet_indent, snippet_with_applicability, snippet_with_context}; use clippy_utils::{ - can_move_expr_to_closure_no_visit, higher, is_expr_final_block_expr, is_expr_used_or_unified, - peel_hir_expr_while, SpanlessEq, + SpanlessEq, can_move_expr_to_closure_no_visit, higher, is_expr_final_block_expr, is_expr_used_or_unified, + peel_hir_expr_while, }; use core::fmt::{self, Write}; use rustc_errors::Applicability; use rustc_hir::hir_id::HirIdSet; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{Block, Expr, ExprKind, HirId, Pat, Stmt, StmtKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span, SyntaxContext, DUMMY_SP}; +use rustc_span::{DUMMY_SP, Span, SyntaxContext, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs index 4755cefe784..e9e9d00907e 100644 --- a/clippy_lints/src/enum_clike.rs +++ b/clippy_lints/src/enum_clike.rs @@ -1,4 +1,4 @@ -use clippy_utils::consts::{mir_to_const, Constant}; +use clippy_utils::consts::{Constant, mir_to_const}; use clippy_utils::diagnostics::span_lint; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 80360697941..5588124e791 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -1,15 +1,15 @@ use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_hir; -use rustc_hir::{intravisit, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node, Pat, PatKind}; +use rustc_hir::{AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node, Pat, PatKind, intravisit}; use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt}; use rustc_session::impl_lint_pass; +use rustc_span::Span; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::kw; -use rustc_span::Span; use rustc_target::spec::abi::Abi; pub struct BoxedLocal { diff --git a/clippy_lints/src/excessive_bools.rs b/clippy_lints/src/excessive_bools.rs index 8f469efb1b5..c88fb50b5af 100644 --- a/clippy_lints/src/excessive_bools.rs +++ b/clippy_lints/src/excessive_bools.rs @@ -5,8 +5,8 @@ use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl, Item, ItemKind, TraitFn, TraitItem, TraitItemKind, Ty}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::def_id::LocalDefId; use rustc_span::Span; +use rustc_span::def_id::LocalDefId; use rustc_target::spec::abi::Abi; declare_clippy_lint! { diff --git a/clippy_lints/src/excessive_nesting.rs b/clippy_lints/src/excessive_nesting.rs index 5154edd4399..ce0e0faa014 100644 --- a/clippy_lints/src/excessive_nesting.rs +++ b/clippy_lints/src/excessive_nesting.rs @@ -2,7 +2,7 @@ use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet; use rustc_ast::node_id::NodeSet; -use rustc_ast::visit::{walk_block, walk_item, Visitor}; +use rustc_ast::visit::{Visitor, walk_block, walk_item}; use rustc_ast::{Block, Crate, Inline, Item, ItemKind, ModKind, NodeId}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs index 3c4a043a732..5b423a96918 100644 --- a/clippy_lints/src/explicit_write.rs +++ b/clippy_lints/src/explicit_write.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::macros::{format_args_inputs_span, FormatArgsStorage}; +use clippy_utils::macros::{FormatArgsStorage, format_args_inputs_span}; use clippy_utils::source::snippet_with_applicability; use clippy_utils::{is_expn_of, path_def_id}; use rustc_errors::Applicability; @@ -7,7 +7,7 @@ use rustc_hir::def::Res; use rustc_hir::{BindingMode, Block, BlockCheckMode, Expr, ExprKind, Node, PatKind, QPath, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::{sym, ExpnId}; +use rustc_span::{ExpnId, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/extra_unused_type_parameters.rs b/clippy_lints/src/extra_unused_type_parameters.rs index bfe4e253ae4..bf9388b4a70 100644 --- a/clippy_lints/src/extra_unused_type_parameters.rs +++ b/clippy_lints/src/extra_unused_type_parameters.rs @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then}; use clippy_utils::{is_from_proc_macro, trait_ref_of_method}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_impl_item, walk_item, walk_param_bound, walk_ty, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_impl_item, walk_item, walk_param_bound, walk_ty}; use rustc_hir::{ BodyId, ExprKind, GenericBound, GenericParam, GenericParamKind, Generics, ImplItem, ImplItemKind, Item, ItemKind, PredicateOrigin, Ty, TyKind, WherePredicate, @@ -12,8 +12,8 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::hir::nested_filter; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; -use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::Span; +use rustc_span::def_id::{DefId, LocalDefId}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 0446943321a..747ea9a4344 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -6,7 +6,7 @@ use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/floating_point_arithmetic.rs b/clippy_lints/src/floating_point_arithmetic.rs index bf4bcabfe89..8da6623f34d 100644 --- a/clippy_lints/src/floating_point_arithmetic.rs +++ b/clippy_lints/src/floating_point_arithmetic.rs @@ -1,4 +1,4 @@ -use clippy_utils::consts::Constant::{Int, F32, F64}; +use clippy_utils::consts::Constant::{F32, F64, Int}; use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::{ diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 4dedff69b9a..5e3f6b6a137 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::macros::{find_format_arg_expr, root_macro_call_first_node, FormatArgsStorage}; -use clippy_utils::source::{snippet_with_context, SpanRangeExt}; +use clippy_utils::macros::{FormatArgsStorage, find_format_arg_expr, root_macro_call_first_node}; +use clippy_utils::source::{SpanRangeExt, snippet_with_context}; use clippy_utils::sugg::Sugg; use rustc_ast::{FormatArgsPiece, FormatOptions, FormatTrait}; use rustc_errors::Applicability; @@ -8,7 +8,7 @@ use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index 020c0c5440d..83ab9f6557b 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -1,11 +1,12 @@ use arrayvec::ArrayVec; -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::is_diag_trait_item; use clippy_utils::macros::{ - find_format_arg_expr, format_arg_removal_span, format_placeholder_format_span, is_assert_macro, is_format_macro, - is_panic, matching_root_macro_call, root_macro_call_first_node, FormatArgsStorage, FormatParamUsage, MacroCall, + FormatArgsStorage, FormatParamUsage, MacroCall, find_format_arg_expr, format_arg_removal_span, + format_placeholder_format_span, is_assert_macro, is_format_macro, is_panic, matching_root_macro_call, + root_macro_call_first_node, }; use clippy_utils::source::SpanRangeExt; use clippy_utils::ty::{implements_trait, is_type_lang_item}; @@ -18,11 +19,11 @@ use rustc_errors::Applicability; use rustc_errors::SuggestionStyle::{CompletelyHidden, ShowCode}; use rustc_hir::{Expr, ExprKind, LangItem}; use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_middle::ty::adjustment::{Adjust, Adjustment}; use rustc_middle::ty::Ty; +use rustc_middle::ty::adjustment::{Adjust, Adjustment}; use rustc_session::impl_lint_pass; use rustc_span::edition::Edition::Edition2021; -use rustc_span::{sym, Span, Symbol}; +use rustc_span::{Span, Symbol, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/format_impl.rs b/clippy_lints/src/format_impl.rs index 7cd12ac7db8..c196f404ce6 100644 --- a/clippy_lints/src/format_impl.rs +++ b/clippy_lints/src/format_impl.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; -use clippy_utils::macros::{find_format_arg_expr, is_format_macro, root_macro_call_first_node, FormatArgsStorage}; +use clippy_utils::macros::{FormatArgsStorage, find_format_arg_expr, is_format_macro, root_macro_call_first_node}; use clippy_utils::{get_parent_as_impl, is_diag_trait_item, path_to_local, peel_ref_operators}; use rustc_ast::{FormatArgsPiece, FormatTrait}; use rustc_errors::Applicability; @@ -7,7 +7,7 @@ use rustc_hir::{Expr, ExprKind, Impl, ImplItem, ImplItemKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/format_push_string.rs b/clippy_lints/src/format_push_string.rs index c6f03c3a7cf..8b1f86cbb91 100644 --- a/clippy_lints/src/format_push_string.rs +++ b/clippy_lints/src/format_push_string.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::ty::is_type_lang_item; use clippy_utils::higher; +use clippy_utils::ty::is_type_lang_item; use rustc_hir::{BinOpKind, Expr, ExprKind, LangItem, MatchSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; diff --git a/clippy_lints/src/from_over_into.rs b/clippy_lints/src/from_over_into.rs index 5e9098474dc..d716a624cc6 100644 --- a/clippy_lints/src/from_over_into.rs +++ b/clippy_lints/src/from_over_into.rs @@ -1,11 +1,11 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::macros::span_is_local; use clippy_utils::path_def_id; use clippy_utils::source::SpanRangeExt; use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_path, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_path}; use rustc_hir::{ FnRetTy, GenericArg, GenericArgs, HirId, Impl, ImplItemKind, ImplItemRef, Item, ItemKind, PatKind, Path, PathSegment, Ty, TyKind, diff --git a/clippy_lints/src/from_str_radix_10.rs b/clippy_lints/src/from_str_radix_10.rs index e5fa67d6964..7361546153c 100644 --- a/clippy_lints/src/from_str_radix_10.rs +++ b/clippy_lints/src/from_str_radix_10.rs @@ -3,7 +3,7 @@ use clippy_utils::sugg::Sugg; use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item}; use clippy_utils::{is_in_const_context, is_integer_literal}; use rustc_errors::Applicability; -use rustc_hir::{def, Expr, ExprKind, LangItem, PrimTy, QPath, TyKind}; +use rustc_hir::{Expr, ExprKind, LangItem, PrimTy, QPath, TyKind, def}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; use rustc_session::declare_lint_pass; diff --git a/clippy_lints/src/functions/mod.rs b/clippy_lints/src/functions/mod.rs index 0f48941783b..ba8a459c917 100644 --- a/clippy_lints/src/functions/mod.rs +++ b/clippy_lints/src/functions/mod.rs @@ -14,8 +14,8 @@ use rustc_hir::intravisit; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::TyCtxt; use rustc_session::impl_lint_pass; -use rustc_span::def_id::{DefIdSet, LocalDefId}; use rustc_span::Span; +use rustc_span::def_id::{DefIdSet, LocalDefId}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/functions/must_use.rs b/clippy_lints/src/functions/must_use.rs index 93828121047..cfd11e9339f 100644 --- a/clippy_lints/src/functions/must_use.rs +++ b/clippy_lints/src/functions/must_use.rs @@ -8,7 +8,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, Ty}; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use clippy_utils::attrs::is_proc_macro; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then}; diff --git a/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs b/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs index 1aeefe73cf6..c2b40ae01d4 100644 --- a/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs +++ b/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs @@ -1,4 +1,4 @@ -use rustc_hir::{self as hir, intravisit, HirId, HirIdSet}; +use rustc_hir::{self as hir, HirId, HirIdSet, intravisit}; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_span::def_id::LocalDefId; diff --git a/clippy_lints/src/functions/renamed_function_params.rs b/clippy_lints/src/functions/renamed_function_params.rs index c7de0385c02..ac2e866e4ff 100644 --- a/clippy_lints/src/functions/renamed_function_params.rs +++ b/clippy_lints/src/functions/renamed_function_params.rs @@ -4,8 +4,8 @@ use rustc_hir::def_id::{DefId, DefIdSet}; use rustc_hir::hir_id::OwnerId; use rustc_hir::{Impl, ImplItem, ImplItemKind, ImplItemRef, ItemKind, Node, TraitRef}; use rustc_lint::LateContext; -use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_span::Span; +use rustc_span::symbol::{Ident, Symbol, kw}; use super::RENAMED_FUNCTION_PARAMS; diff --git a/clippy_lints/src/functions/result.rs b/clippy_lints/src/functions/result.rs index c3a0b40a677..d4eaa166320 100644 --- a/clippy_lints/src/functions/result.rs +++ b/clippy_lints/src/functions/result.rs @@ -3,11 +3,11 @@ use rustc_hir as hir; use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, Ty}; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then}; use clippy_utils::trait_ref_of_method; -use clippy_utils::ty::{approx_ty_size, is_type_diagnostic_item, AdtVariantInfo}; +use clippy_utils::ty::{AdtVariantInfo, approx_ty_size, is_type_diagnostic_item}; use super::{RESULT_LARGE_ERR, RESULT_UNIT_ERR}; diff --git a/clippy_lints/src/future_not_send.rs b/clippy_lints/src/future_not_send.rs index 9488ba75686..a4dbe134f36 100644 --- a/clippy_lints/src/future_not_send.rs +++ b/clippy_lints/src/future_not_send.rs @@ -8,7 +8,7 @@ use rustc_middle::ty::print::PrintTraitRefExt; use rustc_middle::ty::{self, AliasTy, ClauseKind, PredicateKind}; use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::traits::{self, FulfillmentError, ObligationCtxt}; diff --git a/clippy_lints/src/if_then_some_else_none.rs b/clippy_lints/src/if_then_some_else_none.rs index 55f9625709b..d63c18c0eda 100644 --- a/clippy_lints/src/if_then_some_else_none.rs +++ b/clippy_lints/src/if_then_some_else_none.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::eager_or_lazy::switch_to_eager_eval; use clippy_utils::source::snippet_with_context; diff --git a/clippy_lints/src/implicit_hasher.rs b/clippy_lints/src/implicit_hasher.rs index e56f33f8dcf..f683925145a 100644 --- a/clippy_lints/src/implicit_hasher.rs +++ b/clippy_lints/src/implicit_hasher.rs @@ -3,18 +3,18 @@ use std::collections::BTreeMap; use rustc_errors::{Applicability, Diag}; use rustc_hir as hir; -use rustc_hir::intravisit::{walk_body, walk_expr, walk_inf, walk_ty, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_body, walk_expr, walk_inf, walk_ty}; use rustc_hir::{Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind}; use rustc_hir_analysis::lower_ty; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{Ty, TypeckResults}; use rustc_session::declare_lint_pass; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::source::{snippet, IntoSpan, SpanRangeExt}; +use clippy_utils::source::{IntoSpan, SpanRangeExt, snippet}; use clippy_utils::ty::is_type_diagnostic_item; declare_clippy_lint! { diff --git a/clippy_lints/src/implicit_saturating_sub.rs b/clippy_lints/src/implicit_saturating_sub.rs index 3536309d83c..f4a64f5c20b 100644 --- a/clippy_lints/src/implicit_saturating_sub.rs +++ b/clippy_lints/src/implicit_saturating_sub.rs @@ -1,9 +1,9 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_opt; use clippy_utils::{ - higher, is_in_const_context, is_integer_literal, path_to_local, peel_blocks, peel_blocks_with_stmt, SpanlessEq, + SpanlessEq, higher, is_in_const_context, is_integer_literal, path_to_local, peel_blocks, peel_blocks_with_stmt, }; use rustc_ast::ast::LitKind; use rustc_data_structures::packed::Pu128; diff --git a/clippy_lints/src/incompatible_msrv.rs b/clippy_lints/src/incompatible_msrv.rs index 2ad045e1268..0b3a6ee1bea 100644 --- a/clippy_lints/src/incompatible_msrv.rs +++ b/clippy_lints/src/incompatible_msrv.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::Msrv; use clippy_config::Conf; +use clippy_config::msrvs::Msrv; use clippy_utils::diagnostics::span_lint; use clippy_utils::is_in_test; use rustc_attr::{StabilityLevel, StableSince}; @@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_hir::{Expr, ExprKind, HirId}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::TyCtxt; -use rustc_session::{impl_lint_pass, RustcVersion}; +use rustc_session::{RustcVersion, impl_lint_pass}; use rustc_span::def_id::DefId; use rustc_span::{ExpnKind, Span}; diff --git a/clippy_lints/src/index_refutable_slice.rs b/clippy_lints/src/index_refutable_slice.rs index 2f9661c9ea3..39afb6810b8 100644 --- a/clippy_lints/src/index_refutable_slice.rs +++ b/clippy_lints/src/index_refutable_slice.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::higher::IfLet; @@ -8,14 +8,14 @@ use clippy_utils::{is_expn_of, is_lint_allowed, path_to_local}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_errors::Applicability; use rustc_hir as hir; -use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::HirId; +use rustc_hir::intravisit::{self, Visitor}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_middle::ty; use rustc_session::impl_lint_pass; -use rustc_span::symbol::Ident; use rustc_span::Span; +use rustc_span::symbol::Ident; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/ineffective_open_options.rs b/clippy_lints/src/ineffective_open_options.rs index af5b1f95739..3a28553b55e 100644 --- a/clippy_lints/src/ineffective_open_options.rs +++ b/clippy_lints/src/ineffective_open_options.rs @@ -7,7 +7,7 @@ use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::declare_lint_pass; -use rustc_span::{sym, BytePos, Span}; +use rustc_span::{BytePos, Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/instant_subtraction.rs b/clippy_lints/src/instant_subtraction.rs index 6d6820311b6..66931a7f98c 100644 --- a/clippy_lints/src/instant_subtraction.rs +++ b/clippy_lints/src/instant_subtraction.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_context; use clippy_utils::sugg::Sugg; diff --git a/clippy_lints/src/item_name_repetitions.rs b/clippy_lints/src/item_name_repetitions.rs index 74bf82f58bd..66a8a3167a4 100644 --- a/clippy_lints/src/item_name_repetitions.rs +++ b/clippy_lints/src/item_name_repetitions.rs @@ -8,8 +8,8 @@ use rustc_data_structures::fx::FxHashSet; use rustc_hir::{EnumDef, FieldDef, Item, ItemKind, OwnerId, Variant, VariantData}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::symbol::Symbol; use rustc_span::Span; +use rustc_span::symbol::Symbol; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/items_after_test_module.rs b/clippy_lints/src/items_after_test_module.rs index 8caa484bb99..1ac549b74ac 100644 --- a/clippy_lints/src/items_after_test_module.rs +++ b/clippy_lints/src/items_after_test_module.rs @@ -6,7 +6,7 @@ use rustc_hir::{HirId, Item, ItemKind, Mod}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::hygiene::AstPass; -use rustc_span::{sym, ExpnKind}; +use rustc_span::{ExpnKind, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/iter_not_returning_iterator.rs b/clippy_lints/src/iter_not_returning_iterator.rs index ba0cd5d6eb3..b19b348c743 100644 --- a/clippy_lints/src/iter_not_returning_iterator.rs +++ b/clippy_lints/src/iter_not_returning_iterator.rs @@ -4,7 +4,7 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::{FnSig, ImplItem, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/iter_over_hash_type.rs b/clippy_lints/src/iter_over_hash_type.rs index f162948bb44..5131f5b7269 100644 --- a/clippy_lints/src/iter_over_hash_type.rs +++ b/clippy_lints/src/iter_over_hash_type.rs @@ -55,7 +55,9 @@ impl LateLintPass<'_> for IterOverHashType { if let Some(for_loop) = ForLoop::hir(expr) && !for_loop.body.span.from_expansion() && let ty = cx.typeck_results().expr_ty(for_loop.arg).peel_refs() - && hash_iter_tys.into_iter().any(|sym| is_type_diagnostic_item(cx, ty, sym)) + && hash_iter_tys + .into_iter() + .any(|sym| is_type_diagnostic_item(cx, ty, sym)) { span_lint( cx, diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index 2f027c11707..923089c7223 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -1,7 +1,7 @@ use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_with_applicability; -use clippy_utils::ty::{approx_ty_size, is_copy, AdtVariantInfo}; +use clippy_utils::ty::{AdtVariantInfo, approx_ty_size, is_copy}; use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/large_stack_arrays.rs b/clippy_lints/src/large_stack_arrays.rs index 15a75b06089..0f061d6de50 100644 --- a/clippy_lints/src/large_stack_arrays.rs +++ b/clippy_lints/src/large_stack_arrays.rs @@ -8,7 +8,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, ConstKind}; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/legacy_numeric_constants.rs b/clippy_lints/src/legacy_numeric_constants.rs index ccab1e27d3b..e17d6213679 100644 --- a/clippy_lints/src/legacy_numeric_constants.rs +++ b/clippy_lints/src/legacy_numeric_constants.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{Msrv, NUMERIC_ASSOCIATED_CONSTANTS}; use clippy_config::Conf; +use clippy_config::msrvs::{Msrv, NUMERIC_ASSOCIATED_CONSTANTS}; use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then}; use clippy_utils::{get_parent_expr, is_from_proc_macro}; use hir::def_id::DefId; @@ -10,7 +10,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 0bc7fc2dd9d..c1ba66de57e 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then}; -use clippy_utils::source::{snippet_with_context, SpanRangeExt}; -use clippy_utils::sugg::{has_enclosing_paren, Sugg}; +use clippy_utils::source::{SpanRangeExt, snippet_with_context}; +use clippy_utils::sugg::{Sugg, has_enclosing_paren}; use clippy_utils::{get_item_name, get_parent_as_impl, is_lint_allowed, peel_ref_operators}; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index b21d3f8d09e..1d41f568f37 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -394,7 +394,7 @@ mod zero_sized_map_values; mod zombie_processes; // end lints modules, do not remove this comment, it’s used in `update_lints` -use clippy_config::{get_configuration_metadata, Conf}; +use clippy_config::{Conf, get_configuration_metadata}; use clippy_utils::macros::FormatArgsStorage; use rustc_data_structures::fx::FxHashSet; use rustc_lint::{Lint, LintId}; diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index ba34af9c100..755afe959b3 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -3,25 +3,25 @@ use clippy_utils::trait_ref_of_method; use itertools::Itertools; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::Applicability; +use rustc_hir::FnRetTy::Return; use rustc_hir::intravisit::nested_filter::{self as hir_nested_filter, NestedFilter}; use rustc_hir::intravisit::{ - walk_fn_decl, walk_generic_param, walk_generics, walk_impl_item_ref, walk_item, walk_param_bound, - walk_poly_trait_ref, walk_trait_ref, walk_ty, Visitor, + Visitor, walk_fn_decl, walk_generic_param, walk_generics, walk_impl_item_ref, walk_item, walk_param_bound, + walk_poly_trait_ref, walk_trait_ref, walk_ty, }; -use rustc_hir::FnRetTy::Return; use rustc_hir::{ - lang_items, BareFnTy, BodyId, FnDecl, FnSig, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, - Impl, ImplItem, ImplItemKind, Item, ItemKind, Lifetime, LifetimeName, LifetimeParamKind, Node, PolyTraitRef, - PredicateOrigin, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate, + BareFnTy, BodyId, FnDecl, FnSig, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, Impl, + ImplItem, ImplItemKind, Item, ItemKind, Lifetime, LifetimeName, LifetimeParamKind, Node, PolyTraitRef, + PredicateOrigin, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate, lang_items, }; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::hir::map::Map; use rustc_middle::hir::nested_filter as middle_nested_filter; use rustc_middle::lint::in_external_macro; use rustc_session::declare_lint_pass; -use rustc_span::def_id::LocalDefId; -use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_span::Span; +use rustc_span::def_id::LocalDefId; +use rustc_span::symbol::{Ident, Symbol, kw}; use std::ops::ControlFlow; declare_clippy_lint! { diff --git a/clippy_lints/src/loops/explicit_counter_loop.rs b/clippy_lints/src/loops/explicit_counter_loop.rs index 73a23615c2d..9aa4d2f0adc 100644 --- a/clippy_lints/src/loops/explicit_counter_loop.rs +++ b/clippy_lints/src/loops/explicit_counter_loop.rs @@ -1,4 +1,4 @@ -use super::{make_iterator_snippet, IncrementVisitor, InitializeVisitor, EXPLICIT_COUNTER_LOOP}; +use super::{EXPLICIT_COUNTER_LOOP, IncrementVisitor, InitializeVisitor, make_iterator_snippet}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_with_applicability; use clippy_utils::{get_enclosing_block, is_integer_const}; diff --git a/clippy_lints/src/loops/infinite_loop.rs b/clippy_lints/src/loops/infinite_loop.rs index 5b5bb88c179..858e3be5093 100644 --- a/clippy_lints/src/loops/infinite_loop.rs +++ b/clippy_lints/src/loops/infinite_loop.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::{fn_def_id, is_from_proc_macro, is_lint_allowed}; -use hir::intravisit::{walk_expr, Visitor}; +use hir::intravisit::{Visitor, walk_expr}; use hir::{Expr, ExprKind, FnRetTy, FnSig, Node}; use rustc_ast::Label; use rustc_errors::Applicability; diff --git a/clippy_lints/src/loops/manual_find.rs b/clippy_lints/src/loops/manual_find.rs index b27528c11d4..bfe2e68b5d1 100644 --- a/clippy_lints/src/loops/manual_find.rs +++ b/clippy_lints/src/loops/manual_find.rs @@ -1,5 +1,5 @@ -use super::utils::make_iterator_snippet; use super::MANUAL_FIND; +use super::utils::make_iterator_snippet; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::implements_trait; diff --git a/clippy_lints/src/loops/manual_flatten.rs b/clippy_lints/src/loops/manual_flatten.rs index dbc094a6d73..366c310592f 100644 --- a/clippy_lints/src/loops/manual_flatten.rs +++ b/clippy_lints/src/loops/manual_flatten.rs @@ -1,5 +1,5 @@ -use super::utils::make_iterator_snippet; use super::MANUAL_FLATTEN; +use super::utils::make_iterator_snippet; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::visitors::is_local_used; use clippy_utils::{higher, path_to_local_id, peel_blocks_with_stmt}; diff --git a/clippy_lints/src/loops/manual_while_let_some.rs b/clippy_lints/src/loops/manual_while_let_some.rs index 55d1b9ee676..7476a87267f 100644 --- a/clippy_lints/src/loops/manual_while_let_some.rs +++ b/clippy_lints/src/loops/manual_while_let_some.rs @@ -1,10 +1,10 @@ +use clippy_utils::SpanlessEq; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; -use clippy_utils::SpanlessEq; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, Pat, Stmt, StmtKind, UnOp}; use rustc_lint::LateContext; -use rustc_span::{sym, Symbol, Span}; +use rustc_span::{Span, Symbol, sym}; use std::borrow::Cow; use super::MANUAL_WHILE_LET_SOME; diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 5155fd76b25..17215621d2a 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -22,15 +22,15 @@ mod while_immutable_condition; mod while_let_loop; mod while_let_on_iterator; -use clippy_config::msrvs::Msrv; use clippy_config::Conf; +use clippy_config::msrvs::Msrv; use clippy_utils::higher; use rustc_ast::Label; use rustc_hir::{Expr, ExprKind, LoopSource, Pat}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; use rustc_span::Span; -use utils::{make_iterator_snippet, IncrementVisitor, InitializeVisitor}; +use utils::{IncrementVisitor, InitializeVisitor, make_iterator_snippet}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/loops/needless_range_loop.rs b/clippy_lints/src/loops/needless_range_loop.rs index e18e4374667..20dd5a311dc 100644 --- a/clippy_lints/src/loops/needless_range_loop.rs +++ b/clippy_lints/src/loops/needless_range_loop.rs @@ -3,17 +3,17 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use clippy_utils::ty::has_iter_method; use clippy_utils::visitors::is_local_used; -use clippy_utils::{contains_name, higher, is_integer_const, sugg, SpanlessEq}; +use clippy_utils::{SpanlessEq, contains_name, higher, is_integer_const, sugg}; use rustc_ast::ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{BinOpKind, BorrowKind, Closure, Expr, ExprKind, HirId, Mutability, Pat, PatKind, QPath}; use rustc_lint::LateContext; use rustc_middle::middle::region; use rustc_middle::ty::{self, Ty}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{Symbol, sym}; use std::{iter, mem}; /// Checks for looping over a range and then indexing a sequence with it. diff --git a/clippy_lints/src/loops/never_loop.rs b/clippy_lints/src/loops/never_loop.rs index 313a5bfefbc..1c55e3e22e8 100644 --- a/clippy_lints/src/loops/never_loop.rs +++ b/clippy_lints/src/loops/never_loop.rs @@ -1,5 +1,5 @@ -use super::utils::make_iterator_snippet; use super::NEVER_LOOP; +use super::utils::make_iterator_snippet; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::higher::ForLoop; use clippy_utils::macros::root_macro_call_first_node; @@ -7,7 +7,7 @@ use clippy_utils::source::snippet; use rustc_errors::Applicability; use rustc_hir::{Block, Destination, Expr, ExprKind, HirId, InlineAsmOperand, Pat, Stmt, StmtKind}; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use std::iter::once; pub(super) fn check<'tcx>( diff --git a/clippy_lints/src/loops/same_item_push.rs b/clippy_lints/src/loops/same_item_push.rs index 9185cf1f8b2..5662d3013e1 100644 --- a/clippy_lints/src/loops/same_item_push.rs +++ b/clippy_lints/src/loops/same_item_push.rs @@ -6,11 +6,11 @@ use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, Mutability, Node, Pat, PatKind, Stmt, StmtKind}; use rustc_lint::LateContext; -use rustc_span::symbol::sym; use rustc_span::SyntaxContext; +use rustc_span::symbol::sym; /// Detects for loop pushing the same item into a Vec pub(super) fn check<'tcx>( diff --git a/clippy_lints/src/loops/single_element_loop.rs b/clippy_lints/src/loops/single_element_loop.rs index 2b41911e8ec..70f76ced09a 100644 --- a/clippy_lints/src/loops/single_element_loop.rs +++ b/clippy_lints/src/loops/single_element_loop.rs @@ -2,10 +2,10 @@ use super::SINGLE_ELEMENT_LOOP; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{indent_of, snippet, snippet_with_applicability}; use clippy_utils::visitors::contains_break_or_continue; -use rustc_ast::util::parser::PREC_PREFIX; use rustc_ast::Mutability; +use rustc_ast::util::parser::PREC_PREFIX; use rustc_errors::Applicability; -use rustc_hir::{is_range_literal, BorrowKind, Expr, ExprKind, Pat, PatKind}; +use rustc_hir::{BorrowKind, Expr, ExprKind, Pat, PatKind, is_range_literal}; use rustc_lint::LateContext; use rustc_span::edition::Edition; use rustc_span::sym; diff --git a/clippy_lints/src/loops/utils.rs b/clippy_lints/src/loops/utils.rs index 7b45cc95431..9a89a41d2b3 100644 --- a/clippy_lints/src/loops/utils.rs +++ b/clippy_lints/src/loops/utils.rs @@ -2,13 +2,13 @@ use clippy_utils::ty::{has_iter_method, implements_trait}; use clippy_utils::{get_parent_expr, is_integer_const, path_to_local, path_to_local_id, sugg}; use rustc_ast::ast::{LitIntType, LitKind}; use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_expr, walk_local, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr, walk_local}; use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, HirId, HirIdMap, LetStmt, Mutability, PatKind}; use rustc_lint::LateContext; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, Ty}; use rustc_span::source_map::Spanned; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{Symbol, sym}; #[derive(Debug, PartialEq, Eq)] enum IncrementVisitorVarState { diff --git a/clippy_lints/src/loops/while_immutable_condition.rs b/clippy_lints/src/loops/while_immutable_condition.rs index cc1bd5929d0..eab096e9a22 100644 --- a/clippy_lints/src/loops/while_immutable_condition.rs +++ b/clippy_lints/src/loops/while_immutable_condition.rs @@ -4,7 +4,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::usage::mutated_variables; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefIdMap; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{Expr, ExprKind, HirIdSet, QPath}; use rustc_lint::LateContext; use std::ops::ControlFlow; diff --git a/clippy_lints/src/loops/while_let_on_iterator.rs b/clippy_lints/src/loops/while_let_on_iterator.rs index c171fa1c622..7d9fbaf3cea 100644 --- a/clippy_lints/src/loops/while_let_on_iterator.rs +++ b/clippy_lints/src/loops/while_let_on_iterator.rs @@ -5,13 +5,13 @@ use clippy_utils::visitors::is_res_used; use clippy_utils::{get_enclosing_loop_or_multi_call_closure, higher, is_refutable, is_res_lang_ctor, is_trait_method}; use rustc_errors::Applicability; use rustc_hir::def::Res; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{Closure, Expr, ExprKind, HirId, LangItem, LetStmt, Mutability, PatKind, UnOp}; use rustc_lint::LateContext; use rustc_middle::hir::nested_filter::OnlyBodies; use rustc_middle::ty::adjustment::Adjust; -use rustc_span::symbol::sym; use rustc_span::Symbol; +use rustc_span::symbol::sym; pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if let Some(higher::WhileLet { if_then, let_pat, let_expr, label, .. }) = higher::WhileLet::hir(expr) diff --git a/clippy_lints/src/macro_metavars_in_unsafe.rs b/clippy_lints/src/macro_metavars_in_unsafe.rs index e215097142b..ccc554042d6 100644 --- a/clippy_lints/src/macro_metavars_in_unsafe.rs +++ b/clippy_lints/src/macro_metavars_in_unsafe.rs @@ -3,13 +3,13 @@ use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::is_lint_allowed; use itertools::Itertools; use rustc_hir::def_id::LocalDefId; -use rustc_hir::intravisit::{walk_block, walk_expr, walk_stmt, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_block, walk_expr, walk_stmt}; use rustc_hir::{BlockCheckMode, Expr, ExprKind, HirId, Stmt, UnsafeSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span, SyntaxContext}; -use std::collections::btree_map::Entry; +use rustc_span::{Span, SyntaxContext, sym}; use std::collections::BTreeMap; +use std::collections::btree_map::Entry; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs index 067384b0901..bd6b3f1a47b 100644 --- a/clippy_lints/src/macro_use.rs +++ b/clippy_lints/src/macro_use.rs @@ -8,7 +8,7 @@ use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_session::impl_lint_pass; use rustc_span::edition::Edition; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use std::collections::BTreeMap; declare_clippy_lint! { diff --git a/clippy_lints/src/manual_async_fn.rs b/clippy_lints/src/manual_async_fn.rs index 61723aec590..fc3bba9e512 100644 --- a/clippy_lints/src/manual_async_fn.rs +++ b/clippy_lints/src/manual_async_fn.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::source::{position_before_rarrow, snippet_block, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, position_before_rarrow, snippet_block}; use rustc_errors::Applicability; use rustc_hir::intravisit::FnKind; use rustc_hir::{ @@ -9,7 +9,7 @@ use rustc_hir::{ use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/manual_bits.rs b/clippy_lints/src/manual_bits.rs index 5cbdc7f864a..c0e87e8a1fa 100644 --- a/clippy_lints/src/manual_bits.rs +++ b/clippy_lints/src/manual_bits.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::get_parent_expr; use clippy_utils::source::snippet_with_context; diff --git a/clippy_lints/src/manual_clamp.rs b/clippy_lints/src/manual_clamp.rs index 4123c933660..788649fd4f9 100644 --- a/clippy_lints/src/manual_clamp.rs +++ b/clippy_lints/src/manual_clamp.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then}; use clippy_utils::higher::If; @@ -7,8 +7,8 @@ use clippy_utils::sugg::Sugg; use clippy_utils::ty::implements_trait; use clippy_utils::visitors::is_const_evaluatable; use clippy_utils::{ - eq_expr_value, is_diag_trait_item, is_in_const_context, is_trait_method, path_res, path_to_local_id, peel_blocks, - peel_blocks_with_stmt, MaybePath, + MaybePath, eq_expr_value, is_diag_trait_item, is_in_const_context, is_trait_method, path_res, path_to_local_id, + peel_blocks, peel_blocks_with_stmt, }; use itertools::Itertools; use rustc_errors::{Applicability, Diag}; @@ -17,8 +17,8 @@ use rustc_hir::{Arm, BinOpKind, Block, Expr, ExprKind, HirId, PatKind, PathSegme use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; use rustc_session::impl_lint_pass; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; use std::cmp::Ordering; use std::ops::Deref; diff --git a/clippy_lints/src/manual_div_ceil.rs b/clippy_lints/src/manual_div_ceil.rs index 024c2547dc6..00e02e2a336 100644 --- a/clippy_lints/src/manual_div_ceil.rs +++ b/clippy_lints/src/manual_div_ceil.rs @@ -1,8 +1,8 @@ use clippy_config::msrvs::{self, Msrv}; +use clippy_utils::SpanlessEq; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::sugg::Sugg; -use clippy_utils::SpanlessEq; use rustc_ast::{BinOpKind, LitKind}; use rustc_data_structures::packed::Pu128; use rustc_errors::Applicability; diff --git a/clippy_lints/src/manual_hash_one.rs b/clippy_lints/src/manual_hash_one.rs index 11716a539ab..c62bd65bea6 100644 --- a/clippy_lints/src/manual_hash_one.rs +++ b/clippy_lints/src/manual_hash_one.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::source::SpanRangeExt; use clippy_utils::visitors::{is_local_used, local_used_once}; diff --git a/clippy_lints/src/manual_is_ascii_check.rs b/clippy_lints/src/manual_is_ascii_check.rs index 31c37c3bc3b..24207705743 100644 --- a/clippy_lints/src/manual_is_ascii_check.rs +++ b/clippy_lints/src/manual_is_ascii_check.rs @@ -1,17 +1,17 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::macros::matching_root_macro_call; use clippy_utils::sugg::Sugg; use clippy_utils::{higher, is_in_const_context, path_to_local, peel_ref_operators}; -use rustc_ast::ast::RangeLimits; use rustc_ast::LitKind::{Byte, Char}; +use rustc_ast::ast::RangeLimits; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, Node, Param, PatKind, RangeEnd}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/manual_is_power_of_two.rs b/clippy_lints/src/manual_is_power_of_two.rs index d7879403ebb..da2a982ee17 100644 --- a/clippy_lints/src/manual_is_power_of_two.rs +++ b/clippy_lints/src/manual_is_power_of_two.rs @@ -1,6 +1,6 @@ +use clippy_utils::SpanlessEq; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; -use clippy_utils::SpanlessEq; use rustc_ast::LitKind; use rustc_data_structures::packed::Pu128; use rustc_errors::Applicability; diff --git a/clippy_lints/src/manual_let_else.rs b/clippy_lints/src/manual_let_else.rs index ebebdf679a8..17185df5d76 100644 --- a/clippy_lints/src/manual_let_else.rs +++ b/clippy_lints/src/manual_let_else.rs @@ -1,4 +1,4 @@ -use crate::question_mark::{QuestionMark, QUESTION_MARK}; +use crate::question_mark::{QUESTION_MARK, QuestionMark}; use clippy_config::msrvs; use clippy_config::types::MatchLintBehaviour; use clippy_utils::diagnostics::span_lint_and_then; @@ -12,8 +12,8 @@ use rustc_hir::{Expr, ExprKind, MatchSource, Pat, PatKind, QPath, Stmt, StmtKind use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; +use rustc_span::symbol::{Symbol, sym}; use std::slice; declare_clippy_lint! { diff --git a/clippy_lints/src/manual_main_separator_str.rs b/clippy_lints/src/manual_main_separator_str.rs index 5198d7838a2..85e99a92cf5 100644 --- a/clippy_lints/src/manual_main_separator_str.rs +++ b/clippy_lints/src/manual_main_separator_str.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::{is_trait_method, peel_hir_expr_refs}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/manual_non_exhaustive.rs b/clippy_lints/src/manual_non_exhaustive.rs index 01f1d9c3beb..25868ccae40 100644 --- a/clippy_lints/src/manual_non_exhaustive.rs +++ b/clippy_lints/src/manual_non_exhaustive.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then}; use clippy_utils::is_doc_hidden; use clippy_utils::source::snippet_indent; @@ -12,7 +12,7 @@ use rustc_hir::{Expr, ExprKind, Item, ItemKind, QPath, TyKind, VariantData}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/manual_range_patterns.rs b/clippy_lints/src/manual_range_patterns.rs index 66d2ab6b24a..ffa3eacf354 100644 --- a/clippy_lints/src/manual_range_patterns.rs +++ b/clippy_lints/src/manual_range_patterns.rs @@ -7,7 +7,7 @@ use rustc_hir::{Expr, ExprKind, PatKind, RangeEnd, UnOp}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::declare_lint_pass; -use rustc_span::{Span, DUMMY_SP}; +use rustc_span::{DUMMY_SP, Span}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/manual_rem_euclid.rs b/clippy_lints/src/manual_rem_euclid.rs index 6cf5d272d7d..86293169ea2 100644 --- a/clippy_lints/src/manual_rem_euclid.rs +++ b/clippy_lints/src/manual_rem_euclid.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::consts::{ConstEvalCtxt, FullInt}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_context; diff --git a/clippy_lints/src/manual_retain.rs b/clippy_lints/src/manual_retain.rs index a35b0f914e0..a60163be770 100644 --- a/clippy_lints/src/manual_retain.rs +++ b/clippy_lints/src/manual_retain.rs @@ -1,17 +1,17 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; +use clippy_utils::SpanlessEq; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::{get_type_diagnostic_name, is_type_lang_item}; -use clippy_utils::SpanlessEq; use rustc_errors::Applicability; use rustc_hir as hir; -use rustc_hir::def_id::DefId; use rustc_hir::ExprKind::Assign; +use rustc_hir::def_id::DefId; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; +use rustc_span::symbol::{Symbol, sym}; const ACCEPTABLE_METHODS: [Symbol; 5] = [ sym::binaryheap_iter, diff --git a/clippy_lints/src/manual_string_new.rs b/clippy_lints/src/manual_string_new.rs index 781db4b97f0..198f7aaddc7 100644 --- a/clippy_lints/src/manual_string_new.rs +++ b/clippy_lints/src/manual_string_new.rs @@ -5,7 +5,7 @@ use rustc_hir::{Expr, ExprKind, PathSegment, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::declare_lint_pass; -use rustc_span::{sym, symbol, Span}; +use rustc_span::{Span, sym, symbol}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index 02d433ecc5a..9aceca66bf7 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; @@ -8,13 +8,13 @@ use clippy_utils::{eq_expr_value, higher}; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; use rustc_hir::def::Res; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::impl_lint_pass; use rustc_span::source_map::Spanned; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use std::iter; declare_clippy_lint! { diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 2db71b1f7a3..a97dbbbc33f 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -7,7 +7,7 @@ use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, Ty}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/matches/collapsible_match.rs b/clippy_lints/src/matches/collapsible_match.rs index b666e77c09e..50e6dfc6298 100644 --- a/clippy_lints/src/matches/collapsible_match.rs +++ b/clippy_lints/src/matches/collapsible_match.rs @@ -4,7 +4,7 @@ use clippy_utils::higher::IfLetOrMatch; use clippy_utils::source::snippet; use clippy_utils::visitors::is_local_used; use clippy_utils::{ - is_res_lang_ctor, is_unit_expr, path_to_local, peel_blocks_with_stmt, peel_ref_operators, SpanlessEq, + SpanlessEq, is_res_lang_ctor, is_unit_expr, path_to_local, peel_blocks_with_stmt, peel_ref_operators, }; use rustc_errors::MultiSpan; use rustc_hir::LangItem::OptionNone; @@ -12,7 +12,7 @@ use rustc_hir::{Arm, Expr, HirId, Pat, PatKind}; use rustc_lint::LateContext; use rustc_span::Span; -use super::{pat_contains_disallowed_or, COLLAPSIBLE_MATCH}; +use super::{COLLAPSIBLE_MATCH, pat_contains_disallowed_or}; pub(super) fn check_match<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>], msrv: &Msrv) { if let Some(els_arm) = arms.iter().rfind(|arm| arm_is_wild_like(cx, arm)) { diff --git a/clippy_lints/src/matches/manual_filter.rs b/clippy_lints/src/matches/manual_filter.rs index 619ec83127a..cfa054706d6 100644 --- a/clippy_lints/src/matches/manual_filter.rs +++ b/clippy_lints/src/matches/manual_filter.rs @@ -6,10 +6,10 @@ use clippy_utils::{is_res_lang_ctor, path_res, path_to_local_id}; use rustc_hir::LangItem::{OptionNone, OptionSome}; use rustc_hir::{Arm, Expr, ExprKind, HirId, Pat, PatKind}; use rustc_lint::LateContext; -use rustc_span::{sym, SyntaxContext}; +use rustc_span::{SyntaxContext, sym}; -use super::manual_utils::{check_with, SomeExpr}; use super::MANUAL_FILTER; +use super::manual_utils::{SomeExpr, check_with}; // Function called on the of `[&+]Some((ref | ref mut) x) => ` // Need to check if it's of the form `=if {} else {}` diff --git a/clippy_lints/src/matches/manual_map.rs b/clippy_lints/src/matches/manual_map.rs index ed3d8b09fdc..de57d1eee92 100644 --- a/clippy_lints/src/matches/manual_map.rs +++ b/clippy_lints/src/matches/manual_map.rs @@ -1,5 +1,5 @@ -use super::manual_utils::{check_with, SomeExpr}; use super::MANUAL_MAP; +use super::manual_utils::{SomeExpr, check_with}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::{is_res_lang_ctor, path_res}; diff --git a/clippy_lints/src/matches/manual_unwrap_or.rs b/clippy_lints/src/matches/manual_unwrap_or.rs index d5d83df9347..59d37520011 100644 --- a/clippy_lints/src/matches/manual_unwrap_or.rs +++ b/clippy_lints/src/matches/manual_unwrap_or.rs @@ -1,12 +1,12 @@ use clippy_utils::consts::ConstEvalCtxt; use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::source::{indent_of, reindent_multiline, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, indent_of, reindent_multiline}; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::usage::contains_return_break_continue_macro; use clippy_utils::{is_res_lang_ctor, path_to_local_id, peel_blocks, sugg}; use rustc_errors::Applicability; -use rustc_hir::def::{DefKind, Res}; use rustc_hir::LangItem::{OptionNone, ResultErr}; +use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Arm, Expr, Pat, PatKind}; use rustc_lint::LateContext; use rustc_middle::ty::Ty; diff --git a/clippy_lints/src/matches/manual_utils.rs b/clippy_lints/src/matches/manual_utils.rs index be80aebed6d..d38560998a5 100644 --- a/clippy_lints/src/matches/manual_utils.rs +++ b/clippy_lints/src/matches/manual_utils.rs @@ -4,16 +4,16 @@ use clippy_utils::source::{snippet_with_applicability, snippet_with_context}; use clippy_utils::sugg::Sugg; use clippy_utils::ty::{is_copy, is_type_diagnostic_item, peel_mid_ty_refs_is_mutable, type_is_unsafe_function}; use clippy_utils::{ - can_move_expr_to_closure, is_else_clause, is_lint_allowed, is_res_lang_ctor, path_res, path_to_local_id, - peel_blocks, peel_hir_expr_refs, peel_hir_expr_while, CaptureKind, + CaptureKind, can_move_expr_to_closure, is_else_clause, is_lint_allowed, is_res_lang_ctor, path_res, + path_to_local_id, peel_blocks, peel_hir_expr_refs, peel_hir_expr_while, }; use rustc_ast::util::parser::PREC_UNAMBIGUOUS; use rustc_errors::Applicability; -use rustc_hir::def::Res; use rustc_hir::LangItem::{OptionNone, OptionSome}; +use rustc_hir::def::Res; use rustc_hir::{BindingMode, Expr, ExprKind, HirId, Mutability, Pat, PatKind, Path, QPath}; use rustc_lint::LateContext; -use rustc_span::{sym, SyntaxContext}; +use rustc_span::{SyntaxContext, sym}; #[expect(clippy::too_many_arguments)] #[expect(clippy::too_many_lines)] diff --git a/clippy_lints/src/matches/match_same_arms.rs b/clippy_lints/src/matches/match_same_arms.rs index da8c918a62b..f9ffbc5dc0b 100644 --- a/clippy_lints/src/matches/match_same_arms.rs +++ b/clippy_lints/src/matches/match_same_arms.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::source::snippet_with_applicability; -use clippy_utils::{is_lint_allowed, path_to_local, search_same, SpanlessEq, SpanlessHash}; +use clippy_utils::{SpanlessEq, SpanlessHash, is_lint_allowed, path_to_local, search_same}; use core::cmp::Ordering; use core::{iter, slice}; use rustc_arena::DroplessArena; diff --git a/clippy_lints/src/matches/match_str_case_mismatch.rs b/clippy_lints/src/matches/match_str_case_mismatch.rs index 322e9c3ebe5..40518ce2ca7 100644 --- a/clippy_lints/src/matches/match_str_case_mismatch.rs +++ b/clippy_lints/src/matches/match_str_case_mismatch.rs @@ -2,12 +2,12 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::ty::is_type_lang_item; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{Arm, Expr, ExprKind, LangItem, PatKind}; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::symbol::Symbol; use rustc_span::Span; +use rustc_span::symbol::Symbol; use super::MATCH_STR_CASE_MISMATCH; diff --git a/clippy_lints/src/matches/mod.rs b/clippy_lints/src/matches/mod.rs index cf5377e0725..686fc4a0fa0 100644 --- a/clippy_lints/src/matches/mod.rs +++ b/clippy_lints/src/matches/mod.rs @@ -24,8 +24,8 @@ mod single_match; mod try_err; mod wild_in_or_pats; -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::source::walk_span_to_context; use clippy_utils::{higher, is_direct_expn_of, is_in_const_context, is_span_match, span_contains_cfg}; use rustc_hir::{Arm, Expr, ExprKind, LetStmt, MatchSource, Pat, PatKind}; diff --git a/clippy_lints/src/matches/overlapping_arms.rs b/clippy_lints/src/matches/overlapping_arms.rs index 71f211be925..6a4c553cee0 100644 --- a/clippy_lints/src/matches/overlapping_arms.rs +++ b/clippy_lints/src/matches/overlapping_arms.rs @@ -1,4 +1,4 @@ -use clippy_utils::consts::{mir_to_const, ConstEvalCtxt, FullInt}; +use clippy_utils::consts::{ConstEvalCtxt, FullInt, mir_to_const}; use clippy_utils::diagnostics::span_lint_and_note; use core::cmp::Ordering; use rustc_hir::{Arm, Expr, PatKind, RangeEnd}; diff --git a/clippy_lints/src/matches/redundant_guards.rs b/clippy_lints/src/matches/redundant_guards.rs index 8222c3057f7..564c598a334 100644 --- a/clippy_lints/src/matches/redundant_guards.rs +++ b/clippy_lints/src/matches/redundant_guards.rs @@ -10,11 +10,11 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Arm, BinOpKind, Expr, ExprKind, MatchSource, Node, PatKind, UnOp}; use rustc_lint::LateContext; use rustc_span::symbol::Ident; -use rustc_span::{sym, Span, Symbol}; +use rustc_span::{Span, Symbol, sym}; use std::borrow::Cow; use std::ops::ControlFlow; -use super::{pat_contains_disallowed_or, REDUNDANT_GUARDS}; +use super::{REDUNDANT_GUARDS, pat_contains_disallowed_or}; pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'tcx>], msrv: &Msrv) { for outer_arm in arms { diff --git a/clippy_lints/src/matches/redundant_pattern_match.rs b/clippy_lints/src/matches/redundant_pattern_match.rs index 0e4b2d9d34a..b646e87a439 100644 --- a/clippy_lints/src/matches/redundant_pattern_match.rs +++ b/clippy_lints/src/matches/redundant_pattern_match.rs @@ -1,18 +1,18 @@ use super::REDUNDANT_PATTERN_MATCHING; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::{snippet, walk_span_to_context}; -use clippy_utils::sugg::{make_unop, Sugg}; +use clippy_utils::sugg::{Sugg, make_unop}; use clippy_utils::ty::{is_type_diagnostic_item, needs_ordered_drop}; use clippy_utils::visitors::{any_temporaries_need_ordered_drop, for_each_expr_without_closures}; use clippy_utils::{higher, is_expn_of, is_trait_method}; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; -use rustc_hir::def::{DefKind, Res}; use rustc_hir::LangItem::{self, OptionNone, OptionSome, PollPending, PollReady, ResultErr, ResultOk}; +use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Arm, Expr, ExprKind, Node, Pat, PatKind, QPath, UnOp}; use rustc_lint::LateContext; use rustc_middle::ty::{self, GenericArgKind, Ty}; -use rustc_span::{sym, Span, Symbol}; +use rustc_span::{Span, Symbol, sym}; use std::fmt::Write; use std::ops::ControlFlow; diff --git a/clippy_lints/src/matches/significant_drop_in_scrutinee.rs b/clippy_lints/src/matches/significant_drop_in_scrutinee.rs index 9c2f42d2187..537f7272f7f 100644 --- a/clippy_lints/src/matches/significant_drop_in_scrutinee.rs +++ b/clippy_lints/src/matches/significant_drop_in_scrutinee.rs @@ -8,7 +8,7 @@ use clippy_utils::{get_attr, is_lint_allowed}; use itertools::Itertools; use rustc_ast::Mutability; use rustc_errors::{Applicability, Diag}; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{Arm, Expr, ExprKind, MatchSource}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::ty::{GenericArgKind, Region, RegionKind, Ty, TyCtxt, TypeVisitable, TypeVisitor}; diff --git a/clippy_lints/src/matches/single_match.rs b/clippy_lints/src/matches/single_match.rs index e7cef5bdbd7..2eda238ae8c 100644 --- a/clippy_lints/src/matches/single_match.rs +++ b/clippy_lints/src/matches/single_match.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::source::{expr_block, snippet, snippet_block_with_context, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, expr_block, snippet, snippet_block_with_context}; use clippy_utils::ty::implements_trait; use clippy_utils::{ is_lint_allowed, is_unit_expr, peel_blocks, peel_hir_pat_refs, peel_middle_ty_refs, peel_n_hir_expr_refs, @@ -8,11 +8,11 @@ use core::ops::ControlFlow; use rustc_arena::DroplessArena; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::intravisit::{walk_pat, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_pat}; use rustc_hir::{Arm, Expr, ExprKind, HirId, Node, Pat, PatKind, QPath, StmtKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, AdtDef, ParamEnv, TyCtxt, TypeckResults, VariantDef}; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::{MATCH_BOOL, SINGLE_MATCH, SINGLE_MATCH_ELSE}; diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index 72a5945ad9b..146748734cf 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::sugg::Sugg; @@ -13,8 +13,8 @@ use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/methods/bind_instead_of_map.rs b/clippy_lints/src/methods/bind_instead_of_map.rs index 2a8a5fcc3b6..91a5de16e96 100644 --- a/clippy_lints/src/methods/bind_instead_of_map.rs +++ b/clippy_lints/src/methods/bind_instead_of_map.rs @@ -1,4 +1,4 @@ -use super::{contains_return, BIND_INSTEAD_OF_MAP}; +use super::{BIND_INSTEAD_OF_MAP, contains_return}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::peel_blocks; use clippy_utils::source::{snippet, snippet_with_context}; diff --git a/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs b/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs index 740cce0a6c2..76bdbe55e2f 100644 --- a/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs +++ b/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs @@ -1,12 +1,12 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::source::{indent_of, reindent_multiline, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, indent_of, reindent_multiline}; use clippy_utils::ty::is_type_lang_item; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, LangItem}; use rustc_lint::LateContext; -use rustc_span::source_map::Spanned; use rustc_span::Span; +use rustc_span::source_map::Spanned; use super::CASE_SENSITIVE_FILE_EXTENSION_COMPARISONS; diff --git a/clippy_lints/src/methods/clear_with_drain.rs b/clippy_lints/src/methods/clear_with_drain.rs index 5389861245a..6e24cabca8b 100644 --- a/clippy_lints/src/methods/clear_with_drain.rs +++ b/clippy_lints/src/methods/clear_with_drain.rs @@ -4,8 +4,8 @@ use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, LangItem, QPath}; use rustc_lint::LateContext; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; use super::CLEAR_WITH_DRAIN; diff --git a/clippy_lints/src/methods/clone_on_copy.rs b/clippy_lints/src/methods/clone_on_copy.rs index e7a2060be04..79a473e0e6f 100644 --- a/clippy_lints/src/methods/clone_on_copy.rs +++ b/clippy_lints/src/methods/clone_on_copy.rs @@ -7,7 +7,7 @@ use rustc_lint::LateContext; use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::{self}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{Symbol, sym}; use super::CLONE_ON_COPY; diff --git a/clippy_lints/src/methods/clone_on_ref_ptr.rs b/clippy_lints/src/methods/clone_on_ref_ptr.rs index e0826b53004..96e2de0dc1c 100644 --- a/clippy_lints/src/methods/clone_on_ref_ptr.rs +++ b/clippy_lints/src/methods/clone_on_ref_ptr.rs @@ -4,7 +4,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{Symbol, sym}; use super::CLONE_ON_REF_PTR; diff --git a/clippy_lints/src/methods/cloned_instead_of_copied.rs b/clippy_lints/src/methods/cloned_instead_of_copied.rs index fcafa162236..fa04f74eec1 100644 --- a/clippy_lints/src/methods/cloned_instead_of_copied.rs +++ b/clippy_lints/src/methods/cloned_instead_of_copied.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::CLONED_INSTEAD_OF_COPIED; diff --git a/clippy_lints/src/methods/collapsible_str_replace.rs b/clippy_lints/src/methods/collapsible_str_replace.rs index 1fab6c0e499..f7bf8764bde 100644 --- a/clippy_lints/src/methods/collapsible_str_replace.rs +++ b/clippy_lints/src/methods/collapsible_str_replace.rs @@ -8,7 +8,7 @@ use rustc_hir as hir; use rustc_lint::LateContext; use std::collections::VecDeque; -use super::{method_call, COLLAPSIBLE_STR_REPLACE}; +use super::{COLLAPSIBLE_STR_REPLACE, method_call}; pub(super) fn check<'tcx>( cx: &LateContext<'tcx>, diff --git a/clippy_lints/src/methods/drain_collect.rs b/clippy_lints/src/methods/drain_collect.rs index 56171a13452..10360b4817b 100644 --- a/clippy_lints/src/methods/drain_collect.rs +++ b/clippy_lints/src/methods/drain_collect.rs @@ -8,7 +8,7 @@ use rustc_hir::{Expr, ExprKind, LangItem, Path, QPath}; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_middle::ty::Ty; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; /// Checks if both types match the given diagnostic item, e.g.: /// diff --git a/clippy_lints/src/methods/err_expect.rs b/clippy_lints/src/methods/err_expect.rs index dc978c8a584..3b1adb16b80 100644 --- a/clippy_lints/src/methods/err_expect.rs +++ b/clippy_lints/src/methods/err_expect.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_middle::ty::Ty; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; pub(super) fn check( cx: &LateContext<'_>, diff --git a/clippy_lints/src/methods/expect_fun_call.rs b/clippy_lints/src/methods/expect_fun_call.rs index c9f56e1d980..2922086522c 100644 --- a/clippy_lints/src/methods/expect_fun_call.rs +++ b/clippy_lints/src/methods/expect_fun_call.rs @@ -1,13 +1,13 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::macros::{format_args_inputs_span, root_macro_call_first_node, FormatArgsStorage}; +use clippy_utils::macros::{FormatArgsStorage, format_args_inputs_span, root_macro_call_first_node}; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; use std::borrow::Cow; use super::EXPECT_FUN_CALL; diff --git a/clippy_lints/src/methods/filetype_is_file.rs b/clippy_lints/src/methods/filetype_is_file.rs index 2ab0401947c..35008c39c08 100644 --- a/clippy_lints/src/methods/filetype_is_file.rs +++ b/clippy_lints/src/methods/filetype_is_file.rs @@ -3,7 +3,7 @@ use clippy_utils::get_parent_expr; use clippy_utils::ty::is_type_diagnostic_item; use rustc_hir as hir; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::FILETYPE_IS_FILE; diff --git a/clippy_lints/src/methods/filter_map.rs b/clippy_lints/src/methods/filter_map.rs index 02a11257007..06482a743dd 100644 --- a/clippy_lints/src/methods/filter_map.rs +++ b/clippy_lints/src/methods/filter_map.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::macros::{is_panic, matching_root_macro_call, root_macro_call}; use clippy_utils::source::{indent_of, reindent_multiline, snippet}; use clippy_utils::ty::is_type_diagnostic_item; -use clippy_utils::{higher, is_trait_method, path_to_local_id, peel_blocks, SpanlessEq}; +use clippy_utils::{SpanlessEq, higher, is_trait_method, path_to_local_id, peel_blocks}; use hir::{Body, HirId, MatchSource, Pat}; use rustc_errors::Applicability; use rustc_hir as hir; @@ -10,8 +10,8 @@ use rustc_hir::def::Res; use rustc_hir::{Closure, Expr, ExprKind, PatKind, PathSegment, QPath, UnOp}; use rustc_lint::LateContext; use rustc_middle::ty::adjustment::Adjust; -use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::Span; +use rustc_span::symbol::{Ident, Symbol, sym}; use std::borrow::Cow; use super::{MANUAL_FILTER_MAP, MANUAL_FIND_MAP, OPTION_FILTER_MAP, RESULT_FILTER_MAP}; diff --git a/clippy_lints/src/methods/filter_map_bool_then.rs b/clippy_lints/src/methods/filter_map_bool_then.rs index 77a62fbb4fb..129e6925428 100644 --- a/clippy_lints/src/methods/filter_map_bool_then.rs +++ b/clippy_lints/src/methods/filter_map_bool_then.rs @@ -7,9 +7,9 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::Binder; -use rustc_span::{sym, Span}; +use rustc_middle::ty::adjustment::Adjust; +use rustc_span::{Span, sym}; pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, arg: &Expr<'_>, call_span: Span) { if !in_external_macro(cx.sess(), expr.span) diff --git a/clippy_lints/src/methods/filter_map_identity.rs b/clippy_lints/src/methods/filter_map_identity.rs index 999df875c75..cf7f276dabb 100644 --- a/clippy_lints/src/methods/filter_map_identity.rs +++ b/clippy_lints/src/methods/filter_map_identity.rs @@ -3,7 +3,7 @@ use clippy_utils::{is_expr_identity_function, is_expr_untyped_identity_function, use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::FILTER_MAP_IDENTITY; diff --git a/clippy_lints/src/methods/flat_map_identity.rs b/clippy_lints/src/methods/flat_map_identity.rs index 651ea34f9d0..0c2ecfbc8ff 100644 --- a/clippy_lints/src/methods/flat_map_identity.rs +++ b/clippy_lints/src/methods/flat_map_identity.rs @@ -3,7 +3,7 @@ use clippy_utils::{is_expr_untyped_identity_function, is_trait_method}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::FLAT_MAP_IDENTITY; diff --git a/clippy_lints/src/methods/flat_map_option.rs b/clippy_lints/src/methods/flat_map_option.rs index 0a4a381b861..3242dcadb70 100644 --- a/clippy_lints/src/methods/flat_map_option.rs +++ b/clippy_lints/src/methods/flat_map_option.rs @@ -4,7 +4,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::FLAT_MAP_OPTION; use clippy_utils::ty::is_type_diagnostic_item; diff --git a/clippy_lints/src/methods/get_last_with_len.rs b/clippy_lints/src/methods/get_last_with_len.rs index 62037651134..5f6fb4c821d 100644 --- a/clippy_lints/src/methods/get_last_with_len.rs +++ b/clippy_lints/src/methods/get_last_with_len.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; -use clippy_utils::{is_integer_literal, SpanlessEq}; +use clippy_utils::{SpanlessEq, is_integer_literal}; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/inefficient_to_string.rs b/clippy_lints/src/methods/inefficient_to_string.rs index 230a8eb2ec4..4ed7de81ea3 100644 --- a/clippy_lints/src/methods/inefficient_to_string.rs +++ b/clippy_lints/src/methods/inefficient_to_string.rs @@ -5,7 +5,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; -use rustc_span::symbol::{sym, Symbol}; +use rustc_span::symbol::{Symbol, sym}; use super::INEFFICIENT_TO_STRING; diff --git a/clippy_lints/src/methods/inspect_for_each.rs b/clippy_lints/src/methods/inspect_for_each.rs index ad4b6fa130e..3706f3b670b 100644 --- a/clippy_lints/src/methods/inspect_for_each.rs +++ b/clippy_lints/src/methods/inspect_for_each.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::is_trait_method; use rustc_hir as hir; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::INSPECT_FOR_EACH; diff --git a/clippy_lints/src/methods/into_iter_on_ref.rs b/clippy_lints/src/methods/into_iter_on_ref.rs index bbc7ce8d78a..bedeb63367d 100644 --- a/clippy_lints/src/methods/into_iter_on_ref.rs +++ b/clippy_lints/src/methods/into_iter_on_ref.rs @@ -5,8 +5,8 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; -use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; +use rustc_span::symbol::{Symbol, sym}; use super::INTO_ITER_ON_REF; diff --git a/clippy_lints/src/methods/iter_filter.rs b/clippy_lints/src/methods/iter_filter.rs index b93d51eac64..f6612c984a7 100644 --- a/clippy_lints/src/methods/iter_filter.rs +++ b/clippy_lints/src/methods/iter_filter.rs @@ -10,8 +10,8 @@ use clippy_utils::{get_parent_expr, is_trait_method, peel_blocks, span_contains_ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::QPath; -use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::Span; +use rustc_span::symbol::{Ident, Symbol, sym}; use std::borrow::Cow; /// diff --git a/clippy_lints/src/methods/iter_nth.rs b/clippy_lints/src/methods/iter_nth.rs index e31fa2f777d..82bda5d9512 100644 --- a/clippy_lints/src/methods/iter_nth.rs +++ b/clippy_lints/src/methods/iter_nth.rs @@ -3,8 +3,8 @@ use clippy_utils::ty::get_type_diagnostic_name; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; use super::ITER_NTH; diff --git a/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs b/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs index 7f6b666e434..9d562f5e51d 100644 --- a/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs +++ b/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs @@ -5,9 +5,9 @@ use clippy_utils::source::snippet; use clippy_utils::{get_expr_use_or_unification_node, is_res_lang_ctor, path_res, std_or_core}; use rustc_errors::Applicability; +use rustc_hir::LangItem::{OptionNone, OptionSome}; use rustc_hir::def_id::DefId; use rustc_hir::hir_id::HirId; -use rustc_hir::LangItem::{OptionNone, OptionSome}; use rustc_hir::{Expr, ExprKind, Node}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/iter_with_drain.rs b/clippy_lints/src/methods/iter_with_drain.rs index 1378a07cbc4..16305871337 100644 --- a/clippy_lints/src/methods/iter_with_drain.rs +++ b/clippy_lints/src/methods/iter_with_drain.rs @@ -3,8 +3,8 @@ use clippy_utils::is_range_full; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::LateContext; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; use super::ITER_WITH_DRAIN; diff --git a/clippy_lints/src/methods/join_absolute_paths.rs b/clippy_lints/src/methods/join_absolute_paths.rs index 2dad7fcf3c1..2ad070793cb 100644 --- a/clippy_lints/src/methods/join_absolute_paths.rs +++ b/clippy_lints/src/methods/join_absolute_paths.rs @@ -6,8 +6,8 @@ use rustc_ast::ast::LitKind; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; use super::JOIN_ABSOLUTE_PATHS; diff --git a/clippy_lints/src/methods/manual_c_str_literals.rs b/clippy_lints/src/methods/manual_c_str_literals.rs index cb9fb373c10..96af9db1af7 100644 --- a/clippy_lints/src/methods/manual_c_str_literals.rs +++ b/clippy_lints/src/methods/manual_c_str_literals.rs @@ -6,7 +6,7 @@ use rustc_ast::{LitKind, StrStyle}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, Node, QPath, TyKind}; use rustc_lint::LateContext; -use rustc_span::{sym, Span, Symbol}; +use rustc_span::{Span, Symbol, sym}; use super::MANUAL_C_STR_LITERALS; diff --git a/clippy_lints/src/methods/manual_inspect.rs b/clippy_lints/src/methods/manual_inspect.rs index cac2e11f591..64c19c327b2 100644 --- a/clippy_lints/src/methods/manual_inspect.rs +++ b/clippy_lints/src/methods/manual_inspect.rs @@ -3,13 +3,13 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::{IntoSpan, SpanRangeExt}; use clippy_utils::ty::get_field_by_name; use clippy_utils::visitors::{for_each_expr, for_each_expr_without_closures}; -use clippy_utils::{expr_use_ctxt, is_diag_item_method, is_diag_trait_item, path_to_local_id, ExprUseNode}; +use clippy_utils::{ExprUseNode, expr_use_ctxt, is_diag_item_method, is_diag_trait_item, path_to_local_id}; use core::ops::ControlFlow; use rustc_errors::Applicability; use rustc_hir::{BindingMode, BorrowKind, ByRef, ClosureKind, Expr, ExprKind, Mutability, Node, PatKind}; use rustc_lint::LateContext; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability}; -use rustc_span::{sym, Span, Symbol, DUMMY_SP}; +use rustc_span::{DUMMY_SP, Span, Symbol, sym}; use super::MANUAL_INSPECT; diff --git a/clippy_lints/src/methods/manual_is_variant_and.rs b/clippy_lints/src/methods/manual_is_variant_and.rs index d29acd4622a..c377abd6237 100644 --- a/clippy_lints/src/methods/manual_is_variant_and.rs +++ b/clippy_lints/src/methods/manual_is_variant_and.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::MANUAL_IS_VARIANT_AND; diff --git a/clippy_lints/src/methods/manual_ok_or.rs b/clippy_lints/src/methods/manual_ok_or.rs index b1a8e1e5e47..4321dd6b0e0 100644 --- a/clippy_lints/src/methods/manual_ok_or.rs +++ b/clippy_lints/src/methods/manual_ok_or.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::source::{indent_of, reindent_multiline, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, indent_of, reindent_multiline}; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{is_res_lang_ctor, path_res, path_to_local_id}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/methods/manual_try_fold.rs b/clippy_lints/src/methods/manual_try_fold.rs index 11fba35c16e..31449d41770 100644 --- a/clippy_lints/src/methods/manual_try_fold.rs +++ b/clippy_lints/src/methods/manual_try_fold.rs @@ -8,7 +8,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::MANUAL_TRY_FOLD; diff --git a/clippy_lints/src/methods/map_clone.rs b/clippy_lints/src/methods/map_clone.rs index 08ce7e204dd..ac378ff3702 100644 --- a/clippy_lints/src/methods/map_clone.rs +++ b/clippy_lints/src/methods/map_clone.rs @@ -11,7 +11,7 @@ use rustc_middle::mir::Mutability; use rustc_middle::ty; use rustc_middle::ty::adjustment::Adjust; use rustc_span::symbol::Ident; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::MAP_CLONE; diff --git a/clippy_lints/src/methods/map_flatten.rs b/clippy_lints/src/methods/map_flatten.rs index 22a03825194..07a7a12b162 100644 --- a/clippy_lints/src/methods/map_flatten.rs +++ b/clippy_lints/src/methods/map_flatten.rs @@ -6,8 +6,8 @@ use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; use super::MAP_FLATTEN; diff --git a/clippy_lints/src/methods/map_identity.rs b/clippy_lints/src/methods/map_identity.rs index 5dd7b1b02ad..1f204de01da 100644 --- a/clippy_lints/src/methods/map_identity.rs +++ b/clippy_lints/src/methods/map_identity.rs @@ -4,7 +4,7 @@ use clippy_utils::{is_expr_untyped_identity_function, is_trait_method}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::MAP_IDENTITY; diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 098d3fca9b2..7696dd16b25 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -132,8 +132,8 @@ mod waker_clone_wake; mod wrong_self_convention; mod zst_offset; -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use clippy_utils::macros::FormatArgsStorage; @@ -147,7 +147,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::{self, TraitRef, Ty}; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does @@ -5174,12 +5174,9 @@ impl ShouldImplTraitCase { fn lifetime_param_cond(&self, impl_item: &hir::ImplItem<'_>) -> bool { self.lint_explicit_lifetime || !impl_item.generics.params.iter().any(|p| { - matches!( - p.kind, - hir::GenericParamKind::Lifetime { - kind: hir::LifetimeParamKind::Explicit - } - ) + matches!(p.kind, hir::GenericParamKind::Lifetime { + kind: hir::LifetimeParamKind::Explicit + }) }) } } diff --git a/clippy_lints/src/methods/mut_mutex_lock.rs b/clippy_lints/src/methods/mut_mutex_lock.rs index 1a0fce2876d..83e8370f939 100644 --- a/clippy_lints/src/methods/mut_mutex_lock.rs +++ b/clippy_lints/src/methods/mut_mutex_lock.rs @@ -5,7 +5,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability}; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::MUT_MUTEX_LOCK; diff --git a/clippy_lints/src/methods/needless_character_iteration.rs b/clippy_lints/src/methods/needless_character_iteration.rs index 332da722a37..348f740e7dd 100644 --- a/clippy_lints/src/methods/needless_character_iteration.rs +++ b/clippy_lints/src/methods/needless_character_iteration.rs @@ -4,8 +4,8 @@ use rustc_lint::LateContext; use rustc_middle::ty; use rustc_span::Span; -use super::utils::get_last_chain_binding_hir_id; use super::NEEDLESS_CHARACTER_ITERATION; +use super::utils::get_last_chain_binding_hir_id; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::SpanRangeExt; use clippy_utils::{match_def_path, path_to_local_id, peel_blocks}; diff --git a/clippy_lints/src/methods/needless_collect.rs b/clippy_lints/src/methods/needless_collect.rs index f61923e5bf5..421c7a5e070 100644 --- a/clippy_lints/src/methods/needless_collect.rs +++ b/clippy_lints/src/methods/needless_collect.rs @@ -4,12 +4,12 @@ use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::sugg::Sugg; use clippy_utils::ty::{get_type_diagnostic_name, make_normalized_projection, make_projection}; use clippy_utils::{ - can_move_expr_to_closure, fn_def_id, get_enclosing_block, higher, is_trait_method, path_to_local, path_to_local_id, - CaptureKind, + CaptureKind, can_move_expr_to_closure, fn_def_id, get_enclosing_block, higher, is_trait_method, path_to_local, + path_to_local_id, }; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{Applicability, MultiSpan}; -use rustc_hir::intravisit::{walk_block, walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_block, walk_expr}; use rustc_hir::{ BindingMode, Block, Expr, ExprKind, HirId, HirIdSet, LetStmt, Mutability, Node, PatKind, Stmt, StmtKind, }; @@ -17,7 +17,7 @@ use rustc_lint::LateContext; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, AssocKind, ClauseKind, EarlyBinder, GenericArg, GenericArgKind, Ty}; use rustc_span::symbol::Ident; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; const NEEDLESS_COLLECT_MSG: &str = "avoid using `collect()` when not needed"; diff --git a/clippy_lints/src/methods/needless_option_as_deref.rs b/clippy_lints/src/methods/needless_option_as_deref.rs index 9f714fdd47b..538aa9097a4 100644 --- a/clippy_lints/src/methods/needless_option_as_deref.rs +++ b/clippy_lints/src/methods/needless_option_as_deref.rs @@ -4,8 +4,8 @@ use clippy_utils::source::SpanRangeExt; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::usage::local_used_after_expr; use rustc_errors::Applicability; -use rustc_hir::def::Res; use rustc_hir::Expr; +use rustc_hir::def::Res; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/no_effect_replace.rs b/clippy_lints/src/methods/no_effect_replace.rs index a301a5f7d65..32f32f1b216 100644 --- a/clippy_lints/src/methods/no_effect_replace.rs +++ b/clippy_lints/src/methods/no_effect_replace.rs @@ -1,6 +1,6 @@ +use clippy_utils::SpanlessEq; use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::is_type_lang_item; -use clippy_utils::SpanlessEq; use rustc_ast::LitKind; use rustc_hir::{ExprKind, LangItem}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/open_options.rs b/clippy_lints/src/methods/open_options.rs index f1a3c81cebb..da084871402 100644 --- a/clippy_lints/src/methods/open_options.rs +++ b/clippy_lints/src/methods/open_options.rs @@ -8,7 +8,7 @@ use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::Ty; use rustc_span::source_map::Spanned; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::{NONSENSICAL_OPEN_OPTIONS, SUSPICIOUS_OPEN_OPTIONS}; @@ -126,17 +126,13 @@ fn get_open_options( && let ExprKind::Path(path) = callee.kind && let Some(did) = cx.qpath_res(&path, callee.hir_id).opt_def_id() { - let std_file_options = [ - sym::file_options, - sym::open_options_new, - ]; + let std_file_options = [sym::file_options, sym::open_options_new]; - let tokio_file_options: &[&[&str]] = &[ - &paths::TOKIO_IO_OPEN_OPTIONS_NEW, - &paths::TOKIO_FILE_OPTIONS, - ]; + let tokio_file_options: &[&[&str]] = &[&paths::TOKIO_IO_OPEN_OPTIONS_NEW, &paths::TOKIO_FILE_OPTIONS]; - let is_std_options = std_file_options.into_iter().any(|sym| cx.tcx.is_diagnostic_item(sym, did)); + let is_std_options = std_file_options + .into_iter() + .any(|sym| cx.tcx.is_diagnostic_item(sym, did)); is_std_options || match_any_def_paths(cx, did, tokio_file_options).is_some() } else { false diff --git a/clippy_lints/src/methods/option_as_ref_cloned.rs b/clippy_lints/src/methods/option_as_ref_cloned.rs index ba167f9d9c2..9b22494888f 100644 --- a/clippy_lints/src/methods/option_as_ref_cloned.rs +++ b/clippy_lints/src/methods/option_as_ref_cloned.rs @@ -3,9 +3,9 @@ use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; -use super::{method_call, OPTION_AS_REF_CLONED}; +use super::{OPTION_AS_REF_CLONED, method_call}; pub(super) fn check(cx: &LateContext<'_>, cloned_recv: &Expr<'_>, cloned_ident_span: Span) { if let Some((method @ ("as_ref" | "as_mut"), as_ref_recv, [], as_ref_ident_span, _)) = method_call(cloned_recv) diff --git a/clippy_lints/src/methods/option_as_ref_deref.rs b/clippy_lints/src/methods/option_as_ref_deref.rs index 9a18d8a1421..389e02056b2 100644 --- a/clippy_lints/src/methods/option_as_ref_deref.rs +++ b/clippy_lints/src/methods/option_as_ref_deref.rs @@ -7,7 +7,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; use super::OPTION_AS_REF_DEREF; @@ -48,7 +48,9 @@ pub(super) fn check( .map_or(false, |fun_def_id| { cx.tcx.is_diagnostic_item(sym::deref_method, fun_def_id) || cx.tcx.is_diagnostic_item(sym::deref_mut_method, fun_def_id) - || deref_aliases.iter().any(|&sym| cx.tcx.is_diagnostic_item(sym, fun_def_id)) + || deref_aliases + .iter() + .any(|&sym| cx.tcx.is_diagnostic_item(sym, fun_def_id)) }) }, hir::ExprKind::Closure(&hir::Closure { body, .. }) => { @@ -69,7 +71,9 @@ pub(super) fn check( let method_did = cx.typeck_results().type_dependent_def_id(closure_expr.hir_id).unwrap(); cx.tcx.is_diagnostic_item(sym::deref_method, method_did) || cx.tcx.is_diagnostic_item(sym::deref_mut_method, method_did) - || deref_aliases.iter().any(|&sym| cx.tcx.is_diagnostic_item(sym, method_did)) + || deref_aliases + .iter() + .any(|&sym| cx.tcx.is_diagnostic_item(sym, method_did)) } else { false } diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs index ed3bed42eb3..b160ab6de8e 100644 --- a/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -5,11 +5,11 @@ use clippy_utils::ty::{is_copy, is_type_diagnostic_item}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir::def::Res; -use rustc_hir::intravisit::{walk_path, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_path}; use rustc_hir::{ExprKind, HirId, Node, PatKind, Path, QPath}; use rustc_lint::LateContext; use rustc_middle::hir::nested_filter; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use std::ops::ControlFlow; use super::MAP_UNWRAP_OR; diff --git a/clippy_lints/src/methods/or_fun_call.rs b/clippy_lints/src/methods/or_fun_call.rs index e4326cb958e..8a7e72b63bb 100644 --- a/clippy_lints/src/methods/or_fun_call.rs +++ b/clippy_lints/src/methods/or_fun_call.rs @@ -11,8 +11,8 @@ use clippy_utils::{ use rustc_errors::Applicability; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::symbol::{self, sym, Symbol}; use rustc_span::Span; +use rustc_span::symbol::{self, Symbol, sym}; use {rustc_ast as ast, rustc_hir as hir}; use super::{OR_FUN_CALL, UNWRAP_OR_DEFAULT}; diff --git a/clippy_lints/src/methods/or_then_unwrap.rs b/clippy_lints/src/methods/or_then_unwrap.rs index 7b0bdcf99e7..3e64e15dc86 100644 --- a/clippy_lints/src/methods/or_then_unwrap.rs +++ b/clippy_lints/src/methods/or_then_unwrap.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::lang_items::LangItem; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::OR_THEN_UNWRAP; diff --git a/clippy_lints/src/methods/range_zip_with_len.rs b/clippy_lints/src/methods/range_zip_with_len.rs index 28ca76832eb..f4d206c5307 100644 --- a/clippy_lints/src/methods/range_zip_with_len.rs +++ b/clippy_lints/src/methods/range_zip_with_len.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::source::snippet; -use clippy_utils::{higher, is_integer_const, is_trait_method, SpanlessEq}; +use clippy_utils::{SpanlessEq, higher, is_integer_const, is_trait_method}; use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::LateContext; use rustc_span::sym; diff --git a/clippy_lints/src/methods/search_is_some.rs b/clippy_lints/src/methods/search_is_some.rs index 3b2dd285b8c..4ab165a5528 100644 --- a/clippy_lints/src/methods/search_is_some.rs +++ b/clippy_lints/src/methods/search_is_some.rs @@ -8,8 +8,8 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::PatKind; use rustc_lint::LateContext; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; use super::SEARCH_IS_SOME; diff --git a/clippy_lints/src/methods/seek_from_current.rs b/clippy_lints/src/methods/seek_from_current.rs index 8bc535ac47a..7ef07fe899c 100644 --- a/clippy_lints/src/methods/seek_from_current.rs +++ b/clippy_lints/src/methods/seek_from_current.rs @@ -6,9 +6,9 @@ use rustc_lint::LateContext; use rustc_span::sym; use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_enum_variant_ctor; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::implements_trait; -use clippy_utils::is_enum_variant_ctor; use super::SEEK_FROM_CURRENT; diff --git a/clippy_lints/src/methods/seek_to_start_instead_of_rewind.rs b/clippy_lints/src/methods/seek_to_start_instead_of_rewind.rs index 7c09cc252e1..9c966f010f1 100644 --- a/clippy_lints/src/methods/seek_to_start_instead_of_rewind.rs +++ b/clippy_lints/src/methods/seek_to_start_instead_of_rewind.rs @@ -1,12 +1,12 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::implements_trait; -use clippy_utils::{is_expr_used_or_unified, is_enum_variant_ctor}; +use clippy_utils::{is_enum_variant_ctor, is_expr_used_or_unified}; use rustc_ast::ast::{LitIntType, LitKind}; use rustc_data_structures::packed::Pu128; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::SEEK_TO_START_INSTEAD_OF_REWIND; diff --git a/clippy_lints/src/methods/str_splitn.rs b/clippy_lints/src/methods/str_splitn.rs index 12cabd43cb1..69032776b2b 100644 --- a/clippy_lints/src/methods/str_splitn.rs +++ b/clippy_lints/src/methods/str_splitn.rs @@ -3,7 +3,7 @@ use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet_with_context; use clippy_utils::usage::local_used_after_expr; -use clippy_utils::visitors::{for_each_expr, Descend}; +use clippy_utils::visitors::{Descend, for_each_expr}; use clippy_utils::{is_diag_item_method, match_def_path, path_to_local_id, paths}; use core::ops::ControlFlow; use rustc_errors::Applicability; @@ -12,7 +12,7 @@ use rustc_hir::{ }; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::{sym, Span, Symbol, SyntaxContext}; +use rustc_span::{Span, Symbol, SyntaxContext, sym}; use super::{MANUAL_SPLIT_ONCE, NEEDLESS_SPLITN}; diff --git a/clippy_lints/src/methods/suspicious_command_arg_space.rs b/clippy_lints/src/methods/suspicious_command_arg_space.rs index 38f2c916912..c60a49067ec 100644 --- a/clippy_lints/src/methods/suspicious_command_arg_space.rs +++ b/clippy_lints/src/methods/suspicious_command_arg_space.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use rustc_errors::{Applicability, Diag}; use rustc_lint::LateContext; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use {rustc_ast as ast, rustc_hir as hir}; use super::SUSPICIOUS_COMMAND_ARG_SPACE; diff --git a/clippy_lints/src/methods/type_id_on_box.rs b/clippy_lints/src/methods/type_id_on_box.rs index db8cc4595d4..e67ba5c4d31 100644 --- a/clippy_lints/src/methods/type_id_on_box.rs +++ b/clippy_lints/src/methods/type_id_on_box.rs @@ -7,7 +7,7 @@ use rustc_lint::LateContext; use rustc_middle::ty::adjustment::{Adjust, Adjustment}; use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::{self, ExistentialPredicate, Ty}; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; /// Checks if the given type is `dyn Any`, or a trait object that has `Any` as a supertrait. /// Only in those cases will its vtable have a `type_id` method that returns the implementor's diff --git a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs index d46b584f8f4..ce81282ddfe 100644 --- a/clippy_lints/src/methods/unnecessary_fallible_conversions.rs +++ b/clippy_lints/src/methods/unnecessary_fallible_conversions.rs @@ -6,7 +6,7 @@ use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_middle::ty::print::with_forced_trimmed_paths; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::UNNECESSARY_FALLIBLE_CONVERSIONS; diff --git a/clippy_lints/src/methods/unnecessary_filter_map.rs b/clippy_lints/src/methods/unnecessary_filter_map.rs index c9b9d98dbe6..ca46da81fa0 100644 --- a/clippy_lints/src/methods/unnecessary_filter_map.rs +++ b/clippy_lints/src/methods/unnecessary_filter_map.rs @@ -2,7 +2,7 @@ use super::utils::clone_or_copy_needed; use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::is_copy; use clippy_utils::usage::mutated_variables; -use clippy_utils::visitors::{for_each_expr_without_closures, Descend}; +use clippy_utils::visitors::{Descend, for_each_expr_without_closures}; use clippy_utils::{is_res_lang_ctor, is_trait_method, path_res, path_to_local_id}; use core::ops::ControlFlow; use rustc_hir as hir; diff --git a/clippy_lints/src/methods/unnecessary_fold.rs b/clippy_lints/src/methods/unnecessary_fold.rs index 380ea317b94..b5d8972d7aa 100644 --- a/clippy_lints/src/methods/unnecessary_fold.rs +++ b/clippy_lints/src/methods/unnecessary_fold.rs @@ -8,7 +8,7 @@ use rustc_hir as hir; use rustc_hir::PatKind; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::UNNECESSARY_FOLD; @@ -123,60 +123,32 @@ pub(super) fn check( if let hir::ExprKind::Lit(lit) = init.kind { match lit.node { ast::LitKind::Bool(false) => { - check_fold_with_op( - cx, - expr, - acc, - fold_span, - hir::BinOpKind::Or, - Replacement { - has_args: true, - has_generic_return: false, - method_name: "any", - }, - ); + check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Or, Replacement { + has_args: true, + has_generic_return: false, + method_name: "any", + }); }, ast::LitKind::Bool(true) => { - check_fold_with_op( - cx, - expr, - acc, - fold_span, - hir::BinOpKind::And, - Replacement { - has_args: true, - has_generic_return: false, - method_name: "all", - }, - ); + check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::And, Replacement { + has_args: true, + has_generic_return: false, + method_name: "all", + }); }, ast::LitKind::Int(Pu128(0), _) => { - check_fold_with_op( - cx, - expr, - acc, - fold_span, - hir::BinOpKind::Add, - Replacement { - has_args: false, - has_generic_return: needs_turbofish(cx, expr), - method_name: "sum", - }, - ); + check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Add, Replacement { + has_args: false, + has_generic_return: needs_turbofish(cx, expr), + method_name: "sum", + }); }, ast::LitKind::Int(Pu128(1), _) => { - check_fold_with_op( - cx, - expr, - acc, - fold_span, - hir::BinOpKind::Mul, - Replacement { - has_args: false, - has_generic_return: needs_turbofish(cx, expr), - method_name: "product", - }, - ); + check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Mul, Replacement { + has_args: false, + has_generic_return: needs_turbofish(cx, expr), + method_name: "product", + }); }, _ => (), } diff --git a/clippy_lints/src/methods/unnecessary_get_then_check.rs b/clippy_lints/src/methods/unnecessary_get_then_check.rs index 64eb8411795..39fce2c40c9 100644 --- a/clippy_lints/src/methods/unnecessary_get_then_check.rs +++ b/clippy_lints/src/methods/unnecessary_get_then_check.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::Ty; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::UNNECESSARY_GET_THEN_CHECK; diff --git a/clippy_lints/src/methods/unnecessary_iter_cloned.rs b/clippy_lints/src/methods/unnecessary_iter_cloned.rs index 4d18bc7ac77..029704882dd 100644 --- a/clippy_lints/src/methods/unnecessary_iter_cloned.rs +++ b/clippy_lints/src/methods/unnecessary_iter_cloned.rs @@ -10,7 +10,7 @@ use rustc_errors::Applicability; use rustc_hir::def_id::DefId; use rustc_hir::{BindingMode, Expr, ExprKind, Node, PatKind}; use rustc_lint::LateContext; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; use super::UNNECESSARY_TO_OWNED; diff --git a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs index 494d71fc053..6dc8adb42df 100644 --- a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs +++ b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::{is_res_lang_ctor, last_path_segment, path_res, MaybePath}; +use clippy_utils::{MaybePath, is_res_lang_ctor, last_path_segment, path_res}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/clippy_lints/src/methods/unnecessary_min_or_max.rs b/clippy_lints/src/methods/unnecessary_min_or_max.rs index ff5fa7d33e3..062d1348555 100644 --- a/clippy_lints/src/methods/unnecessary_min_or_max.rs +++ b/clippy_lints/src/methods/unnecessary_min_or_max.rs @@ -9,7 +9,7 @@ use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; pub(super) fn check<'tcx>( cx: &LateContext<'tcx>, diff --git a/clippy_lints/src/methods/unnecessary_result_map_or_else.rs b/clippy_lints/src/methods/unnecessary_result_map_or_else.rs index c14a87c1534..dc50717112d 100644 --- a/clippy_lints/src/methods/unnecessary_result_map_or_else.rs +++ b/clippy_lints/src/methods/unnecessary_result_map_or_else.rs @@ -8,8 +8,8 @@ use rustc_hir::{Closure, Expr, ExprKind, HirId, QPath}; use rustc_lint::LateContext; use rustc_span::symbol::sym; -use super::utils::get_last_chain_binding_hir_id; use super::UNNECESSARY_RESULT_MAP_OR_ELSE; +use super::utils::get_last_chain_binding_hir_id; fn emit_lint(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, def_arg: &Expr<'_>) { let msg = "unused \"map closure\" when calling `Result::map_or_else` value"; diff --git a/clippy_lints/src/methods/unnecessary_to_owned.rs b/clippy_lints/src/methods/unnecessary_to_owned.rs index f62cf55e72a..cfa1fdb8137 100644 --- a/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -2,12 +2,11 @@ use super::implicit_clone::is_clone_like; use super::unnecessary_iter_cloned::{self, is_into_iter}; use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; -use clippy_utils::source::{snippet, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, snippet}; use clippy_utils::ty::{get_iterator_item_ty, implements_trait, is_copy, is_type_diagnostic_item, is_type_lang_item}; use clippy_utils::visitors::find_all_ret_expressions; use clippy_utils::{ - fn_def_id, get_parent_expr, is_diag_item_method, is_diag_trait_item, peel_middle_ty_refs, - return_ty, + fn_def_id, get_parent_expr, is_diag_item_method, is_diag_trait_item, peel_middle_ty_refs, return_ty, }; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; @@ -20,7 +19,7 @@ use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref}; use rustc_middle::ty::{ self, ClauseKind, GenericArg, GenericArgKind, GenericArgsRef, ParamTy, ProjectionPredicate, TraitPredicate, Ty, }; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; use rustc_trait_selection::traits::{Obligation, ObligationCause}; diff --git a/clippy_lints/src/methods/unused_enumerate_index.rs b/clippy_lints/src/methods/unused_enumerate_index.rs index ee5177d1ffa..6c2ae9cc6bf 100644 --- a/clippy_lints/src/methods/unused_enumerate_index.rs +++ b/clippy_lints/src/methods/unused_enumerate_index.rs @@ -1,11 +1,11 @@ use clippy_utils::diagnostics::span_lint_hir_and_then; -use clippy_utils::source::{snippet, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, snippet}; use clippy_utils::{expr_or_init, is_trait_method, pat_is_wild}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, FnDecl, PatKind, TyKind}; use rustc_lint::LateContext; use rustc_middle::ty::AdtDef; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use crate::loops::UNUSED_ENUMERATE_INDEX; diff --git a/clippy_lints/src/methods/useless_asref.rs b/clippy_lints/src/methods/useless_asref.rs index ebad4ae6ee9..eafe7486bb0 100644 --- a/clippy_lints/src/methods/useless_asref.rs +++ b/clippy_lints/src/methods/useless_asref.rs @@ -9,7 +9,7 @@ use rustc_hir::{self as hir, LangItem}; use rustc_lint::LateContext; use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::{Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor}; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use core::ops::ControlFlow; diff --git a/clippy_lints/src/methods/utils.rs b/clippy_lints/src/methods/utils.rs index fe860e5ae26..4e33dc1df54 100644 --- a/clippy_lints/src/methods/utils.rs +++ b/clippy_lints/src/methods/utils.rs @@ -1,12 +1,12 @@ use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{get_parent_expr, path_to_local_id, usage}; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{BorrowKind, Expr, ExprKind, HirId, Mutability, Pat, QPath, Stmt, StmtKind}; use rustc_lint::LateContext; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, Ty}; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; pub(super) fn derefs_to_slice<'tcx>( cx: &LateContext<'tcx>, diff --git a/clippy_lints/src/methods/vec_resize_to_zero.rs b/clippy_lints/src/methods/vec_resize_to_zero.rs index 3e271a60611..5ea4ada128a 100644 --- a/clippy_lints/src/methods/vec_resize_to_zero.rs +++ b/clippy_lints/src/methods/vec_resize_to_zero.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_span::source_map::Spanned; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use super::VEC_RESIZE_TO_ZERO; diff --git a/clippy_lints/src/methods/waker_clone_wake.rs b/clippy_lints/src/methods/waker_clone_wake.rs index 9b64cc7589c..b5f34a9be2e 100644 --- a/clippy_lints/src/methods/waker_clone_wake.rs +++ b/clippy_lints/src/methods/waker_clone_wake.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::source::snippet_with_applicability; use clippy_utils::is_trait_method; +use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; diff --git a/clippy_lints/src/min_ident_chars.rs b/clippy_lints/src/min_ident_chars.rs index c83e5198c27..a99e21d938c 100644 --- a/clippy_lints/src/min_ident_chars.rs +++ b/clippy_lints/src/min_ident_chars.rs @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::is_from_proc_macro; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::intravisit::{walk_item, walk_trait_item, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_item, walk_trait_item}; use rustc_hir::{GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind, TraitItem, UsePath}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 3e80e48a948..408dbef9cb1 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -2,8 +2,8 @@ use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir, span_lint_hir use clippy_utils::source::{snippet, snippet_with_context}; use clippy_utils::sugg::Sugg; use clippy_utils::{ - fulfill_or_allowed, get_parent_expr, in_automatically_derived, is_lint_allowed, iter_input_pats, last_path_segment, - SpanlessEq, + SpanlessEq, fulfill_or_allowed, get_parent_expr, in_automatically_derived, is_lint_allowed, iter_input_pats, + last_path_segment, }; use rustc_errors::Applicability; use rustc_hir::def::Res; @@ -15,8 +15,8 @@ use rustc_hir::{ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::declare_lint_pass; -use rustc_span::def_id::LocalDefId; use rustc_span::Span; +use rustc_span::def_id::LocalDefId; use crate::ref_patterns::REF_PATTERNS; diff --git a/clippy_lints/src/missing_assert_message.rs b/clippy_lints/src/missing_assert_message.rs index a9ea11f4c2b..86348f04600 100644 --- a/clippy_lints/src/missing_assert_message.rs +++ b/clippy_lints/src/missing_assert_message.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_in_test; -use clippy_utils::macros::{find_assert_args, find_assert_eq_args, root_macro_call_first_node, PanicExpn}; +use clippy_utils::macros::{PanicExpn, find_assert_args, find_assert_eq_args, root_macro_call_first_node}; use rustc_hir::Expr; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; diff --git a/clippy_lints/src/missing_asserts_for_indexing.rs b/clippy_lints/src/missing_asserts_for_indexing.rs index 94c91b09517..b40d7eba15e 100644 --- a/clippy_lints/src/missing_asserts_for_indexing.rs +++ b/clippy_lints/src/missing_asserts_for_indexing.rs @@ -1,7 +1,7 @@ use std::mem; use std::ops::ControlFlow; -use clippy_utils::comparisons::{normalize_comparison, Rel}; +use clippy_utils::comparisons::{Rel, normalize_comparison}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use clippy_utils::visitors::for_each_expr_without_closures; @@ -14,7 +14,7 @@ use rustc_hir::{BinOp, Block, Body, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::source_map::Spanned; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/missing_const_for_fn.rs b/clippy_lints/src/missing_const_for_fn.rs index 859afe1b963..eea0459e026 100644 --- a/clippy_lints/src/missing_const_for_fn.rs +++ b/clippy_lints/src/missing_const_for_fn.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::qualify_min_const_fn::is_min_const_fn; use clippy_utils::{fn_has_unsatisfiable_preds, is_entrypoint_fn, is_from_proc_macro, trait_ref_of_method}; @@ -11,8 +11,8 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_session::impl_lint_pass; -use rustc_span::def_id::LocalDefId; use rustc_span::Span; +use rustc_span::def_id::LocalDefId; use rustc_target::spec::abi::Abi; declare_clippy_lint! { diff --git a/clippy_lints/src/missing_const_for_thread_local.rs b/clippy_lints/src/missing_const_for_thread_local.rs index 954216038fb..c2f524a6353 100644 --- a/clippy_lints/src/missing_const_for_thread_local.rs +++ b/clippy_lints/src/missing_const_for_thread_local.rs @@ -1,12 +1,12 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::macros::macro_backtrace; use clippy_utils::qualify_min_const_fn::is_min_const_fn; use clippy_utils::source::snippet; use clippy_utils::{fn_has_unsatisfiable_preds, peel_blocks}; use rustc_errors::Applicability; -use rustc_hir::{intravisit, Expr, ExprKind}; +use rustc_hir::{Expr, ExprKind, intravisit}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; use rustc_span::sym::{self, thread_local_macro}; diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 2166b0fe5a0..64fc1a8a1a5 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -17,7 +17,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::Visibility; use rustc_session::impl_lint_pass; use rustc_span::def_id::CRATE_DEF_ID; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/missing_fields_in_debug.rs b/clippy_lints/src/missing_fields_in_debug.rs index 77595b121aa..fc01b6753f1 100644 --- a/clippy_lints/src/missing_fields_in_debug.rs +++ b/clippy_lints/src/missing_fields_in_debug.rs @@ -3,7 +3,7 @@ use std::ops::ControlFlow; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_path_lang_item; use clippy_utils::ty::is_type_diagnostic_item; -use clippy_utils::visitors::{for_each_expr, Visitable}; +use clippy_utils::visitors::{Visitable, for_each_expr}; use rustc_ast::LitKind; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def::{DefKind, Res}; @@ -13,7 +13,7 @@ use rustc_hir::{ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{Ty, TypeckResults}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span, Symbol}; +use rustc_span::{Span, Symbol, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 33a14d8b7fe..d342be4545c 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -3,7 +3,7 @@ use rustc_ast::ast; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/mixed_read_write_in_expression.rs b/clippy_lints/src/mixed_read_write_in_expression.rs index 0b7d97c32c5..d333b71edb1 100644 --- a/clippy_lints/src/mixed_read_write_in_expression.rs +++ b/clippy_lints/src/mixed_read_write_in_expression.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; use clippy_utils::macros::root_macro_call_first_node; use clippy_utils::{get_parent_expr, path_to_local, path_to_local_id}; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{BinOpKind, Block, Expr, ExprKind, HirId, LetStmt, Node, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; diff --git a/clippy_lints/src/multiple_unsafe_ops_per_block.rs b/clippy_lints/src/multiple_unsafe_ops_per_block.rs index 0bde0da3cd8..12bcc608174 100644 --- a/clippy_lints/src/multiple_unsafe_ops_per_block.rs +++ b/clippy_lints/src/multiple_unsafe_ops_per_block.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::visitors::{for_each_expr, Descend, Visitable}; +use clippy_utils::visitors::{Descend, Visitable, for_each_expr}; use core::ops::ControlFlow::Continue; use hir::def::{DefKind, Res}; use hir::{BlockCheckMode, ExprKind, QPath, Safety, UnOp}; @@ -153,19 +153,16 @@ fn collect_unsafe_exprs<'tcx>( ExprKind::AssignOp(_, lhs, rhs) | ExprKind::Assign(lhs, rhs, _) => { if matches!( lhs.kind, - ExprKind::Path(QPath::Resolved( - _, - hir::Path { - res: Res::Def( - DefKind::Static { - mutability: Mutability::Mut, - .. - }, - _ - ), - .. - } - )) + ExprKind::Path(QPath::Resolved(_, hir::Path { + res: Res::Def( + DefKind::Static { + mutability: Mutability::Mut, + .. + }, + _ + ), + .. + })) ) { unsafe_ops.push(("modification of a mutable static occurs here", expr.span)); collect_unsafe_exprs(cx, rhs, unsafe_ops); diff --git a/clippy_lints/src/mut_key.rs b/clippy_lints/src/mut_key.rs index f52b3a6a5a1..8118c14bd4a 100644 --- a/clippy_lints/src/mut_key.rs +++ b/clippy_lints/src/mut_key.rs @@ -6,9 +6,9 @@ use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::impl_lint_pass; +use rustc_span::Span; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::sym; -use rustc_span::Span; use std::iter; declare_clippy_lint! { diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 563ce2d82ea..6ab811b4f2f 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::macros::{find_assert_eq_args, root_macro_call_first_node}; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{BorrowKind, Expr, ExprKind, MatchSource, Mutability}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; diff --git a/clippy_lints/src/needless_arbitrary_self_type.rs b/clippy_lints/src/needless_arbitrary_self_type.rs index 60c44382059..3c47d0edfdc 100644 --- a/clippy_lints/src/needless_arbitrary_self_type.rs +++ b/clippy_lints/src/needless_arbitrary_self_type.rs @@ -3,8 +3,8 @@ use rustc_ast::ast::{BindingMode, ByRef, Lifetime, Mutability, Param, PatKind, P use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::symbol::kw; use rustc_span::Span; +use rustc_span::symbol::kw; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index df155a7a412..2eacd6875d6 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -2,16 +2,16 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet_with_applicability; use clippy_utils::sugg::Sugg; use clippy_utils::{ - get_parent_expr, higher, is_block_like, is_else_clause, is_expn_of, is_parent_stmt, is_receiver_of_method_call, - peel_blocks, peel_blocks_with_stmt, span_extract_comment, SpanlessEq, + SpanlessEq, get_parent_expr, higher, is_block_like, is_else_clause, is_expn_of, is_parent_stmt, + is_receiver_of_method_call, peel_blocks, peel_blocks_with_stmt, span_extract_comment, }; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::source_map::Spanned; use rustc_span::Span; +use rustc_span::source_map::Spanned; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/needless_borrows_for_generic_args.rs b/clippy_lints/src/needless_borrows_for_generic_args.rs index 32e7fde03b2..f6db12ed84e 100644 --- a/clippy_lints/src/needless_borrows_for_generic_args.rs +++ b/clippy_lints/src/needless_borrows_for_generic_args.rs @@ -1,10 +1,10 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::mir::{enclosing_mir, expr_local, local_assignments, used_exactly_once, PossibleBorrowerMap}; +use clippy_utils::mir::{PossibleBorrowerMap, enclosing_mir, expr_local, local_assignments, used_exactly_once}; use clippy_utils::source::snippet_with_context; use clippy_utils::ty::{implements_trait, is_copy}; -use clippy_utils::{expr_use_ctxt, peel_n_hir_expr_refs, DefinedTy, ExprUseNode}; +use clippy_utils::{DefinedTy, ExprUseNode, expr_use_ctxt, peel_n_hir_expr_refs}; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId}; diff --git a/clippy_lints/src/needless_for_each.rs b/clippy_lints/src/needless_for_each.rs index 6390e51f916..b54eb164e81 100644 --- a/clippy_lints/src/needless_for_each.rs +++ b/clippy_lints/src/needless_for_each.rs @@ -1,9 +1,9 @@ use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{Block, BlockCheckMode, Closure, Expr, ExprKind, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_trait_method; diff --git a/clippy_lints/src/needless_pass_by_ref_mut.rs b/clippy_lints/src/needless_pass_by_ref_mut.rs index d543fd467ab..19cbf595908 100644 --- a/clippy_lints/src/needless_pass_by_ref_mut.rs +++ b/clippy_lints/src/needless_pass_by_ref_mut.rs @@ -17,9 +17,9 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::{self, Ty, TyCtxt, UpvarId, UpvarPath}; use rustc_session::impl_lint_pass; +use rustc_span::Span; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::kw; -use rustc_span::Span; use rustc_target::spec::abi::Abi; declare_clippy_lint! { diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 887070bcf9a..0775d7abdbb 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_self; use clippy_utils::ptr::get_spans; -use clippy_utils::source::{snippet, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, snippet}; use clippy_utils::ty::{ implements_trait, implements_trait_with_env_from_iter, is_copy, is_type_diagnostic_item, is_type_lang_item, }; @@ -19,7 +19,7 @@ use rustc_middle::ty::{self, Ty, TypeVisitableExt}; use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::kw; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use rustc_target::spec::abi::Abi; use rustc_trait_selection::traits; use rustc_trait_selection::traits::misc::type_allowed_to_implement_copy; @@ -182,14 +182,9 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { && !is_copy(cx, ty) && ty.is_sized(cx.tcx, cx.param_env) && !allowed_traits.iter().any(|&t| { - implements_trait_with_env_from_iter( - cx.tcx, - cx.param_env, - ty, - t, - None, - [Option::>::None], - ) + implements_trait_with_env_from_iter(cx.tcx, cx.param_env, ty, t, None, [Option::< + ty::GenericArg<'tcx>, + >::None]) }) && !implements_borrow_trait && !all_borrowable_trait diff --git a/clippy_lints/src/no_effect.rs b/clippy_lints/src/no_effect.rs index b181791699a..392cfcb813e 100644 --- a/clippy_lints/src/no_effect.rs +++ b/clippy_lints/src/no_effect.rs @@ -7,8 +7,8 @@ use clippy_utils::{ use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{ - is_range_literal, BinOpKind, BlockCheckMode, Expr, ExprKind, HirId, HirIdMap, ItemKind, LocalSource, Node, PatKind, - Stmt, StmtKind, UnsafeSource, + BinOpKind, BlockCheckMode, Expr, ExprKind, HirId, HirIdMap, ItemKind, LocalSource, Node, PatKind, Stmt, StmtKind, + UnsafeSource, is_range_literal, }; use rustc_infer::infer::TyCtxtInferExt as _; use rustc_lint::{LateContext, LateLintPass, LintContext}; diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 25f547f1a43..5e20b406426 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -4,7 +4,7 @@ use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_in_const_context; use clippy_utils::macros::macro_backtrace; -use clippy_utils::ty::{implements_trait, InteriorMut}; +use clippy_utils::ty::{InteriorMut, implements_trait}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{ @@ -15,7 +15,7 @@ use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult, GlobalId}; use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span, DUMMY_SP}; +use rustc_span::{DUMMY_SP, Span, sym}; use rustc_target::abi::VariantIdx; // FIXME: this is a correctness problem but there's no suitable diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 832518d2d35..d85032e9eee 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -3,12 +3,12 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; use rustc_ast::ast::{ self, Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Item, ItemKind, Local, Pat, PatKind, }; -use rustc_ast::visit::{walk_block, walk_expr, walk_pat, Visitor}; +use rustc_ast::visit::{Visitor, walk_block, walk_expr, walk_pat}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; use rustc_span::symbol::{Ident, Symbol}; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use std::cmp::Ordering; declare_clippy_lint! { diff --git a/clippy_lints/src/non_octal_unix_permissions.rs b/clippy_lints/src/non_octal_unix_permissions.rs index cfc15d92715..3f156aa5510 100644 --- a/clippy_lints/src/non_octal_unix_permissions.rs +++ b/clippy_lints/src/non_octal_unix_permissions.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::source::{snippet_with_applicability, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, snippet_with_applicability}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/nonstandard_macro_braces.rs b/clippy_lints/src/nonstandard_macro_braces.rs index 51ba29d7389..a13391a5945 100644 --- a/clippy_lints/src/nonstandard_macro_braces.rs +++ b/clippy_lints/src/nonstandard_macro_braces.rs @@ -1,5 +1,5 @@ -use clippy_config::types::MacroMatcher; use clippy_config::Conf; +use clippy_config::types::MacroMatcher; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{SourceText, SpanRangeExt}; use rustc_ast::ast; @@ -8,8 +8,8 @@ use rustc_errors::Applicability; use rustc_hir::def_id::DefId; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::Span; +use rustc_span::hygiene::{ExpnKind, MacroKind}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/only_used_in_recursion.rs b/clippy_lints/src/only_used_in_recursion.rs index aadd729f32a..372128ac16f 100644 --- a/clippy_lints/src/only_used_in_recursion.rs +++ b/clippy_lints/src/only_used_in_recursion.rs @@ -9,8 +9,8 @@ use rustc_hir::{Body, Expr, ExprKind, HirId, ImplItem, ImplItemKind, Node, PatKi use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, ConstKind, EarlyBinder, GenericArgKind, GenericArgsRef}; use rustc_session::impl_lint_pass; -use rustc_span::symbol::{kw, Ident}; use rustc_span::Span; +use rustc_span::symbol::{Ident, kw}; use std::iter; declare_clippy_lint! { diff --git a/clippy_lints/src/operators/absurd_extreme_comparisons.rs b/clippy_lints/src/operators/absurd_extreme_comparisons.rs index a0de5ea711c..dbc9948eeed 100644 --- a/clippy_lints/src/operators/absurd_extreme_comparisons.rs +++ b/clippy_lints/src/operators/absurd_extreme_comparisons.rs @@ -2,7 +2,7 @@ use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty; -use clippy_utils::comparisons::{normalize_comparison, Rel}; +use clippy_utils::comparisons::{Rel, normalize_comparison}; use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet; diff --git a/clippy_lints/src/operators/const_comparisons.rs b/clippy_lints/src/operators/const_comparisons.rs index c1317524396..5d94cfab3b0 100644 --- a/clippy_lints/src/operators/const_comparisons.rs +++ b/clippy_lints/src/operators/const_comparisons.rs @@ -7,12 +7,12 @@ use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::layout::HasTyCtxt; use rustc_middle::ty::{Ty, TypeckResults}; -use rustc_span::source_map::Spanned; use rustc_span::Span; +use rustc_span::source_map::Spanned; +use clippy_utils::SpanlessEq; use clippy_utils::diagnostics::span_lint_and_note; use clippy_utils::source::snippet; -use clippy_utils::SpanlessEq; use super::{IMPOSSIBLE_COMPARISONS, REDUNDANT_COMPARISONS}; diff --git a/clippy_lints/src/operators/float_equality_without_abs.rs b/clippy_lints/src/operators/float_equality_without_abs.rs index be97ad389bf..34f7dbea84e 100644 --- a/clippy_lints/src/operators/float_equality_without_abs.rs +++ b/clippy_lints/src/operators/float_equality_without_abs.rs @@ -6,7 +6,8 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty; -use rustc_span::{sym, source_map::Spanned}; +use rustc_span::source_map::Spanned; +use rustc_span::sym; use super::FLOAT_EQUALITY_WITHOUT_ABS; diff --git a/clippy_lints/src/option_if_let_else.rs b/clippy_lints/src/option_if_let_else.rs index ae02d22512e..6d9e75f51d6 100644 --- a/clippy_lints/src/option_if_let_else.rs +++ b/clippy_lints/src/option_if_let_else.rs @@ -1,12 +1,12 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::sugg::Sugg; use clippy_utils::{ - can_move_expr_to_closure, eager_or_lazy, higher, is_else_clause, is_in_const_context, is_res_lang_ctor, - peel_blocks, peel_hir_expr_while, CaptureKind, + CaptureKind, can_move_expr_to_closure, eager_or_lazy, higher, is_else_clause, is_in_const_context, + is_res_lang_ctor, peel_blocks, peel_hir_expr_while, }; use rustc_errors::Applicability; -use rustc_hir::def::Res; use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk}; +use rustc_hir::def::Res; use rustc_hir::{Arm, BindingMode, Expr, ExprKind, MatchSource, Mutability, Pat, PatKind, Path, QPath, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; diff --git a/clippy_lints/src/panic_in_result_fn.rs b/clippy_lints/src/panic_in_result_fn.rs index fa15d5e4f9f..eebc62e2a5a 100644 --- a/clippy_lints/src/panic_in_result_fn.rs +++ b/clippy_lints/src/panic_in_result_fn.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::macros::root_macro_call_first_node; use clippy_utils::ty::is_type_diagnostic_item; -use clippy_utils::visitors::{for_each_expr, Descend}; +use clippy_utils::visitors::{Descend, for_each_expr}; use clippy_utils::{is_inside_always_const_context, return_ty}; use core::ops::ControlFlow; use rustc_hir as hir; @@ -9,7 +9,7 @@ use rustc_hir::intravisit::FnKind; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index 5ca244f0141..75d8c09f2b0 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -18,7 +18,7 @@ use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, RegionKind, TyCtxt}; use rustc_session::impl_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use rustc_target::spec::abi::Abi; declare_clippy_lint! { diff --git a/clippy_lints/src/pathbuf_init_then_push.rs b/clippy_lints/src/pathbuf_init_then_push.rs index d7fa48c1e38..1b9a5a44382 100644 --- a/clippy_lints/src/pathbuf_init_then_push.rs +++ b/clippy_lints/src/pathbuf_init_then_push.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::path_to_local_id; -use clippy_utils::source::{snippet, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, snippet}; use clippy_utils::ty::is_type_diagnostic_item; use rustc_ast::{LitKind, StrStyle}; use rustc_errors::Applicability; @@ -9,7 +9,7 @@ use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, LetStmt, PatKind, QPa use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span, Symbol}; +use rustc_span::{Span, Symbol, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/pattern_type_mismatch.rs b/clippy_lints/src/pattern_type_mismatch.rs index c1296b04387..42fbba8ef6d 100644 --- a/clippy_lints/src/pattern_type_mismatch.rs +++ b/clippy_lints/src/pattern_type_mismatch.rs @@ -1,13 +1,13 @@ use clippy_utils::diagnostics::span_lint_and_then; use rustc_hir::{ - intravisit, Body, Expr, ExprKind, FnDecl, LetExpr, LocalSource, Mutability, Pat, PatKind, Stmt, StmtKind, + Body, Expr, ExprKind, FnDecl, LetExpr, LocalSource, Mutability, Pat, PatKind, Stmt, StmtKind, intravisit, }; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_session::declare_lint_pass; -use rustc_span::def_id::LocalDefId; use rustc_span::Span; +use rustc_span::def_id::LocalDefId; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index cd8e921347c..807636bb642 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -5,7 +5,7 @@ use clippy_utils::{get_expr_use_or_unification_node, is_lint_allowed, path_def_i use hir::LifetimeName; use rustc_errors::{Applicability, MultiSpan}; use rustc_hir::hir_id::{HirId, HirIdMap}; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{ self as hir, AnonConst, BinOpKind, BindingMode, Body, Expr, ExprKind, FnRetTy, FnSig, GenericArg, ImplItemKind, ItemKind, Lifetime, Mutability, Node, Param, PatKind, QPath, Safety, TraitFn, TraitItem, TraitItemKind, TyKind, @@ -17,7 +17,7 @@ use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, Binder, ClauseKind, ExistentialPredicate, List, PredicateKind, Ty}; use rustc_session::declare_lint_pass; use rustc_span::symbol::Symbol; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use rustc_target::spec::abi::Abi; use rustc_trait_selection::infer::InferCtxtExt as _; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; diff --git a/clippy_lints/src/pub_underscore_fields.rs b/clippy_lints/src/pub_underscore_fields.rs index 77b707567e4..db03657c9af 100644 --- a/clippy_lints/src/pub_underscore_fields.rs +++ b/clippy_lints/src/pub_underscore_fields.rs @@ -1,5 +1,5 @@ -use clippy_config::types::PubUnderscoreFieldsBehaviour; use clippy_config::Conf; +use clippy_config::types::PubUnderscoreFieldsBehaviour; use clippy_utils::attrs::is_doc_hidden; use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::is_path_lang_item; diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index e1e3ded2c79..aa9a9001afb 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -1,8 +1,8 @@ use crate::manual_let_else::MANUAL_LET_ELSE; use crate::question_mark_used::QUESTION_MARK_USED; +use clippy_config::Conf; use clippy_config::msrvs::Msrv; use clippy_config::types::MatchLintBehaviour; -use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; @@ -12,8 +12,8 @@ use clippy_utils::{ span_contains_comment, }; use rustc_errors::Applicability; -use rustc_hir::def::Res; use rustc_hir::LangItem::{self, OptionNone, OptionSome, ResultErr, ResultOk}; +use rustc_hir::def::Res; use rustc_hir::{ BindingMode, Block, Body, ByRef, Expr, ExprKind, LetStmt, Mutability, Node, PatKind, PathSegment, QPath, Stmt, StmtKind, diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 81189fe517c..21cd3367262 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -1,8 +1,8 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then}; -use clippy_utils::source::{snippet, snippet_with_applicability, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, snippet, snippet_with_applicability}; use clippy_utils::sugg::Sugg; use clippy_utils::{get_parent_expr, higher, is_in_const_context, is_integer_const, path_to_local}; use rustc_ast::ast::RangeLimits; @@ -11,8 +11,8 @@ use rustc_hir::{BinOpKind, Expr, ExprKind, HirId}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::impl_lint_pass; -use rustc_span::source_map::Spanned; use rustc_span::Span; +use rustc_span::source_map::Spanned; use std::cmp::Ordering; declare_clippy_lint! { diff --git a/clippy_lints/src/rc_clone_in_vec_init.rs b/clippy_lints/src/rc_clone_in_vec_init.rs index d0b45b59526..e877f5d6ed4 100644 --- a/clippy_lints/src/rc_clone_in_vec_init.rs +++ b/clippy_lints/src/rc_clone_in_vec_init.rs @@ -8,7 +8,7 @@ use rustc_hir::{Expr, ExprKind, QPath, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span, Symbol}; +use rustc_span::{Span, Symbol, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/read_zero_byte_vec.rs b/clippy_lints/src/read_zero_byte_vec.rs index 7f4735c6a88..6bd68dd4109 100644 --- a/clippy_lints/src/read_zero_byte_vec.rs +++ b/clippy_lints/src/read_zero_byte_vec.rs @@ -1,13 +1,13 @@ use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then}; use clippy_utils::get_enclosing_block; -use clippy_utils::higher::{get_vec_init_kind, VecInitKind}; +use clippy_utils::higher::{VecInitKind, get_vec_init_kind}; use clippy_utils::source::snippet; use hir::{Expr, ExprKind, HirId, LetStmt, PatKind, PathSegment, QPath, StmtKind}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::def::Res; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 4e24ddad83a..b9e0106fc86 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -1,17 +1,17 @@ use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then}; -use clippy_utils::mir::{visit_local_usage, LocalUsage, PossibleBorrowerMap}; +use clippy_utils::fn_has_unsatisfiable_preds; +use clippy_utils::mir::{LocalUsage, PossibleBorrowerMap, visit_local_usage}; use clippy_utils::source::SpanRangeExt; use clippy_utils::ty::{has_drop, is_copy, is_type_diagnostic_item, is_type_lang_item, walk_ptrs_ty_depth}; -use clippy_utils::fn_has_unsatisfiable_preds; use rustc_errors::Applicability; use rustc_hir::intravisit::FnKind; -use rustc_hir::{def_id, Body, FnDecl, LangItem}; +use rustc_hir::{Body, FnDecl, LangItem, def_id}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir; use rustc_middle::ty::{self, Ty}; use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, BytePos, Span}; +use rustc_span::{BytePos, Span, sym}; macro_rules! unwrap_or_continue { ($x:expr) => { @@ -349,14 +349,10 @@ fn visit_clone_usage(cloned: mir::Local, clone: mir::Local, mir: &mir::Body<'_>, local_use_locs: _, local_consume_or_mutate_locs: clone_consume_or_mutate_locs, }, - )) = visit_local_usage( - &[cloned, clone], - mir, - mir::Location { - block: bb, - statement_index: mir.basic_blocks[bb].statements.len(), - }, - ) + )) = visit_local_usage(&[cloned, clone], mir, mir::Location { + block: bb, + statement_index: mir.basic_blocks[bb].statements.len(), + }) .map(|mut vec| (vec.remove(0), vec.remove(0))) { CloneUsage { diff --git a/clippy_lints/src/redundant_closure_call.rs b/clippy_lints/src/redundant_closure_call.rs index bad9b979203..6930a01d48b 100644 --- a/clippy_lints/src/redundant_closure_call.rs +++ b/clippy_lints/src/redundant_closure_call.rs @@ -6,7 +6,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::intravisit::{Visitor as HirVisitor, Visitor}; use rustc_hir::{ - intravisit as hir_visit, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, ExprKind, Node, + ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, ExprKind, Node, intravisit as hir_visit, }; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::hir::nested_filter; diff --git a/clippy_lints/src/redundant_else.rs b/clippy_lints/src/redundant_else.rs index 3bdf13dbbea..6a1d40334e7 100644 --- a/clippy_lints/src/redundant_else.rs +++ b/clippy_lints/src/redundant_else.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Block, Expr, ExprKind, Stmt, StmtKind}; -use rustc_ast::visit::{walk_expr, Visitor}; +use rustc_ast::visit::{Visitor, walk_expr}; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::declare_lint_pass; diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index 0e637538615..d0dbff081f9 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use rustc_ast::ast::{Expr, ExprKind}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/redundant_locals.rs b/clippy_lints/src/redundant_locals.rs index d94ca5bc7ec..4f46ca3c715 100644 --- a/clippy_lints/src/redundant_locals.rs +++ b/clippy_lints/src/redundant_locals.rs @@ -9,8 +9,8 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::UpvarCapture; use rustc_session::declare_lint_pass; -use rustc_span::symbol::Ident; use rustc_span::DesugaringKind; +use rustc_span::symbol::Ident; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index d6e741dd974..b27bb2e78af 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use rustc_ast::ast::{ConstItem, Item, ItemKind, StaticItem, Ty, TyKind}; diff --git a/clippy_lints/src/reference.rs b/clippy_lints/src/reference.rs index 2b4ef21fc48..4bff37216ed 100644 --- a/clippy_lints/src/reference.rs +++ b/clippy_lints/src/reference.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::source::{snippet_with_applicability, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, snippet_with_applicability}; use rustc_ast::ast::{Expr, ExprKind, Mutability, UnOp}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; diff --git a/clippy_lints/src/repeat_vec_with_capacity.rs b/clippy_lints/src/repeat_vec_with_capacity.rs index 08de10f69b0..f54cafffb83 100644 --- a/clippy_lints/src/repeat_vec_with_capacity.rs +++ b/clippy_lints/src/repeat_vec_with_capacity.rs @@ -8,7 +8,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/reserve_after_initialization.rs b/clippy_lints/src/reserve_after_initialization.rs index caf3fb8707d..6157adad059 100644 --- a/clippy_lints/src/reserve_after_initialization.rs +++ b/clippy_lints/src/reserve_after_initialization.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::higher::{get_vec_init_kind, VecInitKind}; +use clippy_utils::higher::{VecInitKind, get_vec_init_kind}; use clippy_utils::source::snippet; use clippy_utils::{is_from_proc_macro, path_to_local_id}; use rustc_errors::Applicability; diff --git a/clippy_lints/src/return_self_not_must_use.rs b/clippy_lints/src/return_self_not_must_use.rs index 5962e8be959..42d9cf2c88c 100644 --- a/clippy_lints/src/return_self_not_must_use.rs +++ b/clippy_lints/src/return_self_not_must_use.rs @@ -7,7 +7,7 @@ use rustc_hir::{Body, FnDecl, OwnerId, TraitItem, TraitItemKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 1e709649695..3754fdddedf 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then}; -use clippy_utils::source::{snippet_with_context, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, snippet_with_context}; use clippy_utils::sugg::has_enclosing_paren; -use clippy_utils::visitors::{for_each_expr, for_each_unconsumed_temporary, Descend}; +use clippy_utils::visitors::{Descend, for_each_expr, for_each_unconsumed_temporary}; use clippy_utils::{ binary_expr_needs_parentheses, fn_def_id, is_from_proc_macro, is_inside_let_else, is_res_lang_ctor, path_res, path_to_local_id, span_contains_cfg, span_find_starting_semi, @@ -9,8 +9,8 @@ use clippy_utils::{ use core::ops::ControlFlow; use rustc_ast::NestedMetaItem; use rustc_errors::Applicability; -use rustc_hir::intravisit::FnKind; use rustc_hir::LangItem::ResultErr; +use rustc_hir::intravisit::FnKind; use rustc_hir::{ Block, Body, Expr, ExprKind, FnDecl, HirId, ItemKind, LangItem, MatchSource, Node, OwnerNode, PatKind, QPath, Stmt, StmtKind, @@ -21,7 +21,7 @@ use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::{self, GenericArgKind, Ty}; use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, BytePos, Pos, Span}; +use rustc_span::{BytePos, Pos, Span, sym}; use std::borrow::Cow; use std::fmt::Display; diff --git a/clippy_lints/src/same_name_method.rs b/clippy_lints/src/same_name_method.rs index 508f3ae6def..8d31641d483 100644 --- a/clippy_lints/src/same_name_method.rs +++ b/clippy_lints/src/same_name_method.rs @@ -5,8 +5,8 @@ use rustc_hir::{HirId, Impl, ItemKind, Node, Path, QPath, TraitRef, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::AssocKind; use rustc_session::declare_lint_pass; -use rustc_span::symbol::Symbol; use rustc_span::Span; +use rustc_span::symbol::Symbol; use std::collections::{BTreeMap, BTreeSet}; declare_clippy_lint! { @@ -62,13 +62,10 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod { && let TyKind::Path(QPath::Resolved(_, Path { res, .. })) = self_ty.kind { if !map.contains_key(res) { - map.insert( - *res, - ExistingName { - impl_methods: BTreeMap::new(), - trait_methods: BTreeMap::new(), - }, - ); + map.insert(*res, ExistingName { + impl_methods: BTreeMap::new(), + trait_methods: BTreeMap::new(), + }); } let existing_name = map.get_mut(res).unwrap(); diff --git a/clippy_lints/src/set_contains_or_insert.rs b/clippy_lints/src/set_contains_or_insert.rs index bc2a71c42b9..1185d67b125 100644 --- a/clippy_lints/src/set_contains_or_insert.rs +++ b/clippy_lints/src/set_contains_or_insert.rs @@ -3,12 +3,12 @@ use std::ops::ControlFlow; use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::visitors::for_each_expr; -use clippy_utils::{higher, peel_hir_expr_while, SpanlessEq}; +use clippy_utils::{SpanlessEq, higher, peel_hir_expr_while}; use rustc_hir::{Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::symbol::Symbol; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/significant_drop_tightening.rs b/clippy_lints/src/significant_drop_tightening.rs index 979d6dc77ae..d1114cb29f7 100644 --- a/clippy_lints/src/significant_drop_tightening.rs +++ b/clippy_lints/src/significant_drop_tightening.rs @@ -4,13 +4,13 @@ use clippy_utils::{expr_or_init, get_attr, path_to_local, peel_hir_expr_unary}; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{self as hir, HirId}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::{GenericArgKind, Ty}; use rustc_session::impl_lint_pass; use rustc_span::symbol::Ident; -use rustc_span::{sym, Span, DUMMY_SP}; +use rustc_span::{DUMMY_SP, Span, sym}; use std::borrow::Cow; use std::collections::hash_map::Entry; diff --git a/clippy_lints/src/single_component_path_imports.rs b/clippy_lints/src/single_component_path_imports.rs index acf44a9bb5a..c986c3e8aa6 100644 --- a/clippy_lints/src/single_component_path_imports.rs +++ b/clippy_lints/src/single_component_path_imports.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; use rustc_ast::node_id::{NodeId, NodeMap}; use rustc_ast::ptr::P; -use rustc_ast::visit::{walk_expr, Visitor}; +use rustc_ast::visit::{Visitor, walk_expr}; use rustc_ast::{Crate, Expr, ExprKind, Item, ItemKind, MacroDef, ModKind, Ty, TyKind, UseTreeKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index 04c16281ec4..5129bbf2665 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -2,11 +2,10 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::macros::matching_root_macro_call; use clippy_utils::sugg::Sugg; use clippy_utils::{ - get_enclosing_block, is_integer_literal, is_path_diagnostic_item, path_to_local, - path_to_local_id, SpanlessEq, + SpanlessEq, get_enclosing_block, is_integer_literal, is_path_diagnostic_item, path_to_local, path_to_local_id, }; use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_block, walk_expr, walk_stmt, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_block, walk_expr, walk_stmt}; use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, PatKind, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; diff --git a/clippy_lints/src/std_instead_of_core.rs b/clippy_lints/src/std_instead_of_core.rs index 44283a49e84..8dd99858793 100644 --- a/clippy_lints/src/std_instead_of_core.rs +++ b/clippy_lints/src/std_instead_of_core.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::Msrv; use clippy_config::Conf; +use clippy_config::msrvs::Msrv; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_from_proc_macro; use rustc_attr::{StabilityLevel, StableSince}; @@ -11,7 +11,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/string_patterns.rs b/clippy_lints/src/string_patterns.rs index 8af50ca87d6..ba2ddac2ec3 100644 --- a/clippy_lints/src/string_patterns.rs +++ b/clippy_lints/src/string_patterns.rs @@ -1,13 +1,13 @@ use std::ops::ControlFlow; -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::eager_or_lazy::switch_to_eager_eval; use clippy_utils::macros::matching_root_macro_call; use clippy_utils::path_to_local_id; use clippy_utils::source::{snippet, str_literal_to_char_literal}; -use clippy_utils::visitors::{for_each_expr, Descend}; +use clippy_utils::visitors::{Descend, for_each_expr}; use itertools::Itertools; use rustc_ast::{BinOpKind, LitKind}; use rustc_errors::Applicability; @@ -15,7 +15,7 @@ use rustc_hir::{Expr, ExprKind, PatKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 6ca4ca000e9..1fb82b66ab8 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -2,8 +2,8 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_the use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::ty::is_type_lang_item; use clippy_utils::{ - get_expr_use_or_unification_node, get_parent_expr, is_lint_allowed, is_path_diagnostic_item, method_calls, - peel_blocks, SpanlessEq, + SpanlessEq, get_expr_use_or_unification_node, get_parent_expr, is_lint_allowed, is_path_diagnostic_item, + method_calls, peel_blocks, }; use rustc_errors::Applicability; use rustc_hir::def_id::DefId; diff --git a/clippy_lints/src/suspicious_operation_groupings.rs b/clippy_lints/src/suspicious_operation_groupings.rs index 1c1de805db0..be32dc0aab0 100644 --- a/clippy_lints/src/suspicious_operation_groupings.rs +++ b/clippy_lints/src/suspicious_operation_groupings.rs @@ -1,4 +1,4 @@ -use clippy_utils::ast_utils::{eq_id, is_useless_with_eq_exprs, IdentIter}; +use clippy_utils::ast_utils::{IdentIter, eq_id, is_useless_with_eq_exprs}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use core::ops::{Add, AddAssign}; @@ -7,9 +7,9 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::declare_lint_pass; +use rustc_span::Span; use rustc_span::source_map::Spanned; use rustc_span::symbol::Ident; -use rustc_span::Span; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index 744d6392e06..e9779d437d4 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::visitors::for_each_expr_without_closures; -use clippy_utils::{binop_traits, trait_ref_of_method, BINOP_TRAITS, OP_ASSIGN_TRAITS}; +use clippy_utils::{BINOP_TRAITS, OP_ASSIGN_TRAITS, binop_traits, trait_ref_of_method}; use core::ops::ControlFlow; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 197011cde3a..e05fa4095b8 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -6,7 +6,7 @@ use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{can_mut_borrow_both, eq_expr_value, is_in_const_context, std_or_core}; use itertools::Itertools; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use crate::FxHashSet; use rustc_errors::Applicability; @@ -17,7 +17,7 @@ use rustc_middle::ty; use rustc_session::declare_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::symbol::Ident; -use rustc_span::{sym, Span, SyntaxContext}; +use rustc_span::{Span, SyntaxContext, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/swap_ptr_to_ref.rs b/clippy_lints/src/swap_ptr_to_ref.rs index 20e9608a15d..8c5cf93ab6e 100644 --- a/clippy_lints/src/swap_ptr_to_ref.rs +++ b/clippy_lints/src/swap_ptr_to_ref.rs @@ -5,7 +5,7 @@ use rustc_errors::Applicability; use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span, SyntaxContext}; +use rustc_span::{Span, SyntaxContext, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/tests_outside_test_module.rs b/clippy_lints/src/tests_outside_test_module.rs index 25d0a16e2ab..3cd4fefffad 100644 --- a/clippy_lints/src/tests_outside_test_module.rs +++ b/clippy_lints/src/tests_outside_test_module.rs @@ -4,8 +4,8 @@ use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::def_id::LocalDefId; use rustc_span::Span; +use rustc_span::def_id::LocalDefId; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/to_digit_is_some.rs b/clippy_lints/src/to_digit_is_some.rs index dafe9e38818..4f96a566b63 100644 --- a/clippy_lints/src/to_digit_is_some.rs +++ b/clippy_lints/src/to_digit_is_some.rs @@ -56,11 +56,13 @@ impl<'tcx> LateLintPass<'tcx> for ToDigitIsSome { && let hir::ExprKind::Path(to_digits_path) = &to_digits_call.kind && let to_digits_call_res = cx.qpath_res(to_digits_path, to_digits_call.hir_id) && let Some(to_digits_def_id) = to_digits_call_res.opt_def_id() - && match_def_path( - cx, - to_digits_def_id, - &["core", "char", "methods", "", "to_digit"], - ) + && match_def_path(cx, to_digits_def_id, &[ + "core", + "char", + "methods", + "", + "to_digit", + ]) { Some((false, char_arg, radix_arg)) } else { diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index 2e87d36df31..00277593622 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -1,8 +1,8 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; -use clippy_utils::source::{snippet, snippet_with_applicability, SpanRangeExt}; -use clippy_utils::{is_from_proc_macro, SpanlessEq, SpanlessHash}; +use clippy_utils::source::{SpanRangeExt, snippet, snippet_with_applicability}; +use clippy_utils::{SpanlessEq, SpanlessHash, is_from_proc_macro}; use core::hash::{Hash, Hasher}; use itertools::Itertools; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; diff --git a/clippy_lints/src/transmute/mod.rs b/clippy_lints/src/transmute/mod.rs index ced53a808f9..25fec9f688c 100644 --- a/clippy_lints/src/transmute/mod.rs +++ b/clippy_lints/src/transmute/mod.rs @@ -19,8 +19,8 @@ mod useless_transmute; mod utils; mod wrong_transmute; -use clippy_config::msrvs::Msrv; use clippy_config::Conf; +use clippy_config::msrvs::Msrv; use clippy_utils::is_in_const_context; use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs index ba8c7d6bfcb..fca332dba40 100644 --- a/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs +++ b/clippy_lints/src/transmute/transmutes_expressible_as_ptr_casts.rs @@ -6,8 +6,8 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, Node}; use rustc_hir_typeck::cast::check_cast; use rustc_lint::LateContext; -use rustc_middle::ty::cast::CastKind; use rustc_middle::ty::Ty; +use rustc_middle::ty::cast::CastKind; /// Checks for `transmutes_expressible_as_ptr_casts` lint. /// Returns `true` if it's triggered, otherwise returns `false`. diff --git a/clippy_lints/src/transmute/unsound_collection_transmute.rs b/clippy_lints/src/transmute/unsound_collection_transmute.rs index 35e93830766..f46e95b0b83 100644 --- a/clippy_lints/src/transmute/unsound_collection_transmute.rs +++ b/clippy_lints/src/transmute/unsound_collection_transmute.rs @@ -1,5 +1,5 @@ -use super::utils::is_layout_incompatible; use super::UNSOUND_COLLECTION_TRANSMUTE; +use super::utils::is_layout_incompatible; use clippy_utils::diagnostics::span_lint; use rustc_hir::Expr; use rustc_lint::LateContext; diff --git a/clippy_lints/src/tuple_array_conversions.rs b/clippy_lints/src/tuple_array_conversions.rs index 1d0de932754..3da8a449a7c 100644 --- a/clippy_lints/src/tuple_array_conversions.rs +++ b/clippy_lints/src/tuple_array_conversions.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::visitors::for_each_local_use_after_expr; use clippy_utils::{is_from_proc_macro, path_to_local}; diff --git a/clippy_lints/src/types/box_collection.rs b/clippy_lints/src/types/box_collection.rs index 9ac73394548..24fe4e08a5b 100644 --- a/clippy_lints/src/types/box_collection.rs +++ b/clippy_lints/src/types/box_collection.rs @@ -3,7 +3,7 @@ use clippy_utils::{path_def_id, qpath_generic_tys}; use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, QPath}; use rustc_lint::LateContext; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; use super::BOX_COLLECTION; diff --git a/clippy_lints/src/types/mod.rs b/clippy_lints/src/types/mod.rs index 120d5ffbbd3..363aea8be72 100644 --- a/clippy_lints/src/types/mod.rs +++ b/clippy_lints/src/types/mod.rs @@ -18,8 +18,8 @@ use rustc_hir::{ }; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::def_id::LocalDefId; use rustc_span::Span; +use rustc_span::def_id::LocalDefId; declare_clippy_lint! { /// ### What it does @@ -386,30 +386,22 @@ impl<'tcx> LateLintPass<'tcx> for Types { let is_exported = cx.effective_visibilities.is_exported(def_id); - self.check_fn_decl( - cx, - decl, - CheckTyContext { - is_in_trait_impl, - is_exported, - in_body: matches!(fn_kind, FnKind::Closure), - ..CheckTyContext::default() - }, - ); + self.check_fn_decl(cx, decl, CheckTyContext { + is_in_trait_impl, + is_exported, + in_body: matches!(fn_kind, FnKind::Closure), + ..CheckTyContext::default() + }); } fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) { let is_exported = cx.effective_visibilities.is_exported(item.owner_id.def_id); match item.kind { - ItemKind::Static(ty, _, _) | ItemKind::Const(ty, _, _) => self.check_ty( - cx, - ty, - CheckTyContext { - is_exported, - ..CheckTyContext::default() - }, - ), + ItemKind::Static(ty, _, _) | ItemKind::Const(ty, _, _) => self.check_ty(cx, ty, CheckTyContext { + is_exported, + ..CheckTyContext::default() + }), // functions, enums, structs, impls and traits are covered _ => (), } @@ -427,14 +419,10 @@ impl<'tcx> LateLintPass<'tcx> for Types { false }; - self.check_ty( - cx, - ty, - CheckTyContext { - is_in_trait_impl, - ..CheckTyContext::default() - }, - ); + self.check_ty(cx, ty, CheckTyContext { + is_in_trait_impl, + ..CheckTyContext::default() + }); }, // Methods are covered by check_fn. // Type aliases are ignored because oftentimes it's impossible to @@ -450,14 +438,10 @@ impl<'tcx> LateLintPass<'tcx> for Types { let is_exported = cx.effective_visibilities.is_exported(field.def_id); - self.check_ty( - cx, - field.ty, - CheckTyContext { - is_exported, - ..CheckTyContext::default() - }, - ); + self.check_ty(cx, field.ty, CheckTyContext { + is_exported, + ..CheckTyContext::default() + }); } fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &TraitItem<'tcx>) { @@ -485,14 +469,10 @@ impl<'tcx> LateLintPass<'tcx> for Types { fn check_local(&mut self, cx: &LateContext<'tcx>, local: &LetStmt<'tcx>) { if let Some(ty) = local.ty { - self.check_ty( - cx, - ty, - CheckTyContext { - in_body: true, - ..CheckTyContext::default() - }, - ); + self.check_ty(cx, ty, CheckTyContext { + in_body: true, + ..CheckTyContext::default() + }); } } } diff --git a/clippy_lints/src/types/redundant_allocation.rs b/clippy_lints/src/types/redundant_allocation.rs index 0801eace4fc..1a656088b17 100644 --- a/clippy_lints/src/types/redundant_allocation.rs +++ b/clippy_lints/src/types/redundant_allocation.rs @@ -9,7 +9,7 @@ use rustc_lint::LateContext; use rustc_middle::ty::TypeVisitableExt; use rustc_span::symbol::sym; -use super::{utils, REDUNDANT_ALLOCATION}; +use super::{REDUNDANT_ALLOCATION, utils}; pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, hir_ty: &hir::Ty<'tcx>, qpath: &QPath<'tcx>, def_id: DefId) -> bool { let mut applicability = Applicability::MaybeIncorrect; diff --git a/clippy_lints/src/types/type_complexity.rs b/clippy_lints/src/types/type_complexity.rs index 7fcfd5c8f35..0b64fddb447 100644 --- a/clippy_lints/src/types/type_complexity.rs +++ b/clippy_lints/src/types/type_complexity.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint; use rustc_hir as hir; -use rustc_hir::intravisit::{walk_inf, walk_ty, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_inf, walk_ty}; use rustc_hir::{GenericParamKind, TyKind}; use rustc_lint::LateContext; use rustc_target::spec::abi::Abi; diff --git a/clippy_lints/src/types/vec_box.rs b/clippy_lints/src/types/vec_box.rs index 29996a6f783..230239335c6 100644 --- a/clippy_lints/src/types/vec_box.rs +++ b/clippy_lints/src/types/vec_box.rs @@ -6,8 +6,8 @@ use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, GenericArg, LangItem, QPath, TyKind}; use rustc_hir_analysis::lower_ty; use rustc_lint::LateContext; -use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::TypeVisitableExt; +use rustc_middle::ty::layout::LayoutOf; use rustc_span::symbol::sym; use super::VEC_BOX; diff --git a/clippy_lints/src/unconditional_recursion.rs b/clippy_lints/src/unconditional_recursion.rs index 42100e1d755..3fc08e8192d 100644 --- a/clippy_lints/src/unconditional_recursion.rs +++ b/clippy_lints/src/unconditional_recursion.rs @@ -5,7 +5,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::intravisit::{walk_body, walk_expr, FnKind, Visitor}; +use rustc_hir::intravisit::{FnKind, Visitor, walk_body, walk_expr}; use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId, Item, ItemKind, Node, QPath, TyKind}; use rustc_hir_analysis::lower_ty; use rustc_lint::{LateContext, LateLintPass}; @@ -13,8 +13,8 @@ use rustc_middle::hir::map::Map; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, AssocKind, Ty, TyCtxt}; use rustc_session::impl_lint_pass; -use rustc_span::symbol::{kw, Ident}; -use rustc_span::{sym, Span}; +use rustc_span::symbol::{Ident, kw}; +use rustc_span::{Span, sym}; use rustc_trait_selection::error_reporting::traits::suggestions::ReturnsVisitor; use std::ops::ControlFlow; @@ -257,13 +257,10 @@ fn is_default_method_on_current_ty<'tcx>(tcx: TyCtxt<'tcx>, qpath: QPath<'tcx>, } if matches!( ty.kind, - TyKind::Path(QPath::Resolved( - _, - hir::Path { - res: Res::SelfTyAlias { .. }, - .. - }, - )) + TyKind::Path(QPath::Resolved(_, hir::Path { + res: Res::SelfTyAlias { .. }, + .. + },)) ) { return true; } diff --git a/clippy_lints/src/undocumented_unsafe_blocks.rs b/clippy_lints/src/undocumented_unsafe_blocks.rs index f51c5f74d99..44eb0a6c593 100644 --- a/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -4,12 +4,12 @@ use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_lint_allowed; use clippy_utils::source::walk_span_to_context; -use clippy_utils::visitors::{for_each_expr, Descend}; +use clippy_utils::visitors::{Descend, for_each_expr}; use hir::HirId; use rustc_data_structures::sync::Lrc; use rustc_hir as hir; use rustc_hir::{Block, BlockCheckMode, ItemKind, Node, UnsafeSource}; -use rustc_lexer::{tokenize, TokenKind}; +use rustc_lexer::{TokenKind, tokenize}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; diff --git a/clippy_lints/src/uninhabited_references.rs b/clippy_lints/src/uninhabited_references.rs index 88039372ebd..cfa565cf803 100644 --- a/clippy_lints/src/uninhabited_references.rs +++ b/clippy_lints/src/uninhabited_references.rs @@ -5,8 +5,8 @@ use rustc_hir_analysis::lower_ty; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_session::declare_lint_pass; -use rustc_span::def_id::LocalDefId; use rustc_span::Span; +use rustc_span::def_id::LocalDefId; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/uninit_vec.rs b/clippy_lints/src/uninit_vec.rs index 9ffcfcc0f50..93ed15777e0 100644 --- a/clippy_lints/src/uninit_vec.rs +++ b/clippy_lints/src/uninit_vec.rs @@ -1,13 +1,13 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; -use clippy_utils::higher::{get_vec_init_kind, VecInitKind}; +use clippy_utils::higher::{VecInitKind, get_vec_init_kind}; use clippy_utils::ty::{is_type_diagnostic_item, is_uninit_value_valid_for_ty}; -use clippy_utils::{is_integer_literal, is_lint_allowed, path_to_local_id, peel_hir_expr_while, SpanlessEq}; +use clippy_utils::{SpanlessEq, is_integer_literal, is_lint_allowed, path_to_local_id, peel_hir_expr_while}; use rustc_hir::{Block, Expr, ExprKind, HirId, PatKind, PathSegment, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; // TODO: add `ReadBuf` (RFC 2930) in "How to fix" once it is available in std declare_clippy_lint! { diff --git a/clippy_lints/src/unit_return_expecting_ord.rs b/clippy_lints/src/unit_return_expecting_ord.rs index a8cc2f97963..87478a120dd 100644 --- a/clippy_lints/src/unit_return_expecting_ord.rs +++ b/clippy_lints/src/unit_return_expecting_ord.rs @@ -5,7 +5,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_middle::ty::{ClauseKind, GenericPredicates, ProjectionPredicate, TraitPredicate}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, BytePos, Span}; +use rustc_span::{BytePos, Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/unit_types/let_unit_value.rs b/clippy_lints/src/unit_types/let_unit_value.rs index 80b661a757c..bf2d75ea1a9 100644 --- a/clippy_lints/src/unit_types/let_unit_value.rs +++ b/clippy_lints/src/unit_types/let_unit_value.rs @@ -4,7 +4,7 @@ use clippy_utils::visitors::{for_each_local_assignment, for_each_value_source, i use core::ops::ControlFlow; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::intravisit::{walk_body, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_body}; use rustc_hir::{Expr, ExprKind, HirId, HirIdSet, LetStmt, MatchSource, Node, PatKind, QPath, TyKind}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::{in_external_macro, is_from_async_await}; diff --git a/clippy_lints/src/unit_types/unit_arg.rs b/clippy_lints/src/unit_types/unit_arg.rs index 978d49f09c3..41b2ca5d268 100644 --- a/clippy_lints/src/unit_types/unit_arg.rs +++ b/clippy_lints/src/unit_types/unit_arg.rs @@ -1,11 +1,11 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_from_proc_macro; -use clippy_utils::source::{indent_of, reindent_multiline, SourceText, SpanRangeExt}; +use clippy_utils::source::{SourceText, SpanRangeExt, indent_of, reindent_multiline}; use rustc_errors::Applicability; use rustc_hir::{Block, Expr, ExprKind, MatchSource, Node, StmtKind}; use rustc_lint::LateContext; -use super::{utils, UNIT_ARG}; +use super::{UNIT_ARG, utils}; pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { if expr.span.from_expansion() { diff --git a/clippy_lints/src/unnecessary_wraps.rs b/clippy_lints/src/unnecessary_wraps.rs index 080efe983c2..937e35dea96 100644 --- a/clippy_lints/src/unnecessary_wraps.rs +++ b/clippy_lints/src/unnecessary_wraps.rs @@ -4,15 +4,15 @@ use clippy_utils::source::snippet; use clippy_utils::visitors::find_all_ret_expressions; use clippy_utils::{contains_return, is_res_lang_ctor, path_res, return_ty}; use rustc_errors::Applicability; -use rustc_hir::intravisit::FnKind; use rustc_hir::LangItem::{OptionSome, ResultOk}; +use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, ExprKind, FnDecl, Impl, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::impl_lint_pass; +use rustc_span::Span; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::sym; -use rustc_span::Span; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/unnested_or_patterns.rs b/clippy_lints/src/unnested_or_patterns.rs index 98f0be3135d..104be63bb15 100644 --- a/clippy_lints/src/unnested_or_patterns.rs +++ b/clippy_lints/src/unnested_or_patterns.rs @@ -1,14 +1,14 @@ #![allow(clippy::wildcard_imports, clippy::enum_glob_use)] -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::ast_utils::{eq_field_pat, eq_id, eq_maybe_qself, eq_pat, eq_path}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::over; +use rustc_ast::PatKind::*; use rustc_ast::mut_visit::*; use rustc_ast::ptr::P; -use rustc_ast::PatKind::*; -use rustc_ast::{self as ast, Mutability, Pat, PatKind, DUMMY_NODE_ID}; +use rustc_ast::{self as ast, DUMMY_NODE_ID, Mutability, Pat, PatKind}; use rustc_ast_pretty::pprust; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; @@ -16,7 +16,7 @@ use rustc_session::impl_lint_pass; use rustc_span::DUMMY_SP; use std::cell::Cell; use std::mem; -use thin_vec::{thin_vec, ThinVec}; +use thin_vec::{ThinVec, thin_vec}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index 309eaedac8d..e70d2a2dafe 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -2,8 +2,8 @@ use clippy_utils::diagnostics::span_lint; use rustc_ast::ast::{Item, ItemKind, UseTree, UseTreeKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::symbol::Ident; use rustc_span::Span; +use rustc_span::symbol::Ident; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/unused_async.rs b/clippy_lints/src/unused_async.rs index 738fba54fa8..a1f08cf6623 100644 --- a/clippy_lints/src/unused_async.rs +++ b/clippy_lints/src/unused_async.rs @@ -1,13 +1,13 @@ use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::is_def_id_trait_method; use rustc_hir::def::DefKind; -use rustc_hir::intravisit::{walk_expr, walk_fn, FnKind, Visitor}; +use rustc_hir::intravisit::{FnKind, Visitor, walk_expr, walk_fn}; use rustc_hir::{Body, Expr, ExprKind, FnDecl, Node, YieldSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; use rustc_session::impl_lint_pass; -use rustc_span::def_id::{LocalDefId, LocalDefIdSet}; use rustc_span::Span; +use rustc_span::def_id::{LocalDefId, LocalDefIdSet}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/unused_io_amount.rs b/clippy_lints/src/unused_io_amount.rs index af7abd009d2..d2a21b11ef4 100644 --- a/clippy_lints/src/unused_io_amount.rs +++ b/clippy_lints/src/unused_io_amount.rs @@ -5,7 +5,7 @@ use hir::{ExprKind, HirId, PatKind}; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/unused_peekable.rs b/clippy_lints/src/unused_peekable.rs index 86a811e17ca..71aa57e0a14 100644 --- a/clippy_lints/src/unused_peekable.rs +++ b/clippy_lints/src/unused_peekable.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::ty::{is_type_diagnostic_item, peel_mid_ty_refs_is_mutable}; use clippy_utils::{fn_def_id, is_trait_method, path_to_local_id, peel_ref_operators}; use rustc_ast::Mutability; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{Block, Expr, ExprKind, HirId, LetStmt, Node, PatKind, PathSegment, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter::OnlyBodies; diff --git a/clippy_lints/src/unused_trait_names.rs b/clippy_lints/src/unused_trait_names.rs index c1cf58dcfce..9fd6ebccd02 100644 --- a/clippy_lints/src/unused_trait_names.rs +++ b/clippy_lints/src/unused_trait_names.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::is_from_proc_macro; use clippy_utils::source::snippet_opt; diff --git a/clippy_lints/src/unused_unit.rs b/clippy_lints/src/unused_unit.rs index 65f431d338b..d5309aade7a 100644 --- a/clippy_lints/src/unused_unit.rs +++ b/clippy_lints/src/unused_unit.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::source::{position_before_rarrow, SpanRangeExt}; +use clippy_utils::source::{SpanRangeExt, position_before_rarrow}; use rustc_ast::visit::FnKind; -use rustc_ast::{ast, ClosureBinder}; +use rustc_ast::{ClosureBinder, ast}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::declare_lint_pass; diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 0b4ea0752b6..596f0fd9c8b 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -3,7 +3,7 @@ use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::usage::is_potentially_local_place; use clippy_utils::{higher, path_to_local}; use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_expr, walk_fn, FnKind, Visitor}; +use rustc_hir::intravisit::{FnKind, Visitor, walk_expr, walk_fn}; use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, HirId, Node, PathSegment, UnOp}; use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceWithHirId}; use rustc_lint::{LateContext, LateLintPass}; @@ -13,7 +13,7 @@ use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::declare_lint_pass; use rustc_span::def_id::LocalDefId; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/unwrap_in_result.rs b/clippy_lints/src/unwrap_in_result.rs index f77badd97b7..9b9a2ffbbc8 100644 --- a/clippy_lints/src/unwrap_in_result.rs +++ b/clippy_lints/src/unwrap_in_result.rs @@ -7,7 +7,7 @@ use rustc_hir as hir; use rustc_hir::ImplItemKind; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index 5da48f4f7fb..e340b419bd0 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -1,5 +1,5 @@ -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::is_from_proc_macro; use clippy_utils::ty::same_type_and_consts; @@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::LocalDefId; -use rustc_hir::intravisit::{walk_inf, walk_ty, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_inf, walk_ty}; use rustc_hir::{ self as hir, Expr, ExprKind, FnRetTy, FnSig, GenericArgsParentheses, GenericParam, GenericParamKind, HirId, Impl, ImplItemKind, Item, ItemKind, Pat, PatKind, Path, QPath, Ty, TyKind, diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index 1890b3fdd40..29a7949b343 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -12,7 +12,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::traits::ObligationCause; use rustc_middle::ty::{self, EarlyBinder, GenericArg, GenericArgsRef, Ty, TypeVisitableExt}; use rustc_session::impl_lint_pass; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; declare_clippy_lint! { diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index 0cce45290cf..31f9d84f5e4 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -1,6 +1,6 @@ use clippy_utils::{get_attr, higher}; -use rustc_ast::ast::{LitFloatType, LitKind}; use rustc_ast::LitIntType; +use rustc_ast::ast::{LitFloatType, LitKind}; use rustc_data_structures::fx::FxHashMap; use rustc_hir::{ self as hir, ArrayLen, BindingMode, CaptureBy, Closure, ClosureKind, ConstArg, ConstArgKind, CoroutineKind, diff --git a/clippy_lints/src/utils/format_args_collector.rs b/clippy_lints/src/utils/format_args_collector.rs index f50ce6c99de..8f314ce7a60 100644 --- a/clippy_lints/src/utils/format_args_collector.rs +++ b/clippy_lints/src/utils/format_args_collector.rs @@ -3,10 +3,10 @@ use clippy_utils::source::SpanRangeExt; use itertools::Itertools; use rustc_ast::{Crate, Expr, ExprKind, FormatArgs}; use rustc_data_structures::fx::FxHashMap; -use rustc_lexer::{tokenize, TokenKind}; +use rustc_lexer::{TokenKind, tokenize}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::{hygiene, Span}; +use rustc_span::{Span, hygiene}; use std::iter::once; use std::mem; diff --git a/clippy_lints/src/utils/internal_lints/collapsible_calls.rs b/clippy_lints/src/utils/internal_lints/collapsible_calls.rs index f7529682675..d8f101a8614 100644 --- a/clippy_lints/src/utils/internal_lints/collapsible_calls.rs +++ b/clippy_lints/src/utils/internal_lints/collapsible_calls.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; -use clippy_utils::{is_expr_path_def_path, is_lint_allowed, peel_blocks_with_stmt, SpanlessEq}; +use clippy_utils::{SpanlessEq, is_expr_path_def_path, is_lint_allowed, peel_blocks_with_stmt}; use rustc_errors::Applicability; use rustc_hir::{Closure, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/clippy_lints/src/utils/internal_lints/invalid_paths.rs b/clippy_lints/src/utils/internal_lints/invalid_paths.rs index 0ffcb433481..d444ad45087 100644 --- a/clippy_lints/src/utils/internal_lints/invalid_paths.rs +++ b/clippy_lints/src/utils/internal_lints/invalid_paths.rs @@ -2,11 +2,11 @@ use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::def_path_res; use clippy_utils::diagnostics::span_lint; use rustc_hir as hir; -use rustc_hir::def::DefKind; use rustc_hir::Item; +use rustc_hir::def::DefKind; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::FloatTy; +use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_session::declare_lint_pass; use rustc_span::symbol::Symbol; diff --git a/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs b/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs index 20526113d69..7c45a5b2f09 100644 --- a/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs +++ b/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs @@ -12,7 +12,7 @@ use rustc_middle::hir::nested_filter; use rustc_session::impl_lint_pass; use rustc_span::source_map::Spanned; use rustc_span::symbol::Symbol; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use {rustc_ast as ast, rustc_hir as hir}; declare_clippy_lint! { diff --git a/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs b/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs index 41183700f09..76b0a52621b 100644 --- a/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs +++ b/clippy_lints/src/utils/internal_lints/unnecessary_def_path.rs @@ -8,12 +8,12 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{Expr, ExprKind, LetStmt, Mutability, Node}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::mir::interpret::{Allocation, GlobalAlloc}; use rustc_middle::mir::ConstValue; +use rustc_middle::mir::interpret::{Allocation, GlobalAlloc}; use rustc_middle::ty::{self, Ty}; use rustc_session::impl_lint_pass; -use rustc_span::symbol::Symbol; use rustc_span::Span; +use rustc_span::symbol::Symbol; use std::str; diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index d3e49bff422..ce4f41e854d 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -1,8 +1,8 @@ use std::collections::BTreeMap; use std::ops::ControlFlow; -use clippy_config::msrvs::{self, Msrv}; use clippy_config::Conf; +use clippy_config::msrvs::{self, Msrv}; use clippy_utils::consts::{ConstEvalCtxt, Constant}; use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::source::SpanRangeExt; @@ -15,7 +15,7 @@ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_middle::ty::layout::LayoutOf; use rustc_session::impl_lint_pass; -use rustc_span::{sym, DesugaringKind, Span}; +use rustc_span::{DesugaringKind, Span, sym}; #[expect(clippy::module_name_repetitions)] pub struct UselessVec { diff --git a/clippy_lints/src/vec_init_then_push.rs b/clippy_lints/src/vec_init_then_push.rs index a599415a2dd..91dff5a9523 100644 --- a/clippy_lints/src/vec_init_then_push.rs +++ b/clippy_lints/src/vec_init_then_push.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::higher::{get_vec_init_kind, VecInitKind}; +use clippy_utils::higher::{VecInitKind, get_vec_init_kind}; use clippy_utils::source::snippet; use clippy_utils::visitors::for_each_local_use_after_expr; use clippy_utils::{get_parent_expr, path_to_local_id}; diff --git a/clippy_lints/src/visibility.rs b/clippy_lints/src/visibility.rs index 7a85196ceca..2e5fc5834e2 100644 --- a/clippy_lints/src/visibility.rs +++ b/clippy_lints/src/visibility.rs @@ -5,8 +5,8 @@ use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::declare_lint_pass; -use rustc_span::symbol::kw; use rustc_span::Span; +use rustc_span::symbol::kw; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/wildcard_imports.rs b/clippy_lints/src/wildcard_imports.rs index 7d9e58ad2f8..405310512df 100644 --- a/clippy_lints/src/wildcard_imports.rs +++ b/clippy_lints/src/wildcard_imports.rs @@ -10,7 +10,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty; use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; -use rustc_span::{sym, BytePos}; +use rustc_span::{BytePos, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index ec5a5896fb2..1dd46ed5a89 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -1,8 +1,8 @@ use clippy_config::Conf; use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; use clippy_utils::is_in_test; -use clippy_utils::macros::{format_arg_removal_span, root_macro_call_first_node, FormatArgsStorage, MacroCall}; -use clippy_utils::source::{expand_past_previous_comma, SpanRangeExt}; +use clippy_utils::macros::{FormatArgsStorage, MacroCall, format_arg_removal_span, root_macro_call_first_node}; +use clippy_utils::source::{SpanRangeExt, expand_past_previous_comma}; use rustc_ast::token::LitKind; use rustc_ast::{ FormatArgPosition, FormatArgPositionKind, FormatArgs, FormatArgsPiece, FormatOptions, FormatPlaceholder, @@ -12,7 +12,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_session::impl_lint_pass; -use rustc_span::{sym, BytePos, Span}; +use rustc_span::{BytePos, Span, sym}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_lints/src/zombie_processes.rs b/clippy_lints/src/zombie_processes.rs index eda3d7820c1..ba2a80ee66b 100644 --- a/clippy_lints/src/zombie_processes.rs +++ b/clippy_lints/src/zombie_processes.rs @@ -1,14 +1,14 @@ +use ControlFlow::{Break, Continue}; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::{fn_def_id, get_enclosing_block, match_any_def_paths, match_def_path, path_to_local_id, paths}; use rustc_ast::Mutability; use rustc_errors::Applicability; -use rustc_hir::intravisit::{walk_block, walk_expr, walk_local, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_block, walk_expr, walk_local}; use rustc_hir::{Expr, ExprKind, HirId, LetStmt, Node, PatKind, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::sym; use std::ops::ControlFlow; -use ControlFlow::{Break, Continue}; declare_clippy_lint! { /// ### What it does diff --git a/clippy_utils/src/ast_utils/ident_iter.rs b/clippy_utils/src/ast_utils/ident_iter.rs index eefcbabd835..032cd3ed739 100644 --- a/clippy_utils/src/ast_utils/ident_iter.rs +++ b/clippy_utils/src/ast_utils/ident_iter.rs @@ -1,5 +1,5 @@ use core::iter::FusedIterator; -use rustc_ast::visit::{walk_attribute, walk_expr, Visitor}; +use rustc_ast::visit::{Visitor, walk_attribute, walk_expr}; use rustc_ast::{Attribute, Expr}; use rustc_span::symbol::Ident; diff --git a/clippy_utils/src/attrs.rs b/clippy_utils/src/attrs.rs index 935a1686c0a..edc9c6ccdff 100644 --- a/clippy_utils/src/attrs.rs +++ b/clippy_utils/src/attrs.rs @@ -4,7 +4,7 @@ use rustc_lexer::TokenKind; use rustc_lint::LateContext; use rustc_middle::ty::{AdtDef, TyCtxt}; use rustc_session::Session; -use rustc_span::{sym, Span}; +use rustc_span::{Span, sym}; use std::str::FromStr; use crate::source::SpanRangeExt; diff --git a/clippy_utils/src/check_proc_macro.rs b/clippy_utils/src/check_proc_macro.rs index 2bd6837d973..9143d292f67 100644 --- a/clippy_utils/src/check_proc_macro.rs +++ b/clippy_utils/src/check_proc_macro.rs @@ -12,9 +12,9 @@ //! code was written, and check if the span contains that text. Note this will only work correctly //! if the span is not from a `macro_rules` based macro. +use rustc_ast::AttrStyle; use rustc_ast::ast::{AttrKind, Attribute, IntTy, LitIntType, LitKind, StrStyle, TraitObjectSyntax, UintTy}; use rustc_ast::token::CommentKind; -use rustc_ast::AttrStyle; use rustc_hir::intravisit::FnKind; use rustc_hir::{ Block, BlockCheckMode, Body, Closure, Destination, Expr, ExprKind, FieldDef, FnHeader, FnRetTy, HirId, Impl, @@ -24,7 +24,7 @@ use rustc_hir::{ use rustc_lint::{LateContext, LintContext}; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_span::symbol::{kw, Ident}; +use rustc_span::symbol::{Ident, kw}; use rustc_span::{Span, Symbol}; use rustc_target::spec::abi::Abi; diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs index 760d5bc95f7..bf47cf6d372 100644 --- a/clippy_utils/src/consts.rs +++ b/clippy_utils/src/consts.rs @@ -1,24 +1,24 @@ #![allow(clippy::float_cmp)] use crate::macros::HirNode; -use crate::source::{walk_span_to_context, SpanRangeExt}; +use crate::source::{SpanRangeExt, walk_span_to_context}; use crate::{clip, is_direct_expn_of, sext, unsext}; -use rustc_apfloat::ieee::{Half, Quad}; use rustc_apfloat::Float; +use rustc_apfloat::ieee::{Half, Quad}; use rustc_ast::ast::{self, LitFloatType, LitKind}; use rustc_data_structures::sync::Lrc; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{BinOp, BinOpKind, Block, ConstBlock, Expr, ExprKind, HirId, Item, ItemKind, Node, QPath, UnOp}; use rustc_lexer::tokenize; use rustc_lint::LateContext; -use rustc_middle::mir::interpret::{alloc_range, Scalar}; use rustc_middle::mir::ConstValue; +use rustc_middle::mir::interpret::{Scalar, alloc_range}; use rustc_middle::ty::{self, FloatTy, IntTy, ParamEnv, ScalarInt, Ty, TyCtxt, TypeckResults, UintTy}; use rustc_middle::{bug, mir, span_bug}; use rustc_span::def_id::DefId; use rustc_span::symbol::Ident; -use rustc_span::{sym, SyntaxContext}; +use rustc_span::{SyntaxContext, sym}; use rustc_target::abi::Size; use std::cell::Cell; use std::cmp::Ordering; @@ -581,7 +581,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> { } fn constant_negate(&self, o: &Constant<'tcx>, ty: Ty<'_>) -> Option> { - use self::Constant::{Int, F32, F64}; + use self::Constant::{F32, F64, Int}; match *o { Int(value) => { let ty::Int(ity) = *ty.kind() else { return None }; diff --git a/clippy_utils/src/eager_or_lazy.rs b/clippy_utils/src/eager_or_lazy.rs index a6dd12a28c5..9420d84b959 100644 --- a/clippy_utils/src/eager_or_lazy.rs +++ b/clippy_utils/src/eager_or_lazy.rs @@ -14,12 +14,12 @@ use crate::ty::{all_predicates_of, is_copy}; use crate::visitors::is_const_evaluatable; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::{walk_expr, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{BinOpKind, Block, Expr, ExprKind, QPath, UnOp}; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_middle::ty::adjustment::Adjust; -use rustc_span::{sym, Symbol}; +use rustc_span::{Symbol, sym}; use std::{cmp, ops}; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] diff --git a/clippy_utils/src/higher.rs b/clippy_utils/src/higher.rs index e09cc9edf3a..3175a9a1dd3 100644 --- a/clippy_utils/src/higher.rs +++ b/clippy_utils/src/higher.rs @@ -3,14 +3,14 @@ #![deny(clippy::missing_docs_in_private_items)] use crate::consts::{ConstEvalCtxt, Constant}; -use crate::ty::is_type_diagnostic_item; use crate::is_expn_of; +use crate::ty::is_type_diagnostic_item; use rustc_ast::ast; use rustc_hir as hir; use rustc_hir::{Arm, Block, Expr, ExprKind, HirId, LoopSource, MatchSource, Node, Pat, QPath}; use rustc_lint::LateContext; -use rustc_span::{sym, symbol, Span}; +use rustc_span::{Span, sym, symbol}; /// The essential nodes of a desugared for loop as well as the entire span: /// `for pat in arg { body }` becomes `(pat, arg, body)`. Returns `(pat, arg, body, span)`. diff --git a/clippy_utils/src/hir_utils.rs b/clippy_utils/src/hir_utils.rs index c1e21ec4e39..76900379ac7 100644 --- a/clippy_utils/src/hir_utils.rs +++ b/clippy_utils/src/hir_utils.rs @@ -1,20 +1,20 @@ use crate::consts::ConstEvalCtxt; use crate::macros::macro_backtrace; -use crate::source::{walk_span_to_context, SpanRange, SpanRangeExt}; +use crate::source::{SpanRange, SpanRangeExt, walk_span_to_context}; use crate::tokenize_with_text; use rustc_ast::ast::InlineAsmTemplatePiece; use rustc_data_structures::fx::FxHasher; -use rustc_hir::def::Res; use rustc_hir::MatchSource::TryDesugar; +use rustc_hir::def::Res; use rustc_hir::{ ArrayLen, AssocItemConstraint, BinOpKind, BindingMode, Block, BodyId, Closure, ConstArg, ConstArgKind, Expr, ExprField, ExprKind, FnRetTy, GenericArg, GenericArgs, HirId, HirIdMap, InlineAsmOperand, LetExpr, Lifetime, LifetimeName, Pat, PatField, PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind, Ty, TyKind, }; -use rustc_lexer::{tokenize, TokenKind}; +use rustc_lexer::{TokenKind, tokenize}; use rustc_lint::LateContext; use rustc_middle::ty::TypeckResults; -use rustc_span::{sym, BytePos, ExpnKind, MacroKind, Symbol, SyntaxContext}; +use rustc_span::{BytePos, ExpnKind, MacroKind, Symbol, SyntaxContext, sym}; use std::hash::{Hash, Hasher}; use std::ops::Range; diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 5a68b0860bc..a925549b0bf 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -78,7 +78,7 @@ pub mod visitors; pub use self::attrs::*; pub use self::check_proc_macro::{is_from_proc_macro, is_span_if, is_span_match}; pub use self::hir_utils::{ - both, count_eq, eq_expr_value, hash_expr, hash_stmt, is_bool, over, HirEqInterExpr, SpanlessEq, SpanlessHash, + HirEqInterExpr, SpanlessEq, SpanlessHash, both, count_eq, eq_expr_value, hash_expr, hash_stmt, is_bool, over, }; use core::mem; @@ -94,20 +94,20 @@ use rustc_ast::ast::{self, LitKind, RangeLimits}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::packed::Pu128; use rustc_data_structures::unhash::UnhashMap; +use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk}; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalModDefId, LOCAL_CRATE}; +use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE, LocalDefId, LocalModDefId}; use rustc_hir::definitions::{DefPath, DefPathData}; use rustc_hir::hir_id::{HirIdMap, HirIdSet}; -use rustc_hir::intravisit::{walk_expr, FnKind, Visitor}; -use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk}; +use rustc_hir::intravisit::{FnKind, Visitor, walk_expr}; use rustc_hir::{ - self as hir, def, Arm, ArrayLen, BindingMode, Block, BlockCheckMode, Body, ByRef, Closure, ConstArgKind, - ConstContext, Destination, Expr, ExprField, ExprKind, FnDecl, FnRetTy, GenericArgs, HirId, Impl, ImplItem, - ImplItemKind, ImplItemRef, Item, ItemKind, LangItem, LetStmt, MatchSource, Mutability, Node, OwnerId, OwnerNode, - Param, Pat, PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind, TraitItem, TraitItemKind, TraitItemRef, - TraitRef, TyKind, UnOp, + self as hir, Arm, ArrayLen, BindingMode, Block, BlockCheckMode, Body, ByRef, Closure, ConstArgKind, ConstContext, + Destination, Expr, ExprField, ExprKind, FnDecl, FnRetTy, GenericArgs, HirId, Impl, ImplItem, ImplItemKind, + ImplItemRef, Item, ItemKind, LangItem, LetStmt, MatchSource, Mutability, Node, OwnerId, OwnerNode, Param, Pat, + PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind, TraitItem, TraitItemKind, TraitItemRef, TraitRef, + TyKind, UnOp, def, }; -use rustc_lexer::{tokenize, TokenKind}; +use rustc_lexer::{TokenKind, tokenize}; use rustc_lint::{LateContext, Level, Lint, LintContext}; use rustc_middle::hir::place::PlaceBase; use rustc_middle::mir::Const; @@ -120,12 +120,12 @@ use rustc_middle::ty::{ }; use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::source_map::SourceMap; -use rustc_span::symbol::{kw, Ident, Symbol}; -use rustc_span::{sym, InnerSpan, Span}; +use rustc_span::symbol::{Ident, Symbol, kw}; +use rustc_span::{InnerSpan, Span, sym}; use rustc_target::abi::Integer; use visitors::Visitable; -use crate::consts::{mir_to_const, ConstEvalCtxt, Constant}; +use crate::consts::{ConstEvalCtxt, Constant, mir_to_const}; use crate::higher::Range; use crate::ty::{adt_and_variant_of_res, can_partially_move_ty, expr_sig, is_copy, is_recursively_primitive_type}; use crate::visitors::for_each_expr_without_closures; @@ -263,9 +263,13 @@ pub fn is_res_lang_ctor(cx: &LateContext<'_>, res: Res, lang_item: LangItem) -> } } - /// Checks if `{ctor_call_id}(...)` is `{enum_item}::{variant_name}(...)`. -pub fn is_enum_variant_ctor(cx: &LateContext<'_>, enum_item: Symbol, variant_name: Symbol, ctor_call_id: DefId) -> bool { +pub fn is_enum_variant_ctor( + cx: &LateContext<'_>, + enum_item: Symbol, + variant_name: Symbol, + ctor_call_id: DefId, +) -> bool { let Some(enum_def_id) = cx.tcx.get_diagnostic_item(enum_item) else { return false; }; diff --git a/clippy_utils/src/macros.rs b/clippy_utils/src/macros.rs index 1d7479bff82..9c4d19ac1f1 100644 --- a/clippy_utils/src/macros.rs +++ b/clippy_utils/src/macros.rs @@ -1,6 +1,6 @@ #![allow(clippy::similar_names)] // `expr` and `expn` -use crate::visitors::{for_each_expr_without_closures, Descend}; +use crate::visitors::{Descend, for_each_expr_without_closures}; use arrayvec::ArrayVec; use rustc_ast::{FormatArgs, FormatArgument, FormatPlaceholder}; @@ -10,7 +10,7 @@ use rustc_hir::{self as hir, Expr, ExprKind, HirId, Node, QPath}; use rustc_lint::LateContext; use rustc_span::def_id::DefId; use rustc_span::hygiene::{self, MacroKind, SyntaxContext}; -use rustc_span::{sym, BytePos, ExpnData, ExpnId, ExpnKind, Span, SpanData, Symbol}; +use rustc_span::{BytePos, ExpnData, ExpnId, ExpnKind, Span, SpanData, Symbol, sym}; use std::ops::ControlFlow; const FORMAT_MACRO_DIAG_ITEMS: &[Symbol] = &[ diff --git a/clippy_utils/src/mir/mod.rs b/clippy_utils/src/mir/mod.rs index 654fb564848..59bb5e35cda 100644 --- a/clippy_utils/src/mir/mod.rs +++ b/clippy_utils/src/mir/mod.rs @@ -2,7 +2,7 @@ use rustc_hir::{Expr, HirId}; use rustc_index::bit_set::BitSet; use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor}; use rustc_middle::mir::{ - traversal, BasicBlock, Body, InlineAsmOperand, Local, Location, Place, StatementKind, TerminatorKind, START_BLOCK, + BasicBlock, Body, InlineAsmOperand, Local, Location, Place, START_BLOCK, StatementKind, TerminatorKind, traversal, }; use rustc_middle::ty::TyCtxt; @@ -112,14 +112,10 @@ pub fn block_in_cycle(body: &Body<'_>, block: BasicBlock) -> bool { /// Convenience wrapper around `visit_local_usage`. pub fn used_exactly_once(mir: &Body<'_>, local: Local) -> Option { - visit_local_usage( - &[local], - mir, - Location { - block: START_BLOCK, - statement_index: 0, - }, - ) + visit_local_usage(&[local], mir, Location { + block: START_BLOCK, + statement_index: 0, + }) .map(|mut vec| { let LocalUsage { local_use_locs, .. } = vec.remove(0); let mut locations = local_use_locs diff --git a/clippy_utils/src/ptr.rs b/clippy_utils/src/ptr.rs index 991ea428dc3..273c1b0defa 100644 --- a/clippy_utils/src/ptr.rs +++ b/clippy_utils/src/ptr.rs @@ -1,5 +1,5 @@ use crate::source::snippet; -use crate::visitors::{for_each_expr_without_closures, Descend}; +use crate::visitors::{Descend, for_each_expr_without_closures}; use crate::{path_to_local_id, strip_pat_refs}; use core::ops::ControlFlow; use rustc_hir::{Body, BodyId, ExprKind, HirId, PatKind}; diff --git a/clippy_utils/src/qualify_min_const_fn.rs b/clippy_utils/src/qualify_min_const_fn.rs index d9befb3c157..2ed20b7202c 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -18,8 +18,8 @@ use rustc_middle::mir::{ use rustc_middle::traits::{BuiltinImplSource, ImplSource, ObligationCause}; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::{self, GenericArgKind, TraitRef, Ty, TyCtxt}; -use rustc_span::symbol::sym; use rustc_span::Span; +use rustc_span::symbol::sym; use rustc_trait_selection::traits::{ObligationCtxt, SelectionContext}; use std::borrow::Cow; diff --git a/clippy_utils/src/source.rs b/clippy_utils/src/source.rs index f97fb4a6471..4ad7575e720 100644 --- a/clippy_utils/src/source.rs +++ b/clippy_utils/src/source.rs @@ -9,10 +9,10 @@ use rustc_hir::{BlockCheckMode, Expr, ExprKind, UnsafeSource}; use rustc_lint::{EarlyContext, LateContext}; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_span::source_map::{original_sp, SourceMap}; +use rustc_span::source_map::{SourceMap, original_sp}; use rustc_span::{ - hygiene, BytePos, FileNameDisplayPreference, Pos, SourceFile, SourceFileAndLine, Span, SpanData, SyntaxContext, - DUMMY_SP, + BytePos, DUMMY_SP, FileNameDisplayPreference, Pos, SourceFile, SourceFileAndLine, Span, SpanData, SyntaxContext, + hygiene, }; use std::borrow::Cow; use std::fmt; @@ -725,15 +725,12 @@ pub fn str_literal_to_char_literal( &snip[1..(snip.len() - 1)] }; - let hint = format!( - "'{}'", - match ch { - "'" => "\\'", - r"\" => "\\\\", - "\\\"" => "\"", // no need to escape `"` in `'"'` - _ => ch, - } - ); + let hint = format!("'{}'", match ch { + "'" => "\\'", + r"\" => "\\\\", + "\\\"" => "\"", // no need to escape `"` in `'"'` + _ => ch, + }); Some(hint) } else { diff --git a/clippy_utils/src/str_utils.rs b/clippy_utils/src/str_utils.rs index 421b25a77fe..1588ee452da 100644 --- a/clippy_utils/src/str_utils.rs +++ b/clippy_utils/src/str_utils.rs @@ -370,9 +370,11 @@ mod test { assert_eq!(camel_case_split("AbcDef"), vec!["Abc", "Def"]); assert_eq!(camel_case_split("Abc"), vec!["Abc"]); assert_eq!(camel_case_split("abcDef"), vec!["abc", "Def"]); - assert_eq!( - camel_case_split("\u{f6}\u{f6}AabABcd"), - vec!["\u{f6}\u{f6}", "Aab", "A", "Bcd"] - ); + assert_eq!(camel_case_split("\u{f6}\u{f6}AabABcd"), vec![ + "\u{f6}\u{f6}", + "Aab", + "A", + "Bcd" + ]); } } diff --git a/clippy_utils/src/ty.rs b/clippy_utils/src/ty.rs index 9c5e761abe4..775a98fe361 100644 --- a/clippy_utils/src/ty.rs +++ b/clippy_utils/src/ty.rs @@ -12,8 +12,8 @@ use rustc_hir::def_id::DefId; use rustc_hir::{Expr, FnDecl, LangItem, Safety, TyKind}; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::LateContext; -use rustc_middle::mir::interpret::Scalar; use rustc_middle::mir::ConstValue; +use rustc_middle::mir::interpret::Scalar; use rustc_middle::traits::EvaluationResult; use rustc_middle::ty::layout::ValidityRequirement; use rustc_middle::ty::{ @@ -22,7 +22,7 @@ use rustc_middle::ty::{ TypeVisitable, TypeVisitableExt, TypeVisitor, UintTy, Upcast, VariantDef, VariantDiscr, }; use rustc_span::symbol::Ident; -use rustc_span::{sym, Span, Symbol, DUMMY_SP}; +use rustc_span::{DUMMY_SP, Span, Symbol, sym}; use rustc_target::abi::VariantIdx; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt; diff --git a/clippy_utils/src/ty/type_certainty/mod.rs b/clippy_utils/src/ty/type_certainty/mod.rs index 875ddec259e..e612e9c6cb6 100644 --- a/clippy_utils/src/ty/type_certainty/mod.rs +++ b/clippy_utils/src/ty/type_certainty/mod.rs @@ -14,14 +14,14 @@ use crate::def_path_res; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::{walk_qpath, walk_ty, Visitor}; +use rustc_hir::intravisit::{Visitor, walk_qpath, walk_ty}; use rustc_hir::{self as hir, Expr, ExprKind, GenericArgs, HirId, Node, PathSegment, QPath, TyKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, AdtDef, GenericArgKind, Ty}; use rustc_span::{Span, Symbol}; mod certainty; -use certainty::{join, meet, Certainty, Meet}; +use certainty::{Certainty, Meet, join, meet}; pub fn expr_type_is_certain(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { expr_type_certainty(cx, expr).is_certain() diff --git a/clippy_utils/src/usage.rs b/clippy_utils/src/usage.rs index fbf3d95365a..1230b60c3a6 100644 --- a/clippy_utils/src/usage.rs +++ b/clippy_utils/src/usage.rs @@ -1,4 +1,4 @@ -use crate::visitors::{for_each_expr, for_each_expr_without_closures, Descend, Visitable}; +use crate::visitors::{Descend, Visitable, for_each_expr, for_each_expr_without_closures}; use crate::{self as utils, get_enclosing_loop_or_multi_call_closure}; use core::ops::ControlFlow; use hir::def::Res; diff --git a/clippy_utils/src/visitors.rs b/clippy_utils/src/visitors.rs index e5b6d3965e9..6d9a85a1181 100644 --- a/clippy_utils/src/visitors.rs +++ b/clippy_utils/src/visitors.rs @@ -1,10 +1,10 @@ use crate::ty::needs_ordered_drop; use crate::{get_enclosing_block, path_to_local_id}; use core::ops::ControlFlow; -use rustc_ast::visit::{try_visit, VisitorResult}; +use rustc_ast::visit::{VisitorResult, try_visit}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; -use rustc_hir::intravisit::{self, walk_block, walk_expr, Visitor}; +use rustc_hir::intravisit::{self, Visitor, walk_block, walk_expr}; use rustc_hir::{ AnonConst, Arm, Block, BlockCheckMode, Body, BodyId, Expr, ExprKind, HirId, ItemId, ItemKind, LetExpr, Pat, QPath, Safety, Stmt, UnOp, UnsafeSource, diff --git a/declare_clippy_lint/src/lib.rs b/declare_clippy_lint/src/lib.rs index 6aa24329b06..fefc1a0a6c4 100644 --- a/declare_clippy_lint/src/lib.rs +++ b/declare_clippy_lint/src/lib.rs @@ -5,7 +5,7 @@ use proc_macro::TokenStream; use quote::{format_ident, quote}; use syn::parse::{Parse, ParseStream}; -use syn::{parse_macro_input, Attribute, Error, Expr, ExprLit, Ident, Lit, LitStr, Meta, Result, Token}; +use syn::{Attribute, Error, Expr, ExprLit, Ident, Lit, LitStr, Meta, Result, Token, parse_macro_input}; fn parse_attr(path: [&'static str; LEN], attr: &Attribute) -> Option { if let Meta::NameValue(name_value) = &attr.meta { @@ -140,15 +140,12 @@ pub fn declare_clippy_lint(input: TokenStream) -> TokenStream { let mut category = category.to_string(); - let level = format_ident!( - "{}", - match category.as_str() { - "correctness" => "Deny", - "style" | "suspicious" | "complexity" | "perf" => "Warn", - "pedantic" | "restriction" | "cargo" | "nursery" | "internal" => "Allow", - _ => panic!("unknown category {category}"), - }, - ); + let level = format_ident!("{}", match category.as_str() { + "correctness" => "Deny", + "style" | "suspicious" | "complexity" | "perf" => "Warn", + "pedantic" | "restriction" | "cargo" | "nursery" | "internal" => "Allow", + _ => panic!("unknown category {category}"), + },); let info_name = format_ident!("{name}_INFO"); diff --git a/lintcheck/src/driver.rs b/lintcheck/src/driver.rs index 2fda2b00f87..87ab14ba0cf 100644 --- a/lintcheck/src/driver.rs +++ b/lintcheck/src/driver.rs @@ -1,4 +1,4 @@ -use crate::recursive::{deserialize_line, serialize_line, DriverInfo}; +use crate::recursive::{DriverInfo, deserialize_line, serialize_line}; use std::io::{self, BufReader, Write}; use std::net::TcpStream; diff --git a/lintcheck/src/recursive.rs b/lintcheck/src/recursive.rs index 6a662970ae8..57073f52364 100644 --- a/lintcheck/src/recursive.rs +++ b/lintcheck/src/recursive.rs @@ -3,8 +3,8 @@ //! [`LintcheckServer`] to ask if it should be skipped, and if not sends the stderr of running //! clippy on the crate to the server -use crate::input::RecursiveOptions; use crate::ClippyWarning; +use crate::input::RecursiveOptions; use std::collections::HashSet; use std::io::{BufRead, BufReader, Read, Write}; diff --git a/src/driver.rs b/src/driver.rs index 414957938a4..324f754e615 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -15,9 +15,9 @@ extern crate rustc_session; extern crate rustc_span; use rustc_interface::interface; +use rustc_session::EarlyDiagCtxt; use rustc_session::config::ErrorOutputType; use rustc_session::parse::ParseSess; -use rustc_session::EarlyDiagCtxt; use rustc_span::symbol::Symbol; use std::env; diff --git a/tests/compile-test.rs b/tests/compile-test.rs index c7243348ce4..af2aa519257 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -2,25 +2,25 @@ #![warn(rust_2018_idioms, unused_lifetimes)] #![allow(unused_extern_crates)] -use cargo_metadata::diagnostic::{Applicability, Diagnostic}; use cargo_metadata::Message; +use cargo_metadata::diagnostic::{Applicability, Diagnostic}; use clippy_config::ClippyConfiguration; +use clippy_lints::LintInfo; use clippy_lints::declared_lints::LINTS; use clippy_lints::deprecated_lints::{DEPRECATED, DEPRECATED_VERSION, RENAMED}; -use clippy_lints::LintInfo; use serde::{Deserialize, Serialize}; use test_utils::IS_RUSTC_TEST_SUITE; -use ui_test::custom_flags::rustfix::RustfixMode; use ui_test::custom_flags::Flag; +use ui_test::custom_flags::rustfix::RustfixMode; use ui_test::spanned::Spanned; -use ui_test::{status_emitter, Args, CommandBuilder, Config, Match, OutputConflictHandling}; +use ui_test::{Args, CommandBuilder, Config, Match, OutputConflictHandling, status_emitter}; use std::collections::{BTreeMap, HashMap}; use std::env::{self, set_var, var_os}; use std::ffi::{OsStr, OsString}; use std::fmt::Write; use std::path::{Path, PathBuf}; -use std::sync::mpsc::{channel, Sender}; +use std::sync::mpsc::{Sender, channel}; use std::{fs, iter, thread}; // Test dependencies may need an `extern crate` here to ensure that they show up diff --git a/tests/config-metadata.rs b/tests/config-metadata.rs index 3e3711873ba..628dfc8f758 100644 --- a/tests/config-metadata.rs +++ b/tests/config-metadata.rs @@ -1,6 +1,6 @@ #![feature(rustc_private)] -use clippy_config::{get_configuration_metadata, ClippyConfiguration}; +use clippy_config::{ClippyConfiguration, get_configuration_metadata}; use itertools::Itertools; use regex::Regex; use std::borrow::Cow; diff --git a/tests/ui-internal/unnecessary_def_path.fixed b/tests/ui-internal/unnecessary_def_path.fixed index 04d990896e5..0a994842834 100644 --- a/tests/ui-internal/unnecessary_def_path.fixed +++ b/tests/ui-internal/unnecessary_def_path.fixed @@ -22,8 +22,8 @@ use rustc_hir::LangItem; #[allow(unused)] use rustc_span::sym; -use rustc_hir::def_id::DefId; use rustc_hir::Expr; +use rustc_hir::def_id::DefId; use rustc_lint::LateContext; use rustc_middle::ty::Ty; diff --git a/tests/ui-internal/unnecessary_def_path.rs b/tests/ui-internal/unnecessary_def_path.rs index ade5e9280e3..ba68de6c6d0 100644 --- a/tests/ui-internal/unnecessary_def_path.rs +++ b/tests/ui-internal/unnecessary_def_path.rs @@ -22,8 +22,8 @@ use rustc_hir::LangItem; #[allow(unused)] use rustc_span::sym; -use rustc_hir::def_id::DefId; use rustc_hir::Expr; +use rustc_hir::def_id::DefId; use rustc_lint::LateContext; use rustc_middle::ty::Ty; diff --git a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.fixed b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.fixed index 5f4f007cf5c..a6072111dc0 100644 --- a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.fixed +++ b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.fixed @@ -2,7 +2,7 @@ use std::alloc as colla; use std::option::Option as Maybe; -use std::process::{exit as goodbye, Child as Kid}; +use std::process::{Child as Kid, exit as goodbye}; use std::thread::sleep as thread_sleep; #[rustfmt::skip] use std::{ diff --git a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs index f60058c8628..c2b61aab5b3 100644 --- a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs +++ b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs @@ -2,7 +2,7 @@ use std::alloc as colla; use std::option::Option as Maybe; -use std::process::{exit as wrong_exit, Child as Kid}; +use std::process::{Child as Kid, exit as wrong_exit}; use std::thread::sleep; #[rustfmt::skip] use std::{ diff --git a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr index f66938c83fb..d3bb07ec47f 100644 --- a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr +++ b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr @@ -1,8 +1,8 @@ error: this import should be renamed - --> tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:5:20 + --> tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.rs:5:34 | -LL | use std::process::{exit as wrong_exit, Child as Kid}; - | ^^^^^^^^^^^^^^^^^^ help: try: `exit as goodbye` +LL | use std::process::{Child as Kid, exit as wrong_exit}; + | ^^^^^^^^^^^^^^^^^^ help: try: `exit as goodbye` | = note: `-D clippy::missing-enforced-import-renames` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::missing_enforced_import_renames)]` diff --git a/tests/ui/arithmetic_side_effects.rs b/tests/ui/arithmetic_side_effects.rs index 0838d064a5f..3f204073085 100644 --- a/tests/ui/arithmetic_side_effects.rs +++ b/tests/ui/arithmetic_side_effects.rs @@ -2,7 +2,6 @@ #![feature(f128)] #![feature(f16)] - #![allow( clippy::assign_op_pattern, clippy::erasing_op, diff --git a/tests/ui/arithmetic_side_effects.stderr b/tests/ui/arithmetic_side_effects.stderr index 78914667bf3..78b1aca4b8a 100644 --- a/tests/ui/arithmetic_side_effects.stderr +++ b/tests/ui/arithmetic_side_effects.stderr @@ -1,5 +1,5 @@ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:167:13 + --> tests/ui/arithmetic_side_effects.rs:166:13 | LL | let _ = 1f16 + 1f16; | ^^^^^^^^^^^ @@ -8,733 +8,733 @@ LL | let _ = 1f16 + 1f16; = help: to override `-D warnings` add `#[allow(clippy::arithmetic_side_effects)]` error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:170:13 + --> tests/ui/arithmetic_side_effects.rs:169:13 | LL | let _ = 1f128 + 1f128; | ^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:308:5 + --> tests/ui/arithmetic_side_effects.rs:307:5 | LL | _n += 1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:309:5 + --> tests/ui/arithmetic_side_effects.rs:308:5 | LL | _n += &1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:310:5 + --> tests/ui/arithmetic_side_effects.rs:309:5 | LL | _n -= 1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:311:5 + --> tests/ui/arithmetic_side_effects.rs:310:5 | LL | _n -= &1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:312:5 + --> tests/ui/arithmetic_side_effects.rs:311:5 | LL | _n /= 0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:313:5 + --> tests/ui/arithmetic_side_effects.rs:312:5 | LL | _n /= &0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:314:5 + --> tests/ui/arithmetic_side_effects.rs:313:5 | LL | _n %= 0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:315:5 + --> tests/ui/arithmetic_side_effects.rs:314:5 | LL | _n %= &0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:316:5 + --> tests/ui/arithmetic_side_effects.rs:315:5 | LL | _n *= 2; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:317:5 + --> tests/ui/arithmetic_side_effects.rs:316:5 | LL | _n *= &2; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:318:5 + --> tests/ui/arithmetic_side_effects.rs:317:5 | LL | _n += -1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:319:5 + --> tests/ui/arithmetic_side_effects.rs:318:5 | LL | _n += &-1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:320:5 + --> tests/ui/arithmetic_side_effects.rs:319:5 | LL | _n -= -1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:321:5 + --> tests/ui/arithmetic_side_effects.rs:320:5 | LL | _n -= &-1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:322:5 + --> tests/ui/arithmetic_side_effects.rs:321:5 | LL | _n /= -0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:323:5 + --> tests/ui/arithmetic_side_effects.rs:322:5 | LL | _n /= &-0; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:324:5 + --> tests/ui/arithmetic_side_effects.rs:323:5 | LL | _n %= -0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:325:5 + --> tests/ui/arithmetic_side_effects.rs:324:5 | LL | _n %= &-0; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:326:5 + --> tests/ui/arithmetic_side_effects.rs:325:5 | LL | _n *= -2; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:327:5 + --> tests/ui/arithmetic_side_effects.rs:326:5 | LL | _n *= &-2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:328:5 + --> tests/ui/arithmetic_side_effects.rs:327:5 | LL | _custom += Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:329:5 + --> tests/ui/arithmetic_side_effects.rs:328:5 | LL | _custom += &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:330:5 + --> tests/ui/arithmetic_side_effects.rs:329:5 | LL | _custom -= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:331:5 + --> tests/ui/arithmetic_side_effects.rs:330:5 | LL | _custom -= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:332:5 + --> tests/ui/arithmetic_side_effects.rs:331:5 | LL | _custom /= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:333:5 + --> tests/ui/arithmetic_side_effects.rs:332:5 | LL | _custom /= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:334:5 + --> tests/ui/arithmetic_side_effects.rs:333:5 | LL | _custom %= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:335:5 + --> tests/ui/arithmetic_side_effects.rs:334:5 | LL | _custom %= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:336:5 + --> tests/ui/arithmetic_side_effects.rs:335:5 | LL | _custom *= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:337:5 + --> tests/ui/arithmetic_side_effects.rs:336:5 | LL | _custom *= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:338:5 + --> tests/ui/arithmetic_side_effects.rs:337:5 | LL | _custom >>= Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:339:5 + --> tests/ui/arithmetic_side_effects.rs:338:5 | LL | _custom >>= &Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:340:5 + --> tests/ui/arithmetic_side_effects.rs:339:5 | LL | _custom <<= Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:341:5 + --> tests/ui/arithmetic_side_effects.rs:340:5 | LL | _custom <<= &Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:342:5 + --> tests/ui/arithmetic_side_effects.rs:341:5 | LL | _custom += -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:343:5 + --> tests/ui/arithmetic_side_effects.rs:342:5 | LL | _custom += &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:344:5 + --> tests/ui/arithmetic_side_effects.rs:343:5 | LL | _custom -= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:345:5 + --> tests/ui/arithmetic_side_effects.rs:344:5 | LL | _custom -= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:346:5 + --> tests/ui/arithmetic_side_effects.rs:345:5 | LL | _custom /= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:347:5 + --> tests/ui/arithmetic_side_effects.rs:346:5 | LL | _custom /= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:348:5 + --> tests/ui/arithmetic_side_effects.rs:347:5 | LL | _custom %= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:349:5 + --> tests/ui/arithmetic_side_effects.rs:348:5 | LL | _custom %= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:350:5 + --> tests/ui/arithmetic_side_effects.rs:349:5 | LL | _custom *= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:351:5 + --> tests/ui/arithmetic_side_effects.rs:350:5 | LL | _custom *= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:352:5 + --> tests/ui/arithmetic_side_effects.rs:351:5 | LL | _custom >>= -Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:353:5 + --> tests/ui/arithmetic_side_effects.rs:352:5 | LL | _custom >>= &-Custom; | ^^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:354:5 + --> tests/ui/arithmetic_side_effects.rs:353:5 | LL | _custom <<= -Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:355:5 + --> tests/ui/arithmetic_side_effects.rs:354:5 | LL | _custom <<= &-Custom; | ^^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:358:10 + --> tests/ui/arithmetic_side_effects.rs:357:10 | LL | _n = _n + 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:359:10 + --> tests/ui/arithmetic_side_effects.rs:358:10 | LL | _n = _n + &1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:360:10 + --> tests/ui/arithmetic_side_effects.rs:359:10 | LL | _n = 1 + _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:361:10 + --> tests/ui/arithmetic_side_effects.rs:360:10 | LL | _n = &1 + _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:362:10 + --> tests/ui/arithmetic_side_effects.rs:361:10 | LL | _n = _n - 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:363:10 + --> tests/ui/arithmetic_side_effects.rs:362:10 | LL | _n = _n - &1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:364:10 + --> tests/ui/arithmetic_side_effects.rs:363:10 | LL | _n = 1 - _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:365:10 + --> tests/ui/arithmetic_side_effects.rs:364:10 | LL | _n = &1 - _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:366:10 + --> tests/ui/arithmetic_side_effects.rs:365:10 | LL | _n = _n / 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:367:10 + --> tests/ui/arithmetic_side_effects.rs:366:10 | LL | _n = _n / &0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:368:10 + --> tests/ui/arithmetic_side_effects.rs:367:10 | LL | _n = _n % 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:369:10 + --> tests/ui/arithmetic_side_effects.rs:368:10 | LL | _n = _n % &0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:370:10 + --> tests/ui/arithmetic_side_effects.rs:369:10 | LL | _n = _n * 2; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:371:10 + --> tests/ui/arithmetic_side_effects.rs:370:10 | LL | _n = _n * &2; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:372:10 + --> tests/ui/arithmetic_side_effects.rs:371:10 | LL | _n = 2 * _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:373:10 + --> tests/ui/arithmetic_side_effects.rs:372:10 | LL | _n = &2 * _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:374:10 + --> tests/ui/arithmetic_side_effects.rs:373:10 | LL | _n = 23 + &85; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:375:10 + --> tests/ui/arithmetic_side_effects.rs:374:10 | LL | _n = &23 + 85; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:376:10 + --> tests/ui/arithmetic_side_effects.rs:375:10 | LL | _n = &23 + &85; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:377:15 + --> tests/ui/arithmetic_side_effects.rs:376:15 | LL | _custom = _custom + _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:378:15 + --> tests/ui/arithmetic_side_effects.rs:377:15 | LL | _custom = _custom + &_custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:379:15 + --> tests/ui/arithmetic_side_effects.rs:378:15 | LL | _custom = Custom + _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:380:15 + --> tests/ui/arithmetic_side_effects.rs:379:15 | LL | _custom = &Custom + _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:381:15 + --> tests/ui/arithmetic_side_effects.rs:380:15 | LL | _custom = _custom - Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:382:15 + --> tests/ui/arithmetic_side_effects.rs:381:15 | LL | _custom = _custom - &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:383:15 + --> tests/ui/arithmetic_side_effects.rs:382:15 | LL | _custom = Custom - _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:384:15 + --> tests/ui/arithmetic_side_effects.rs:383:15 | LL | _custom = &Custom - _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:385:15 + --> tests/ui/arithmetic_side_effects.rs:384:15 | LL | _custom = _custom / Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:386:15 + --> tests/ui/arithmetic_side_effects.rs:385:15 | LL | _custom = _custom / &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:387:15 + --> tests/ui/arithmetic_side_effects.rs:386:15 | LL | _custom = _custom % Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:388:15 + --> tests/ui/arithmetic_side_effects.rs:387:15 | LL | _custom = _custom % &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:389:15 + --> tests/ui/arithmetic_side_effects.rs:388:15 | LL | _custom = _custom * Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:390:15 + --> tests/ui/arithmetic_side_effects.rs:389:15 | LL | _custom = _custom * &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:391:15 + --> tests/ui/arithmetic_side_effects.rs:390:15 | LL | _custom = Custom * _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:392:15 + --> tests/ui/arithmetic_side_effects.rs:391:15 | LL | _custom = &Custom * _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:393:15 + --> tests/ui/arithmetic_side_effects.rs:392:15 | LL | _custom = Custom + &Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:394:15 + --> tests/ui/arithmetic_side_effects.rs:393:15 | LL | _custom = &Custom + Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:395:15 + --> tests/ui/arithmetic_side_effects.rs:394:15 | LL | _custom = &Custom + &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:396:15 + --> tests/ui/arithmetic_side_effects.rs:395:15 | LL | _custom = _custom >> _custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:397:15 + --> tests/ui/arithmetic_side_effects.rs:396:15 | LL | _custom = _custom >> &_custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:398:15 + --> tests/ui/arithmetic_side_effects.rs:397:15 | LL | _custom = Custom << _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:399:15 + --> tests/ui/arithmetic_side_effects.rs:398:15 | LL | _custom = &Custom << _custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:402:23 + --> tests/ui/arithmetic_side_effects.rs:401:23 | LL | _n.saturating_div(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:403:21 + --> tests/ui/arithmetic_side_effects.rs:402:21 | LL | _n.wrapping_div(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:404:21 + --> tests/ui/arithmetic_side_effects.rs:403:21 | LL | _n.wrapping_rem(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:405:28 + --> tests/ui/arithmetic_side_effects.rs:404:28 | LL | _n.wrapping_rem_euclid(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:407:23 + --> tests/ui/arithmetic_side_effects.rs:406:23 | LL | _n.saturating_div(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:408:21 + --> tests/ui/arithmetic_side_effects.rs:407:21 | LL | _n.wrapping_div(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:409:21 + --> tests/ui/arithmetic_side_effects.rs:408:21 | LL | _n.wrapping_rem(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:410:28 + --> tests/ui/arithmetic_side_effects.rs:409:28 | LL | _n.wrapping_rem_euclid(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:413:10 + --> tests/ui/arithmetic_side_effects.rs:412:10 | LL | _n = -_n; | ^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:414:10 + --> tests/ui/arithmetic_side_effects.rs:413:10 | LL | _n = -&_n; | ^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:415:15 + --> tests/ui/arithmetic_side_effects.rs:414:15 | LL | _custom = -_custom; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:416:15 + --> tests/ui/arithmetic_side_effects.rs:415:15 | LL | _custom = -&_custom; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:425:5 + --> tests/ui/arithmetic_side_effects.rs:424:5 | LL | 1 + i; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:426:5 + --> tests/ui/arithmetic_side_effects.rs:425:5 | LL | i * 2; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:427:5 + --> tests/ui/arithmetic_side_effects.rs:426:5 | LL | 1 % i / 2; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:428:5 + --> tests/ui/arithmetic_side_effects.rs:427:5 | LL | i - 2 + 2 - i; | ^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:429:5 + --> tests/ui/arithmetic_side_effects.rs:428:5 | LL | -i; | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:440:5 + --> tests/ui/arithmetic_side_effects.rs:439:5 | LL | i += 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:441:5 + --> tests/ui/arithmetic_side_effects.rs:440:5 | LL | i -= 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:442:5 + --> tests/ui/arithmetic_side_effects.rs:441:5 | LL | i *= 2; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:444:5 + --> tests/ui/arithmetic_side_effects.rs:443:5 | LL | i /= 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:446:5 + --> tests/ui/arithmetic_side_effects.rs:445:5 | LL | i /= var1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:447:5 + --> tests/ui/arithmetic_side_effects.rs:446:5 | LL | i /= var2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:449:5 + --> tests/ui/arithmetic_side_effects.rs:448:5 | LL | i %= 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:451:5 + --> tests/ui/arithmetic_side_effects.rs:450:5 | LL | i %= var1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:452:5 + --> tests/ui/arithmetic_side_effects.rs:451:5 | LL | i %= var2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:462:5 + --> tests/ui/arithmetic_side_effects.rs:461:5 | LL | 10 / a | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:516:9 + --> tests/ui/arithmetic_side_effects.rs:515:9 | LL | x / maybe_zero | ^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:520:9 + --> tests/ui/arithmetic_side_effects.rs:519:9 | LL | x % maybe_zero | ^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:531:5 + --> tests/ui/arithmetic_side_effects.rs:530:5 | LL | one.add_assign(1); | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> tests/ui/arithmetic_side_effects.rs:535:5 + --> tests/ui/arithmetic_side_effects.rs:534:5 | LL | one.sub_assign(1); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/auxiliary/proc_macro_attr.rs b/tests/ui/auxiliary/proc_macro_attr.rs index f6fdebaf252..e72d6b6cead 100644 --- a/tests/ui/auxiliary/proc_macro_attr.rs +++ b/tests/ui/auxiliary/proc_macro_attr.rs @@ -11,8 +11,8 @@ use quote::{quote, quote_spanned}; use syn::spanned::Spanned; use syn::token::Star; use syn::{ - parse_macro_input, parse_quote, FnArg, ImplItem, ItemFn, ItemImpl, ItemStruct, ItemTrait, Lifetime, Pat, PatIdent, - PatType, Signature, TraitItem, Type, Visibility, + FnArg, ImplItem, ItemFn, ItemImpl, ItemStruct, ItemTrait, Lifetime, Pat, PatIdent, PatType, Signature, TraitItem, + Type, Visibility, parse_macro_input, parse_quote, }; #[proc_macro_attribute] diff --git a/tests/ui/auxiliary/proc_macro_derive.rs b/tests/ui/auxiliary/proc_macro_derive.rs index 4c3df472269..bd90042c1da 100644 --- a/tests/ui/auxiliary/proc_macro_derive.rs +++ b/tests/ui/auxiliary/proc_macro_derive.rs @@ -5,7 +5,7 @@ extern crate proc_macro; -use proc_macro::{quote, Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; +use proc_macro::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree, quote}; #[proc_macro_derive(DeriveSomething)] pub fn derive(_: TokenStream) -> TokenStream { diff --git a/tests/ui/auxiliary/proc_macro_suspicious_else_formatting.rs b/tests/ui/auxiliary/proc_macro_suspicious_else_formatting.rs index 79e8eff3aa1..3d6f164d358 100644 --- a/tests/ui/auxiliary/proc_macro_suspicious_else_formatting.rs +++ b/tests/ui/auxiliary/proc_macro_suspicious_else_formatting.rs @@ -1,5 +1,5 @@ extern crate proc_macro; -use proc_macro::{token_stream, Delimiter, Group, Ident, Span, TokenStream, TokenTree}; +use proc_macro::{Delimiter, Group, Ident, Span, TokenStream, TokenTree, token_stream}; fn read_ident(iter: &mut token_stream::IntoIter) -> Ident { match iter.next() { diff --git a/tests/ui/auxiliary/proc_macros.rs b/tests/ui/auxiliary/proc_macros.rs index ed7412f7c40..1a2a4ec2311 100644 --- a/tests/ui/auxiliary/proc_macros.rs +++ b/tests/ui/auxiliary/proc_macros.rs @@ -5,9 +5,9 @@ extern crate proc_macro; use core::mem; -use proc_macro::token_stream::IntoIter; use proc_macro::Delimiter::{self, Brace, Parenthesis}; use proc_macro::Spacing::{self, Alone, Joint}; +use proc_macro::token_stream::IntoIter; use proc_macro::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree as TT}; use syn::spanned::Spanned; diff --git a/tests/ui/borrow_interior_mutable_const/others.rs b/tests/ui/borrow_interior_mutable_const/others.rs index 452d1b19813..de220505c3e 100644 --- a/tests/ui/borrow_interior_mutable_const/others.rs +++ b/tests/ui/borrow_interior_mutable_const/others.rs @@ -5,8 +5,8 @@ use std::borrow::Cow; use std::cell::{Cell, UnsafeCell}; use std::fmt::Display; -use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Once; +use std::sync::atomic::{AtomicUsize, Ordering}; const ATOMIC: AtomicUsize = AtomicUsize::new(5); const CELL: Cell = Cell::new(6); diff --git a/tests/ui/declare_interior_mutable_const/others.rs b/tests/ui/declare_interior_mutable_const/others.rs index 9dafad8b784..0dccf18c493 100644 --- a/tests/ui/declare_interior_mutable_const/others.rs +++ b/tests/ui/declare_interior_mutable_const/others.rs @@ -4,8 +4,8 @@ use std::borrow::Cow; use std::cell::Cell; use std::fmt::Display; use std::ptr; -use std::sync::atomic::AtomicUsize; use std::sync::Once; +use std::sync::atomic::AtomicUsize; const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR: interior mutable const CELL: Cell = Cell::new(6); //~ ERROR: interior mutable diff --git a/tests/ui/field_reassign_with_default.rs b/tests/ui/field_reassign_with_default.rs index 620cffb4f04..2a432751952 100644 --- a/tests/ui/field_reassign_with_default.rs +++ b/tests/ui/field_reassign_with_default.rs @@ -192,8 +192,8 @@ struct WrapperMulti { } mod issue6312 { - use std::sync::atomic::AtomicBool; use std::sync::Arc; + use std::sync::atomic::AtomicBool; // do not lint: type implements `Drop` but not all fields are `Copy` #[derive(Clone, Default)] diff --git a/tests/ui/format_args.fixed b/tests/ui/format_args.fixed index 4d812f6bf1d..20d1e3d9050 100644 --- a/tests/ui/format_args.fixed +++ b/tests/ui/format_args.fixed @@ -8,7 +8,7 @@ clippy::uninlined_format_args )] -use std::io::{stdout, Write}; +use std::io::{Write, stdout}; use std::ops::Deref; use std::panic::Location; diff --git a/tests/ui/format_args.rs b/tests/ui/format_args.rs index d242623feb6..18ab223db78 100644 --- a/tests/ui/format_args.rs +++ b/tests/ui/format_args.rs @@ -8,7 +8,7 @@ clippy::uninlined_format_args )] -use std::io::{stdout, Write}; +use std::io::{Write, stdout}; use std::ops::Deref; use std::panic::Location; diff --git a/tests/ui/format_args_unfixable.rs b/tests/ui/format_args_unfixable.rs index b7492e38b25..f04715f4f01 100644 --- a/tests/ui/format_args_unfixable.rs +++ b/tests/ui/format_args_unfixable.rs @@ -2,7 +2,7 @@ #![allow(unused)] #![allow(clippy::assertions_on_constants, clippy::eq_op, clippy::uninlined_format_args)] -use std::io::{stdout, Error, ErrorKind, Write}; +use std::io::{Error, ErrorKind, Write, stdout}; use std::ops::Deref; use std::panic::Location; diff --git a/tests/ui/ignored_unit_patterns.fixed b/tests/ui/ignored_unit_patterns.fixed index 118f0b48895..fde40437309 100644 --- a/tests/ui/ignored_unit_patterns.fixed +++ b/tests/ui/ignored_unit_patterns.fixed @@ -21,15 +21,12 @@ fn main() { let _ = foo().map_err(|()| todo!()); //~^ ERROR: matching over `()` is more explicit - println!( - "{:?}", - match foo() { - Ok(()) => {}, - //~^ ERROR: matching over `()` is more explicit - Err(()) => {}, - //~^ ERROR: matching over `()` is more explicit - } - ); + println!("{:?}", match foo() { + Ok(()) => {}, + //~^ ERROR: matching over `()` is more explicit + Err(()) => {}, + //~^ ERROR: matching over `()` is more explicit + }); } // ignored_unit_patterns in derive macro should be ok diff --git a/tests/ui/ignored_unit_patterns.rs b/tests/ui/ignored_unit_patterns.rs index 92feb9e6c28..528844d76e0 100644 --- a/tests/ui/ignored_unit_patterns.rs +++ b/tests/ui/ignored_unit_patterns.rs @@ -21,15 +21,12 @@ fn main() { let _ = foo().map_err(|_| todo!()); //~^ ERROR: matching over `()` is more explicit - println!( - "{:?}", - match foo() { - Ok(_) => {}, - //~^ ERROR: matching over `()` is more explicit - Err(_) => {}, - //~^ ERROR: matching over `()` is more explicit - } - ); + println!("{:?}", match foo() { + Ok(_) => {}, + //~^ ERROR: matching over `()` is more explicit + Err(_) => {}, + //~^ ERROR: matching over `()` is more explicit + }); } // ignored_unit_patterns in derive macro should be ok diff --git a/tests/ui/ignored_unit_patterns.stderr b/tests/ui/ignored_unit_patterns.stderr index 00a254e3919..54ff4454d6b 100644 --- a/tests/ui/ignored_unit_patterns.stderr +++ b/tests/ui/ignored_unit_patterns.stderr @@ -26,31 +26,31 @@ LL | let _ = foo().map_err(|_| todo!()); | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> tests/ui/ignored_unit_patterns.rs:27:16 + --> tests/ui/ignored_unit_patterns.rs:25:12 | -LL | Ok(_) => {}, - | ^ help: use `()` instead of `_`: `()` +LL | Ok(_) => {}, + | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> tests/ui/ignored_unit_patterns.rs:29:17 + --> tests/ui/ignored_unit_patterns.rs:27:13 | -LL | Err(_) => {}, - | ^ help: use `()` instead of `_`: `()` +LL | Err(_) => {}, + | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> tests/ui/ignored_unit_patterns.rs:41:9 + --> tests/ui/ignored_unit_patterns.rs:38:9 | LL | let _ = foo().unwrap(); | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> tests/ui/ignored_unit_patterns.rs:50:13 + --> tests/ui/ignored_unit_patterns.rs:47:13 | LL | (1, _) => unimplemented!(), | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> tests/ui/ignored_unit_patterns.rs:57:13 + --> tests/ui/ignored_unit_patterns.rs:54:13 | LL | for (x, _) in v { | ^ help: use `()` instead of `_`: `()` diff --git a/tests/ui/incompatible_msrv.rs b/tests/ui/incompatible_msrv.rs index 8ef1f554bc3..c23df223d50 100644 --- a/tests/ui/incompatible_msrv.rs +++ b/tests/ui/incompatible_msrv.rs @@ -2,8 +2,8 @@ #![feature(custom_inner_attributes)] #![clippy::msrv = "1.3.0"] -use std::collections::hash_map::Entry; use std::collections::HashMap; +use std::collections::hash_map::Entry; use std::future::Future; use std::thread::sleep; use std::time::Duration; diff --git a/tests/ui/legacy_numeric_constants.fixed b/tests/ui/legacy_numeric_constants.fixed index a6ef8f8c119..3a2294ef4c5 100644 --- a/tests/ui/legacy_numeric_constants.fixed +++ b/tests/ui/legacy_numeric_constants.fixed @@ -22,8 +22,8 @@ macro_rules! b { }; } -use std::u32::MAX; use std::u8::MIN; +use std::u32::MAX; use std::{f64, u32}; #[warn(clippy::legacy_numeric_constants)] @@ -99,8 +99,8 @@ fn allow() { ::std::primitive::u8::MIN; ::std::u8::MIN; ::std::primitive::u8::min_value(); - use std::u64; use std::u8::MIN; + use std::u64; } #[warn(clippy::legacy_numeric_constants)] diff --git a/tests/ui/legacy_numeric_constants.rs b/tests/ui/legacy_numeric_constants.rs index cd633545372..6cb3e694ea1 100644 --- a/tests/ui/legacy_numeric_constants.rs +++ b/tests/ui/legacy_numeric_constants.rs @@ -22,8 +22,8 @@ macro_rules! b { }; } -use std::u32::MAX; use std::u8::MIN; +use std::u32::MAX; use std::{f64, u32}; #[warn(clippy::legacy_numeric_constants)] @@ -99,8 +99,8 @@ fn allow() { ::std::primitive::u8::MIN; ::std::u8::MIN; ::std::primitive::u8::min_value(); - use std::u64; use std::u8::MIN; + use std::u64; } #[warn(clippy::legacy_numeric_constants)] diff --git a/tests/ui/manual_saturating_arithmetic.fixed b/tests/ui/manual_saturating_arithmetic.fixed index 41a32df32ee..528a65790c4 100644 --- a/tests/ui/manual_saturating_arithmetic.fixed +++ b/tests/ui/manual_saturating_arithmetic.fixed @@ -1,6 +1,6 @@ #![allow(clippy::legacy_numeric_constants, unused_imports)] -use std::{i128, i32, u128, u32}; +use std::{i32, i128, u32, u128}; fn main() { let _ = 1u32.saturating_add(1); diff --git a/tests/ui/manual_saturating_arithmetic.rs b/tests/ui/manual_saturating_arithmetic.rs index 3a6b32d8069..55f3720dfcc 100644 --- a/tests/ui/manual_saturating_arithmetic.rs +++ b/tests/ui/manual_saturating_arithmetic.rs @@ -1,6 +1,6 @@ #![allow(clippy::legacy_numeric_constants, unused_imports)] -use std::{i128, i32, u128, u32}; +use std::{i32, i128, u32, u128}; fn main() { let _ = 1u32.checked_add(1).unwrap_or(u32::max_value()); diff --git a/tests/ui/must_use_candidates.fixed b/tests/ui/must_use_candidates.fixed index adb266ffbc8..2459af60688 100644 --- a/tests/ui/must_use_candidates.fixed +++ b/tests/ui/must_use_candidates.fixed @@ -7,8 +7,8 @@ )] #![warn(clippy::must_use_candidate)] use std::rc::Rc; -use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicBool, Ordering}; pub struct MyAtomic(AtomicBool); pub struct MyPure; diff --git a/tests/ui/must_use_candidates.rs b/tests/ui/must_use_candidates.rs index 49bb16af788..5f9b2449552 100644 --- a/tests/ui/must_use_candidates.rs +++ b/tests/ui/must_use_candidates.rs @@ -7,8 +7,8 @@ )] #![warn(clippy::must_use_candidate)] use std::rc::Rc; -use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicBool, Ordering}; pub struct MyAtomic(AtomicBool); pub struct MyPure; diff --git a/tests/ui/mut_key.rs b/tests/ui/mut_key.rs index 81d8732b3b2..43ff705c477 100644 --- a/tests/ui/mut_key.rs +++ b/tests/ui/mut_key.rs @@ -2,9 +2,9 @@ use std::cell::Cell; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::hash::{Hash, Hasher}; use std::rc::Rc; +use std::sync::Arc; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::Relaxed; -use std::sync::Arc; struct Key(AtomicUsize); diff --git a/tests/ui/non_zero_suggestions.fixed b/tests/ui/non_zero_suggestions.fixed index 9851063782e..e67c992fdde 100644 --- a/tests/ui/non_zero_suggestions.fixed +++ b/tests/ui/non_zero_suggestions.fixed @@ -1,5 +1,5 @@ #![warn(clippy::non_zero_suggestions)] -use std::num::{NonZeroI16, NonZeroI8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; +use std::num::{NonZeroI8, NonZeroI16, NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; fn main() { /// Positive test cases (lint should trigger) diff --git a/tests/ui/non_zero_suggestions.rs b/tests/ui/non_zero_suggestions.rs index 1605c459248..de82371a8f2 100644 --- a/tests/ui/non_zero_suggestions.rs +++ b/tests/ui/non_zero_suggestions.rs @@ -1,5 +1,5 @@ #![warn(clippy::non_zero_suggestions)] -use std::num::{NonZeroI16, NonZeroI8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; +use std::num::{NonZeroI8, NonZeroI16, NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; fn main() { /// Positive test cases (lint should trigger) diff --git a/tests/ui/non_zero_suggestions_unfixable.rs b/tests/ui/non_zero_suggestions_unfixable.rs index 4eb22a8d4c7..193c710e589 100644 --- a/tests/ui/non_zero_suggestions_unfixable.rs +++ b/tests/ui/non_zero_suggestions_unfixable.rs @@ -1,6 +1,6 @@ #![warn(clippy::non_zero_suggestions)] //@no-rustfix -use std::num::{NonZeroI16, NonZeroI8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; +use std::num::{NonZeroI8, NonZeroI16, NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; fn main() { let x: u64 = u64::from(NonZeroU32::new(5).unwrap().get()); diff --git a/tests/ui/single_match.fixed b/tests/ui/single_match.fixed index dcf5a1d33c2..4016b2699d6 100644 --- a/tests/ui/single_match.fixed +++ b/tests/ui/single_match.fixed @@ -39,8 +39,8 @@ enum Foo { Bar, Baz(u8), } -use std::borrow::Cow; use Foo::*; +use std::borrow::Cow; fn single_match_know_enum() { let x = Some(1u8); diff --git a/tests/ui/single_match.rs b/tests/ui/single_match.rs index 3ba5eebd01b..75edaa60605 100644 --- a/tests/ui/single_match.rs +++ b/tests/ui/single_match.rs @@ -51,8 +51,8 @@ enum Foo { Bar, Baz(u8), } -use std::borrow::Cow; use Foo::*; +use std::borrow::Cow; fn single_match_know_enum() { let x = Some(1u8); diff --git a/tests/ui/suspicious_to_owned.rs b/tests/ui/suspicious_to_owned.rs index f32b07d45f6..794c2e7174a 100644 --- a/tests/ui/suspicious_to_owned.rs +++ b/tests/ui/suspicious_to_owned.rs @@ -3,7 +3,7 @@ #![warn(clippy::implicit_clone)] #![allow(clippy::redundant_clone)] use std::borrow::Cow; -use std::ffi::{c_char, CStr}; +use std::ffi::{CStr, c_char}; fn main() { let moo = "Moooo"; diff --git a/tests/ui/transmute_collection.rs b/tests/ui/transmute_collection.rs index e30b34a5d7d..6748b66e0eb 100644 --- a/tests/ui/transmute_collection.rs +++ b/tests/ui/transmute_collection.rs @@ -2,7 +2,7 @@ #![allow(clippy::missing_transmute_annotations)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; -use std::mem::{transmute, MaybeUninit}; +use std::mem::{MaybeUninit, transmute}; fn main() { unsafe { diff --git a/tests/ui/transmute_undefined_repr.rs b/tests/ui/transmute_undefined_repr.rs index dd4bac7f1ed..5b16d71f114 100644 --- a/tests/ui/transmute_undefined_repr.rs +++ b/tests/ui/transmute_undefined_repr.rs @@ -8,7 +8,7 @@ use core::any::TypeId; use core::ffi::c_void; -use core::mem::{size_of, transmute, MaybeUninit}; +use core::mem::{MaybeUninit, size_of, transmute}; use core::ptr::NonNull; fn value() -> T { -- cgit 1.4.1-3-g733a5 From 66f1f544afaf7e277fefa7702bcc91ca498879c5 Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Sun, 18 Aug 2024 07:32:24 -0400 Subject: Fix `clippy_lints` and `clippy_utils` --- clippy_lints/src/booleans.rs | 8 ++++---- clippy_lints/src/box_default.rs | 2 +- clippy_lints/src/checked_conversions.rs | 2 +- clippy_lints/src/default_numeric_fallback.rs | 2 +- clippy_lints/src/doc/mod.rs | 2 +- clippy_lints/src/empty_enum.rs | 2 +- clippy_lints/src/escape.rs | 4 ++-- clippy_lints/src/excessive_nesting.rs | 2 +- clippy_lints/src/extra_unused_type_parameters.rs | 2 +- clippy_lints/src/fallible_impl_from.rs | 2 +- clippy_lints/src/format_args.rs | 2 +- clippy_lints/src/format_impl.rs | 2 +- clippy_lints/src/from_over_into.rs | 2 +- clippy_lints/src/implicit_hasher.rs | 4 ++-- clippy_lints/src/index_refutable_slice.rs | 2 +- clippy_lints/src/lifetimes.rs | 2 +- clippy_lints/src/loops/manual_memcpy.rs | 2 +- clippy_lints/src/loops/needless_range_loop.rs | 4 ++-- clippy_lints/src/loops/same_item_push.rs | 2 +- clippy_lints/src/loops/utils.rs | 4 ++-- clippy_lints/src/loops/while_immutable_condition.rs | 4 ++-- clippy_lints/src/loops/while_let_on_iterator.rs | 2 +- clippy_lints/src/macro_metavars_in_unsafe.rs | 2 +- clippy_lints/src/macro_use.rs | 2 +- clippy_lints/src/manual_clamp.rs | 2 +- clippy_lints/src/manual_strip.rs | 2 +- clippy_lints/src/map_unit_fn.rs | 2 +- clippy_lints/src/matches/match_str_case_mismatch.rs | 4 ++-- clippy_lints/src/matches/overlapping_arms.rs | 4 ++-- clippy_lints/src/matches/significant_drop_in_scrutinee.rs | 4 ++-- clippy_lints/src/methods/needless_collect.rs | 2 +- clippy_lints/src/methods/option_map_unwrap_or.rs | 4 ++-- clippy_lints/src/methods/utils.rs | 4 ++-- clippy_lints/src/mixed_read_write_in_expression.rs | 6 +++--- clippy_lints/src/mut_mut.rs | 2 +- clippy_lints/src/mutable_debug_assertion.rs | 2 +- clippy_lints/src/needless_for_each.rs | 2 +- clippy_lints/src/needless_pass_by_ref_mut.rs | 2 +- clippy_lints/src/non_expressive_names.rs | 10 +++++----- clippy_lints/src/non_send_fields_in_send_ty.rs | 2 +- clippy_lints/src/pass_by_ref_or_value.rs | 4 ++-- clippy_lints/src/pathbuf_init_then_push.rs | 2 +- clippy_lints/src/redundant_closure_call.rs | 2 +- clippy_lints/src/returns.rs | 4 ++-- clippy_lints/src/significant_drop_tightening.rs | 2 +- clippy_lints/src/single_component_path_imports.rs | 2 +- clippy_lints/src/slow_vector_initialization.rs | 4 ++-- clippy_lints/src/swap.rs | 2 +- clippy_lints/src/unused_async.rs | 2 +- clippy_lints/src/unwrap.rs | 4 ++-- clippy_lints/src/use_self.rs | 2 +- .../src/utils/internal_lints/lint_without_lint_pass.rs | 2 +- clippy_lints/src/zombie_processes.rs | 4 ++-- clippy_utils/src/consts.rs | 6 +++--- clippy_utils/src/eager_or_lazy.rs | 2 +- clippy_utils/src/lib.rs | 4 ++-- clippy_utils/src/mir/mod.rs | 2 +- clippy_utils/src/mir/possible_borrower.rs | 6 +++--- clippy_utils/src/mir/possible_origin.rs | 2 +- clippy_utils/src/ty/type_certainty/mod.rs | 2 +- clippy_utils/src/usage.rs | 6 +++--- clippy_utils/src/visitors.rs | 4 ++-- 62 files changed, 94 insertions(+), 94 deletions(-) (limited to 'clippy_lints/src/mutable_debug_assertion.rs') diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 3c2af72624f..87aaf7ec16d 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -205,7 +205,7 @@ struct Hir2Qmm<'a, 'tcx, 'v> { cx: &'a LateContext<'tcx>, } -impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> { +impl<'v> Hir2Qmm<'_, '_, 'v> { fn extract(&mut self, op: BinOpKind, a: &[&'v Expr<'_>], mut v: Vec) -> Result, String> { for a in a { if let ExprKind::Binary(binop, lhs, rhs) = &a.kind { @@ -292,7 +292,7 @@ struct SuggestContext<'a, 'tcx, 'v> { output: String, } -impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> { +impl SuggestContext<'_, '_, '_> { fn recurse(&mut self, suggestion: &Bool) -> Option<()> { use quine_mc_cluskey::Bool::{And, False, Not, Or, Term, True}; match suggestion { @@ -475,7 +475,7 @@ fn terminal_stats(b: &Bool) -> Stats { stats } -impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> { +impl<'tcx> NonminimalBoolVisitor<'_, 'tcx> { fn bool_expr(&self, e: &'tcx Expr<'_>) { let mut h2q = Hir2Qmm { terminals: Vec::new(), @@ -582,7 +582,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'_, 'tcx> { fn visit_expr(&mut self, e: &'tcx Expr<'_>) { if !e.span.from_expansion() { match &e.kind { diff --git a/clippy_lints/src/box_default.rs b/clippy_lints/src/box_default.rs index 8261c65354f..40d154c0bdf 100644 --- a/clippy_lints/src/box_default.rs +++ b/clippy_lints/src/box_default.rs @@ -91,7 +91,7 @@ fn is_local_vec_expn(cx: &LateContext<'_>, expr: &Expr<'_>, ref_expr: &Expr<'_>) #[derive(Default)] struct InferVisitor(bool); -impl<'tcx> Visitor<'tcx> for InferVisitor { +impl Visitor<'_> for InferVisitor { fn visit_ty(&mut self, t: &Ty<'_>) { self.0 |= matches!(t.kind, TyKind::Infer | TyKind::OpaqueDef(..) | TyKind::TraitObject(..)); if !self.0 { diff --git a/clippy_lints/src/checked_conversions.rs b/clippy_lints/src/checked_conversions.rs index d3aa2fd1ea1..2e7f91a842e 100644 --- a/clippy_lints/src/checked_conversions.rs +++ b/clippy_lints/src/checked_conversions.rs @@ -48,7 +48,7 @@ impl CheckedConversions { impl_lint_pass!(CheckedConversions => [CHECKED_CONVERSIONS]); -impl<'tcx> LateLintPass<'tcx> for CheckedConversions { +impl LateLintPass<'_> for CheckedConversions { fn check_expr(&mut self, cx: &LateContext<'_>, item: &Expr<'_>) { if let ExprKind::Binary(op, lhs, rhs) = item.kind && let (lt1, gt1, op2) = match op.node { diff --git a/clippy_lints/src/default_numeric_fallback.rs b/clippy_lints/src/default_numeric_fallback.rs index a065dc2cf7e..4808c372754 100644 --- a/clippy_lints/src/default_numeric_fallback.rs +++ b/clippy_lints/src/default_numeric_fallback.rs @@ -119,7 +119,7 @@ impl<'a, 'tcx> NumericFallbackVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for NumericFallbackVisitor<'_, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { match &expr.kind { ExprKind::Block( diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 0ae1fad5692..e090644ae44 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -970,7 +970,7 @@ impl<'a, 'tcx> FindPanicUnwrap<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for FindPanicUnwrap<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { diff --git a/clippy_lints/src/empty_enum.rs b/clippy_lints/src/empty_enum.rs index f4c55738cb8..70eb81fa09c 100644 --- a/clippy_lints/src/empty_enum.rs +++ b/clippy_lints/src/empty_enum.rs @@ -60,7 +60,7 @@ declare_clippy_lint! { declare_lint_pass!(EmptyEnum => [EMPTY_ENUM]); -impl<'tcx> LateLintPass<'tcx> for EmptyEnum { +impl LateLintPass<'_> for EmptyEnum { fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) { if let ItemKind::Enum(..) = item.kind // Only suggest the `never_type` if the feature is enabled diff --git a/clippy_lints/src/escape.rs b/clippy_lints/src/escape.rs index 5588124e791..a89f0d9c432 100644 --- a/clippy_lints/src/escape.rs +++ b/clippy_lints/src/escape.rs @@ -141,7 +141,7 @@ fn is_argument(tcx: TyCtxt<'_>, id: HirId) -> bool { matches!(tcx.parent_hir_node(id), Node::Param(_)) } -impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { +impl<'tcx> Delegate<'tcx> for EscapeDelegate<'_, 'tcx> { fn consume(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId) { if cmt.place.projections.is_empty() { if let PlaceBase::Local(lid) = cmt.place.base { @@ -188,7 +188,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { fn fake_read(&mut self, _: &PlaceWithHirId<'tcx>, _: FakeReadCause, _: HirId) {} } -impl<'a, 'tcx> EscapeDelegate<'a, 'tcx> { +impl<'tcx> EscapeDelegate<'_, 'tcx> { fn is_large_box(&self, ty: Ty<'tcx>) -> bool { // Large types need to be boxed to avoid stack overflows. if let Some(boxed_ty) = ty.boxed_ty() { diff --git a/clippy_lints/src/excessive_nesting.rs b/clippy_lints/src/excessive_nesting.rs index ce0e0faa014..ffc76366983 100644 --- a/clippy_lints/src/excessive_nesting.rs +++ b/clippy_lints/src/excessive_nesting.rs @@ -135,7 +135,7 @@ impl NestingVisitor<'_, '_> { } } -impl<'conf, 'cx> Visitor<'_> for NestingVisitor<'conf, 'cx> { +impl Visitor<'_> for NestingVisitor<'_, '_> { fn visit_block(&mut self, block: &Block) { if block.span.from_expansion() { return; diff --git a/clippy_lints/src/extra_unused_type_parameters.rs b/clippy_lints/src/extra_unused_type_parameters.rs index bf9388b4a70..3b93d3ff93e 100644 --- a/clippy_lints/src/extra_unused_type_parameters.rs +++ b/clippy_lints/src/extra_unused_type_parameters.rs @@ -193,7 +193,7 @@ fn bound_to_trait_def_id(bound: &GenericBound<'_>) -> Option { bound.trait_ref()?.trait_def_id()?.as_local() } -impl<'cx, 'tcx> Visitor<'tcx> for TypeWalker<'cx, 'tcx> { +impl<'tcx> Visitor<'tcx> for TypeWalker<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_ty(&mut self, t: &'tcx Ty<'tcx>) { diff --git a/clippy_lints/src/fallible_impl_from.rs b/clippy_lints/src/fallible_impl_from.rs index 747ea9a4344..f822432cce6 100644 --- a/clippy_lints/src/fallible_impl_from.rs +++ b/clippy_lints/src/fallible_impl_from.rs @@ -73,7 +73,7 @@ fn lint_impl_body(cx: &LateContext<'_>, impl_span: Span, impl_items: &[hir::Impl result: Vec, } - impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> { + impl<'tcx> Visitor<'tcx> for FindPanicUnwrap<'_, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { if let Some(macro_call) = root_macro_call_first_node(self.lcx, expr) { if is_panic(self.lcx, macro_call.def_id) { diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index 83ab9f6557b..4c043f8dc14 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -219,7 +219,7 @@ struct FormatArgsExpr<'a, 'tcx> { ignore_mixed: bool, } -impl<'a, 'tcx> FormatArgsExpr<'a, 'tcx> { +impl FormatArgsExpr<'_, '_> { fn check_templates(&self) { for piece in &self.format_args.template { if let FormatArgsPiece::Placeholder(placeholder) = piece diff --git a/clippy_lints/src/format_impl.rs b/clippy_lints/src/format_impl.rs index c196f404ce6..7c0515b8c56 100644 --- a/clippy_lints/src/format_impl.rs +++ b/clippy_lints/src/format_impl.rs @@ -148,7 +148,7 @@ struct FormatImplExpr<'a, 'tcx> { format_trait_impl: FormatTraitNames, } -impl<'a, 'tcx> FormatImplExpr<'a, 'tcx> { +impl FormatImplExpr<'_, '_> { fn check_to_string_in_display(&self) { if self.format_trait_impl.name == sym::Display && let ExprKind::MethodCall(path, self_arg, ..) = self.expr.kind diff --git a/clippy_lints/src/from_over_into.rs b/clippy_lints/src/from_over_into.rs index d716a624cc6..0aac81fa388 100644 --- a/clippy_lints/src/from_over_into.rs +++ b/clippy_lints/src/from_over_into.rs @@ -126,7 +126,7 @@ struct SelfFinder<'a, 'tcx> { invalid: bool, } -impl<'a, 'tcx> Visitor<'tcx> for SelfFinder<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for SelfFinder<'_, 'tcx> { type NestedFilter = OnlyBodies; fn nested_visit_map(&mut self) -> Self::Map { diff --git a/clippy_lints/src/implicit_hasher.rs b/clippy_lints/src/implicit_hasher.rs index f683925145a..4c5375730b8 100644 --- a/clippy_lints/src/implicit_hasher.rs +++ b/clippy_lints/src/implicit_hasher.rs @@ -281,7 +281,7 @@ impl<'a, 'tcx> ImplicitHasherTypeVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for ImplicitHasherTypeVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for ImplicitHasherTypeVisitor<'_, 'tcx> { fn visit_ty(&mut self, t: &'tcx hir::Ty<'_>) { if let Some(target) = ImplicitHasherType::new(self.cx, t) { self.found.push(target); @@ -318,7 +318,7 @@ impl<'a, 'b, 'tcx> ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> { } } -impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> { +impl<'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'_, '_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_body(&mut self, body: &Body<'tcx>) { diff --git a/clippy_lints/src/index_refutable_slice.rs b/clippy_lints/src/index_refutable_slice.rs index 39afb6810b8..73ebe6aec15 100644 --- a/clippy_lints/src/index_refutable_slice.rs +++ b/clippy_lints/src/index_refutable_slice.rs @@ -226,7 +226,7 @@ struct SliceIndexLintingVisitor<'a, 'tcx> { max_suggested_slice: u64, } -impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn nested_visit_map(&mut self) -> Self::Map { diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 42083b1a879..5a3c749cab1 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -397,7 +397,7 @@ impl<'a, 'tcx> RefVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for RefVisitor<'_, 'tcx> { // for lifetimes as parameters of generics fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) { self.lts.push(*lifetime); diff --git a/clippy_lints/src/loops/manual_memcpy.rs b/clippy_lints/src/loops/manual_memcpy.rs index a7c1d1bd6cd..68d063ad5e5 100644 --- a/clippy_lints/src/loops/manual_memcpy.rs +++ b/clippy_lints/src/loops/manual_memcpy.rs @@ -209,7 +209,7 @@ fn build_manual_memcpy_suggestion<'tcx>( #[derive(Clone)] struct MinifyingSugg<'a>(Sugg<'a>); -impl<'a> Display for MinifyingSugg<'a> { +impl Display for MinifyingSugg<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } diff --git a/clippy_lints/src/loops/needless_range_loop.rs b/clippy_lints/src/loops/needless_range_loop.rs index 20dd5a311dc..745f070a577 100644 --- a/clippy_lints/src/loops/needless_range_loop.rs +++ b/clippy_lints/src/loops/needless_range_loop.rs @@ -241,7 +241,7 @@ struct VarVisitor<'a, 'tcx> { prefer_mutable: bool, } -impl<'a, 'tcx> VarVisitor<'a, 'tcx> { +impl<'tcx> VarVisitor<'_, 'tcx> { fn check(&mut self, idx: &'tcx Expr<'_>, seqexpr: &'tcx Expr<'_>, expr: &'tcx Expr<'_>) -> bool { if let ExprKind::Path(ref seqpath) = seqexpr.kind // the indexed container is referenced by a name @@ -292,7 +292,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for VarVisitor<'_, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { if let ExprKind::MethodCall(meth, args_0, [args_1, ..], _) = &expr.kind // a range index op diff --git a/clippy_lints/src/loops/same_item_push.rs b/clippy_lints/src/loops/same_item_push.rs index 5662d3013e1..f8659897ffe 100644 --- a/clippy_lints/src/loops/same_item_push.rs +++ b/clippy_lints/src/loops/same_item_push.rs @@ -123,7 +123,7 @@ impl<'a, 'tcx> SameItemPushVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for SameItemPushVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for SameItemPushVisitor<'_, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { match &expr.kind { // Non-determinism may occur ... don't give a lint diff --git a/clippy_lints/src/loops/utils.rs b/clippy_lints/src/loops/utils.rs index 9a89a41d2b3..c4c504e1ae4 100644 --- a/clippy_lints/src/loops/utils.rs +++ b/clippy_lints/src/loops/utils.rs @@ -44,7 +44,7 @@ impl<'a, 'tcx> IncrementVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for IncrementVisitor<'_, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { // If node is a variable if let Some(def_id) = path_to_local(expr) { @@ -138,7 +138,7 @@ impl<'a, 'tcx> InitializeVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for InitializeVisitor<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_local(&mut self, l: &'tcx LetStmt<'_>) { diff --git a/clippy_lints/src/loops/while_immutable_condition.rs b/clippy_lints/src/loops/while_immutable_condition.rs index eab096e9a22..1a1cde3c5bd 100644 --- a/clippy_lints/src/loops/while_immutable_condition.rs +++ b/clippy_lints/src/loops/while_immutable_condition.rs @@ -84,7 +84,7 @@ struct VarCollectorVisitor<'a, 'tcx> { skip: bool, } -impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> { +impl<'tcx> VarCollectorVisitor<'_, 'tcx> { fn insert_def_id(&mut self, ex: &'tcx Expr<'_>) { if let ExprKind::Path(ref qpath) = ex.kind && let QPath::Resolved(None, _) = *qpath @@ -103,7 +103,7 @@ impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for VarCollectorVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for VarCollectorVisitor<'_, 'tcx> { fn visit_expr(&mut self, ex: &'tcx Expr<'_>) { match ex.kind { ExprKind::Path(_) => self.insert_def_id(ex), diff --git a/clippy_lints/src/loops/while_let_on_iterator.rs b/clippy_lints/src/loops/while_let_on_iterator.rs index 7d9fbaf3cea..74467522619 100644 --- a/clippy_lints/src/loops/while_let_on_iterator.rs +++ b/clippy_lints/src/loops/while_let_on_iterator.rs @@ -283,7 +283,7 @@ fn needs_mutable_borrow(cx: &LateContext<'_>, iter_expr: &IterExpr, loop_expr: & found_local: bool, used_after: bool, } - impl<'a, 'b, 'tcx> Visitor<'tcx> for NestedLoopVisitor<'a, 'b, 'tcx> { + impl<'tcx> Visitor<'tcx> for NestedLoopVisitor<'_, '_, 'tcx> { type NestedFilter = OnlyBodies; fn nested_visit_map(&mut self) -> Self::Map { self.cx.tcx.hir() diff --git a/clippy_lints/src/macro_metavars_in_unsafe.rs b/clippy_lints/src/macro_metavars_in_unsafe.rs index ccc554042d6..312bcb55a95 100644 --- a/clippy_lints/src/macro_metavars_in_unsafe.rs +++ b/clippy_lints/src/macro_metavars_in_unsafe.rs @@ -149,7 +149,7 @@ fn is_public_macro(cx: &LateContext<'_>, def_id: LocalDefId) -> bool { && !cx.tcx.is_doc_hidden(def_id) } -impl<'a, 'tcx> Visitor<'tcx> for BodyVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for BodyVisitor<'_, 'tcx> { fn visit_stmt(&mut self, s: &'tcx Stmt<'tcx>) { let from_expn = s.span.from_expansion(); if from_expn { diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs index bd6b3f1a47b..50680331fbc 100644 --- a/clippy_lints/src/macro_use.rs +++ b/clippy_lints/src/macro_use.rs @@ -81,7 +81,7 @@ impl MacroUseImports { } } -impl<'tcx> LateLintPass<'tcx> for MacroUseImports { +impl LateLintPass<'_> for MacroUseImports { fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) { if cx.sess().opts.edition >= Edition::Edition2018 && let hir::ItemKind::Use(path, _kind) = &item.kind diff --git a/clippy_lints/src/manual_clamp.rs b/clippy_lints/src/manual_clamp.rs index 788649fd4f9..fd66cacdfe9 100644 --- a/clippy_lints/src/manual_clamp.rs +++ b/clippy_lints/src/manual_clamp.rs @@ -741,7 +741,7 @@ enum MaybeBorrowedStmtKind<'a> { Owned(StmtKind<'a>), } -impl<'a> Clone for MaybeBorrowedStmtKind<'a> { +impl Clone for MaybeBorrowedStmtKind<'_> { fn clone(&self) -> Self { match self { Self::Borrowed(t) => Self::Borrowed(t), diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index 9aceca66bf7..828c5a3f6ff 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -203,7 +203,7 @@ fn find_stripping<'tcx>( results: Vec, } - impl<'a, 'tcx> Visitor<'tcx> for StrippingFinder<'a, 'tcx> { + impl<'tcx> Visitor<'tcx> for StrippingFinder<'_, 'tcx> { fn visit_expr(&mut self, ex: &'tcx Expr<'_>) { if is_ref_str(self.cx, ex) && let unref = peel_ref(ex) diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index a97dbbbc33f..3221a04d2d0 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -251,7 +251,7 @@ fn lint_map_unit_fn( } } -impl<'tcx> LateLintPass<'tcx> for MapUnit { +impl LateLintPass<'_> for MapUnit { fn check_stmt(&mut self, cx: &LateContext<'_>, stmt: &hir::Stmt<'_>) { if let hir::StmtKind::Semi(expr) = stmt.kind && !stmt.span.from_expansion() diff --git a/clippy_lints/src/matches/match_str_case_mismatch.rs b/clippy_lints/src/matches/match_str_case_mismatch.rs index 40518ce2ca7..463aa602bc8 100644 --- a/clippy_lints/src/matches/match_str_case_mismatch.rs +++ b/clippy_lints/src/matches/match_str_case_mismatch.rs @@ -40,7 +40,7 @@ struct MatchExprVisitor<'a, 'tcx> { case_method: Option, } -impl<'a, 'tcx> Visitor<'tcx> for MatchExprVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for MatchExprVisitor<'_, 'tcx> { fn visit_expr(&mut self, ex: &'tcx Expr<'_>) { match ex.kind { ExprKind::MethodCall(segment, receiver, [], _) if self.case_altered(segment.ident.as_str(), receiver) => {}, @@ -49,7 +49,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MatchExprVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> MatchExprVisitor<'a, 'tcx> { +impl MatchExprVisitor<'_, '_> { fn case_altered(&mut self, segment_ident: &str, receiver: &Expr<'_>) -> bool { if let Some(case_method) = get_case_method(segment_ident) { let ty = self.cx.typeck_results().expr_ty(receiver).peel_refs(); diff --git a/clippy_lints/src/matches/overlapping_arms.rs b/clippy_lints/src/matches/overlapping_arms.rs index 6a4c553cee0..856311899f2 100644 --- a/clippy_lints/src/matches/overlapping_arms.rs +++ b/clippy_lints/src/matches/overlapping_arms.rs @@ -96,13 +96,13 @@ where #[derive(Copy, Clone, Debug, Eq, PartialEq)] struct RangeBound<'a, T>(T, BoundKind, &'a SpannedRange); - impl<'a, T: Copy + Ord> PartialOrd for RangeBound<'a, T> { + impl PartialOrd for RangeBound<'_, T> { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } - impl<'a, T: Copy + Ord> Ord for RangeBound<'a, T> { + impl Ord for RangeBound<'_, T> { fn cmp(&self, RangeBound(other_value, other_kind, _): &Self) -> Ordering { let RangeBound(self_value, self_kind, _) = *self; (self_value, self_kind).cmp(&(*other_value, *other_kind)) diff --git a/clippy_lints/src/matches/significant_drop_in_scrutinee.rs b/clippy_lints/src/matches/significant_drop_in_scrutinee.rs index 537f7272f7f..7372f52e1e5 100644 --- a/clippy_lints/src/matches/significant_drop_in_scrutinee.rs +++ b/clippy_lints/src/matches/significant_drop_in_scrutinee.rs @@ -424,7 +424,7 @@ fn ty_has_erased_regions(ty: Ty<'_>) -> bool { ty.visit_with(&mut V).is_break() } -impl<'a, 'tcx> Visitor<'tcx> for SigDropHelper<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for SigDropHelper<'_, 'tcx> { fn visit_expr(&mut self, ex: &'tcx Expr<'_>) { // We've emitted a lint on some neighborhood expression. That lint will suggest to move out the // _parent_ expression (not the expression itself). Since we decide to move out the parent @@ -495,7 +495,7 @@ fn has_significant_drop_in_arms<'tcx>(cx: &LateContext<'tcx>, arms: &[&'tcx Expr helper.found_sig_drop_spans } -impl<'a, 'tcx> Visitor<'tcx> for ArmSigDropHelper<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for ArmSigDropHelper<'_, 'tcx> { fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) { if self.sig_drop_checker.is_sig_drop_expr(ex) { self.found_sig_drop_spans.insert(ex.span); diff --git a/clippy_lints/src/methods/needless_collect.rs b/clippy_lints/src/methods/needless_collect.rs index 421c7a5e070..c58e27e37ad 100644 --- a/clippy_lints/src/methods/needless_collect.rs +++ b/clippy_lints/src/methods/needless_collect.rs @@ -441,7 +441,7 @@ struct UsedCountVisitor<'a, 'tcx> { count: usize, } -impl<'a, 'tcx> Visitor<'tcx> for UsedCountVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for UsedCountVisitor<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs index b160ab6de8e..528e2204cf8 100644 --- a/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -130,7 +130,7 @@ struct UnwrapVisitor<'a, 'tcx> { identifiers: FxHashSet, } -impl<'a, 'tcx> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for UnwrapVisitor<'_, 'tcx> { type NestedFilter = nested_filter::All; fn visit_path(&mut self, path: &Path<'tcx>, _: HirId) { @@ -154,7 +154,7 @@ struct ReferenceVisitor<'a, 'tcx> { unwrap_or_span: Span, } -impl<'a, 'tcx> Visitor<'tcx> for ReferenceVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for ReferenceVisitor<'_, 'tcx> { type NestedFilter = nested_filter::All; type Result = ControlFlow<()>; fn visit_expr(&mut self, expr: &'tcx rustc_hir::Expr<'_>) -> ControlFlow<()> { diff --git a/clippy_lints/src/methods/utils.rs b/clippy_lints/src/methods/utils.rs index 4e33dc1df54..cf0ee569f13 100644 --- a/clippy_lints/src/methods/utils.rs +++ b/clippy_lints/src/methods/utils.rs @@ -86,7 +86,7 @@ struct CloneOrCopyVisitor<'cx, 'tcx> { references_to_binding: Vec<(Span, String)>, } -impl<'cx, 'tcx> Visitor<'tcx> for CloneOrCopyVisitor<'cx, 'tcx> { +impl<'tcx> Visitor<'tcx> for CloneOrCopyVisitor<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn nested_visit_map(&mut self) -> Self::Map { @@ -123,7 +123,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for CloneOrCopyVisitor<'cx, 'tcx> { } } -impl<'cx, 'tcx> CloneOrCopyVisitor<'cx, 'tcx> { +impl<'tcx> CloneOrCopyVisitor<'_, 'tcx> { fn is_binding(&self, expr: &Expr<'tcx>) -> bool { self.binding_hir_ids .iter() diff --git a/clippy_lints/src/mixed_read_write_in_expression.rs b/clippy_lints/src/mixed_read_write_in_expression.rs index d333b71edb1..a7452c8a3c8 100644 --- a/clippy_lints/src/mixed_read_write_in_expression.rs +++ b/clippy_lints/src/mixed_read_write_in_expression.rs @@ -116,7 +116,7 @@ struct DivergenceVisitor<'a, 'tcx> { cx: &'a LateContext<'tcx>, } -impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> { +impl<'tcx> DivergenceVisitor<'_, 'tcx> { fn maybe_walk_expr(&mut self, e: &'tcx Expr<'_>) { match e.kind { ExprKind::Closure(..) | ExprKind::If(..) | ExprKind::Loop(..) => {}, @@ -148,7 +148,7 @@ fn stmt_might_diverge(stmt: &Stmt<'_>) -> bool { !matches!(stmt.kind, StmtKind::Item(..)) } -impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for DivergenceVisitor<'_, 'tcx> { fn visit_expr(&mut self, e: &'tcx Expr<'_>) { match e.kind { // fix #10776 @@ -321,7 +321,7 @@ struct ReadVisitor<'a, 'tcx> { last_expr: &'tcx Expr<'tcx>, } -impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for ReadVisitor<'_, 'tcx> { fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { if expr.hir_id == self.last_expr.hir_id { return; diff --git a/clippy_lints/src/mut_mut.rs b/clippy_lints/src/mut_mut.rs index 60372121a7a..6cddd7ea813 100644 --- a/clippy_lints/src/mut_mut.rs +++ b/clippy_lints/src/mut_mut.rs @@ -55,7 +55,7 @@ pub struct MutVisitor<'a, 'tcx> { cx: &'a LateContext<'tcx>, } -impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> { +impl<'tcx> intravisit::Visitor<'tcx> for MutVisitor<'_, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) { if in_external_macro(self.cx.sess(), expr.span) { return; diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index 6ab811b4f2f..e589b3608b3 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -87,7 +87,7 @@ impl<'a, 'tcx> MutArgVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for MutArgVisitor<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { diff --git a/clippy_lints/src/needless_for_each.rs b/clippy_lints/src/needless_for_each.rs index b54eb164e81..93e20f37ef8 100644 --- a/clippy_lints/src/needless_for_each.rs +++ b/clippy_lints/src/needless_for_each.rs @@ -133,7 +133,7 @@ struct RetCollector { loop_depth: u16, } -impl<'tcx> Visitor<'tcx> for RetCollector { +impl Visitor<'_> for RetCollector { fn visit_expr(&mut self, expr: &Expr<'_>) { match expr.kind { ExprKind::Ret(..) => { diff --git a/clippy_lints/src/needless_pass_by_ref_mut.rs b/clippy_lints/src/needless_pass_by_ref_mut.rs index 19cbf595908..c2facb2fcf6 100644 --- a/clippy_lints/src/needless_pass_by_ref_mut.rs +++ b/clippy_lints/src/needless_pass_by_ref_mut.rs @@ -311,7 +311,7 @@ struct MutablyUsedVariablesCtxt<'tcx> { tcx: TyCtxt<'tcx>, } -impl<'tcx> MutablyUsedVariablesCtxt<'tcx> { +impl MutablyUsedVariablesCtxt<'_> { fn add_mutably_used_var(&mut self, used_id: HirId) { self.mutably_used_vars.insert(used_id); } diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index d85032e9eee..2fee1c72a91 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -104,7 +104,7 @@ struct SimilarNamesLocalVisitor<'a, 'tcx> { single_char_names: Vec>, } -impl<'a, 'tcx> SimilarNamesLocalVisitor<'a, 'tcx> { +impl SimilarNamesLocalVisitor<'_, '_> { fn check_single_char_names(&self) { if self.single_char_names.last().map(Vec::len) == Some(0) { return; @@ -152,7 +152,7 @@ fn chars_are_similar(a: char, b: char) -> bool { struct SimilarNamesNameVisitor<'a, 'tcx, 'b>(&'b mut SimilarNamesLocalVisitor<'a, 'tcx>); -impl<'a, 'tcx, 'b> Visitor<'tcx> for SimilarNamesNameVisitor<'a, 'tcx, 'b> { +impl<'tcx> Visitor<'tcx> for SimilarNamesNameVisitor<'_, 'tcx, '_> { fn visit_pat(&mut self, pat: &'tcx Pat) { match pat.kind { PatKind::Ident(_, ident, _) => { @@ -189,7 +189,7 @@ fn allowed_to_be_similar(interned_name: &str, list: &[&str]) -> bool { .any(|&name| interned_name.starts_with(name) || interned_name.ends_with(name)) } -impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> { +impl SimilarNamesNameVisitor<'_, '_, '_> { fn check_short_ident(&mut self, ident: Ident) { // Ignore shadowing if self @@ -329,7 +329,7 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> { } } -impl<'a, 'b> SimilarNamesLocalVisitor<'a, 'b> { +impl SimilarNamesLocalVisitor<'_, '_> { /// ensure scoping rules work fn apply Fn(&'c mut Self)>(&mut self, f: F) { let n = self.names.len(); @@ -340,7 +340,7 @@ impl<'a, 'b> SimilarNamesLocalVisitor<'a, 'b> { } } -impl<'a, 'tcx> Visitor<'tcx> for SimilarNamesLocalVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for SimilarNamesLocalVisitor<'_, 'tcx> { fn visit_local(&mut self, local: &'tcx Local) { if let Some((init, els)) = &local.kind.init_else_opt() { self.apply(|this| walk_expr(this, init)); diff --git a/clippy_lints/src/non_send_fields_in_send_ty.rs b/clippy_lints/src/non_send_fields_in_send_ty.rs index a60988ac5db..793eb5d9456 100644 --- a/clippy_lints/src/non_send_fields_in_send_ty.rs +++ b/clippy_lints/src/non_send_fields_in_send_ty.rs @@ -159,7 +159,7 @@ struct NonSendField<'tcx> { generic_params: Vec>, } -impl<'tcx> NonSendField<'tcx> { +impl NonSendField<'_> { fn generic_params_string(&self) -> String { self.generic_params .iter() diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index 75d8c09f2b0..1bddfab39c6 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -110,7 +110,7 @@ pub struct PassByRefOrValue { avoid_breaking_exported_api: bool, } -impl<'tcx> PassByRefOrValue { +impl PassByRefOrValue { pub fn new(tcx: TyCtxt<'_>, conf: &'static Conf) -> Self { let ref_min_size = conf.trivial_copy_size_limit.unwrap_or_else(|| { let bit_width = u64::from(tcx.sess.target.pointer_width); @@ -130,7 +130,7 @@ impl<'tcx> PassByRefOrValue { } } - fn check_poly_fn(&mut self, cx: &LateContext<'tcx>, def_id: LocalDefId, decl: &FnDecl<'_>, span: Option) { + fn check_poly_fn(&mut self, cx: &LateContext<'_>, def_id: LocalDefId, decl: &FnDecl<'_>, span: Option) { if self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(def_id) { return; } diff --git a/clippy_lints/src/pathbuf_init_then_push.rs b/clippy_lints/src/pathbuf_init_then_push.rs index 1b9a5a44382..9f84686a0b1 100644 --- a/clippy_lints/src/pathbuf_init_then_push.rs +++ b/clippy_lints/src/pathbuf_init_then_push.rs @@ -60,7 +60,7 @@ struct PathbufPushSearcher<'tcx> { err_span: Span, } -impl<'tcx> PathbufPushSearcher<'tcx> { +impl PathbufPushSearcher<'_> { /// Try to generate a suggestion with `PathBuf::from`. /// Returns `None` if the suggestion would be invalid. fn gen_pathbuf_from(&self, cx: &LateContext<'_>) -> Option { diff --git a/clippy_lints/src/redundant_closure_call.rs b/clippy_lints/src/redundant_closure_call.rs index 6930a01d48b..41a44de536b 100644 --- a/clippy_lints/src/redundant_closure_call.rs +++ b/clippy_lints/src/redundant_closure_call.rs @@ -228,7 +228,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall { path: &'tcx hir::Path<'tcx>, count: usize, } - impl<'a, 'tcx> Visitor<'tcx> for ClosureUsageCount<'a, 'tcx> { + impl<'tcx> Visitor<'tcx> for ClosureUsageCount<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 34bd9a1210c..1f223048ce5 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -140,7 +140,7 @@ enum RetReplacement<'tcx> { Expr(Cow<'tcx, str>, Applicability), } -impl<'tcx> RetReplacement<'tcx> { +impl RetReplacement<'_> { fn sugg_help(&self) -> &'static str { match self { Self::Empty | Self::Expr(..) => "remove `return`", @@ -158,7 +158,7 @@ impl<'tcx> RetReplacement<'tcx> { } } -impl<'tcx> Display for RetReplacement<'tcx> { +impl Display for RetReplacement<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Empty => write!(f, ""), diff --git a/clippy_lints/src/significant_drop_tightening.rs b/clippy_lints/src/significant_drop_tightening.rs index d1114cb29f7..0eece922143 100644 --- a/clippy_lints/src/significant_drop_tightening.rs +++ b/clippy_lints/src/significant_drop_tightening.rs @@ -249,7 +249,7 @@ impl<'ap, 'lc, 'others, 'stmt, 'tcx> StmtsChecker<'ap, 'lc, 'others, 'stmt, 'tcx } } -impl<'ap, 'lc, 'others, 'stmt, 'tcx> Visitor<'tcx> for StmtsChecker<'ap, 'lc, 'others, 'stmt, 'tcx> { +impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> { fn visit_block(&mut self, block: &'tcx hir::Block<'tcx>) { self.ap.curr_block_hir_id = block.hir_id; self.ap.curr_block_span = block.span; diff --git a/clippy_lints/src/single_component_path_imports.rs b/clippy_lints/src/single_component_path_imports.rs index c986c3e8aa6..9fdee8543a8 100644 --- a/clippy_lints/src/single_component_path_imports.rs +++ b/clippy_lints/src/single_component_path_imports.rs @@ -102,7 +102,7 @@ struct ImportUsageVisitor { imports_referenced_with_self: Vec, } -impl<'tcx> Visitor<'tcx> for ImportUsageVisitor { +impl Visitor<'_> for ImportUsageVisitor { fn visit_expr(&mut self, expr: &Expr) { if let ExprKind::Path(_, path) = &expr.kind && path.segments.len() > 1 diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index 5129bbf2665..fc799cad67e 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -229,7 +229,7 @@ struct VectorInitializationVisitor<'a, 'tcx> { initialization_found: bool, } -impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> { +impl<'tcx> VectorInitializationVisitor<'_, 'tcx> { /// Checks if the given expression is extending a vector with `repeat(0).take(..)` fn search_slow_extend_filling(&mut self, expr: &'tcx Expr<'_>) { if self.initialization_found @@ -299,7 +299,7 @@ impl<'a, 'tcx> VectorInitializationVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> Visitor<'tcx> for VectorInitializationVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for VectorInitializationVisitor<'_, 'tcx> { fn visit_stmt(&mut self, stmt: &'tcx Stmt<'_>) { if self.initialization_found { match stmt.kind { diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index e05fa4095b8..a3145c4647c 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -332,7 +332,7 @@ struct IndexBinding<'a, 'tcx> { applicability: &'a mut Applicability, } -impl<'a, 'tcx> IndexBinding<'a, 'tcx> { +impl<'tcx> IndexBinding<'_, 'tcx> { fn snippet_index_bindings(&mut self, exprs: &[&'tcx Expr<'tcx>]) -> String { let mut bindings = FxHashSet::default(); for expr in exprs { diff --git a/clippy_lints/src/unused_async.rs b/clippy_lints/src/unused_async.rs index a1f08cf6623..d6f79ae4836 100644 --- a/clippy_lints/src/unused_async.rs +++ b/clippy_lints/src/unused_async.rs @@ -67,7 +67,7 @@ struct AsyncFnVisitor<'a, 'tcx> { async_depth: usize, } -impl<'a, 'tcx> Visitor<'tcx> for AsyncFnVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for AsyncFnVisitor<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) { diff --git a/clippy_lints/src/unwrap.rs b/clippy_lints/src/unwrap.rs index 596f0fd9c8b..6fe660b6a47 100644 --- a/clippy_lints/src/unwrap.rs +++ b/clippy_lints/src/unwrap.rs @@ -235,7 +235,7 @@ impl<'tcx> Delegate<'tcx> for MutationVisitor<'tcx> { fn fake_read(&mut self, _: &PlaceWithHirId<'tcx>, _: FakeReadCause, _: HirId) {} } -impl<'a, 'tcx> UnwrappableVariablesVisitor<'a, 'tcx> { +impl<'tcx> UnwrappableVariablesVisitor<'_, 'tcx> { fn visit_branch( &mut self, if_expr: &'tcx Expr<'_>, @@ -288,7 +288,7 @@ fn consume_option_as_ref<'tcx>(expr: &'tcx Expr<'tcx>) -> (&'tcx Expr<'tcx>, Opt } } -impl<'a, 'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index e340b419bd0..08449de79b3 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -280,7 +280,7 @@ struct SkipTyCollector { types_to_skip: Vec, } -impl<'tcx> Visitor<'tcx> for SkipTyCollector { +impl Visitor<'_> for SkipTyCollector { fn visit_infer(&mut self, inf: &hir::InferArg) { self.types_to_skip.push(inf.hir_id); diff --git a/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs b/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs index 7c45a5b2f09..dd456022212 100644 --- a/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs +++ b/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs @@ -270,7 +270,7 @@ struct LintCollector<'a, 'tcx> { cx: &'a LateContext<'tcx>, } -impl<'a, 'tcx> Visitor<'tcx> for LintCollector<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for LintCollector<'_, 'tcx> { type NestedFilter = nested_filter::All; fn visit_path(&mut self, path: &Path<'_>, _: HirId) { diff --git a/clippy_lints/src/zombie_processes.rs b/clippy_lints/src/zombie_processes.rs index ba2a80ee66b..58d71bee299 100644 --- a/clippy_lints/src/zombie_processes.rs +++ b/clippy_lints/src/zombie_processes.rs @@ -118,7 +118,7 @@ enum WaitFinder<'a, 'tcx> { Found(&'a LateContext<'tcx>, HirId), } -impl<'a, 'tcx> Visitor<'tcx> for WaitFinder<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for WaitFinder<'_, 'tcx> { type Result = ControlFlow; fn visit_local(&mut self, l: &'tcx LetStmt<'tcx>) -> Self::Result { @@ -300,7 +300,7 @@ struct ExitPointFinder<'a, 'tcx> { struct ExitCallFound; -impl<'a, 'tcx> Visitor<'tcx> for ExitPointFinder<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for ExitPointFinder<'_, 'tcx> { type Result = ControlFlow; fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) -> Self::Result { diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs index bf47cf6d372..e0bc27ebe2e 100644 --- a/clippy_utils/src/consts.rs +++ b/clippy_utils/src/consts.rs @@ -118,7 +118,7 @@ impl IntTypeBounds for IntTy { } } -impl<'tcx> PartialEq for Constant<'tcx> { +impl PartialEq for Constant<'_> { fn eq(&self, other: &Self) -> bool { match (self, other) { (Self::Str(ls), Self::Str(rs)) => ls == rs, @@ -147,7 +147,7 @@ impl<'tcx> PartialEq for Constant<'tcx> { } } -impl<'tcx> Hash for Constant<'tcx> { +impl Hash for Constant<'_> { fn hash(&self, state: &mut H) where H: Hasher, @@ -203,7 +203,7 @@ impl<'tcx> Hash for Constant<'tcx> { } } -impl<'tcx> Constant<'tcx> { +impl Constant<'_> { pub fn partial_cmp(tcx: TyCtxt<'_>, cmp_type: Ty<'_>, left: &Self, right: &Self) -> Option { match (left, right) { (Self::Str(ls), Self::Str(rs)) => Some(ls.cmp(rs)), diff --git a/clippy_utils/src/eager_or_lazy.rs b/clippy_utils/src/eager_or_lazy.rs index 9420d84b959..a2e97919d04 100644 --- a/clippy_utils/src/eager_or_lazy.rs +++ b/clippy_utils/src/eager_or_lazy.rs @@ -118,7 +118,7 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS eagerness: EagernessSuggestion, } - impl<'cx, 'tcx> Visitor<'tcx> for V<'cx, 'tcx> { + impl<'tcx> Visitor<'tcx> for V<'_, 'tcx> { fn visit_expr(&mut self, e: &'tcx Expr<'_>) { use EagernessSuggestion::{ForceNoChange, Lazy, NoChange}; if self.eagerness == ForceNoChange { diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 2fee6473910..12e1bf9a6d6 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -1345,7 +1345,7 @@ pub struct ContainsName<'a, 'tcx> { pub result: bool, } -impl<'a, 'tcx> Visitor<'tcx> for ContainsName<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for ContainsName<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_name(&mut self, name: Symbol) { @@ -3115,7 +3115,7 @@ pub fn is_never_expr<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> Option< is_never: bool, } - impl<'tcx> V<'_, 'tcx> { + impl V<'_, '_> { fn push_break_target(&mut self, id: HirId) { self.break_targets.push(BreakTarget { id, unused: true }); self.break_targets_for_result_ty += u32::from(self.in_final_expr); diff --git a/clippy_utils/src/mir/mod.rs b/clippy_utils/src/mir/mod.rs index 59bb5e35cda..3924e384c37 100644 --- a/clippy_utils/src/mir/mod.rs +++ b/clippy_utils/src/mir/mod.rs @@ -58,7 +58,7 @@ struct V<'a> { results: Vec, } -impl<'a, 'tcx> Visitor<'tcx> for V<'a> { +impl<'tcx> Visitor<'tcx> for V<'_> { fn visit_place(&mut self, place: &Place<'tcx>, ctx: PlaceContext, loc: Location) { if loc.block == self.location.block && loc.statement_index <= self.location.statement_index { return; diff --git a/clippy_utils/src/mir/possible_borrower.rs b/clippy_utils/src/mir/possible_borrower.rs index 07e6705cd3d..6bb434a466f 100644 --- a/clippy_utils/src/mir/possible_borrower.rs +++ b/clippy_utils/src/mir/possible_borrower.rs @@ -65,7 +65,7 @@ impl<'a, 'b, 'tcx> PossibleBorrowerVisitor<'a, 'b, 'tcx> { } } -impl<'a, 'b, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'b, 'tcx> { +impl<'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'_, '_, 'tcx> { fn visit_assign(&mut self, place: &mir::Place<'tcx>, rvalue: &mir::Rvalue<'_>, _location: mir::Location) { let lhs = place.local; match rvalue { @@ -177,8 +177,8 @@ pub struct PossibleBorrowerMap<'b, 'tcx> { pub bitset: (BitSet, BitSet), } -impl<'a, 'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> { - pub fn new(cx: &'a LateContext<'tcx>, mir: &'b mir::Body<'tcx>) -> Self { +impl<'b, 'tcx> PossibleBorrowerMap<'b, 'tcx> { + pub fn new(cx: &LateContext<'tcx>, mir: &'b mir::Body<'tcx>) -> Self { let possible_origin = { let mut vis = PossibleOriginVisitor::new(mir); vis.visit_body(mir); diff --git a/clippy_utils/src/mir/possible_origin.rs b/clippy_utils/src/mir/possible_origin.rs index da04266863f..4157b3f4930 100644 --- a/clippy_utils/src/mir/possible_origin.rs +++ b/clippy_utils/src/mir/possible_origin.rs @@ -39,7 +39,7 @@ impl<'a, 'tcx> PossibleOriginVisitor<'a, 'tcx> { } } -impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleOriginVisitor<'a, 'tcx> { +impl<'tcx> mir::visit::Visitor<'tcx> for PossibleOriginVisitor<'_, 'tcx> { fn visit_assign(&mut self, place: &mir::Place<'tcx>, rvalue: &mir::Rvalue<'_>, _location: mir::Location) { let lhs = place.local; match rvalue { diff --git a/clippy_utils/src/ty/type_certainty/mod.rs b/clippy_utils/src/ty/type_certainty/mod.rs index e612e9c6cb6..91ec120adbf 100644 --- a/clippy_utils/src/ty/type_certainty/mod.rs +++ b/clippy_utils/src/ty/type_certainty/mod.rs @@ -108,7 +108,7 @@ impl<'cx, 'tcx> CertaintyVisitor<'cx, 'tcx> { } } -impl<'cx, 'tcx> Visitor<'cx> for CertaintyVisitor<'cx, 'tcx> { +impl<'cx> Visitor<'cx> for CertaintyVisitor<'cx, '_> { fn visit_qpath(&mut self, qpath: &'cx QPath<'_>, hir_id: HirId, _: Span) { self.certainty = self.certainty.meet(qpath_certainty(self.cx, qpath, true)); if self.certainty != Certainty::Uncertain { diff --git a/clippy_utils/src/usage.rs b/clippy_utils/src/usage.rs index 1230b60c3a6..8af3bdccaa1 100644 --- a/clippy_utils/src/usage.rs +++ b/clippy_utils/src/usage.rs @@ -46,8 +46,8 @@ struct MutVarsDelegate { skip: bool, } -impl<'tcx> MutVarsDelegate { - fn update(&mut self, cat: &PlaceWithHirId<'tcx>) { +impl MutVarsDelegate { + fn update(&mut self, cat: &PlaceWithHirId<'_>) { match cat.place.base { PlaceBase::Local(id) => { self.used_mutably.insert(id); @@ -122,7 +122,7 @@ impl<'a, 'tcx> BindingUsageFinder<'a, 'tcx> { finder.usage_found } } -impl<'a, 'tcx> Visitor<'tcx> for BindingUsageFinder<'a, 'tcx> { +impl<'tcx> Visitor<'tcx> for BindingUsageFinder<'_, 'tcx> { type NestedFilter = nested_filter::OnlyBodies; fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) { diff --git a/clippy_utils/src/visitors.rs b/clippy_utils/src/visitors.rs index 6d9a85a1181..02931306f16 100644 --- a/clippy_utils/src/visitors.rs +++ b/clippy_utils/src/visitors.rs @@ -552,7 +552,7 @@ pub fn for_each_local_use_after_expr<'tcx, B>( res: ControlFlow, f: F, } - impl<'cx, 'tcx, F: FnMut(&'tcx Expr<'tcx>) -> ControlFlow, B> Visitor<'tcx> for V<'cx, 'tcx, F, B> { + impl<'tcx, F: FnMut(&'tcx Expr<'tcx>) -> ControlFlow, B> Visitor<'tcx> for V<'_, 'tcx, F, B> { type NestedFilter = nested_filter::OnlyBodies; fn nested_visit_map(&mut self) -> Self::Map { self.cx.tcx.hir() @@ -734,7 +734,7 @@ pub fn for_each_local_assignment<'tcx, B>( res: ControlFlow, f: F, } - impl<'cx, 'tcx, F: FnMut(&'tcx Expr<'tcx>) -> ControlFlow, B> Visitor<'tcx> for V<'cx, 'tcx, F, B> { + impl<'tcx, F: FnMut(&'tcx Expr<'tcx>) -> ControlFlow, B> Visitor<'tcx> for V<'_, 'tcx, F, B> { type NestedFilter = nested_filter::OnlyBodies; fn nested_visit_map(&mut self) -> Self::Map { self.cx.tcx.hir() -- cgit 1.4.1-3-g733a5