diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-07-30 14:25:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-30 14:25:08 +0200 |
| commit | e3bf088fb5e339a030d200e0acf190a10104da80 (patch) | |
| tree | 1d680d83d8fd3024f17a55adeff5e99b871fdce5 /src | |
| parent | e517ee02b2cd040408657b07b28c97a729d897ea (diff) | |
| parent | 90f9640528d9ea9930a4da586a1c6079dd7e5720 (diff) | |
| download | rust-e3bf088fb5e339a030d200e0acf190a10104da80.tar.gz rust-e3bf088fb5e339a030d200e0acf190a10104da80.zip | |
Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee
Mark `map_or` as `#[must_use]` I don't know what else to say. r? libs
Diffstat (limited to 'src')
3 files changed, 5 insertions, 5 deletions
diff --git a/src/tools/clippy/clippy_lints/src/operators/bit_mask.rs b/src/tools/clippy/clippy_lints/src/operators/bit_mask.rs index 1fddf0f50e3..c146f3ae95b 100644 --- a/src/tools/clippy/clippy_lints/src/operators/bit_mask.rs +++ b/src/tools/clippy/clippy_lints/src/operators/bit_mask.rs @@ -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); + } } } diff --git a/src/tools/clippy/tests/ui/result_map_or_into_option.fixed b/src/tools/clippy/tests/ui/result_map_or_into_option.fixed index 119ff25918a..6850eeb7a4c 100644 --- a/src/tools/clippy/tests/ui/result_map_or_into_option.fixed +++ b/src/tools/clippy/tests/ui/result_map_or_into_option.fixed @@ -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)); } diff --git a/src/tools/clippy/tests/ui/result_map_or_into_option.rs b/src/tools/clippy/tests/ui/result_map_or_into_option.rs index eeeef830af0..8e151814407 100644 --- a/src/tools/clippy/tests/ui/result_map_or_into_option.rs +++ b/src/tools/clippy/tests/ui/result_map_or_into_option.rs @@ -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)); } |
