about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src/keys.rs
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_query_impl/src/keys.rs
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_query_impl/src/keys.rs')
-rw-r--r--compiler/rustc_query_impl/src/keys.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_query_impl/src/keys.rs b/compiler/rustc_query_impl/src/keys.rs
index 1ae5bf12cab..e467f419863 100644
--- a/compiler/rustc_query_impl/src/keys.rs
+++ b/compiler/rustc_query_impl/src/keys.rs
@@ -228,6 +228,15 @@ impl<'tcx> Key for (&'tcx ty::Const<'tcx>, mir::Field) {
     }
 }
 
+impl<'tcx> Key for mir::interpret::ConstAlloc<'tcx> {
+    fn query_crate(&self) -> CrateNum {
+        LOCAL_CRATE
+    }
+    fn default_span(&self, _: TyCtxt<'_>) -> Span {
+        DUMMY_SP
+    }
+}
+
 impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
     fn query_crate(&self) -> CrateNum {
         self.def_id().krate