Skip to content

Commit 4877263

Browse files
committed
fix all warnings caused by new lint
1 parent 128dcd4 commit 4877263

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+124
-140
lines changed

clippy_dev/src/setup/vscode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn delete_vs_task_file(path: &Path) -> bool {
8484
/// It may fail silently.
8585
fn try_delete_vs_directory_if_empty() {
8686
let path = Path::new(VSCODE_DIR);
87-
if path.read_dir().map_or(false, |mut iter| iter.next().is_none()) {
87+
if path.read_dir().is_ok_and(|mut iter| iter.next().is_none()) {
8888
// The directory is empty. We just try to delete it but allow a silence
8989
// fail as an empty `.vscode` directory is still valid
9090
let _silence_result = fs::remove_dir(path);

clippy_lints/src/attrs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -501,15 +501,15 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
501501
return;
502502
}
503503
if let Some(lint_list) = &attr.meta_item_list() {
504-
if attr.ident().map_or(false, |ident| is_lint_level(ident.name)) {
504+
if attr.ident().is_some_and(|ident| is_lint_level(ident.name)) {
505505
for lint in lint_list {
506506
match item.kind {
507507
ItemKind::Use(..) => {
508508
if is_word(lint, sym::unused_imports)
509509
|| is_word(lint, sym::deprecated)
510510
|| is_word(lint, sym!(unreachable_pub))
511511
|| is_word(lint, sym!(unused))
512-
|| extract_clippy_lint(lint).map_or(false, |s| {
512+
|| extract_clippy_lint(lint).is_some_and(|s| {
513513
matches!(
514514
s.as_str(),
515515
"wildcard_imports"
@@ -715,7 +715,7 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_
715715
block
716716
.expr
717717
.as_ref()
718-
.map_or(false, |e| is_relevant_expr(cx, typeck_results, e)),
718+
.is_some_and(|e| is_relevant_expr(cx, typeck_results, e)),
719719
|stmt| match &stmt.kind {
720720
StmtKind::Local(_) => true,
721721
StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr),
@@ -725,7 +725,7 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_
725725
}
726726

727727
fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, expr: &Expr<'_>) -> bool {
728-
if macro_backtrace(expr.span).last().map_or(false, |macro_call| {
728+
if macro_backtrace(expr.span).last().is_some_and(|macro_call| {
729729
is_panic(cx, macro_call.def_id) || cx.tcx.item_name(macro_call.def_id) == sym::unreachable
730730
}) {
731731
return false;

clippy_lints/src/bool_assert_comparison.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -
6060
trait_id,
6161
)
6262
})
63-
.map_or(false, |assoc_item| {
63+
.is_some_and(|assoc_item| {
6464
let proj = Ty::new_projection(cx.tcx, assoc_item.def_id, cx.tcx.mk_args_trait(ty, []));
6565
let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj);
6666

clippy_lints/src/booleans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ fn implements_ord(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
492492
let ty = cx.typeck_results().expr_ty(expr);
493493
cx.tcx
494494
.get_diagnostic_item(sym::Ord)
495-
.map_or(false, |id| implements_trait(cx, ty, id, &[]))
495+
.is_some_and(|id| implements_trait(cx, ty, id, &[]))
496496
}
497497

498498
struct NotSimplificationVisitor<'a, 'tcx> {

clippy_lints/src/box_default.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl LateLintPass<'_> for BoxDefault {
4747
&& !in_external_macro(cx.sess(), expr.span)
4848
&& (expr.span.eq_ctxt(arg.span) || is_vec_expn(cx, arg))
4949
&& seg.ident.name == sym::new
50-
&& path_def_id(cx, ty).map_or(false, |id| Some(id) == cx.tcx.lang_items().owned_box())
50+
&& path_def_id(cx, ty).is_some_and(|id| Some(id) == cx.tcx.lang_items().owned_box())
5151
&& is_default_equivalent(cx, arg)
5252
{
5353
span_lint_and_sugg(
@@ -84,7 +84,7 @@ fn is_plain_default(cx: &LateContext<'_>, arg_path: &Expr<'_>) -> bool {
8484
fn is_vec_expn(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
8585
macro_backtrace(expr.span)
8686
.next()
87-
.map_or(false, |call| cx.tcx.is_diagnostic_item(sym::vec_macro, call.def_id))
87+
.is_some_and(|call| cx.tcx.is_diagnostic_item(sym::vec_macro, call.def_id))
8888
}
8989

9090
#[derive(Default)]

clippy_lints/src/casts/unnecessary_cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub(super) fn check<'tcx>(
160160
expr.span,
161161
&format!("casting to the same type is unnecessary (`{cast_from}` -> `{cast_to}`)"),
162162
"try",
163-
if get_parent_expr(cx, expr).map_or(false, |e| matches!(e.kind, ExprKind::AddrOf(..))) {
163+
if get_parent_expr(cx, expr).is_some_and(|e| matches!(e.kind, ExprKind::AddrOf(..))) {
164164
format!("{{ {cast_str} }}")
165165
} else {
166166
cast_str

clippy_lints/src/comparison_chain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain {
110110
let is_ord = cx
111111
.tcx
112112
.get_diagnostic_item(sym::Ord)
113-
.map_or(false, |id| implements_trait(cx, ty, id, &[]));
113+
.is_some_and(|id| implements_trait(cx, ty, id, &[]));
114114

115115
if !is_ord {
116116
return;

clippy_lints/src/copies.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ fn lint_branches_sharing_code<'tcx>(
273273
let span = span.with_hi(last_block.span.hi());
274274
// Improve formatting if the inner block has indention (i.e. normal Rust formatting)
275275
let test_span = Span::new(span.lo() - BytePos(4), span.lo(), span.ctxt(), span.parent());
276-
let span = if snippet_opt(cx, test_span).map_or(false, |snip| snip == " ") {
276+
let span = if snippet_opt(cx, test_span).is_some_and(|snip| snip == " ") {
277277
span.with_lo(test_span.lo())
278278
} else {
279279
span
@@ -354,7 +354,7 @@ fn eq_binding_names(s: &Stmt<'_>, names: &[(HirId, Symbol)]) -> bool {
354354
let mut i = 0usize;
355355
let mut res = true;
356356
l.pat.each_binding_or_first(&mut |_, _, _, name| {
357-
if names.get(i).map_or(false, |&(_, n)| n == name.name) {
357+
if names.get(i).is_some_and(|&(_, n)| n == name.name) {
358358
i += 1;
359359
} else {
360360
res = false;
@@ -398,12 +398,10 @@ fn eq_stmts(
398398
let new_bindings = &moved_bindings[old_count..];
399399
blocks
400400
.iter()
401-
.all(|b| get_stmt(b).map_or(false, |s| eq_binding_names(s, new_bindings)))
401+
.all(|b| get_stmt(b).is_some_and(|s| eq_binding_names(s, new_bindings)))
402402
} else {
403403
true
404-
}) && blocks
405-
.iter()
406-
.all(|b| get_stmt(b).map_or(false, |s| eq.eq_stmt(s, stmt)))
404+
}) && blocks.iter().all(|b| get_stmt(b).is_some_and(|s| eq.eq_stmt(s, stmt)))
407405
}
408406

409407
#[expect(clippy::too_many_lines)]
@@ -460,9 +458,7 @@ fn scan_block_for_eq<'tcx>(
460458
// x + 50
461459
let expr_hash_eq = if let Some(e) = block.expr {
462460
let hash = hash_expr(cx, e);
463-
blocks
464-
.iter()
465-
.all(|b| b.expr.map_or(false, |e| hash_expr(cx, e) == hash))
461+
blocks.iter().all(|b| b.expr.is_some_and(|e| hash_expr(cx, e) == hash))
466462
} else {
467463
blocks.iter().all(|b| b.expr.is_none())
468464
};
@@ -522,7 +518,7 @@ fn scan_block_for_eq<'tcx>(
522518
});
523519
if let Some(e) = block.expr {
524520
for block in blocks {
525-
if block.expr.map_or(false, |expr| !eq.eq_expr(expr, e)) {
521+
if block.expr.is_some_and(|expr| !eq.eq_expr(expr, e)) {
526522
moved_locals.truncate(moved_locals_at_start);
527523
return BlockEq {
528524
start_end_eq,
@@ -541,7 +537,7 @@ fn scan_block_for_eq<'tcx>(
541537
}
542538

543539
fn check_for_warn_of_moved_symbol(cx: &LateContext<'_>, symbols: &[(HirId, Symbol)], if_expr: &Expr<'_>) -> bool {
544-
get_enclosing_block(cx, if_expr.hir_id).map_or(false, |block| {
540+
get_enclosing_block(cx, if_expr.hir_id).is_some_and(|block| {
545541
let ignore_span = block.span.shrink_to_lo().to(if_expr.span);
546542

547543
symbols

clippy_lints/src/default_numeric_fallback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,6 @@ impl<'tcx> From<Ty<'tcx>> for ExplicitTyBound {
229229

230230
impl<'tcx> From<Option<Ty<'tcx>>> for ExplicitTyBound {
231231
fn from(v: Option<Ty<'tcx>>) -> Self {
232-
Self(v.map_or(false, Ty::is_numeric))
232+
Self(v.is_some_and(Ty::is_numeric))
233233
}
234234
}

clippy_lints/src/derivable_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn is_path_self(e: &Expr<'_>) -> bool {
7979
fn contains_trait_object(ty: Ty<'_>) -> bool {
8080
match ty.kind() {
8181
ty::Ref(_, ty, _) => contains_trait_object(*ty),
82-
ty::Adt(def, args) => def.is_box() && args[0].as_type().map_or(false, contains_trait_object),
82+
ty::Adt(def, args) => def.is_box() && args[0].as_type().is_some_and(contains_trait_object),
8383
ty::Dynamic(..) => true,
8484
_ => false,
8585
}

clippy_lints/src/derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
344344
// there's a Copy impl for any instance of the adt.
345345
if !is_copy(cx, ty) {
346346
if ty_subs.non_erasable_generics(cx.tcx, ty_adt.did()).next().is_some() {
347-
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).map_or(false, |impls| {
347+
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).is_some_and(|impls| {
348348
impls.iter().any(|&id| {
349349
matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _)
350350
if ty_adt.did() == adt.did())

clippy_lints/src/drop_forget_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
111111
MEM_FORGET,
112112
Cow::Owned(format!(
113113
"usage of `mem::forget` on {}",
114-
if arg_ty.ty_adt_def().map_or(false, |def| def.has_dtor(cx.tcx)) {
114+
if arg_ty.ty_adt_def().is_some_and(|def| def.has_dtor(cx.tcx)) {
115115
"`Drop` type"
116116
} else {
117117
"type with `Drop` fields"

clippy_lints/src/eta_reduction.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
168168
cx.param_env,
169169
Binder::bind_with_vars(callee_ty_adjusted, List::empty()),
170170
ImplPolarity::Positive,
171-
) && path_to_local(callee).map_or(false, |l| {
172-
local_used_in(cx, l, args) || local_used_after_expr(cx, l, expr)
173-
}) {
171+
) && path_to_local(callee)
172+
.is_some_and(|l| local_used_in(cx, l, args) || local_used_after_expr(cx, l, expr))
173+
{
174174
// Mutable closure is used after current expr; we cannot consume it.
175175
snippet = format!("&mut {snippet}");
176176
}

clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn raw_ptr_arg(cx: &LateContext<'_>, arg: &hir::Param<'_>) -> Option<hir::HirId>
8787
}
8888

8989
fn check_arg(cx: &LateContext<'_>, raw_ptrs: &HirIdSet, arg: &hir::Expr<'_>) {
90-
if path_to_local(arg).map_or(false, |id| raw_ptrs.contains(&id)) {
90+
if path_to_local(arg).is_some_and(|id| raw_ptrs.contains(&id)) {
9191
span_lint(
9292
cx,
9393
NOT_UNSAFE_PTR_ARG_DEREF,

clippy_lints/src/infinite_iter.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
172172
if let ExprKind::Path(ref qpath) = path.kind {
173173
cx.qpath_res(qpath, path.hir_id)
174174
.opt_def_id()
175-
.map_or(false, |id| cx.tcx.is_diagnostic_item(sym::iter_repeat, id))
175+
.is_some_and(|id| cx.tcx.is_diagnostic_item(sym::iter_repeat, id))
176176
.into()
177177
} else {
178178
Finite
179179
}
180180
},
181-
ExprKind::Struct(..) => higher::Range::hir(expr).map_or(false, |r| r.end.is_none()).into(),
181+
ExprKind::Struct(..) => higher::Range::hir(expr).is_some_and(|r| r.end.is_none()).into(),
182182
_ => Finite,
183183
}
184184
}
@@ -240,9 +240,7 @@ fn complete_infinite_iter(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
240240
let not_double_ended = cx
241241
.tcx
242242
.get_diagnostic_item(sym::DoubleEndedIterator)
243-
.map_or(false, |id| {
244-
!implements_trait(cx, cx.typeck_results().expr_ty(receiver), id, &[])
245-
});
243+
.is_some_and(|id| !implements_trait(cx, cx.typeck_results().expr_ty(receiver), id, &[]));
246244
if not_double_ended {
247245
return is_infinite(cx, receiver);
248246
}

clippy_lints/src/item_name_repetitions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ fn check_enum_start(cx: &LateContext<'_>, item_name: &str, variant: &Variant<'_>
287287
let item_name_chars = item_name.chars().count();
288288

289289
if count_match_start(item_name, name).char_count == item_name_chars
290-
&& name.chars().nth(item_name_chars).map_or(false, |c| !c.is_lowercase())
291-
&& name.chars().nth(item_name_chars + 1).map_or(false, |c| !c.is_numeric())
290+
&& name.chars().nth(item_name_chars).is_some_and(|c| !c.is_lowercase())
291+
&& name.chars().nth(item_name_chars + 1).is_some_and(|c| !c.is_numeric())
292292
{
293293
span_lint_hir(
294294
cx,

clippy_lints/src/iter_not_returning_iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn check_sig(cx: &LateContext<'_>, name: &str, sig: &FnSig<'_>, fn_id: LocalDefI
7979
if cx
8080
.tcx
8181
.get_diagnostic_item(sym::Iterator)
82-
.map_or(false, |iter_id| !implements_trait(cx, ret_ty, iter_id, &[]))
82+
.is_some_and(|iter_id| !implements_trait(cx, ret_ty, iter_id, &[]))
8383
{
8484
span_lint(
8585
cx,

clippy_lints/src/len_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
617617

618618
let ty = &cx.typeck_results().expr_ty(expr).peel_refs();
619619
match ty.kind() {
620-
ty::Dynamic(tt, ..) => tt.principal().map_or(false, |principal| {
620+
ty::Dynamic(tt, ..) => tt.principal().is_some_and(|principal| {
621621
let is_empty = sym!(is_empty);
622622
cx.tcx
623623
.associated_items(principal.def_id())

clippy_lints/src/lifetimes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ fn elision_suggestions(
283283
suggestions.extend(
284284
usages
285285
.iter()
286-
.filter(|usage| named_lifetime(usage).map_or(false, |id| elidable_lts.contains(&id)))
286+
.filter(|usage| named_lifetime(usage).is_some_and(|id| elidable_lts.contains(&id)))
287287
.map(|usage| {
288288
match cx.tcx.hir().get_parent(usage.hir_id) {
289289
Node::Ty(Ty {

clippy_lints/src/loops/manual_find.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub(super) fn check<'tcx>(
5252
);
5353
}
5454
let ty = cx.typeck_results().expr_ty(inner_ret);
55-
if cx.tcx.lang_items().copy_trait().map_or(false, |id| implements_trait(cx, ty, id, &[])) {
55+
if cx.tcx.lang_items().copy_trait().is_some_and(|id| implements_trait(cx, ty, id, &[])) {
5656
snippet.push_str(
5757
&format!(
5858
".find(|{}{}| {})",

clippy_lints/src/loops/manual_memcpy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ fn get_assignments<'a, 'tcx>(
405405
.chain(*expr)
406406
.filter(move |e| {
407407
if let ExprKind::AssignOp(_, place, _) = e.kind {
408-
path_to_local(place).map_or(false, |id| {
408+
path_to_local(place).is_some_and(|id| {
409409
!loop_counters
410410
.iter()
411411
// skip the first item which should be `StartKind::Range`

clippy_lints/src/loops/mut_range_bound.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl BreakAfterExprVisitor {
139139
break_after_expr: false,
140140
};
141141

142-
get_enclosing_block(cx, hir_id).map_or(false, |block| {
142+
get_enclosing_block(cx, hir_id).is_some_and(|block| {
143143
visitor.visit_block(block);
144144
visitor.break_after_expr
145145
})

clippy_lints/src/loops/same_item_push.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ pub(super) fn check<'tcx>(
5252
if cx
5353
.tcx
5454
.lang_items()
55-
.clone_trait()
56-
.map_or(false, |id| implements_trait(cx, ty, id, &[]));
55+
.clone_trait().is_some_and(|id| implements_trait(cx, ty, id, &[]));
5756
then {
5857
// Make sure that the push does not involve possibly mutating values
5958
match pushed_item.kind {

clippy_lints/src/loops/utils.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,10 @@ impl<'tcx> Visitor<'tcx> for LoopNestVisitor {
316316
/// If `arg` was the argument to a `for` loop, return the "cleanest" way of writing the
317317
/// actual `Iterator` that the loop uses.
318318
pub(super) fn make_iterator_snippet(cx: &LateContext<'_>, arg: &Expr<'_>, applic_ref: &mut Applicability) -> String {
319-
let impls_iterator = cx.tcx.get_diagnostic_item(sym::Iterator).map_or(false, |id| {
320-
implements_trait(cx, cx.typeck_results().expr_ty(arg), id, &[])
321-
});
319+
let impls_iterator = cx
320+
.tcx
321+
.get_diagnostic_item(sym::Iterator)
322+
.is_some_and(|id| implements_trait(cx, cx.typeck_results().expr_ty(arg), id, &[]));
322323
if impls_iterator {
323324
format!(
324325
"{}",

clippy_lints/src/manual_clamp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl TypeClampability {
192192
} else if cx
193193
.tcx
194194
.get_diagnostic_item(sym::Ord)
195-
.map_or(false, |id| implements_trait(cx, ty, id, &[]))
195+
.is_some_and(|id| implements_trait(cx, ty, id, &[]))
196196
{
197197
Some(TypeClampability::Ord)
198198
} else {

clippy_lints/src/manual_let_else.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ fn expr_diverges(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
312312
}
313313
},
314314
ExprKind::If(if_expr, if_then, if_else) => {
315-
let else_diverges = if_else.map_or(false, |ex| expr_diverges(self.cx, ex));
315+
let else_diverges = if_else.is_some_and(|ex| expr_diverges(self.cx, ex));
316316
let diverges =
317317
expr_diverges(self.cx, if_expr) || (else_diverges && expr_diverges(self.cx, if_then));
318318
if diverges {
@@ -324,7 +324,7 @@ fn expr_diverges(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
324324
ExprKind::Match(match_expr, match_arms, _) => {
325325
let diverges = expr_diverges(self.cx, match_expr)
326326
|| match_arms.iter().all(|arm| {
327-
let guard_diverges = arm.guard.as_ref().map_or(false, |g| expr_diverges(self.cx, g.body()));
327+
let guard_diverges = arm.guard.as_ref().is_some_and(|g| expr_diverges(self.cx, g.body()));
328328
guard_diverges || expr_diverges(self.cx, arm.body)
329329
});
330330
if diverges {

clippy_lints/src/manual_strip.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ fn eq_pattern_length<'tcx>(cx: &LateContext<'tcx>, pattern: &Expr<'_>, expr: &'t
158158
..
159159
}) = expr.kind
160160
{
161-
constant_length(cx, pattern).map_or(false, |length| length == *n)
161+
constant_length(cx, pattern) == Some(*n)
162162
} else {
163-
len_arg(cx, expr).map_or(false, |arg| eq_expr_value(cx, pattern, arg))
163+
len_arg(cx, expr).is_some_and(|arg| eq_expr_value(cx, pattern, arg))
164164
}
165165
}
166166

clippy_lints/src/matches/match_like_matches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ where
9090
if first_attrs.is_empty();
9191
if iter
9292
.all(|arm| {
93-
find_bool_lit(&arm.2.kind).map_or(false, |b| b == b0) && arm.3.is_none() && arm.0.is_empty()
93+
find_bool_lit(&arm.2.kind) == Some(b0) && arm.3.is_none() && arm.0.is_empty()
9494
});
9595
then {
9696
if let Some(last_pat) = last_pat_opt {

clippy_lints/src/matches/redundant_pattern_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ fn is_pat_variant(cx: &LateContext<'_>, pat: &Pat<'_>, path: &QPath<'_>, expecte
391391
.tcx
392392
.lang_items()
393393
.get(expected_lang_item)
394-
.map_or(false, |expected_id| cx.tcx.parent(id) == expected_id),
394+
.is_some_and(|expected_id| cx.tcx.parent(id) == expected_id),
395395
Item::Diag(expected_ty, expected_variant) => {
396396
let ty = cx.typeck_results().pat_ty(pat);
397397

clippy_lints/src/matches/try_err.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, scrutine
5454
let span = hygiene::walk_chain(err_arg.span, try_arg.span.ctxt());
5555
let mut applicability = Applicability::MachineApplicable;
5656
let origin_snippet = snippet_with_applicability(cx, span, "_", &mut applicability);
57-
let ret_prefix = if get_parent_expr(cx, expr).map_or(false, |e| matches!(e.kind, ExprKind::Ret(_))) {
57+
let ret_prefix = if get_parent_expr(cx, expr).is_some_and(|e| matches!(e.kind, ExprKind::Ret(_))) {
5858
"" // already returns
5959
} else {
6060
"return "

0 commit comments

Comments
 (0)