diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 5e8ff14f0aa..96484034da7 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -1152,10 +1152,7 @@ fn into_metadata( self.size.bits(), self.align.bits() as u32, self.offset.bits(), - match self.discriminant { - None => None, - Some(value) => Some(cx.const_u64(value)), - }, + self.discriminant.map(|v| cx.const_u64(v)), self.flags, self.type_metadata, ) diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 4bf16436855..c906b8ac901 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1106,10 +1106,7 @@ pub fn split(self, f: F) -> (Binder, Binder) impl Binder> { pub fn transpose(self) -> Option> { - match self.0 { - Some(v) => Some(Binder(v)), - None => None, - } + self.0.map(Binder) } } diff --git a/compiler/rustc_typeck/src/check/demand.rs b/compiler/rustc_typeck/src/check/demand.rs index 241803fab1e..d12d2cb59a5 100644 --- a/compiler/rustc_typeck/src/check/demand.rs +++ b/compiler/rustc_typeck/src/check/demand.rs @@ -810,10 +810,12 @@ pub fn check_for_cast( // can be given the suggestion "u32::from(x) > y" rather than // "x > y.try_into().unwrap()". let lhs_expr_and_src = expected_ty_expr.and_then(|expr| { - match self.tcx.sess.source_map().span_to_snippet(expr.span).ok() { - Some(src) => Some((expr, src)), - None => None, - } + self.tcx + .sess + .source_map() + .span_to_snippet(expr.span) + .ok() + .map(|src| (expr, src)) }); let (span, msg, suggestion) = if let (Some((lhs_expr, lhs_src)), false) = (lhs_expr_and_src, exp_to_found_is_fallible)