Skip to content

File tree

12 files changed

+44
-26
lines changed

12 files changed

+44
-26
lines changed
 

‎src/librustc/infer/canonical/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub enum CanonicalVarKind {
142142
/// A "placeholder" that represents "any region". Created when you
143143
/// are solving a goal like `for<'a> T: Foo<'a>` to represent the
144144
/// bound region `'a`.
145-
PlaceholderRegion(ty::Placeholder),
145+
PlaceholderRegion(ty::PlaceholderRegion),
146146
}
147147

148148
impl CanonicalVarKind {
@@ -374,9 +374,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
374374
universe_map(ui),
375375
).into(),
376376

377-
CanonicalVarKind::PlaceholderRegion(ty::Placeholder { universe, name }) => {
377+
CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion { universe, name }) => {
378378
let universe_mapped = universe_map(universe);
379-
let placeholder_mapped = ty::Placeholder {
379+
let placeholder_mapped = ty::PlaceholderRegion {
380380
universe: universe_mapped,
381381
name,
382382
};

‎src/librustc/infer/higher_ranked/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
340340
let next_universe = self.create_next_universe();
341341

342342
let (result, map) = self.tcx.replace_late_bound_regions(binder, |br| {
343-
self.tcx.mk_region(ty::RePlaceholder(ty::Placeholder {
343+
self.tcx.mk_region(ty::RePlaceholder(ty::PlaceholderRegion {
344344
universe: next_universe,
345345
name: br,
346346
}))

‎src/librustc/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ pub enum NLLRegionVariableOrigin {
411411

412412
/// "Universal" instantiation of a higher-ranked region (e.g.,
413413
/// from a `for<'a> T` binder). Meant to represent "any region".
414-
Placeholder(ty::Placeholder),
414+
Placeholder(ty::PlaceholderRegion),
415415

416416
Existential,
417417
}

‎src/librustc/infer/nll_relate/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub trait TypeRelatingDelegate<'tcx> {
9595
/// So e.g. if you have `for<'a> fn(..) <: for<'b> fn(..)`, then
9696
/// we will invoke this method to instantiate `'b` with a
9797
/// placeholder region.
98-
fn next_placeholder_region(&mut self, placeholder: ty::Placeholder) -> ty::Region<'tcx>;
98+
fn next_placeholder_region(&mut self, placeholder: ty::PlaceholderRegion) -> ty::Region<'tcx>;
9999

100100
/// Creates a new existential region in the given universe. This
101101
/// is used when handling subtyping and type variables -- if we
@@ -176,7 +176,7 @@ where
176176
universe
177177
});
178178

179-
let placeholder = ty::Placeholder { universe, name: br };
179+
let placeholder = ty::PlaceholderRegion { universe, name: br };
180180
delegate.next_placeholder_region(placeholder)
181181
} else {
182182
delegate.next_existential_region_var()

‎src/librustc/ty/mod.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -1587,12 +1587,27 @@ impl UniverseIndex {
15871587
/// universe are just two regions with an unknown relationship to one
15881588
/// another.
15891589
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, PartialOrd, Ord)]
1590-
pub struct Placeholder {
1590+
pub struct Placeholder<T> {
15911591
pub universe: UniverseIndex,
1592-
pub name: BoundRegion,
1592+
pub name: T,
15931593
}
15941594

1595-
impl_stable_hash_for!(struct Placeholder { universe, name });
1595+
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for Placeholder<T>
1596+
where T: HashStable<StableHashingContext<'a>>
1597+
{
1598+
fn hash_stable<W: StableHasherResult>(
1599+
&self,
1600+
hcx: &mut StableHashingContext<'a>,
1601+
hasher: &mut StableHasher<W>
1602+
) {
1603+
self.universe.hash_stable(hcx, hasher);
1604+
self.name.hash_stable(hcx, hasher);
1605+
}
1606+
}
1607+
1608+
pub type PlaceholderRegion = Placeholder<BoundRegion>;
1609+
1610+
pub type PlaceholderType = Placeholder<BoundVar>;
15961611

15971612
/// When type checking, we use the `ParamEnv` to track
15981613
/// details about the set of where-clauses that are in scope at this

‎src/librustc/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ pub enum RegionKind {
11651165

11661166
/// A placeholder region - basically the higher-ranked version of ReFree.
11671167
/// Should not exist after typeck.
1168-
RePlaceholder(ty::Placeholder),
1168+
RePlaceholder(ty::PlaceholderRegion),
11691169

11701170
/// Empty lifetime is for data that is never accessed.
11711171
/// Bottom in the region lattice. We treat ReEmpty somewhat

‎src/librustc/util/ppaux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ define_print! {
792792
}
793793
ty::ReLateBound(_, br) |
794794
ty::ReFree(ty::FreeRegion { bound_region: br, .. }) |
795-
ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
795+
ty::RePlaceholder(ty::PlaceholderRegion { name: br, .. }) => {
796796
write!(f, "{}", br)
797797
}
798798
ty::ReScope(scope) if cx.identify_regions => {

‎src/librustc_mir/borrow_check/error_reporting.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2193,7 +2193,7 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
21932193
match ty.sty {
21942194
ty::TyKind::Ref(ty::RegionKind::ReLateBound(_, br), _, _)
21952195
| ty::TyKind::Ref(
2196-
ty::RegionKind::RePlaceholder(ty::Placeholder { name: br, .. }),
2196+
ty::RegionKind::RePlaceholder(ty::PlaceholderRegion { name: br, .. }),
21972197
_,
21982198
_,
21992199
) => with_highlight_region_for_bound_region(*br, counter, || ty.to_string()),
@@ -2207,7 +2207,7 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
22072207
match ty.sty {
22082208
ty::TyKind::Ref(region, _, _) => match region {
22092209
ty::RegionKind::ReLateBound(_, br)
2210-
| ty::RegionKind::RePlaceholder(ty::Placeholder { name: br, .. }) => {
2210+
| ty::RegionKind::RePlaceholder(ty::PlaceholderRegion { name: br, .. }) => {
22112211
with_highlight_region_for_bound_region(*br, counter, || region.to_string())
22122212
}
22132213
_ => region.to_string(),

‎src/librustc_mir/borrow_check/nll/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
12301230
mir: &Mir<'tcx>,
12311231
_mir_def_id: DefId,
12321232
longer_fr: RegionVid,
1233-
placeholder: ty::Placeholder,
1233+
placeholder: ty::PlaceholderRegion,
12341234
) {
12351235
debug!(
12361236
"check_bound_universal_region(fr={:?}, placeholder={:?})",

‎src/librustc_mir/borrow_check/nll/region_infer/values.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ crate enum RegionElement {
150150

151151
/// A placeholder (e.g., instantiated from a `for<'a> fn(&'a u32)`
152152
/// type).
153-
PlaceholderRegion(ty::Placeholder),
153+
PlaceholderRegion(ty::PlaceholderRegion),
154154
}
155155

156156
/// When we initially compute liveness, we use a bit matrix storing
@@ -219,17 +219,17 @@ impl<N: Idx> LivenessValues<N> {
219219
}
220220
}
221221

222-
/// Maps from `ty::Placeholder` values that are used in the rest of
222+
/// Maps from `ty::PlaceholderRegion` values that are used in the rest of
223223
/// rustc to the internal `PlaceholderIndex` values that are used in
224224
/// NLL.
225225
#[derive(Default)]
226226
crate struct PlaceholderIndices {
227-
to_index: FxHashMap<ty::Placeholder, PlaceholderIndex>,
228-
from_index: IndexVec<PlaceholderIndex, ty::Placeholder>,
227+
to_index: FxHashMap<ty::PlaceholderRegion, PlaceholderIndex>,
228+
from_index: IndexVec<PlaceholderIndex, ty::PlaceholderRegion>,
229229
}
230230

231231
impl PlaceholderIndices {
232-
crate fn insert(&mut self, placeholder: ty::Placeholder) -> PlaceholderIndex {
232+
crate fn insert(&mut self, placeholder: ty::PlaceholderRegion) -> PlaceholderIndex {
233233
let PlaceholderIndices {
234234
to_index,
235235
from_index,
@@ -239,11 +239,11 @@ impl PlaceholderIndices {
239239
.or_insert_with(|| from_index.push(placeholder))
240240
}
241241

242-
crate fn lookup_index(&self, placeholder: ty::Placeholder) -> PlaceholderIndex {
242+
crate fn lookup_index(&self, placeholder: ty::PlaceholderRegion) -> PlaceholderIndex {
243243
self.to_index[&placeholder]
244244
}
245245

246-
crate fn lookup_placeholder(&self, placeholder: PlaceholderIndex) -> ty::Placeholder {
246+
crate fn lookup_placeholder(&self, placeholder: PlaceholderIndex) -> ty::PlaceholderRegion {
247247
self.from_index[placeholder]
248248
}
249249

@@ -375,7 +375,7 @@ impl<N: Idx> RegionValues<N> {
375375
crate fn placeholders_contained_in<'a>(
376376
&'a self,
377377
r: N,
378-
) -> impl Iterator<Item = ty::Placeholder> + 'a {
378+
) -> impl Iterator<Item = ty::PlaceholderRegion> + 'a {
379379
self.placeholders
380380
.row(r)
381381
.into_iter()
@@ -432,7 +432,7 @@ impl ToElementIndex for RegionVid {
432432
}
433433
}
434434

435-
impl ToElementIndex for ty::Placeholder {
435+
impl ToElementIndex for ty::PlaceholderRegion {
436436
fn add_to_row<N: Idx>(self, values: &mut RegionValues<N>, row: N) -> bool {
437437
let index = values.placeholder_indices.lookup_index(self);
438438
values.placeholders.insert(row, index)

‎src/librustc_mir/borrow_check/nll/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ impl MirTypeckRegionConstraints<'tcx> {
777777
fn placeholder_region(
778778
&mut self,
779779
infcx: &InferCtxt<'_, '_, 'tcx>,
780-
placeholder: ty::Placeholder,
780+
placeholder: ty::PlaceholderRegion,
781781
) -> ty::Region<'tcx> {
782782
let placeholder_index = self.placeholder_indices.insert(placeholder);
783783
match self.placeholder_index_to_region.get(placeholder_index) {

‎src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, '_, 'tcx> {
8484
}
8585
}
8686

87-
fn next_placeholder_region(&mut self, placeholder: ty::Placeholder) -> ty::Region<'tcx> {
87+
fn next_placeholder_region(
88+
&mut self,
89+
placeholder: ty::PlaceholderRegion
90+
) -> ty::Region<'tcx> {
8891
if let Some(borrowck_context) = &mut self.borrowck_context {
8992
borrowck_context.constraints.placeholder_region(self.infcx, placeholder)
9093
} else {

0 commit comments

Comments
 (0)
Please sign in to comment.