Skip to content

implemented lint unnecessary_min #11951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
980ace1
works for 0 and unsigned ints
Dec 4, 2023
6db10d7
lint works if both are known at compiletime
Dec 4, 2023
20257d0
added support for extrema
Dec 8, 2023
e38c7e2
needed to modify other test for cargo test passing
Dec 11, 2023
923d964
made cargo test happy
Dec 11, 2023
b376f46
removed redundant code
Dec 11, 2023
6136434
added description of lint
Dec 11, 2023
8d9d196
remove useless comments
FelixMaetzler Dec 13, 2023
072a077
remove useless comments
FelixMaetzler Dec 13, 2023
7a32e98
modified the test files bc of last commit
Dec 13, 2023
2d36617
got rid of get_both_as_expr
Dec 15, 2023
d1a10bf
used preexisting cmp method
Dec 15, 2023
eabe0d5
Merge branch 'master' into master
FelixMaetzler Dec 17, 2023
768a615
Appease the tools: clippy, rustdoc
compiler-errors Nov 28, 2023
dd39d48
Don't pass lint back out of lint decorator
compiler-errors Dec 8, 2023
57e692b
Rename `Handler` as `DiagCtxt`.
nnethercote Dec 17, 2023
9dee081
Rename `EarlyErrorHandler` as `EarlyDiagCtxt`.
nnethercote Dec 17, 2023
cc9195c
Rename `ParseSess::with_span_handler` as `ParseSess::with_dcx`.
nnethercote Dec 17, 2023
7a7b654
Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.
nnethercote Dec 18, 2023
692636f
Give `VariantData::Struct` named fields, to clairfy `recovered`.
aDotInTheVoid Dec 19, 2023
67d4b98
Plumb awaitness of for loops
eholk Dec 8, 2023
42695d4
Split coroutine desugaring kind from source
compiler-errors Dec 21, 2023
cce967e
bool->enum for ast::PatKind::Struct presence of `..`
aDotInTheVoid Dec 22, 2023
e4a9ba8
Remove `Session` methods that duplicate `DiagCtxt` methods.
nnethercote Dec 18, 2023
9d0924f
Fix clippy's usage of Body's coroutine_kind
compiler-errors Dec 25, 2023
86f3749
Make some non-diagnostic-affecting QPath::LangItem into regular qpaths
compiler-errors Dec 23, 2023
03be3e7
fix: broken GitHub corner, with working dark/light
hamirmahal Dec 10, 2023
6627705
refactor: use CSS vars for GitHub Corner colors
hamirmahal Dec 11, 2023
aa4806f
stop [`bool_comparison`]'s suggestion from consuming parentheses
J-ZhengLi Dec 21, 2023
84b5070
Add check for illegal accessing known length array with a constant index
cocodery Dec 22, 2023
0a84ab4
Add test for indexing_slicing_index and modify related test
cocodery Dec 22, 2023
1eb82a2
fix typos in default constructed unit structs, implied bounds, ineffe…
Takashiidobe Dec 22, 2023
3b2a9a4
Extend `UNNECESSARY_TO_OWNED` to handle `split`
GuillaumeGomez Nov 25, 2023
2d098fe
Add ui tests for `UNNECESSARY_TO_OWNED` on `split`
GuillaumeGomez Nov 25, 2023
9120c06
fix typo in infinite loop lint
Takashiidobe Dec 22, 2023
e7174b3
run cargo uibless
Takashiidobe Dec 23, 2023
c5155b4
[`question_mark`]: also trigger on `return` statements
y21 Dec 21, 2023
360bb44
respect comments in `question_mark`
y21 Dec 23, 2023
c250f69
Move uninhabited_references to nursery
TethysSvensson Dec 22, 2023
d44f604
Remove blyxyas from users_on_vacation
blyxyas Dec 25, 2023
5dba66c
Do not consider `async { (impl IntoFuture).await }` as redundant
samueltardieu Dec 15, 2023
2e18503
New lints `iter_filter_is_some` and `iter_filter_is_ok`
PartiallyUntyped Dec 20, 2023
b23e4bc
Added MSRV and more tests, improved wording
PartiallyUntyped Dec 24, 2023
21643a3
formatting
PartiallyUntyped Dec 24, 2023
f208107
more tests
PartiallyUntyped Dec 24, 2023
ee59198
Update version attribute for 1.75 lints
xFrednet Dec 26, 2023
08530ce
Changelog for Rust 1.75 :christmas_tree:
xFrednet Dec 26, 2023
cebb3e7
Fix typo in changelog for 1.75
xFrednet Dec 26, 2023
45bb4bd
[doc_markdown]: Add "WebGL2", "WebGPU" to default `doc_valid_idents`
waywardmonkeys Dec 26, 2023
154a9ab
new lint: `eager_int_transmute`
y21 Dec 18, 2023
69467a0
6459: Check for redundant `matches!` with `Ready`, `Pending`, `V4`, `V6`
torfsen Dec 27, 2023
7a8c109
Bump nightly version -> 2023-12-28
flip1995 Dec 28, 2023
bf53b19
Bump Clippy version -> 0.1.77
flip1995 Dec 28, 2023
b38f9cd
Remove mitigations for incorrect node args
compiler-errors Dec 29, 2023
35ba1eb
Merge branch 'master' into merge-conflicts
FelixMaetzler Dec 29, 2023
c1b19e0
Merge branch 'rust-lang:master' into merge-conflicts
FelixMaetzler Dec 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5668,6 +5668,7 @@ Released 2018-09-13
[`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
[`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap
[`unnecessary_map_on_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_on_constructor
[`unnecessary_min`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_min
[`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
[`unnecessary_owned_empty_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_owned_empty_strings
Expand Down
3 changes: 1 addition & 2 deletions clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,7 @@ impl Conf {
}
},
Err(error) => {
sess.dcx()
.err(format!("error finding Clippy's configuration file: {error}"));
sess.dcx().err(format!("error finding Clippy's configuration file: {error}"));
},
}

Expand Down
6 changes: 2 additions & 4 deletions clippy_config/src/msrvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ impl Msrv {

if let Some(msrv_attr) = msrv_attrs.next() {
if let Some(duplicate) = msrv_attrs.last() {
sess.dcx()
.struct_span_err(duplicate.span, "`clippy::msrv` is defined multiple times")
sess.dcx().struct_span_err(duplicate.span, "`clippy::msrv` is defined multiple times")
.span_note(msrv_attr.span, "first definition found here")
.emit();
}
Expand All @@ -118,8 +117,7 @@ impl Msrv {
return Some(version);
}

sess.dcx()
.span_err(msrv_attr.span, format!("`{msrv}` is not a valid Rust version"));
sess.dcx().span_err(msrv_attr.span, format!("`{msrv}` is not a valid Rust version"));
} else {
sess.dcx().span_err(msrv_attr.span, "bad clippy attribute");
}
Expand Down
5 changes: 4 additions & 1 deletion clippy_lints/src/async_yields_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use clippy_utils::diagnostics::span_lint_hir_and_then;
use clippy_utils::source::snippet;
use clippy_utils::ty::implements_trait;
use rustc_errors::Applicability;
use rustc_hir::{Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, QPath};
use rustc_hir::{
Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, QPath,
};

use rustc_lint::{LateContext, LateLintPass};
use rustc_session::declare_lint_pass;

Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::methods::UNNECESSARY_JOIN_INFO,
crate::methods::UNNECESSARY_LAZY_EVALUATIONS_INFO,
crate::methods::UNNECESSARY_LITERAL_UNWRAP_INFO,
crate::methods::UNNECESSARY_MIN_INFO,
crate::methods::UNNECESSARY_SORT_BY_INFO,
crate::methods::UNNECESSARY_TO_OWNED_INFO,
crate::methods::UNWRAP_OR_DEFAULT_INFO,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use rustc_hir::def::Res;
use rustc_hir::def_id::{DefId, DefIdSet};
use rustc_hir::{
AssocItemKind, BinOpKind, Expr, ExprKind, FnRetTy, GenericArg, GenericBound, ImplItem, ImplItemKind,
ImplicitSelfKind, Item, ItemKind, Mutability, Node, OpaqueTyOrigin, PatKind, PathSegment, PrimTy, QPath,
TraitItemRef, TyKind, TypeBindingKind,
ImplicitSelfKind, Item, ItemKind, Mutability, Node, PatKind, PathSegment, PrimTy, QPath, TraitItemRef,
TyKind, TypeBindingKind, OpaqueTyOrigin,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{self, AssocKind, FnSig, Ty};
Expand Down
25 changes: 17 additions & 8 deletions clippy_lints/src/manual_async_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use clippy_utils::source::{position_before_rarrow, snippet_block, snippet_opt};
use rustc_errors::Applicability;
use rustc_hir::intravisit::FnKind;
use rustc_hir::{
Block, Body, Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, FnDecl,
FnRetTy, GenericArg, GenericBound, ImplItem, Item, ItemKind, LifetimeName, Node, Term, TraitRef, Ty, TyKind,
TypeBindingKind,
Block, Body, Closure, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, FnDecl, FnRetTy,
GenericArg, GenericBound, ImplItem, Item, ItemKind, LifetimeName, Node, Term, TraitRef, Ty, TyKind,
TypeBindingKind, ClosureKind,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::declare_lint_pass;
Expand Down Expand Up @@ -171,14 +171,23 @@ fn captures_all_lifetimes(inputs: &[Ty<'_>], output_lifetimes: &[LifetimeName])
.iter()
.all(|in_lt| output_lifetimes.iter().any(|out_lt| in_lt == out_lt))
}

fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>) -> Option<&'tcx Body<'tcx>> {
fn desugared_async_block<'tcx>(
cx: &LateContext<'tcx>,
block: &'tcx Block<'tcx>,
) -> Option<&'tcx Body<'tcx>> {
if let Some(Expr {
kind: ExprKind::Closure(&Closure { kind, body, .. }),
kind:
ExprKind::Closure(&Closure {
kind:
ClosureKind::Coroutine(CoroutineKind::Desugared(
CoroutineDesugaring::Async,
CoroutineSource::Block,
)),
body,
..
}),
..
}) = block.expr
&& let ClosureKind::Coroutine(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Block)) =
kind
{
return Some(cx.tcx.hir().body(body));
}
Expand Down
24 changes: 24 additions & 0 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ mod unnecessary_iter_cloned;
mod unnecessary_join;
mod unnecessary_lazy_eval;
mod unnecessary_literal_unwrap;
mod unnecessary_min;
mod unnecessary_sort_by;
mod unnecessary_to_owned;
mod unwrap_expect_used;
Expand Down Expand Up @@ -3754,6 +3755,27 @@ declare_clippy_lint! {
"using `Option.map_or(Err(_), Ok)`, which is more succinctly expressed as `Option.ok_or(_)`"
}

declare_clippy_lint! {
/// ### What it does
/// Checks for unnecessary calls to `min()`
///
/// ### Why is this bad?
///
/// In these cases it is not necessary to call `min()`
/// ### Example
/// ```no_run
/// let _ = 0.min(7_u32);
/// ```
/// Use instead:
/// ```no_run
/// let _ = 7;
/// ```
#[clippy::version = "1.76.0"]
pub UNNECESSARY_MIN,
complexity,
"using 'min()' when there is no need for it"
}

declare_clippy_lint! {
/// ### What it does
/// Checks for iterators of `Result`s using `.filter(Result::is_ok).map(Result::unwrap)` that may
Expand Down Expand Up @@ -3980,6 +4002,7 @@ impl_lint_pass!(Methods => [
UNNECESSARY_FALLIBLE_CONVERSIONS,
JOIN_ABSOLUTE_PATHS,
OPTION_MAP_OR_ERR_OK,
UNNECESSARY_MIN,
RESULT_FILTER_MAP,
ITER_FILTER_IS_SOME,
ITER_FILTER_IS_OK,
Expand Down Expand Up @@ -4264,6 +4287,7 @@ impl Methods {
Some(("bytes", recv2, [], _, _)) => bytes_count_to_len::check(cx, expr, recv, recv2),
_ => {},
},
("min", [arg]) => unnecessary_min::check(cx, expr, recv, arg),
("drain", ..) => {
if let Node::Stmt(Stmt { hir_id: _, kind, .. }) = cx.tcx.hir().get_parent(expr.hir_id)
&& matches!(kind, StmtKind::Semi(_))
Expand Down
111 changes: 111 additions & 0 deletions clippy_lints/src/methods/unnecessary_min.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
use std::cmp::Ordering;

use super::UNNECESSARY_MIN;
use clippy_utils::diagnostics::span_lint_and_sugg;

use clippy_utils::consts::{constant, Constant};
use clippy_utils::source::snippet;
use clippy_utils::{clip, int_bits, unsext};
use hir::Expr;

use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::LateContext;

use rustc_middle::ty;
use rustc_span::Span;

pub fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, recv: &'tcx Expr<'_>, arg: &'tcx Expr<'_>) {
if both_are_constant(cx, expr, recv, arg) {
return;
}
one_extrema(cx, expr, recv, arg);
}
fn lint(cx: &LateContext<'_>, expr: &Expr<'_>, sugg: Span, other: Span) {
let msg = format!(
"`{}` is never greater than `{}` and has therefore no effect",
snippet(cx, sugg, "Not yet implemented"),
snippet(cx, other, "Not yet implemented")
);
span_lint_and_sugg(
cx,
UNNECESSARY_MIN,
expr.span,
&msg,
"try",
snippet(cx, sugg, "Not yet implemented").to_string(),
Applicability::MachineApplicable,
);
}

fn try_to_eval<'tcx>(
cx: &LateContext<'tcx>,
recv: &'tcx Expr<'_>,
arg: &'tcx Expr<'_>,
) -> (Option<Constant<'tcx>>, Option<Constant<'tcx>>) {
(
(constant(cx, cx.typeck_results(), recv)),
(constant(cx, cx.typeck_results(), arg)),
)
}
#[derive(Debug)]
enum Extrema {
Minimum,
Maximum,
}
fn detect_extrema<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<Extrema> {
let ty = cx.typeck_results().expr_ty(expr);

let cv = constant(cx, cx.typeck_results(), expr)?;

match (ty.kind(), cv) {
Comment on lines +59 to +61
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh i didnt know this method existed.
I will look into that.
Thank you!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to implement that change.
I need to use the ty.kind() because i have to know how many bits the integer has.
If i use your proposal, than i only know if it is signed or unsigned and i can't use the math in the arms because it gives me a i128 if it is signed. (unsext wants u128)
Do i miss or misunderstand something here?
Thank you for your feedback. I appreciate it.

(&ty::Uint(_), Constant::Int(0)) => Some(Extrema::Minimum),
(&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::MIN >> (128 - int_bits(cx.tcx, ity)), ity) => {
Some(Extrema::Minimum)
},

(&ty::Int(ity), Constant::Int(i)) if i == unsext(cx.tcx, i128::MAX >> (128 - int_bits(cx.tcx, ity)), ity) => {
Some(Extrema::Maximum)
},
(&ty::Uint(uty), Constant::Int(i)) if i == clip(cx.tcx, u128::MAX, uty) => Some(Extrema::Maximum),

_ => None,
}
}
fn both_are_constant<'tcx>(
cx: &LateContext<'tcx>,
expr: &'tcx Expr<'_>,
recv: &'tcx Expr<'_>,
arg: &'tcx Expr<'_>,
) -> bool {
let ty = cx.typeck_results().expr_ty(recv);
if let (Some(left), Some(right)) = try_to_eval(cx, recv, arg)
&& let Some(ord) = Constant::partial_cmp(cx.tcx, ty, &left, &right)
{
let (sugg, other) = match ord {
Ordering::Less => (recv.span, arg.span),
Ordering::Equal | Ordering::Greater => (arg.span, recv.span),
};

lint(cx, expr, sugg, other);
return true;
}
false
}
fn one_extrema<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, recv: &'tcx Expr<'_>, arg: &'tcx Expr<'_>) -> bool {
if let Some(extrema) = detect_extrema(cx, recv) {
match extrema {
Extrema::Minimum => lint(cx, expr, recv.span, arg.span),
Extrema::Maximum => lint(cx, expr, arg.span, recv.span),
}
return true;
} else if let Some(extrema) = detect_extrema(cx, arg) {
match extrema {
Extrema::Minimum => lint(cx, expr, arg.span, recv.span),
Extrema::Maximum => lint(cx, expr, recv.span, arg.span),
}
return true;
}

false
}
12 changes: 2 additions & 10 deletions clippy_lints/src/redundant_async_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use clippy_utils::source::{snippet, walk_span_to_context};
use clippy_utils::ty::implements_trait;
use clippy_utils::visitors::for_each_expr;
use rustc_errors::Applicability;
use rustc_hir::{
Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, MatchSource,
};
use rustc_hir::{Closure, ClosureKind, CoroutineKind, CoroutineSource, CoroutineDesugaring, Expr, ExprKind, MatchSource};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::lint::in_external_macro;
use rustc_middle::ty::UpvarCapture;
Expand Down Expand Up @@ -77,13 +75,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantAsyncBlock {
fn desugar_async_block<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> {
if let ExprKind::Closure(Closure { body, def_id, kind, .. }) = expr.kind
&& let body = cx.tcx.hir().body(*body)
&& matches!(
kind,
ClosureKind::Coroutine(CoroutineKind::Desugared(
CoroutineDesugaring::Async,
CoroutineSource::Block
))
)
&& matches!(kind, ClosureKind::Coroutine(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Block)))
{
cx.typeck_results()
.closure_min_captures
Expand Down
5 changes: 2 additions & 3 deletions clippy_lints/src/redundant_closure_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use clippy_utils::sugg::Sugg;
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, Node};
use rustc_hir::{intravisit as hir_visit, CoroutineKind, CoroutineSource, CoroutineDesugaring, Node, ClosureKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::hir::nested_filter;
use rustc_middle::lint::in_external_macro;
Expand Down Expand Up @@ -66,8 +66,7 @@ impl<'tcx> Visitor<'tcx> for ReturnVisitor {
fn is_async_closure(body: &hir::Body<'_>) -> bool {
if let hir::ExprKind::Closure(innermost_closure_generated_by_desugar) = body.value.kind
// checks whether it is `async || whatever_expression`
&& let ClosureKind::Coroutine(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Closure))
= innermost_closure_generated_by_desugar.kind
&& let ClosureKind::Coroutine(CoroutineKind::Desugared(CoroutineDesugaring::Async, CoroutineSource::Closure)) = innermost_closure_generated_by_desugar.kind
{
true
} else {
Expand Down
11 changes: 4 additions & 7 deletions clippy_utils/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ pub fn get_attr<'a>(
})
.map_or_else(
|| {
sess.dcx()
.span_err(attr_segments[1].ident.span, "usage of unknown attribute");
sess.dcx().span_err(attr_segments[1].ident.span, "usage of unknown attribute");
false
},
|deprecation_status| {
let mut diag = sess
.dcx()
.struct_span_err(attr_segments[1].ident.span, "usage of deprecated attribute");
let mut diag =
sess.dcx().struct_span_err(attr_segments[1].ident.span, "usage of deprecated attribute");
match *deprecation_status {
DeprecationStatus::Deprecated => {
diag.emit();
Expand Down Expand Up @@ -134,8 +132,7 @@ pub fn get_unique_attr<'a>(
let mut unique_attr: Option<&ast::Attribute> = None;
for attr in get_attr(sess, attrs, name) {
if let Some(duplicate) = unique_attr {
sess.dcx()
.struct_span_err(attr.span, format!("`{name}` is defined multiple times"))
sess.dcx().struct_span_err(attr.span, format!("`{name}` is defined multiple times"))
.span_note(duplicate.span, "first definition found here")
.emit();
} else {
Expand Down
7 changes: 6 additions & 1 deletion tests/ui/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
clippy::cast_sign_loss,
clippy::cast_possible_wrap
)]
#![allow(clippy::cast_abs_to_unsigned, clippy::no_effect, clippy::unnecessary_operation)]
#![allow(
clippy::cast_abs_to_unsigned,
clippy::no_effect,
clippy::unnecessary_operation,
clippy::unnecessary_min
)]

fn main() {
// Test clippy::cast_precision_loss
Expand Down
Loading