about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
diff options
context:
space:
mode:
authorOli Scherer <github35764891676564198441@oli-obk.de>2021-02-22 14:09:24 +0000
committerOli Scherer <github35764891676564198441@oli-obk.de>2021-03-12 12:16:14 +0000
commita4fbac163e7291b052fa5ec64f14cc0a52932ff4 (patch)
treea22e430dc163277eee97d277e2278dbf558e4ac2 /compiler/rustc_middle/src/query
parent0cc64a34e9823a4ce6491dc5e13e920cd4f5aa31 (diff)
downloadrust-a4fbac163e7291b052fa5ec64f14cc0a52932ff4.tar.gz
rust-a4fbac163e7291b052fa5ec64f14cc0a52932ff4.zip
Implement valtree
valtree is a version of constants that is inherently safe to be used within types.
This is in contrast to ty::Const which can have different representations of the same value. These representation differences can show up in hashing or equality comparisons, breaking type equality of otherwise equal types.
valtrees do not have this problem.
Diffstat (limited to 'compiler/rustc_middle/src/query')
-rw-r--r--compiler/rustc_middle/src/query/mod.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index b03b26d6460..b0c066fb42f 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -785,6 +785,14 @@ rustc_queries! {
         cache_on_disk_if { true }
     }
 
+    /// Convert an evaluated constant to a type level constant or
+    /// return `None` if that is not possible.
+    query const_to_valtree(
+        key: ty::ParamEnvAnd<'tcx, ConstAlloc<'tcx>>
+    ) -> Option<ty::ValTree> {
+        desc { "destructure constant" }
+    }
+
     /// Destructure a constant ADT or array into its variant index and its
     /// field values.
     query destructure_const(