Skip to content

Commit 064c3c1

Browse files
Rollup merge of #79337 - LingMan:map, r=jyn514
Use Option::map instead of open coding it r? `@jonas-schievink` since you're frequently sniping these minor cleanups anyway. `@rustbot` modify labels +C-cleanup +T-compiler
2 parents a0cf162 + cd89732 commit 064c3c1

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1152,10 +1152,7 @@ impl<'ll> MemberDescription<'ll> {
11521152
self.size.bits(),
11531153
self.align.bits() as u32,
11541154
self.offset.bits(),
1155-
match self.discriminant {
1156-
None => None,
1157-
Some(value) => Some(cx.const_u64(value)),
1158-
},
1155+
self.discriminant.map(|v| cx.const_u64(v)),
11591156
self.flags,
11601157
self.type_metadata,
11611158
)

compiler/rustc_middle/src/ty/sty.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1106,10 +1106,7 @@ impl<T> Binder<T> {
11061106

11071107
impl<T> Binder<Option<T>> {
11081108
pub fn transpose(self) -> Option<Binder<T>> {
1109-
match self.0 {
1110-
Some(v) => Some(Binder(v)),
1111-
None => None,
1112-
}
1109+
self.0.map(Binder)
11131110
}
11141111
}
11151112

compiler/rustc_typeck/src/check/demand.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
810810
// can be given the suggestion "u32::from(x) > y" rather than
811811
// "x > y.try_into().unwrap()".
812812
let lhs_expr_and_src = expected_ty_expr.and_then(|expr| {
813-
match self.tcx.sess.source_map().span_to_snippet(expr.span).ok() {
814-
Some(src) => Some((expr, src)),
815-
None => None,
816-
}
813+
self.tcx
814+
.sess
815+
.source_map()
816+
.span_to_snippet(expr.span)
817+
.ok()
818+
.map(|src| (expr, src))
817819
});
818820
let (span, msg, suggestion) = if let (Some((lhs_expr, lhs_src)), false) =
819821
(lhs_expr_and_src, exp_to_found_is_fallible)

0 commit comments

Comments
 (0)