about summary refs log tree commit diff
path: root/compiler/rustc_transmute/src/lib.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-09-12 23:28:25 +0200
committerRalf Jung <post@ralfj.de>2023-09-13 07:29:34 +0200
commit6e4779ab1775d0901408c08d64dc12c735069701 (patch)
treec9b26f901b489aa15840a10b12556ea3a7b87b7a /compiler/rustc_transmute/src/lib.rs
parente5fedceabf4e0564231db592b6d1f35e1ca27908 (diff)
downloadrust-6e4779ab1775d0901408c08d64dc12c735069701.tar.gz
rust-6e4779ab1775d0901408c08d64dc12c735069701.zip
make the eval() functions on our const types return the resulting value
Diffstat (limited to 'compiler/rustc_transmute/src/lib.rs')
-rw-r--r--compiler/rustc_transmute/src/lib.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs
index af2ad547480..6c49e94dc31 100644
--- a/compiler/rustc_transmute/src/lib.rs
+++ b/compiler/rustc_transmute/src/lib.rs
@@ -129,19 +129,16 @@ mod rustc {
             c: Const<'tcx>,
         ) -> Option<Self> {
             use rustc_middle::ty::ScalarInt;
-            use rustc_middle::ty::TypeVisitableExt;
             use rustc_span::symbol::sym;
 
-            let c = c.eval(tcx, param_env);
-
-            if let Err(err) = c.error_reported() {
+            let Ok(cv) = c.eval(tcx, param_env, None) else {
                 return Some(Self {
                     alignment: true,
                     lifetimes: true,
                     safety: true,
                     validity: true,
                 });
-            }
+            };
 
             let adt_def = c.ty().ty_adt_def()?;
 
@@ -153,8 +150,8 @@ mod rustc {
             );
 
             let variant = adt_def.non_enum_variant();
-            let fields = match c.try_to_valtree() {
-                Some(ValTree::Branch(branch)) => branch,
+            let fields = match cv {
+                ValTree::Branch(branch) => branch,
                 _ => {
                     return Some(Self {
                         alignment: true,