From 50559ceec491a40ac079aa6cd7943f63387060fd Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 14 Oct 2023 13:31:32 +0000 Subject: [PATCH] Valtrees for primitive types are fine. --- compiler/rustc_middle/src/mir/consts.rs | 5 +++-- 1 file 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 @@ pub fn is_deterministic(&self) -> bool { 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(..)