Skip to content

Commit

Permalink
Replace #[allow] with #[expect] in Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
xFrednet committed May 7, 2022
1 parent 9c78883 commit 03960eb
Show file tree
Hide file tree
Showing 54 changed files with 73 additions and 93 deletions.
6 changes: 3 additions & 3 deletions clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
}
for (n, expr) in self.terminals.iter().enumerate() {
if eq_expr_value(self.cx, e, expr) {
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
return Ok(Bool::Term(n as u8));
}

Expand All @@ -149,15 +149,15 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
if eq_expr_value(self.cx, e_lhs, expr_lhs);
if eq_expr_value(self.cx, e_rhs, expr_rhs);
then {
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
return Ok(Bool::Not(Box::new(Bool::Term(n as u8))));
}
}
}
let n = self.terminals.len();
self.terminals.push(e);
if n < 32 {
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
Ok(Bool::Term(n as u8))
} else {
Err("too many literals".to_owned())
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/cognitive_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl CognitiveComplexity {
impl_lint_pass!(CognitiveComplexity => [COGNITIVE_COMPLEXITY]);

impl CognitiveComplexity {
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
fn check<'tcx>(
&mut self,
cx: &LateContext<'tcx>,
Expand All @@ -70,7 +70,7 @@ impl CognitiveComplexity {
let ret_adjust = if is_type_diagnostic_item(cx, ret_ty, sym::Result) {
returns
} else {
#[allow(clippy::integer_division)]
#[expect(clippy::integer_division)]
(returns / 2)
};

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
}
}

#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
fn check_block(&mut self, cx: &LateContext<'tcx>, block: &Block<'tcx>) {
// start from the `let mut _ = _::default();` and look at all the following
// statements, see if they re-assign the fields of the binding
Expand Down
1 change: 0 additions & 1 deletion clippy_lints/src/default_numeric_fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ impl<'a, 'tcx> NumericFallbackVisitor<'a, 'tcx> {
}

impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
#[allow(clippy::too_many_lines)]
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
match &expr.kind {
ExprKind::Call(func, args) => {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/dereference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ struct RefPat {
}

impl<'tcx> LateLintPass<'tcx> for Dereferencing {
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
// Skip path expressions from deref calls. e.g. `Deref::deref(e)`
if Some(expr.hir_id) == self.skip_expr.take() {
Expand Down Expand Up @@ -580,7 +580,7 @@ fn find_adjustments<'tcx>(
}
}

#[allow(clippy::needless_pass_by_value)]
#[expect(clippy::needless_pass_by_value)]
fn report(cx: &LateContext<'_>, expr: &Expr<'_>, state: State, data: StateData) {
match state {
State::DerefMethod {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ declare_clippy_lint! {
"presence of `fn main() {` in code examples"
}

#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
#[derive(Clone)]
pub struct DocMarkdown {
valid_idents: FxHashSet<String>,
Expand Down Expand Up @@ -373,7 +373,7 @@ fn lint_for_missing_headers<'tcx>(
/// `rustc_ast::parse::lexer::comments::strip_doc_comment_decoration` because we
/// need to keep track of
/// the spans but this function is inspired from the later.
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
#[must_use]
pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span: Span) -> (String, Vec<(usize, Span)>) {
// one-line comments lose their prefix
Expand Down Expand Up @@ -428,7 +428,7 @@ fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs
/// We don't want the parser to choke on intra doc links. Since we don't
/// actually care about rendering them, just pretend that all broken links are
/// point to a fake address.
#[allow(clippy::unnecessary_wraps)] // we're following a type signature
#[expect(clippy::unnecessary_wraps)] // we're following a type signature
fn fake_broken_link_callback<'a>(_: BrokenLink<'_>) -> Option<(CowStr<'a>, CowStr<'a>)> {
Some(("fake".into(), "fake".into()))
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/double_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ declare_clippy_lint! {
declare_lint_pass!(DoubleComparisons => [DOUBLE_COMPARISONS]);

impl<'tcx> DoubleComparisons {
#[allow(clippy::similar_names)]
#[expect(clippy::similar_names)]
fn check_binop(cx: &LateContext<'tcx>, op: BinOpKind, lhs: &'tcx Expr<'_>, rhs: &'tcx Expr<'_>, span: Span) {
let (lkind, llhs, lrhs, rkind, rlhs, rrhs) = match (&lhs.kind, &rhs.kind) {
(ExprKind::Binary(lb, llhs, lrhs), ExprKind::Binary(rb, rlhs, rrhs)) => {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ declare_clippy_lint! {
declare_lint_pass!(HashMapPass => [MAP_ENTRY]);

impl<'tcx> LateLintPass<'tcx> for HashMapPass {
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
let (cond_expr, then_expr, else_expr) = match higher::If::hir(expr) {
Some(higher::If { cond, then, r#else }) => (cond, then, r#else),
Expand Down Expand Up @@ -319,7 +319,7 @@ struct Insertion<'tcx> {
/// `or_insert_with`.
/// * Determine if there's any sub-expression that can't be placed in a closure.
/// * Determine if there's only a single insert statement. `or_insert` can be used in this case.
#[allow(clippy::struct_excessive_bools)]
#[expect(clippy::struct_excessive_bools)]
struct InsertSearcher<'cx, 'tcx> {
cx: &'cx LateContext<'tcx>,
/// The map expression used in the contains call.
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_clike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ declare_clippy_lint! {
declare_lint_pass!(UnportableVariant => [ENUM_CLIKE_UNPORTABLE_VARIANT]);

impl<'tcx> LateLintPass<'tcx> for UnportableVariant {
#[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap, clippy::cast_sign_loss)]
#[expect(clippy::cast_possible_wrap)]
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
if cx.tcx.data_layout.pointer_size.bits() != 64 {
return;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl LateLintPass<'_> for EnumVariantNames {
assert!(last.is_some());
}

#[allow(clippy::similar_names)]
#[expect(clippy::similar_names)]
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
let item_name = item.ident.name.as_str();
let item_camel = to_camel_case(item_name);
Expand Down
3 changes: 1 addition & 2 deletions clippy_lints/src/eq_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ declare_clippy_lint! {
declare_lint_pass!(EqOp => [EQ_OP, OP_REF]);

impl<'tcx> LateLintPass<'tcx> for EqOp {
#[allow(clippy::similar_names, clippy::too_many_lines)]
#[expect(clippy::similar_names, clippy::too_many_lines)]
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
if_chain! {
if let Some((macro_call, macro_name)) = first_node_macro_backtrace(cx, e).find_map(|macro_call| {
Expand Down Expand Up @@ -138,7 +138,6 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
},
};
if let Some(trait_id) = trait_id {
#[allow(clippy::match_same_arms)]
match (&left.kind, &right.kind) {
// do not suggest to dereference literals
(&ExprKind::Lit(..), _) | (_, &ExprKind::Lit(..)) => {},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/floating_point_arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ fn check_ln1p(cx: &LateContext<'_>, expr: &Expr<'_>, args: &[Expr<'_>]) {
// converted to an integer without loss of precision. For now we only check
// ranges [-16777215, 16777216) for type f32 as whole number floats outside
// this range are lossy and ambiguous.
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
fn get_integer_from_float_constant(value: &Constant) -> Option<i32> {
match value {
F32(num) if num.fract() == 0.0 => {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/implicit_hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare_clippy_lint! {
declare_lint_pass!(ImplicitHasher => [IMPLICIT_HASHER]);

impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
#[allow(clippy::cast_possible_truncation, clippy::too_many_lines)]
#[expect(clippy::cast_possible_truncation, clippy::too_many_lines)]
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
use rustc_span::BytePos;

Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/implicit_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fn lint_implicit_returns(
})
.visit_block(block);
if add_return {
#[allow(clippy::option_if_let_else)]
#[expect(clippy::option_if_let_else)]
if let Some(span) = call_site_span {
lint_return(cx, span);
LintLocation::Parent
Expand Down Expand Up @@ -196,7 +196,7 @@ fn lint_implicit_returns(

_ =>
{
#[allow(clippy::option_if_let_else)]
#[expect(clippy::option_if_let_else)]
if let Some(span) = call_site_span {
lint_return(cx, span);
LintLocation::Parent
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/int_plus_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ enum Side {
}

impl IntPlusOne {
#[allow(clippy::cast_sign_loss)]
#[expect(clippy::cast_sign_loss)]
fn check_lit(lit: &Lit, target_value: i128) -> bool {
if let LitKind::Int(value, ..) = lit.kind {
return value == (target_value as u128);
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#![feature(iter_intersperse)]
#![feature(let_chains)]
#![feature(let_else)]
#![feature(lint_reasons)]
#![feature(once_cell)]
#![feature(rustc_private)]
#![feature(stmt_expr_attributes)]
Expand Down Expand Up @@ -472,7 +473,7 @@ pub fn read_conf(sess: &Session) -> Conf {
/// Register all lints and lint groups with the rustc plugin registry
///
/// Used in `./src/driver.rs`.
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: &Conf) {
register_removed_non_tool_lints(store);

Expand Down
3 changes: 1 addition & 2 deletions clippy_lints/src/literal_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ impl WarningType {
}
}

#[allow(clippy::module_name_repetitions)]
#[derive(Copy, Clone)]
pub struct LiteralDigitGrouping {
lint_fraction_readability: bool,
Expand Down Expand Up @@ -432,7 +431,7 @@ impl LiteralDigitGrouping {
}
}

#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
#[derive(Copy, Clone)]
pub struct DecimalLiteralRepresentation {
threshold: u64,
Expand Down
1 change: 0 additions & 1 deletion clippy_lints/src/loops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ declare_lint_pass!(Loops => [
]);

impl<'tcx> LateLintPass<'tcx> for Loops {
#[allow(clippy::too_many_lines)]
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
let for_loop = higher::ForLoop::hir(expr);
if let Some(higher::ForLoop {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/needless_range_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::mem;

/// Checks for looping over a range and then indexing a sequence with it.
/// The iteratee must be a range literal.
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(super) fn check<'tcx>(
cx: &LateContext<'tcx>,
pat: &'tcx Pat<'_>,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/while_let_on_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ fn uses_iter<'tcx>(cx: &LateContext<'tcx>, iter_expr: &IterExpr, container: &'tc
v.uses_iter
}

#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
fn needs_mutable_borrow(cx: &LateContext<'_>, iter_expr: &IterExpr, loop_expr: &Expr<'_>) -> bool {
struct AfterLoopVisitor<'a, 'b, 'tcx> {
cx: &'a LateContext<'tcx>,
Expand Down
3 changes: 1 addition & 2 deletions clippy_lints/src/macro_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl MacroRefData {
}

#[derive(Default)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct MacroUseImports {
/// the actual import path used and the span of the attribute above it.
imports: Vec<(String, Span)>,
Expand Down Expand Up @@ -135,7 +135,6 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
self.push_unique_macro_pat_ty(cx, ty.span);
}
}
#[allow(clippy::too_many_lines)]
fn check_crate_post(&mut self, cx: &LateContext<'_>) {
let mut used = FxHashMap::default();
let mut check_dup = vec![];
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/manual_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ declare_clippy_lint! {
declare_lint_pass!(ManualMap => [MANUAL_MAP]);

impl<'tcx> LateLintPass<'tcx> for ManualMap {
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
let (scrutinee, then_pat, then_body, else_pat, else_body) = match IfLetOrMatch::parse(cx, expr) {
Some(IfLetOrMatch::IfLet(scrutinee, pat, body, Some(r#else))) => (scrutinee, pat, body, None, r#else),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/manual_non_exhaustive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare_clippy_lint! {
"manual implementations of the non-exhaustive pattern can be simplified using #[non_exhaustive]"
}

#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct ManualNonExhaustiveStruct {
msrv: Option<RustcVersion>,
}
Expand All @@ -76,7 +76,7 @@ impl ManualNonExhaustiveStruct {

impl_lint_pass!(ManualNonExhaustiveStruct => [MANUAL_NON_EXHAUSTIVE]);

#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct ManualNonExhaustiveEnum {
msrv: Option<RustcVersion>,
constructed_enum_variants: FxHashSet<(DefId, DefId)>,
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/matches/match_same_arms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::collections::hash_map::Entry;

use super::MATCH_SAME_ARMS;

#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>]) {
let hash = |&(_, arm): &(usize, &Arm<'_>)| -> u64 {
let mut h = SpanlessHash::new(cx);
Expand Down Expand Up @@ -225,9 +225,9 @@ fn iter_matching_struct_fields<'a>(
Iter(left.iter(), right.iter())
}

#[allow(clippy::similar_names)]
#[expect(clippy::similar_names)]
impl<'a> NormalizedPat<'a> {
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
fn from_pat(cx: &LateContext<'_>, arena: &'a DroplessArena, pat: &'a Pat<'_>) -> Self {
match pat.kind {
PatKind::Wild | PatKind::Binding(.., None) => Self::Wild,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/match_single_binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_lint::LateContext;

use super::MATCH_SINGLE_BINDING;

#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], expr: &Expr<'_>) {
if expr.span.from_expansion() || arms.len() != 1 || is_refutable(cx, arms[0].pat) {
return;
Expand Down
3 changes: 1 addition & 2 deletions clippy_lints/src/matches/match_wild_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_span::sym;

use super::{MATCH_WILDCARD_FOR_SINGLE_VARIANTS, WILDCARD_ENUM_MATCH_ARM};

#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
let ty = cx.typeck_results().expr_ty(ex).peel_refs();
let adt_def = match ty.kind() {
Expand Down Expand Up @@ -56,7 +56,6 @@ pub(crate) fn check(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
recurse_or_patterns(arm.pat, |pat| {
let path = match &peel_hir_pat_refs(pat).0.kind {
PatKind::Path(path) => {
#[allow(clippy::match_same_arms)]
let id = match cx.qpath_res(path, pat.hir_id) {
Res::Def(
DefKind::Const | DefKind::ConstParam | DefKind::AnonConst | DefKind::InlineConst,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/redundant_pattern_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ pub(super) fn check_match<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, op
}
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn find_good_method_for_match<'a>(
cx: &LateContext<'_>,
arms: &[Arm<'_>],
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ fn is_array(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
matches!(&cx.typeck_results().expr_ty(expr).peel_refs().kind(), ty::Array(_, _))
}

#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
fn check_to_owned(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool) {
#[derive(Default)]
struct EqImpl {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_pass_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ macro_rules! need {
}

impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
fn check_fn(
&mut self,
cx: &LateContext<'tcx>,
Expand Down
1 change: 0 additions & 1 deletion clippy_lints/src/neg_multiply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ declare_clippy_lint! {

declare_lint_pass!(NegMultiply => [NEG_MULTIPLY]);

#[allow(clippy::match_same_arms)]
impl<'tcx> LateLintPass<'tcx> for NegMultiply {
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
if let ExprKind::Binary(ref op, left, right) = e.kind {
Expand Down
Loading

0 comments on commit 03960eb

Please sign in to comment.