From a4fbac163e7291b052fa5ec64f14cc0a52932ff4 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 22 Feb 2021 14:09:24 +0000 Subject: 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. --- compiler/rustc_query_impl/src/keys.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compiler/rustc_query_impl') 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 -- cgit 1.4.1-3-g733a5