|
1 | 1 | #[cfg(feature = "nightly")]
|
2 | 2 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
3 | 3 | #[cfg(feature = "nightly")]
|
4 |
| -use rustc_macros::{TyDecodable, TyEncodable}; |
| 4 | +use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable}; |
5 | 5 | use std::fmt;
|
6 | 6 |
|
7 | 7 | use crate::{DebruijnIndex, DebugWithInfcx, InferCtxtLike, Interner, WithInfcx};
|
8 | 8 |
|
9 | 9 | use self::RegionKind::*;
|
10 | 10 |
|
| 11 | +rustc_index::newtype_index! { |
| 12 | + /// A **region** **v**ariable **ID**. |
| 13 | + #[encodable] |
| 14 | + #[orderable] |
| 15 | + #[debug_format = "'?{}"] |
| 16 | + #[gate_rustc_only] |
| 17 | + #[cfg_attr(feature = "nightly", derive(HashStable_NoContext))] |
| 18 | + pub struct RegionVid {} |
| 19 | +} |
| 20 | + |
| 21 | +impl<I: Interner> DebugWithInfcx<I> for RegionVid { |
| 22 | + fn fmt<Infcx: InferCtxtLike<Interner = I>>( |
| 23 | + this: WithInfcx<'_, Infcx, &Self>, |
| 24 | + f: &mut core::fmt::Formatter<'_>, |
| 25 | + ) -> core::fmt::Result { |
| 26 | + match this.infcx.universe_of_lt(*this.data) { |
| 27 | + Some(universe) => write!(f, "'?{}_{}", this.data.index(), universe.index()), |
| 28 | + None => write!(f, "{:?}", this.data), |
| 29 | + } |
| 30 | + } |
| 31 | +} |
| 32 | + |
11 | 33 | /// Representation of regions. Note that the NLL checker uses a distinct
|
12 | 34 | /// representation of regions. For this reason, it internally replaces all the
|
13 | 35 | /// regions with inference variables -- the index of the variable is then used
|
@@ -152,7 +174,7 @@ pub enum RegionKind<I: Interner> {
|
152 | 174 | ReStatic,
|
153 | 175 |
|
154 | 176 | /// A region variable. Should not exist outside of type inference.
|
155 |
| - ReVar(I::InferRegion), |
| 177 | + ReVar(RegionVid), |
156 | 178 |
|
157 | 179 | /// A placeholder region -- the higher-ranked version of `ReLateParam`.
|
158 | 180 | /// Should not exist outside of type inference.
|
@@ -251,7 +273,6 @@ where
|
251 | 273 | I::EarlyParamRegion: HashStable<CTX>,
|
252 | 274 | I::BoundRegion: HashStable<CTX>,
|
253 | 275 | I::LateParamRegion: HashStable<CTX>,
|
254 |
| - I::InferRegion: HashStable<CTX>, |
255 | 276 | I::PlaceholderRegion: HashStable<CTX>,
|
256 | 277 | {
|
257 | 278 | #[inline]
|
|
0 commit comments