Skip to content

Commit

Permalink
Rollup merge of rust-lang#112655 - WaffleLapkin:must_use_map_or, r=wo…
Browse files Browse the repository at this point in the history
…rkingjubilee

Mark `map_or` as `#[must_use]`

I don't know what else to say.

r? libs
  • Loading branch information
matthiaskrgr committed Jul 30, 2023
2 parents 436060f + 0c93e30 commit f54263a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions clippy_lints/src/operators/bit_mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ fn check_compare(cx: &LateContext<'_>, bit_op: &Expr<'_>, cmp_op: BinOpKind, cmp
if op.node != BinOpKind::BitAnd && op.node != BinOpKind::BitOr {
return;
}
fetch_int_literal(cx, right)
.or_else(|| fetch_int_literal(cx, left))
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span));
if let Some(mask) = fetch_int_literal(cx, right).or_else(|| fetch_int_literal(cx, left)) {
check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/result_map_or_into_option.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ fn main() {
// A non-Some `f` closure where the argument is not used as the
// return should not emit the lint
let opt: Result<u32, &str> = Ok(1);
opt.map_or(None, |_x| Some(1));
_ = opt.map_or(None, |_x| Some(1));
}
2 changes: 1 addition & 1 deletion tests/ui/result_map_or_into_option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ fn main() {
// A non-Some `f` closure where the argument is not used as the
// return should not emit the lint
let opt: Result<u32, &str> = Ok(1);
opt.map_or(None, |_x| Some(1));
_ = opt.map_or(None, |_x| Some(1));
}

0 comments on commit f54263a

Please sign in to comment.