about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2021-10-21 13:23:00 +0000
committerDeadbeef <ent3rm4n@gmail.com>2021-11-29 21:19:42 +0800
commit22eeff700e4d2b4c4160c63d8d3e14931268b5f8 (patch)
tree03ad9017228525027483ee6d0a9aa65abad95b01
parent44723c5d59ff00daeefbf2a01f67089acd75730d (diff)
downloadrust-22eeff700e4d2b4c4160c63d8d3e14931268b5f8.tar.gz
rust-22eeff700e4d2b4c4160c63d8d3e14931268b5f8.zip
Prepare for more ParamEnv flags
-rw-r--r--compiler/rustc_middle/src/ty/mod.rs25
1 files changed, 15 insertions, 10 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index 2d692670372..4720c895a1e 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -1221,23 +1221,28 @@ pub struct ParamEnv<'tcx> {
     /// want `Reveal::All`.
     ///
     /// Note: This is packed, use the reveal() method to access it.
-    packed: CopyTaggedPtr<&'tcx List<Predicate<'tcx>>, traits::Reveal, true>,
+    packed: CopyTaggedPtr<&'tcx List<Predicate<'tcx>>, ParamTag, true>,
 }
 
-unsafe impl rustc_data_structures::tagged_ptr::Tag for traits::Reveal {
+#[derive(Copy, Clone)]
+struct ParamTag {
+    reveal: traits::Reveal,
+}
+
+unsafe impl rustc_data_structures::tagged_ptr::Tag for ParamTag {
     const BITS: usize = 1;
     #[inline]
     fn into_usize(self) -> usize {
         match self {
-            traits::Reveal::UserFacing => 0,
-            traits::Reveal::All => 1,
+            Self { reveal: traits::Reveal::UserFacing } => 0,
+            Self { reveal: traits::Reveal::All } => 1,
         }
     }
     #[inline]
     unsafe fn from_usize(ptr: usize) -> Self {
         match ptr {
-            0 => traits::Reveal::UserFacing,
-            1 => traits::Reveal::All,
+            0 => Self { reveal: traits::Reveal::UserFacing },
+            1 => Self { reveal: traits::Reveal::All },
             _ => std::hint::unreachable_unchecked(),
         }
     }
@@ -1290,7 +1295,7 @@ impl<'tcx> ParamEnv<'tcx> {
 
     #[inline]
     pub fn reveal(self) -> traits::Reveal {
-        self.packed.tag()
+        self.packed.tag().reveal
     }
 
     /// Construct a trait environment with no where-clauses in scope
@@ -1308,11 +1313,11 @@ impl<'tcx> ParamEnv<'tcx> {
     /// Construct a trait environment with the given set of predicates.
     #[inline]
     pub fn new(caller_bounds: &'tcx List<Predicate<'tcx>>, reveal: Reveal) -> Self {
-        ty::ParamEnv { packed: CopyTaggedPtr::new(caller_bounds, reveal) }
+        ty::ParamEnv { packed: CopyTaggedPtr::new(caller_bounds, ParamTag { reveal }) }
     }
 
     pub fn with_user_facing(mut self) -> Self {
-        self.packed.set_tag(Reveal::UserFacing);
+        self.packed.set_tag(ParamTag { reveal: Reveal::UserFacing, ..self.packed.tag() });
         self
     }
 
@@ -1326,7 +1331,7 @@ impl<'tcx> ParamEnv<'tcx> {
     /// will be normalized to their underlying types.
     /// See PR #65989 and issue #65918 for more details
     pub fn with_reveal_all_normalized(self, tcx: TyCtxt<'tcx>) -> Self {
-        if self.packed.tag() == traits::Reveal::All {
+        if self.packed.tag().reveal == traits::Reveal::All {
             return self;
         }