about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorb-naber <bn263@gmx.de>2022-09-15 22:27:41 +0200
committerb-naber <bn263@gmx.de>2022-09-15 22:27:41 +0200
commitd77248e6d201aca593bac3393bd7ad0159909cff (patch)
treeb2a78fb0c3cf91d396da35def9535b3cffdc49db /compiler
parent6af8fb793697734bf3e19bcb1b5d152d617bb303 (diff)
downloadrust-d77248e6d201aca593bac3393bd7ad0159909cff.tar.gz
rust-d77248e6d201aca593bac3393bd7ad0159909cff.zip
nits
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_borrowck/src/renumber.rs5
-rw-r--r--compiler/rustc_borrowck/src/type_check/mod.rs6
-rw-r--r--compiler/rustc_codegen_cranelift/src/constant.rs12
-rw-r--r--compiler/rustc_middle/src/mir/mod.rs1
-rw-r--r--compiler/rustc_mir_transform/src/const_prop_lint.rs4
5 files changed, 9 insertions, 19 deletions
diff --git a/compiler/rustc_borrowck/src/renumber.rs b/compiler/rustc_borrowck/src/renumber.rs
index 09035dcefa1..63b2088f7fc 100644
--- a/compiler/rustc_borrowck/src/renumber.rs
+++ b/compiler/rustc_borrowck/src/renumber.rs
@@ -38,6 +38,11 @@ where
     })
 }
 
+// FIXME(valtrees): This function is necessary because `fold_regions`
+// panics for mir constants in the visitor.
+//
+// Once `visit_mir_constant` is removed we can also remove this function
+// and just use `renumber_regions`.
 fn renumber_regions_in_mir_constant<'tcx>(
     infcx: &InferCtxt<'_, 'tcx>,
     value: ConstantKind<'tcx>,
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs
index 6854e0e8878..500f9ae08c5 100644
--- a/compiler/rustc_borrowck/src/type_check/mod.rs
+++ b/compiler/rustc_borrowck/src/type_check/mod.rs
@@ -1816,12 +1816,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
     fn check_operand(&mut self, op: &Operand<'tcx>, location: Location) {
         if let Operand::Constant(constant) = op {
             let maybe_uneval = match constant.literal {
-                ConstantKind::Ty(ct) => match ct.kind() {
-                    ty::ConstKind::Unevaluated(uv) => Some(uv.expand()),
-                    _ => None,
-                },
+                ConstantKind::Val(..) | ConstantKind::Ty(_) => None,
                 ConstantKind::Unevaluated(uv, _) => Some(uv),
-                ConstantKind::Val(..) => None,
             };
 
             if let Some(uv) = maybe_uneval {
diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs
index bc34802fa72..6b4ed9b9d40 100644
--- a/compiler/rustc_codegen_cranelift/src/constant.rs
+++ b/compiler/rustc_codegen_cranelift/src/constant.rs
@@ -117,17 +117,7 @@ pub(crate) fn codegen_constant<'tcx>(
     constant: &Constant<'tcx>,
 ) -> CValue<'tcx> {
     let (const_val, ty) = match fx.monomorphize(constant.literal) {
-        ConstantKind::Ty(const_) => match const_.kind() {
-            ConstKind::Value(valtree) => {
-                (fx.tcx.valtree_to_const_val((const_.ty(), valtree)), const_.ty())
-            }
-            ConstKind::Unevaluated(_) => bug!("expected constant to be evaluated at this stage"),
-            ConstKind::Param(_)
-            | ConstKind::Infer(_)
-            | ConstKind::Bound(_, _)
-            | ConstKind::Placeholder(_)
-            | ConstKind::Error(_) => unreachable!("{:?}", const_),
-        },
+        ConstantKind::Ty(const_) => unreachable!("{:?}", const_),
         ConstantKind::Unevaluated(ty::Unevaluated { def, substs, promoted }, ty)
             if fx.tcx.is_static(def.did) =>
         {
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs
index f8059109ad8..2fddb00d719 100644
--- a/compiler/rustc_middle/src/mir/mod.rs
+++ b/compiler/rustc_middle/src/mir/mod.rs
@@ -2643,6 +2643,7 @@ impl<'tcx> Display for ConstantKind<'tcx> {
         match *self {
             ConstantKind::Ty(c) => pretty_print_const(c, fmt, true),
             ConstantKind::Val(val, ty) => pretty_print_const_value(val, ty, fmt, true),
+            // FIXME(valtrees): Correctly print mir constants.
             ConstantKind::Unevaluated(..) => {
                 fmt.write_str("_")?;
                 Ok(())
diff --git a/compiler/rustc_mir_transform/src/const_prop_lint.rs b/compiler/rustc_mir_transform/src/const_prop_lint.rs
index 072abe86008..37e78f4ac07 100644
--- a/compiler/rustc_mir_transform/src/const_prop_lint.rs
+++ b/compiler/rustc_mir_transform/src/const_prop_lint.rs
@@ -307,9 +307,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
                             // Promoteds must lint and not error as the user didn't ask for them
                             true
                         }
-                        ConstantKind::Unevaluated(_, ty) | ConstantKind::Val(_, ty) => {
-                            ty.needs_subst()
-                        }
+                        ConstantKind::Unevaluated(..) | ConstantKind::Val(..) => c.needs_subst(),
                     };
                     if lint_only {
                         // Out of backwards compatibility we cannot report hard errors in unused