about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-07-28 16:59:06 +0200
committerRalf Jung <post@ralfj.de>2025-08-14 09:39:39 +0200
commit3f1e99dca47b2cfc33906f1f1334fbed3a9fc4ce (patch)
tree4041bd26584370d48d0b7b4150e81f07807c1762 /compiler/rustc_middle/src
parent2c1ac85679678dfe5cce7ea8037735b0349ceaf3 (diff)
PatKind: store constants as valtrees
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/thir.rs9
-rw-r--r--compiler/rustc_middle/src/thir/visit.rs2
2 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs
index 3dd6d2c8928..8569f57b79d 100644
--- a/compiler/rustc_middle/src/thir.rs
+++ b/compiler/rustc_middle/src/thir.rs
@@ -832,17 +832,20 @@ pub enum PatKind<'tcx> {
     },
 
     /// One of the following:
-    /// * `&str` (represented as a valtree), which will be handled as a string pattern and thus
+    /// * `&str`, which will be handled as a string pattern and thus
     ///   exhaustiveness checking will detect if you use the same string twice in different
     ///   patterns.
-    /// * integer, bool, char or float (represented as a valtree), which will be handled by
+    /// * integer, bool, char or float, which will be handled by
     ///   exhaustiveness to cover exactly its own value, similar to `&str`, but these values are
     ///   much simpler.
     /// * raw pointers derived from integers, other raw pointers will have already resulted in an
     //    error.
     /// * `String`, if `string_deref_patterns` is enabled.
     Constant {
-        value: mir::Const<'tcx>,
+        // Not using `ty::Value` since this is conceptually not a type-level constant. In
+        // particular, it can have raw pointers.
+        ty: Ty<'tcx>,
+        value: ty::ValTree<'tcx>,
     },
 
     /// Pattern obtained by converting a constant (inline or named) to its pattern
diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs
index dcfa6c4db32..9d3ba74ad0f 100644
--- a/compiler/rustc_middle/src/thir/visit.rs
+++ b/compiler/rustc_middle/src/thir/visit.rs
@@ -265,7 +265,7 @@ pub(crate) fn for_each_immediate_subpat<'a, 'tcx>(
         PatKind::Missing
         | PatKind::Wild
         | PatKind::Binding { subpattern: None, .. }
-        | PatKind::Constant { value: _ }
+        | PatKind::Constant { .. }
         | PatKind::Range(_)
         | PatKind::Never
         | PatKind::Error(_) => {}