about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-01-07 12:33:32 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-01-09 08:48:00 +0000
commit07fcead0732d9460978dd3b428cd5edcfa299f9a (patch)
treeb87dde24347f43c54345023c0db5de75af59b3fb /compiler/rustc_hir_analysis
parent787af97babcb911f2ce70d3d28959cdccc7901bd (diff)
downloadrust-07fcead0732d9460978dd3b428cd5edcfa299f9a.tar.gz
rust-07fcead0732d9460978dd3b428cd5edcfa299f9a.zip
Always take the `Ok` path in `lit_to_const` and produce error constants instead
Diffstat (limited to 'compiler/rustc_hir_analysis')
-rw-r--r--compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs17
1 files changed, 5 insertions, 12 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 5a65d5bafee..6ed5f92e995 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
@@ -2265,18 +2265,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
         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.
-            match tcx.at(expr.span).lit_to_const(lit_input) {
-                Ok(c) => return Some(c),
-                Err(_) if lit_input.ty.has_aliases() => {
-                    // allow the `ty` to be an alias type, though we cannot handle it here
-                    return None;
-                }
-                Err(e) => {
-                    tcx.dcx().span_delayed_bug(
-                        expr.span,
-                        format!("try_lower_anon_const_lit: couldn't lit_to_const {e:?}"),
-                    );
-                }
+
+            // 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).unwrap());
             }
         }