Skip to content

Commit 0c93e30

Browse files
committed
Mark map_or as #[must_use]
1 parent edb3266 commit 0c93e30

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

clippy_lints/src/operators/bit_mask.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ fn check_compare(cx: &LateContext<'_>, bit_op: &Expr<'_>, cmp_op: BinOpKind, cmp
4040
if op.node != BinOpKind::BitAnd && op.node != BinOpKind::BitOr {
4141
return;
4242
}
43-
fetch_int_literal(cx, right)
44-
.or_else(|| fetch_int_literal(cx, left))
45-
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span));
43+
if let Some(mask) = fetch_int_literal(cx, right).or_else(|| fetch_int_literal(cx, left)) {
44+
check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span);
45+
}
4646
}
4747
}
4848

tests/ui/result_map_or_into_option.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ fn main() {
1515
// A non-Some `f` closure where the argument is not used as the
1616
// return should not emit the lint
1717
let opt: Result<u32, &str> = Ok(1);
18-
opt.map_or(None, |_x| Some(1));
18+
_ = opt.map_or(None, |_x| Some(1));
1919
}

tests/ui/result_map_or_into_option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ fn main() {
1515
// A non-Some `f` closure where the argument is not used as the
1616
// return should not emit the lint
1717
let opt: Result<u32, &str> = Ok(1);
18-
opt.map_or(None, |_x| Some(1));
18+
_ = opt.map_or(None, |_x| Some(1));
1919
}

0 commit comments

Comments
 (0)