Skip to content

Commit b966d1c

Browse files
committed
Prepare for more ParamEnv flags
1 parent 56694b0 commit b966d1c

File tree

1 file changed

+15
-10
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+15
-10
lines changed

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,23 +1216,28 @@ pub struct ParamEnv<'tcx> {
12161216
/// want `Reveal::All`.
12171217
///
12181218
/// Note: This is packed, use the reveal() method to access it.
1219-
packed: CopyTaggedPtr<&'tcx List<Predicate<'tcx>>, traits::Reveal, true>,
1219+
packed: CopyTaggedPtr<&'tcx List<Predicate<'tcx>>, ParamTag, true>,
12201220
}
12211221

1222-
unsafe impl rustc_data_structures::tagged_ptr::Tag for traits::Reveal {
1222+
#[derive(Copy, Clone)]
1223+
struct ParamTag {
1224+
reveal: traits::Reveal,
1225+
}
1226+
1227+
unsafe impl rustc_data_structures::tagged_ptr::Tag for ParamTag {
12231228
const BITS: usize = 1;
12241229
#[inline]
12251230
fn into_usize(self) -> usize {
12261231
match self {
1227-
traits::Reveal::UserFacing => 0,
1228-
traits::Reveal::All => 1,
1232+
Self { reveal: traits::Reveal::UserFacing } => 0,
1233+
Self { reveal: traits::Reveal::All } => 1,
12291234
}
12301235
}
12311236
#[inline]
12321237
unsafe fn from_usize(ptr: usize) -> Self {
12331238
match ptr {
1234-
0 => traits::Reveal::UserFacing,
1235-
1 => traits::Reveal::All,
1239+
0 => Self { reveal: traits::Reveal::UserFacing },
1240+
1 => Self { reveal: traits::Reveal::All },
12361241
_ => std::hint::unreachable_unchecked(),
12371242
}
12381243
}
@@ -1282,7 +1287,7 @@ impl<'tcx> ParamEnv<'tcx> {
12821287

12831288
#[inline]
12841289
pub fn reveal(self) -> traits::Reveal {
1285-
self.packed.tag()
1290+
self.packed.tag().reveal
12861291
}
12871292

12881293
/// Construct a trait environment with no where-clauses in scope
@@ -1300,11 +1305,11 @@ impl<'tcx> ParamEnv<'tcx> {
13001305
/// Construct a trait environment with the given set of predicates.
13011306
#[inline]
13021307
pub fn new(caller_bounds: &'tcx List<Predicate<'tcx>>, reveal: Reveal) -> Self {
1303-
ty::ParamEnv { packed: CopyTaggedPtr::new(caller_bounds, reveal) }
1308+
ty::ParamEnv { packed: CopyTaggedPtr::new(caller_bounds, ParamTag { reveal }) }
13041309
}
13051310

13061311
pub fn with_user_facing(mut self) -> Self {
1307-
self.packed.set_tag(Reveal::UserFacing);
1312+
self.packed.set_tag(ParamTag { reveal: Reveal::UserFacing, ..self.packed.tag() });
13081313
self
13091314
}
13101315

@@ -1318,7 +1323,7 @@ impl<'tcx> ParamEnv<'tcx> {
13181323
/// will be normalized to their underlying types.
13191324
/// See PR #65989 and issue #65918 for more details
13201325
pub fn with_reveal_all_normalized(self, tcx: TyCtxt<'tcx>) -> Self {
1321-
if self.packed.tag() == traits::Reveal::All {
1326+
if self.packed.tag().reveal == traits::Reveal::All {
13221327
return self;
13231328
}
13241329

0 commit comments

Comments
 (0)