about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-01-08 12:40:02 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-01-09 08:48:46 +0000
commit84c8d4f52d5be135e2dec89379cb1d0f67be648c (patch)
treee1b9be1ff56c2f6306dc0211390055192f6fcacd
parent8505904dccfb624e663aef3d50f2e5cefefa73d1 (diff)
downloadrust-84c8d4f52d5be135e2dec89379cb1d0f67be648c.tar.gz
rust-84c8d4f52d5be135e2dec89379cb1d0f67be648c.zip
Use option combinators instead of manual if/return
-rw-r--r--compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs13
1 files changed, 3 insertions, 10 deletions
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
index 511ecc06e79..cb90fff782f 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
@@ -2262,18 +2262,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
             _ => None,
         };
 
-        if let Some(lit_input) = lit_input {
-            // If an error occurred, ignore that it's a literal and leave reporting the error up to
-            // mir.
-
+        lit_input
             // Allow the `ty` to be an alias type, though we cannot handle it here, we just go through
             // the more expensive anon const code path.
-            if !lit_input.ty.has_aliases() {
-                return Some(tcx.at(expr.span).lit_to_const(lit_input));
-            }
-        }
-
-        None
+            .filter(|l| !l.ty.has_aliases())
+            .map(|l| tcx.at(expr.span).lit_to_const(l))
     }
 
     fn lower_delegation_ty(&self, idx: hir::InferDelegationKind) -> Ty<'tcx> {