Skip to content

Commit 5ffd2f7

Browse files
committed
new lint unnecessary_map_or
1 parent 0ce07f6 commit 5ffd2f7

File tree

80 files changed

+553
-153
lines changed

Some content is hidden

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

80 files changed

+553
-153
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5918,6 +5918,7 @@ Released 2018-09-13
59185918
[`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap
59195919
[`unnecessary_map_on_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_on_constructor
59205920
[`unnecessary_min_or_max`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_min_or_max
5921+
[`unnecessary_map_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
59215922
[`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
59225923
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
59235924
[`unnecessary_owned_empty_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_owned_empty_strings

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/useless_attribute.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(super) fn check(cx: &LateContext<'_>, item: &Item<'_>, attrs: &[Attribute])
1717
return;
1818
}
1919
if let Some(lint_list) = &attr.meta_item_list() {
20-
if attr.ident().map_or(false, |ident| is_lint_level(ident.name, attr.id)) {
20+
if attr.ident().is_some_and(|ident| is_lint_level(ident.name, attr.id)) {
2121
for lint in lint_list {
2222
match item.kind {
2323
ItemKind::Use(..) => {

clippy_lints/src/attrs/utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_
5050
block
5151
.expr
5252
.as_ref()
53-
.map_or(false, |e| is_relevant_expr(cx, typeck_results, e)),
53+
.is_some_and(|e| is_relevant_expr(cx, typeck_results, e)),
5454
|stmt| match &stmt.kind {
5555
StmtKind::Let(_) => true,
5656
StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr),
@@ -60,7 +60,7 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_
6060
}
6161

6262
fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, expr: &Expr<'_>) -> bool {
63-
if macro_backtrace(expr.span).last().map_or(false, |macro_call| {
63+
if macro_backtrace(expr.span).last().is_some_and(|macro_call| {
6464
is_panic(cx, macro_call.def_id) || cx.tcx.item_name(macro_call.def_id) == sym::unreachable
6565
}) {
6666
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
@@ -607,5 +607,5 @@ fn implements_ord(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
607607
let ty = cx.typeck_results().expr_ty(expr);
608608
cx.tcx
609609
.get_diagnostic_item(sym::Ord)
610-
.map_or(false, |id| implements_trait(cx, ty, id, &[]))
610+
.is_some_and(|id| implements_trait(cx, ty, id, &[]))
611611
}

clippy_lints/src/box_default.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl LateLintPass<'_> for BoxDefault {
4545
// And that method is `new`
4646
&& seg.ident.name == sym::new
4747
// And the call is that of a `Box` method
48-
&& path_def_id(cx, ty).map_or(false, |id| Some(id) == cx.tcx.lang_items().owned_box())
48+
&& path_def_id(cx, ty).is_some_and(|id| Some(id) == cx.tcx.lang_items().owned_box())
4949
// And the single argument to the call is another function call
5050
// This is the `T::default()` of `Box::new(T::default())`
5151
&& let ExprKind::Call(arg_path, _) = arg.kind
@@ -83,9 +83,9 @@ fn is_plain_default(cx: &LateContext<'_>, arg_path: &Expr<'_>) -> bool {
8383
}
8484

8585
fn is_local_vec_expn(cx: &LateContext<'_>, expr: &Expr<'_>, ref_expr: &Expr<'_>) -> bool {
86-
macro_backtrace(expr.span).next().map_or(false, |call| {
87-
cx.tcx.is_diagnostic_item(sym::vec_macro, call.def_id) && call.span.eq_ctxt(ref_expr.span)
88-
})
86+
macro_backtrace(expr.span)
87+
.next()
88+
.is_some_and(|call| cx.tcx.is_diagnostic_item(sym::vec_macro, call.def_id) && call.span.eq_ctxt(ref_expr.span))
8989
}
9090

9191
#[derive(Default)]

clippy_lints/src/casts/unnecessary_cast.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ pub(super) fn check<'tcx>(
159159
// The same is true if the expression encompassing the cast expression is a unary
160160
// expression or an addressof expression.
161161
let needs_block = matches!(cast_expr.kind, ExprKind::Unary(..) | ExprKind::AddrOf(..))
162-
|| get_parent_expr(cx, expr)
163-
.map_or(false, |e| matches!(e.kind, ExprKind::Unary(..) | ExprKind::AddrOf(..)));
162+
|| get_parent_expr(cx, expr).is_some_and(|e| matches!(e.kind, ExprKind::Unary(..) | ExprKind::AddrOf(..)));
164163

165164
span_lint_and_sugg(
166165
cx,

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

+6-10
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ fn eq_binding_names(s: &Stmt<'_>, names: &[(HirId, Symbol)]) -> bool {
348348
let mut i = 0usize;
349349
let mut res = true;
350350
l.pat.each_binding_or_first(&mut |_, _, _, name| {
351-
if names.get(i).map_or(false, |&(_, n)| n == name.name) {
351+
if names.get(i).is_some_and(|&(_, n)| n == name.name) {
352352
i += 1;
353353
} else {
354354
res = false;
@@ -392,12 +392,10 @@ fn eq_stmts(
392392
let new_bindings = &moved_bindings[old_count..];
393393
blocks
394394
.iter()
395-
.all(|b| get_stmt(b).map_or(false, |s| eq_binding_names(s, new_bindings)))
395+
.all(|b| get_stmt(b).is_some_and(|s| eq_binding_names(s, new_bindings)))
396396
} else {
397397
true
398-
}) && blocks
399-
.iter()
400-
.all(|b| get_stmt(b).map_or(false, |s| eq.eq_stmt(s, stmt)))
398+
}) && blocks.iter().all(|b| get_stmt(b).is_some_and(|s| eq.eq_stmt(s, stmt)))
401399
}
402400

403401
#[expect(clippy::too_many_lines)]
@@ -454,9 +452,7 @@ fn scan_block_for_eq<'tcx>(
454452
// x + 50
455453
let expr_hash_eq = if let Some(e) = block.expr {
456454
let hash = hash_expr(cx, e);
457-
blocks
458-
.iter()
459-
.all(|b| b.expr.map_or(false, |e| hash_expr(cx, e) == hash))
455+
blocks.iter().all(|b| b.expr.is_some_and(|e| hash_expr(cx, e) == hash))
460456
} else {
461457
blocks.iter().all(|b| b.expr.is_none())
462458
};
@@ -517,7 +513,7 @@ fn scan_block_for_eq<'tcx>(
517513
});
518514
if let Some(e) = block.expr {
519515
for block in blocks {
520-
if block.expr.map_or(false, |expr| !eq.eq_expr(expr, e)) {
516+
if block.expr.is_some_and(|expr| !eq.eq_expr(expr, e)) {
521517
moved_locals.truncate(moved_locals_at_start);
522518
return BlockEq {
523519
start_end_eq,
@@ -536,7 +532,7 @@ fn scan_block_for_eq<'tcx>(
536532
}
537533

538534
fn check_for_warn_of_moved_symbol(cx: &LateContext<'_>, symbols: &[(HirId, Symbol)], if_expr: &Expr<'_>) -> bool {
539-
get_enclosing_block(cx, if_expr.hir_id).map_or(false, |block| {
535+
get_enclosing_block(cx, if_expr.hir_id).is_some_and(|block| {
540536
let ignore_span = block.span.shrink_to_lo().to(if_expr.span);
541537

542538
symbols

clippy_lints/src/declared_lints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
473473
crate::methods::UNNECESSARY_LITERAL_UNWRAP_INFO,
474474
crate::methods::UNNECESSARY_MIN_OR_MAX_INFO,
475475
crate::methods::UNNECESSARY_RESULT_MAP_OR_ELSE_INFO,
476+
crate::methods::UNNECESSARY_MAP_OR_INFO,
476477
crate::methods::UNNECESSARY_SORT_BY_INFO,
477478
crate::methods::UNNECESSARY_TO_OWNED_INFO,
478479
crate::methods::UNWRAP_OR_DEFAULT_INFO,

clippy_lints/src/default_numeric_fallback.rs

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

253253
impl<'tcx> From<Option<Ty<'tcx>>> for ExplicitTyBound {
254254
fn from(v: Option<Ty<'tcx>>) -> Self {
255-
Self(v.map_or(false, Ty::is_numeric))
255+
Self(v.is_some_and(Ty::is_numeric))
256256
}
257257
}

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
@@ -325,7 +325,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
325325
// there's a Copy impl for any instance of the adt.
326326
if !is_copy(cx, ty) {
327327
if ty_subs.non_erasable_generics(cx.tcx, ty_adt.did()).next().is_some() {
328-
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).map_or(false, |impls| {
328+
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).is_some_and(|impls| {
329329
impls.iter().any(|&id| {
330330
matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _)
331331
if ty_adt.did() == adt.did())

clippy_lints/src/doc/missing_headers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn check(
4747
),
4848
_ => (),
4949
}
50-
if !headers.panics && panic_info.map_or(false, |el| !el.1) {
50+
if !headers.panics && panic_info.is_some_and(|el| !el.1) {
5151
span_lint_and_note(
5252
cx,
5353
MISSING_PANICS_DOC,

clippy_lints/src/drop_forget_ref.rs

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

clippy_lints/src/eta_reduction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
171171
{
172172
span_lint_and_then(cx, REDUNDANT_CLOSURE, expr.span, "redundant closure", |diag| {
173173
if let Some(mut snippet) = snippet_opt(cx, callee.span) {
174-
if path_to_local(callee).map_or(false, |l| {
174+
if path_to_local(callee).is_some_and(|l| {
175175
// FIXME: Do we really need this `local_used_in` check?
176176
// Isn't it checking something like... `callee(callee)`?
177177
// If somehow this check is needed, add some test for it,

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<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
@@ -300,8 +300,8 @@ fn check_enum_start(cx: &LateContext<'_>, item_name: &str, variant: &Variant<'_>
300300
let item_name_chars = item_name.chars().count();
301301

302302
if count_match_start(item_name, name).char_count == item_name_chars
303-
&& name.chars().nth(item_name_chars).map_or(false, |c| !c.is_lowercase())
304-
&& name.chars().nth(item_name_chars + 1).map_or(false, |c| !c.is_numeric())
303+
&& name.chars().nth(item_name_chars).is_some_and(|c| !c.is_lowercase())
304+
&& name.chars().nth(item_name_chars + 1).is_some_and(|c| !c.is_numeric())
305305
{
306306
span_lint_hir(
307307
cx,

clippy_lints/src/iter_not_returning_iterator.rs

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

clippy_lints/src/len_zero.rs

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

630630
let ty = &cx.typeck_results().expr_ty(expr).peel_refs();
631631
match ty.kind() {
632-
ty::Dynamic(tt, ..) => tt.principal().map_or(false, |principal| {
632+
ty::Dynamic(tt, ..) => tt.principal().is_some_and(|principal| {
633633
let is_empty = sym!(is_empty);
634634
cx.tcx
635635
.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.parent_hir_node(usage.hir_id) {
289289
Node::Ty(Ty {

clippy_lints/src/loops/manual_find.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(super) fn check<'tcx>(
5858
.tcx
5959
.lang_items()
6060
.copy_trait()
61-
.map_or(false, |id| implements_trait(cx, ty, id, &[]))
61+
.is_some_and(|id| implements_trait(cx, ty, id, &[]))
6262
{
6363
snippet.push_str(
6464
&format!(

clippy_lints/src/loops/manual_memcpy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ fn get_assignments<'a, 'tcx>(
416416
.chain(*expr)
417417
.filter(move |e| {
418418
if let ExprKind::AssignOp(_, place, _) = e.kind {
419-
path_to_local(place).map_or(false, |id| {
419+
path_to_local(place).is_some_and(|id| {
420420
!loop_counters
421421
.iter()
422422
// 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
@@ -127,7 +127,7 @@ impl BreakAfterExprVisitor {
127127
break_after_expr: false,
128128
};
129129

130-
get_enclosing_block(cx, hir_id).map_or(false, |block| {
130+
get_enclosing_block(cx, hir_id).is_some_and(|block| {
131131
visitor.visit_block(block);
132132
visitor.break_after_expr
133133
})

clippy_lints/src/loops/same_item_push.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(super) fn check<'tcx>(
5050
.tcx
5151
.lang_items()
5252
.clone_trait()
53-
.map_or(false, |id| implements_trait(cx, ty, id, &[]))
53+
.is_some_and(|id| implements_trait(cx, ty, id, &[]))
5454
{
5555
// Make sure that the push does not involve possibly mutating values
5656
match pushed_item.kind {

clippy_lints/src/loops/utils.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,10 @@ fn is_conditional(expr: &Expr<'_>) -> bool {
256256
/// If `arg` was the argument to a `for` loop, return the "cleanest" way of writing the
257257
/// actual `Iterator` that the loop uses.
258258
pub(super) fn make_iterator_snippet(cx: &LateContext<'_>, arg: &Expr<'_>, applic_ref: &mut Applicability) -> String {
259-
let impls_iterator = cx.tcx.get_diagnostic_item(sym::Iterator).map_or(false, |id| {
260-
implements_trait(cx, cx.typeck_results().expr_ty(arg), id, &[])
261-
});
259+
let impls_iterator = cx
260+
.tcx
261+
.get_diagnostic_item(sym::Iterator)
262+
.is_some_and(|id| implements_trait(cx, cx.typeck_results().expr_ty(arg), id, &[]));
262263
if impls_iterator {
263264
format!(
264265
"{}",

clippy_lints/src/manual_clamp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl TypeClampability {
222222
} else if cx
223223
.tcx
224224
.get_diagnostic_item(sym::Ord)
225-
.map_or(false, |id| implements_trait(cx, ty, id, &[]))
225+
.is_some_and(|id| implements_trait(cx, ty, id, &[]))
226226
{
227227
Some(TypeClampability::Ord)
228228
} else {

clippy_lints/src/manual_strip.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ fn eq_pattern_length<'tcx>(cx: &LateContext<'tcx>, pattern: &Expr<'_>, expr: &'t
161161
..
162162
}) = expr.kind
163163
{
164-
constant_length(cx, pattern).map_or(false, |length| *n == length)
164+
constant_length(cx, pattern).is_some_and(|length| *n == length)
165165
} else {
166-
len_arg(cx, expr).map_or(false, |arg| eq_expr_value(cx, pattern, arg))
166+
len_arg(cx, expr).is_some_and(|arg| eq_expr_value(cx, pattern, arg))
167167
}
168168
}
169169

clippy_lints/src/matches/match_like_matches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ where
7474
&& b0 != b1
7575
&& (first_guard.is_none() || iter.len() == 0)
7676
&& first_attrs.is_empty()
77-
&& iter.all(|arm| find_bool_lit(&arm.2.kind).map_or(false, |b| b == b0) && arm.3.is_none() && arm.0.is_empty())
77+
&& iter.all(|arm| find_bool_lit(&arm.2.kind).is_some_and(|b| b == b0) && arm.3.is_none() && arm.0.is_empty())
7878
{
7979
if let Some(last_pat) = last_pat_opt {
8080
if !is_wild(last_pat) {

clippy_lints/src/matches/redundant_pattern_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ fn is_pat_variant(cx: &LateContext<'_>, pat: &Pat<'_>, path: &QPath<'_>, expecte
448448
.tcx
449449
.lang_items()
450450
.get(expected_lang_item)
451-
.map_or(false, |expected_id| cx.tcx.parent(id) == expected_id),
451+
.is_some_and(|expected_id| cx.tcx.parent(id) == expected_id),
452452
Item::Diag(expected_ty, expected_variant) => {
453453
let ty = cx.typeck_results().pat_ty(pat);
454454

clippy_lints/src/matches/try_err.rs

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

clippy_lints/src/methods/expect_fun_call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub(super) fn check<'tcx>(
8383
hir::ExprKind::MethodCall(..) => {
8484
cx.typeck_results()
8585
.type_dependent_def_id(arg.hir_id)
86-
.map_or(false, |method_id| {
86+
.is_some_and(|method_id| {
8787
matches!(
8888
cx.tcx.fn_sig(method_id).instantiate_identity().output().skip_binder().kind(),
8989
ty::Ref(re, ..) if re.is_static()

0 commit comments

Comments
 (0)