about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/consts.rs
diff options
context:
space:
mode:
authorLukas Markeffsky <@>2025-02-07 19:33:58 +0100
committerLukas Markeffsky <@>2025-02-13 00:38:17 +0100
commit885e0f1b96112aae9fbdd97d08b69ddc8eb01b1e (patch)
treee6174f1571c4131f252bb2fa7fe56ea918c344bf /compiler/rustc_ty_utils/src/consts.rs
parentef148cd7eb00a5a973130dc6473da71fd6c487ee (diff)
downloadrust-885e0f1b96112aae9fbdd97d08b69ddc8eb01b1e.tar.gz
rust-885e0f1b96112aae9fbdd97d08b69ddc8eb01b1e.zip
intern valtrees
Diffstat (limited to 'compiler/rustc_ty_utils/src/consts.rs')
-rw-r--r--compiler/rustc_ty_utils/src/consts.rs12
1 files changed, 3 insertions, 9 deletions
diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs
index cbe49d000b7..ece796b3c71 100644
--- a/compiler/rustc_ty_utils/src/consts.rs
+++ b/compiler/rustc_ty_utils/src/consts.rs
@@ -26,10 +26,7 @@ fn destructure_const<'tcx>(
         bug!("cannot destructure constant {:?}", const_)
     };
 
-    let branches = match cv.valtree {
-        ty::ValTree::Branch(b) => b,
-        _ => bug!("cannot destructure constant {:?}", const_),
-    };
+    let branches = cv.valtree.unwrap_branch();
 
     let (fields, variant) = match cv.ty.kind() {
         ty::Array(inner_ty, _) | ty::Slice(inner_ty) => {
@@ -126,13 +123,10 @@ fn recurse_build<'tcx>(
             tcx.at(sp).lit_to_const(LitToConstInput { lit: &lit.node, ty: node.ty, neg })
         }
         &ExprKind::NonHirLiteral { lit, user_ty: _ } => {
-            let val = ty::ValTree::from_scalar_int(lit);
-            ty::Const::new_value(tcx, val, node.ty)
-        }
-        &ExprKind::ZstLiteral { user_ty: _ } => {
-            let val = ty::ValTree::zst();
+            let val = ty::ValTree::from_scalar_int(tcx, lit);
             ty::Const::new_value(tcx, val, node.ty)
         }
+        &ExprKind::ZstLiteral { user_ty: _ } => ty::Const::zero_sized(tcx, node.ty),
         &ExprKind::NamedConst { def_id, args, user_ty: _ } => {
             let uneval = ty::UnevaluatedConst::new(def_id, args);
             ty::Const::new_unevaluated(tcx, uneval)