Skip to content

Commit b29177d

Browse files
authored
Simplify is_some() && …unwrap() to is_some_and in unit_arg (#17055)
## Summary - `is_expr_default_nested` in `clippy_lints/src/unit_types/unit_arg.rs` was written as `block.expr.is_some() && is_expr_default_nested(cx, block.expr.unwrap())`, which is exactly the pattern that clippy's own `unnecessary_unwrap` lint flags. - Replace it with `block.expr.is_some_and(|e| is_expr_default_nested(cx, e))`. changelog: none
2 parents 1e4d280 + 9b99225 commit b29177d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

clippy_lints/src/unit_types/unit_arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn lint_unit_args<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, args_to_
159159
fn is_expr_default_nested<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> bool {
160160
is_expr_default(cx, expr)
161161
|| matches!(expr.kind, ExprKind::Block(block, _)
162-
if block.expr.is_some() && is_expr_default_nested(cx, block.expr.unwrap()))
162+
if block.expr.is_some_and(|e| is_expr_default_nested(cx, e)))
163163
}
164164

165165
enum MaybeTypeUncertain<'tcx> {

0 commit comments

Comments
 (0)