Skip to content
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

Handle Option::map_or(true, …) in unnecessary_map_or lint #13653

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion clippy_lints/src/approx_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl ApproxConstant {
let s = s.as_str();
if s.parse::<f64>().is_ok() {
for &(constant, name, min_digits, msrv) in &KNOWN_CONSTS {
if is_approx_const(constant, s, min_digits) && msrv.map_or(true, |msrv| self.msrv.meets(msrv)) {
if is_approx_const(constant, s, min_digits) && msrv.is_none_or(|msrv| self.msrv.meets(msrv)) {
span_lint_and_help(
cx,
APPROX_CONSTANT,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/assigning_clones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
// TODO: This check currently bails if the local variable has no initializer.
// That is overly conservative - the lint should fire even if there was no initializer,
// but the variable has been initialized before `lhs` was evaluated.
&& path_to_local(lhs).map_or(true, |lhs| local_is_initialized(cx, lhs))
&& path_to_local(lhs).is_none_or(|lhs| local_is_initialized(cx, lhs))
&& let Some(resolved_impl) = cx.tcx.impl_of_method(resolved_fn.def_id())
// Derived forms don't implement `clone_from`/`clone_into`.
// See https://github.com/rust-lang/rust/pull/98445#issuecomment-1190681305
&& !cx.tcx.is_builtin_derived(resolved_impl)
// Don't suggest calling a function we're implementing.
&& resolved_impl.as_local().map_or(true, |block_id| {
&& resolved_impl.as_local().is_none_or(|block_id| {
cx.tcx.hir().parent_owner_iter(e.hir_id).all(|(id, _)| id.def_id != block_id)
})
&& let resolved_assoc_items = cx.tcx.associated_items(resolved_impl)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/borrow_deref_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'tcx> LateLintPass<'tcx> for BorrowDerefRef {
&& !addrof_target.span.from_expansion()
&& let ref_ty = cx.typeck_results().expr_ty(deref_target)
&& let ty::Ref(_, inner_ty, Mutability::Not) = ref_ty.kind()
&& get_parent_expr(cx, e).map_or(true, |parent| {
&& get_parent_expr(cx, e).is_none_or(|parent| {
match parent.kind {
// `*&*foo` should lint `deref_addrof` instead.
ExprKind::Unary(UnOp::Deref, _) => is_lint_allowed(cx, DEREF_ADDROF, parent.hir_id),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/cargo/common_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn missing_warning(cx: &LateContext<'_>, package: &cargo_metadata::Package, fiel
}

fn is_empty_str<T: AsRef<std::ffi::OsStr>>(value: Option<&T>) -> bool {
value.map_or(true, |s| s.as_ref().is_empty())
value.is_none_or(|s| s.as_ref().is_empty())
}

fn is_empty_vec(value: &[String]) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/casts/cast_possible_truncation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub(super) fn check(
};
let to_nbits = utils::int_ty_to_nbits(cast_to, cx.tcx);

let cast_from_ptr_size = def.repr().int.map_or(true, |ty| matches!(ty, IntegerType::Pointer(_),));
let cast_from_ptr_size = def.repr().int.is_none_or(|ty| matches!(ty, IntegerType::Pointer(_),));
let suffix = match (cast_from_ptr_size, is_isize_or_usize(cast_to)) {
(_, false) if from_nbits > to_nbits => "",
(false, true) if from_nbits > 64 => "",
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn lint_if_same_then_else(cx: &LateContext<'_>, conds: &[&Expr<'_>], blocks: &[&
.array_windows::<2>()
.enumerate()
.fold(true, |all_eq, (i, &[lhs, rhs])| {
if eq.eq_block(lhs, rhs) && !contains_let(conds[i]) && conds.get(i + 1).map_or(true, |e| !contains_let(e)) {
if eq.eq_block(lhs, rhs) && !contains_let(conds[i]) && conds.get(i + 1).is_none_or(|e| !contains_let(e)) {
span_lint_and_note(
cx,
IF_SAME_THEN_ELSE,
Expand Down Expand Up @@ -470,7 +470,7 @@ fn scan_block_for_eq<'tcx>(
b.stmts
// the bounds check will catch the underflow
.get(b.stmts.len().wrapping_sub(offset + 1))
.map_or(true, |s| hash != hash_stmt(cx, s))
.is_none_or(|s| hash != hash_stmt(cx, s))
})
})
.map_or(block.stmts.len() - start_end_eq, |(i, _)| i);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/dereference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
));
} else if stability.is_deref_stable()
// Auto-deref doesn't combine with other adjustments
&& next_adjust.map_or(true, |a| matches!(a.kind, Adjust::Deref(_) | Adjust::Borrow(_)))
&& next_adjust.is_none_or(|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 {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ fn check_inputs(
&& typeck
.expr_adjustments(arg)
.last()
.map_or(true, |a| a.target == typeck.expr_ty(arg))
.is_none_or(|a| a.target == typeck.expr_ty(arg))
})
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/excessive_bools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<'tcx> LateLintPass<'tcx> for ExcessiveBools {
&& fn_header.abi == Abi::Rust
&& fn_decl.inputs.len() as u64 > self.max_fn_params_bools
&& get_parent_as_impl(cx.tcx, cx.tcx.local_def_id_to_hir_id(def_id))
.map_or(true, |impl_item| impl_item.of_trait.is_none())
.is_none_or(|impl_item| impl_item.of_trait.is_none())
{
check_fn_decl(cx, fn_decl, span, self.max_fn_params_bools);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/from_over_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<'tcx> LateLintPass<'tcx> for FromOverInto {
|diag| {
// If the target type is likely foreign mention the orphan rules as it's a common source of
// confusion
if path_def_id(cx, target_ty.peel_refs()).map_or(true, |id| !id.is_local()) {
if path_def_id(cx, target_ty.peel_refs()).is_none_or(|id| !id.is_local()) {
diag.help(
"`impl From<Local> for Foreign` is allowed by the orphan rules, for more information see\n\
https://doc.rust-lang.org/reference/items/implementations.html#trait-implementation-coherence"
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/if_let_mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn mutex_lock_call<'tcx>(
&& path.ident.as_str() == "lock"
&& let ty = cx.typeck_results().expr_ty(self_arg).peel_refs()
&& is_type_diagnostic_item(cx, ty, sym::Mutex)
&& op_mutex.map_or(true, |op| eq_expr_value(cx, self_arg, op))
&& op_mutex.is_none_or(|op| eq_expr_value(cx, self_arg, op))
{
ControlFlow::Break(self_arg)
} else {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/explicit_iter_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(super) fn check(
if !msrv.meets(msrvs::ARRAY_INTO_ITERATOR) {
return;
}
} else if count.try_to_target_usize(cx.tcx).map_or(true, |x| x > 32) && !msrv.meets(msrvs::ARRAY_IMPL_ANY_LEN) {
} else if count.try_to_target_usize(cx.tcx).is_none_or(|x| x > 32) && !msrv.meets(msrvs::ARRAY_IMPL_ANY_LEN) {
return;
}
}
Expand Down
5 changes: 2 additions & 3 deletions clippy_lints/src/matches/collapsible_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,13 @@ fn check_arm<'tcx>(
(Some(a), Some(b)) => SpanlessEq::new(cx).eq_expr(a, b),
}
// the binding must not be used in the if guard
&& outer_guard.map_or(
true,
&& outer_guard.is_none_or(
|e| !is_local_used(cx, e, binding_id)
)
// ...or anywhere in the inner expression
&& match inner {
IfLetOrMatch::IfLet(_, _, body, els, _) => {
!is_local_used(cx, body, binding_id) && els.map_or(true, |e| !is_local_used(cx, e, binding_id))
!is_local_used(cx, body, binding_id) && els.is_none_or(|e| !is_local_used(cx, e, binding_id))
},
IfLetOrMatch::Match(_, arms, ..) => !arms.iter().any(|arm| is_local_used(cx, arm, binding_id)),
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/clone_on_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub(super) fn check(
.type_dependent_def_id(expr.hir_id)
.and_then(|id| cx.tcx.trait_of_item(id))
.zip(cx.tcx.lang_items().clone_trait())
.map_or(true, |(x, y)| x != y)
.is_none_or(|(x, y)| x != y)
{
return;
}
Expand Down
20 changes: 14 additions & 6 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4107,24 +4107,32 @@ declare_clippy_lint! {
/// ### Why is this bad?
/// Calls such as `opt.map_or(false, |val| val == 5)` are needlessly long and cumbersome,
/// and can be reduced to, for example, `opt == Some(5)` assuming `opt` implements `PartialEq`.
/// Also, calls such as `opt.map_or(true, |val| val == 5)` can be reduced to
/// `opt.is_none_or(|val| val == 5)`.
/// This lint offers readability and conciseness improvements.
///
/// ### Example
/// ```no_run
/// pub fn a(x: Option<i32>) -> bool {
/// x.map_or(false, |n| n == 5)
/// pub fn a(x: Option<i32>) -> (bool, bool) {
/// (
/// x.map_or(false, |n| n == 5),
/// x.map_or(true, |n| n > 5),
/// )
/// }
/// ```
/// Use instead:
/// ```no_run
/// pub fn a(x: Option<i32>) -> bool {
/// x == Some(5)
/// pub fn a(x: Option<i32>) -> (bool, bool) {
/// (
/// x == Some(5),
/// x.is_none_or(|n| n > 5),
/// )
/// }
/// ```
#[clippy::version = "1.75.0"]
pub UNNECESSARY_MAP_OR,
style,
"reduce unnecessary pattern matching for constructs that implement `PartialEq`"
"reduce unnecessary calls to `.map_or(bool, …)`"
}

declare_clippy_lint! {
Expand Down Expand Up @@ -4531,7 +4539,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
&& method_config.output_type.matches(&sig.decl.output)
// in case there is no first arg, since we already have checked the number of arguments
// it's should be always true
&& first_arg_ty_opt.map_or(true, |first_arg_ty| method_config
&& first_arg_ty_opt.is_none_or(|first_arg_ty| method_config
.self_kind.matches(cx, self_ty, first_arg_ty)
)
&& fn_header_equals(method_config.fn_header, sig.header)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/unnecessary_filter_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>, a
if let hir::ExprKind::Closure(&hir::Closure { body, .. }) = arg.kind {
let body = cx.tcx.hir().body(body);
let arg_id = body.params[0].pat.hir_id;
let mutates_arg = mutated_variables(body.value, cx).map_or(true, |used_mutably| used_mutably.contains(&arg_id));
let mutates_arg = mutated_variables(body.value, cx).is_none_or(|used_mutably| used_mutably.contains(&arg_id));
let (clone_or_copy_needed, _) = clone_or_copy_needed(cx, body.params[0].pat, body.value);

let (mut found_mapping, mut found_filtering) = check_expression(cx, arg_id, body.value);
Expand Down
18 changes: 15 additions & 3 deletions clippy_lints/src/methods/unnecessary_map_or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub(super) fn check<'a>(
Some(_) | None => return,
};

let (sugg, method) = if let ExprKind::Closure(map_closure) = map.kind
let (sugg, method, applicability) = if let ExprKind::Closure(map_closure) = map.kind
&& let closure_body = cx.tcx.hir().body(map_closure.body)
&& let closure_body_value = closure_body.value.peel_blocks()
&& let ExprKind::Binary(op, l, r) = closure_body_value.kind
Expand Down Expand Up @@ -100,7 +100,7 @@ pub(super) fn check<'a>(
.maybe_par()
.into_string();

(binop, "a standard comparison")
(binop, "a standard comparison", Applicability::MaybeIncorrect)
} else if !def_bool
&& msrv.meets(msrvs::OPTION_RESULT_IS_VARIANT_AND)
&& let Some(recv_callsite) = snippet_opt(cx, recv.span.source_callsite())
Expand All @@ -110,6 +110,18 @@ pub(super) fn check<'a>(
(
format!("{recv_callsite}.{suggested_name}({span_callsite})",),
suggested_name,
Applicability::MachineApplicable,
)
} else if def_bool
&& matches!(variant, Variant::Some)
&& msrv.meets(msrvs::IS_NONE_OR)
&& let Some(recv_callsite) = snippet_opt(cx, recv.span.source_callsite())
&& let Some(span_callsite) = snippet_opt(cx, map.span.source_callsite())
{
(
format!("{recv_callsite}.is_none_or({span_callsite})"),
"is_none_or",
Applicability::MachineApplicable,
)
} else {
return;
Expand All @@ -126,6 +138,6 @@ pub(super) fn check<'a>(
"this `map_or` is redundant",
format!("use {method} instead"),
sugg,
Applicability::MaybeIncorrect,
applicability,
);
}
2 changes: 1 addition & 1 deletion clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ fn used_underscore_binding<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
/// `unused_variables`'s idea
/// of what it means for an expression to be "used".
fn is_used(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
get_parent_expr(cx, expr).map_or(true, |parent| match parent.kind {
get_parent_expr(cx, expr).is_none_or(|parent| match parent.kind {
ExprKind::Assign(_, rhs, _) | ExprKind::AssignOp(_, _, rhs) => SpanlessEq::new(cx).eq_expr(rhs, expr),
_ => is_used(cx, parent),
})
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_borrows_for_generic_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ fn referent_used_exactly_once<'tcx>(
let body_owner_local_def_id = cx.tcx.hir().enclosing_body_owner(reference.hir_id);
if possible_borrowers
.last()
.map_or(true, |&(local_def_id, _)| local_def_id != body_owner_local_def_id)
.is_none_or(|&(local_def_id, _)| local_def_id != body_owner_local_def_id)
{
possible_borrowers.push((body_owner_local_def_id, PossibleBorrowerMap::new(cx, mir)));
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/no_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
ExprKind::Struct(_, fields, ref base) => {
!has_drop(cx, cx.typeck_results().expr_ty(expr))
&& fields.iter().all(|field| has_no_effect(cx, field.expr))
&& base.as_ref().map_or(true, |base| has_no_effect(cx, base))
&& base.as_ref().is_none_or(|base| has_no_effect(cx, base))
},
ExprKind::Call(callee, args) => {
if let ExprKind::Path(ref qpath) = callee.kind {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/non_copy_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst<'tcx> {
// i.e. having an enum doesn't necessary mean a type has a frozen variant.
// And, implementing it isn't a trivial task; it'll probably end up
// re-implementing the trait predicate evaluation specific to `Freeze`.
&& body_id_opt.map_or(true, |body_id| Self::is_value_unfrozen_poly(cx, body_id, normalized))
&& body_id_opt.is_none_or(|body_id| Self::is_value_unfrozen_poly(cx, body_id, normalized))
{
lint(cx, Source::Assoc { item: trait_item.span });
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/only_used_in_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl Params {
if self
.get_by_fn(param.fn_id, usage.idx)
// If the parameter can't be found, then it's used for more than just recursion.
.map_or(true, |p| self.try_disable_lint_for_param(p, eval_stack))
.is_none_or(|p| self.try_disable_lint_for_param(p, eval_stack))
{
param.apply_lint.set(false);
eval_stack.pop();
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/operators/assign_op_pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(super) fn check<'tcx>(
if let Some((_, lang_item)) = binop_traits(op.node)
&& let Some(trait_id) = cx.tcx.lang_items().get(lang_item)
&& let parent_fn = cx.tcx.hir().get_parent_item(e.hir_id).def_id
&& trait_ref_of_method(cx, parent_fn).map_or(true, |t| t.path.res.def_id() != trait_id)
&& trait_ref_of_method(cx, parent_fn).is_none_or(|t| t.path.res.def_id() != trait_id)
&& implements_trait(cx, ty, trait_id, &[rty.into()])
{
// Primitive types execute assign-ops right-to-left. Every other type is left-to-right.
Expand Down
4 changes: 1 addition & 3 deletions clippy_lints/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,7 @@ fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Optio
.collect();
if let Some(args) = args
&& !args.is_empty()
&& body.map_or(true, |body| {
sig.header.safety == Safety::Unsafe || contains_unsafe_block(cx, body.value)
})
&& body.is_none_or(|body| sig.header.safety == Safety::Unsafe || contains_unsafe_block(cx, body.value))
{
span_lint_and_then(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/redundant_async_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn desugar_async_block<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Op
cx.typeck_results()
.closure_min_captures
.get(def_id)
.map_or(true, |m| {
.is_none_or(|m| {
m.values().all(|places| {
places
.iter()
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/single_call_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl SingleCallFn {
.tcx
.hir()
.maybe_body_owned_by(fn_def_id)
.map_or(true, |body| is_in_test_function(cx.tcx, body.value.hir_id))
.is_none_or(|body| is_in_test_function(cx.tcx, body.value.hir_id))
|| match cx.tcx.hir_node(fn_hir_id) {
Node::Item(item) => is_from_proc_macro(cx, item),
Node::ImplItem(item) => is_from_proc_macro(cx, item),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/undocumented_unsafe_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ fn is_unsafe_from_proc_macro(cx: &LateContext<'_>, span: Span) -> bool {
.src
.as_deref()
.and_then(|src| src.get(file_pos.pos.to_usize()..))
.map_or(true, |src| !src.starts_with("unsafe"))
.is_none_or(|src| !src.starts_with("unsafe"))
}

// Checks if any parent {expression, statement, block, local, const, static}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unit_types/let_unit_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn expr_needs_inferred_result<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -
}
while let Some(id) = locals_to_check.pop() {
if let Node::LetStmt(l) = cx.tcx.parent_hir_node(id) {
if !l.ty.map_or(true, |ty| matches!(ty.kind, TyKind::Infer)) {
if !l.ty.is_none_or(|ty| matches!(ty.kind, TyKind::Infer)) {
return false;
}
if let Some(e) = l.init {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/upper_case_acronyms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn check_ident(cx: &LateContext<'_>, ident: &Ident, hir_id: HirId, be_aggressive
while let Some(c) = s.next() {
r.push(
if replace(&mut prev_upper, c.is_ascii_uppercase())
&& s.clone().next().map_or(true, |c| c.is_ascii_uppercase())
&& s.clone().next().is_none_or(|c| c.is_ascii_uppercase())
{
c.to_ascii_lowercase()
} else {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/use_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
&& let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).args
&& parameters
.as_ref()
.map_or(true, |params| params.parenthesized == GenericArgsParentheses::No)
.is_none_or(|params| params.parenthesized == GenericArgsParentheses::No)
&& !item.span.from_expansion()
&& !is_from_proc_macro(cx, item)
// expensive, should be last check
Expand Down
4 changes: 2 additions & 2 deletions clippy_utils/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl Constant<'_> {
.zip(r)
.zip(tys)
.map(|((li, ri), cmp_type)| Self::partial_cmp(tcx, cmp_type, li, ri))
.find(|r| r.map_or(true, |o| o != Ordering::Equal))
.find(|r| r.is_none_or(|o| o != Ordering::Equal))
.unwrap_or_else(|| Some(l.len().cmp(&r.len()))),
_ => None,
},
Expand All @@ -236,7 +236,7 @@ impl Constant<'_> {
};
iter::zip(l, r)
.map(|(li, ri)| Self::partial_cmp(tcx, cmp_type, li, ri))
.find(|r| r.map_or(true, |o| o != Ordering::Equal))
.find(|r| r.is_none_or(|o| o != Ordering::Equal))
.unwrap_or_else(|| Some(l.len().cmp(&r.len())))
},
(Self::Repeat(lv, ls), Self::Repeat(rv, rs)) => {
Expand Down
Loading