From 943a8e06469558cb1f16a9847bcf19ea744fd3a0 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Mon, 29 Jul 2024 19:57:39 +0000 Subject: [PATCH] Remove some miscellaneous `#[allow]`s --- clippy_dev/src/serve.rs | 7 ------- clippy_lints/src/incompatible_msrv.rs | 7 +++---- clippy_lints/src/indexing_slicing.rs | 2 -- clippy_lints/src/infinite_iter.rs | 1 - clippy_lints/src/lib.rs | 7 ------- clippy_lints/src/methods/iter_kv_map.rs | 15 ++++++--------- clippy_lints/src/methods/mod.rs | 10 ---------- clippy_lints/src/only_used_in_recursion.rs | 1 - clippy_utils/src/lib.rs | 3 +-- 9 files changed, 10 insertions(+), 43 deletions(-) diff --git a/clippy_dev/src/serve.rs b/clippy_dev/src/serve.rs index 4a4261d1a..16f286faf 100644 --- a/clippy_dev/src/serve.rs +++ b/clippy_dev/src/serve.rs @@ -1,5 +1,3 @@ -use std::ffi::OsStr; -use std::num::ParseIntError; use std::path::Path; use std::process::Command; use std::time::{Duration, SystemTime}; @@ -58,8 +56,3 @@ fn mtime(path: impl AsRef) -> SystemTime { .unwrap_or(SystemTime::UNIX_EPOCH) } } - -#[allow(clippy::missing_errors_doc)] -pub fn validate_port(arg: &OsStr) -> Result<(), ParseIntError> { - arg.to_string_lossy().parse::().map(|_| ()) -} diff --git a/clippy_lints/src/incompatible_msrv.rs b/clippy_lints/src/incompatible_msrv.rs index 12ca6d43b..0ef5b803a 100644 --- a/clippy_lints/src/incompatible_msrv.rs +++ b/clippy_lints/src/incompatible_msrv.rs @@ -55,7 +55,6 @@ impl IncompatibleMsrv { } } - #[allow(clippy::cast_lossless)] fn get_def_id_version(&mut self, tcx: TyCtxt<'_>, def_id: DefId) -> RustcVersion { if let Some(version) = self.is_above_msrv.get(&def_id) { return *version; @@ -67,9 +66,9 @@ impl IncompatibleMsrv { since: StableSince::Version(version), .. } => Some(RustcVersion::new( - version.major as _, - version.minor as _, - version.patch as _, + version.major.into(), + version.minor.into(), + version.patch.into(), )), _ => None, }) { diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index 6729c7c8d..3b65901c1 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -70,8 +70,6 @@ declare_clippy_lint! { /// /// Use instead: /// ```no_run - /// # #![allow(unused)] - /// /// # let x = vec![0; 5]; /// # let y = [0, 1, 2, 3]; /// x.get(2); diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index fa7e7f6b7..676d50c49 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -41,7 +41,6 @@ declare_clippy_lint! { /// ### Example /// ```no_run /// let infinite_iter = 0..; - /// # #[allow(unused)] /// [0..].iter().zip(infinite_iter.take_while(|x| *x > 5)); /// ``` #[clippy::version = "pre 1.29.0"] diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 0ca66063e..6dae77441 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -966,10 +966,3 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) { ls.register_renamed(old_name, new_name); } } - -// only exists to let the dogfood integration test works. -// Don't run clippy as an executable directly -#[allow(dead_code)] -fn main() { - panic!("Please use the cargo-clippy executable"); -} diff --git a/clippy_lints/src/methods/iter_kv_map.rs b/clippy_lints/src/methods/iter_kv_map.rs index 05e773861..33de3b87a 100644 --- a/clippy_lints/src/methods/iter_kv_map.rs +++ b/clippy_lints/src/methods/iter_kv_map.rs @@ -1,15 +1,12 @@ -#![allow(unused_imports)] - use super::ITER_KV_MAP; use clippy_config::msrvs::{self, Msrv}; -use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_sugg, span_lint_and_then}; -use clippy_utils::source::{snippet, snippet_with_applicability}; +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::pat_is_wild; +use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_type_diagnostic_item; -use clippy_utils::{pat_is_wild, sugg}; -use rustc_hir::{BindingMode, Body, BorrowKind, ByRef, Expr, ExprKind, Mutability, Pat, PatKind}; -use rustc_lint::{LateContext, LintContext}; -use rustc_middle::ty; -use rustc_span::{sym, Span}; +use rustc_hir::{Body, Expr, ExprKind, PatKind}; +use rustc_lint::LateContext; +use rustc_span::sym; /// lint use of: /// diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index aa4cad934..4c5300315 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -749,7 +749,6 @@ declare_clippy_lint! { /// /// ### Example /// ```no_run - /// # #![allow(unused)] /// (0_i32..10) /// .filter(|n| n.checked_add(1).is_some()) /// .map(|n| n.checked_add(1).unwrap()); @@ -757,7 +756,6 @@ declare_clippy_lint! { /// /// Use instead: /// ```no_run - /// # #[allow(unused)] /// (0_i32..10).filter_map(|n| n.checked_add(1)); /// ``` #[clippy::version = "1.51.0"] @@ -850,7 +848,6 @@ declare_clippy_lint! { /// /// ### Example /// ```no_run - /// # #![allow(unused)] /// let vec = vec![1]; /// vec.iter().find(|x| **x == 0).is_some(); /// @@ -862,7 +859,6 @@ declare_clippy_lint! { /// let vec = vec![1]; /// vec.iter().any(|x| *x == 0); /// - /// # #[allow(unused)] /// !"hello world".contains("world"); /// ``` #[clippy::version = "pre 1.29.0"] @@ -1505,7 +1501,6 @@ declare_clippy_lint! { /// /// ### Example /// ```no_run - /// # #[allow(unused)] /// (0..3).fold(false, |acc, x| acc || x > 2); /// ``` /// @@ -2008,13 +2003,11 @@ declare_clippy_lint! { /// /// ### Example /// ```no_run - /// # #[allow(unused)] /// "Hello".bytes().nth(3); /// ``` /// /// Use instead: /// ```no_run - /// # #[allow(unused)] /// "Hello".as_bytes().get(3); /// ``` #[clippy::version = "1.52.0"] @@ -2059,7 +2052,6 @@ declare_clippy_lint! { /// /// ### Example /// ```no_run - /// # #![allow(unused)] /// let some_vec = vec![0, 1, 2, 3]; /// /// some_vec.iter().count(); @@ -3656,7 +3648,6 @@ declare_clippy_lint! { /// /// ### Example /// ```no_run - /// # #![allow(unused)] /// let owned_string = "This is a string".to_owned(); /// owned_string.as_str().as_bytes() /// # ; @@ -3664,7 +3655,6 @@ declare_clippy_lint! { /// /// Use instead: /// ```no_run - /// # #![allow(unused)] /// let owned_string = "This is a string".to_owned(); /// owned_string.as_bytes() /// # ; diff --git a/clippy_lints/src/only_used_in_recursion.rs b/clippy_lints/src/only_used_in_recursion.rs index 8b8aabe7a..aadd729f3 100644 --- a/clippy_lints/src/only_used_in_recursion.rs +++ b/clippy_lints/src/only_used_in_recursion.rs @@ -243,7 +243,6 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion { owner_id, .. }) => { - #[allow(trivial_casts)] if let Node::Item(item) = cx.tcx.parent_hir_node(owner_id.into()) && let Some(trait_ref) = cx .tcx diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 1d5f1a2a2..b3898ef8e 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -589,9 +589,8 @@ fn find_primitive_impls<'tcx>(tcx: TyCtxt<'tcx>, name: &str) -> impl Iterator SimplifiedType::Uint(UintTy::U128), "f32" => SimplifiedType::Float(FloatTy::F32), "f64" => SimplifiedType::Float(FloatTy::F64), - #[allow(trivial_casts)] _ => { - return Result::<_, rustc_errors::ErrorGuaranteed>::Ok(&[] as &[_]) + return Result::<&[_], rustc_errors::ErrorGuaranteed>::Ok(&[]) .into_iter() .flatten() .copied();