about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-10-14 13:31:32 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-10-25 06:46:48 +0000
commit50559ceec491a40ac079aa6cd7943f63387060fd (patch)
treec8046d13c8e36fc7074aca899c8a8cfbe91819d8 /compiler/rustc_middle/src/mir
parentf6aa3ee7e8a6c28199ebf09810b330b46adf8610 (diff)
downloadrust-50559ceec491a40ac079aa6cd7943f63387060fd.tar.gz
rust-50559ceec491a40ac079aa6cd7943f63387060fd.zip
Valtrees for primitive types are fine.
Diffstat (limited to 'compiler/rustc_middle/src/mir')
-rw-r--r--compiler/rustc_middle/src/mir/consts.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs
index d427b4ec3f4..88d4a37f210 100644
--- a/compiler/rustc_middle/src/mir/consts.rs
+++ b/compiler/rustc_middle/src/mir/consts.rs
@@ -509,8 +509,9 @@ impl<'tcx> Const<'tcx> {
             Const::Ty(c) => match c.kind() {
                 ty::ConstKind::Param(..) => true,
                 // A valtree may be a reference. Valtree references correspond to a
-                // different allocation each time they are evaluated.
-                ty::ConstKind::Value(_) => false,
+                // different allocation each time they are evaluated. Valtrees for primitive
+                // types are fine though.
+                ty::ConstKind::Value(_) => c.ty().is_primitive(),
                 ty::ConstKind::Unevaluated(..) | ty::ConstKind::Expr(..) => false,
                 // Should not appear in runtime MIR.
                 ty::ConstKind::Infer(..)