/// A "placeholder" that represents "any region". Created when you
/// are solving a goal like `for<'a> T: Foo<'a>` to represent the
/// bound region `'a`.
- PlaceholderRegion(ty::Placeholder),
+ PlaceholderRegion(ty::PlaceholderRegion),
}
impl CanonicalVarKind {
universe_map(ui),
).into(),
- CanonicalVarKind::PlaceholderRegion(ty::Placeholder { universe, name }) => {
+ CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion { universe, name }) => {
let universe_mapped = universe_map(universe);
- let placeholder_mapped = ty::Placeholder {
+ let placeholder_mapped = ty::PlaceholderRegion {
universe: universe_mapped,
name,
};
let next_universe = self.create_next_universe();
let (result, map) = self.tcx.replace_late_bound_regions(binder, |br| {
- self.tcx.mk_region(ty::RePlaceholder(ty::Placeholder {
+ self.tcx.mk_region(ty::RePlaceholder(ty::PlaceholderRegion {
universe: next_universe,
name: br,
}))
/// "Universal" instantiation of a higher-ranked region (e.g.,
/// from a `for<'a> T` binder). Meant to represent "any region".
- Placeholder(ty::Placeholder),
+ Placeholder(ty::PlaceholderRegion),
Existential,
}
/// So e.g. if you have `for<'a> fn(..) <: for<'b> fn(..)`, then
/// we will invoke this method to instantiate `'b` with a
/// placeholder region.
- fn next_placeholder_region(&mut self, placeholder: ty::Placeholder) -> ty::Region<'tcx>;
+ fn next_placeholder_region(&mut self, placeholder: ty::PlaceholderRegion) -> ty::Region<'tcx>;
/// Creates a new existential region in the given universe. This
/// is used when handling subtyping and type variables -- if we
universe
});
- let placeholder = ty::Placeholder { universe, name: br };
+ let placeholder = ty::PlaceholderRegion { universe, name: br };
delegate.next_placeholder_region(placeholder)
} else {
delegate.next_existential_region_var()
/// universe are just two regions with an unknown relationship to one
/// another.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, PartialOrd, Ord)]
-pub struct Placeholder {
+pub struct Placeholder<T> {
pub universe: UniverseIndex,
- pub name: BoundRegion,
+ pub name: T,
}
-impl_stable_hash_for!(struct Placeholder { universe, name });
+impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for Placeholder<T>
+ where T: HashStable<StableHashingContext<'a>>
+{
+ fn hash_stable<W: StableHasherResult>(
+ &self,
+ hcx: &mut StableHashingContext<'a>,
+ hasher: &mut StableHasher<W>
+ ) {
+ self.universe.hash_stable(hcx, hasher);
+ self.name.hash_stable(hcx, hasher);
+ }
+}
+
+pub type PlaceholderRegion = Placeholder<BoundRegion>;
+
+pub type PlaceholderType = Placeholder<BoundVar>;
/// When type checking, we use the `ParamEnv` to track
/// details about the set of where-clauses that are in scope at this
/// A placeholder region - basically the higher-ranked version of ReFree.
/// Should not exist after typeck.
- RePlaceholder(ty::Placeholder),
+ RePlaceholder(ty::PlaceholderRegion),
/// Empty lifetime is for data that is never accessed.
/// Bottom in the region lattice. We treat ReEmpty somewhat
}
ty::ReLateBound(_, br) |
ty::ReFree(ty::FreeRegion { bound_region: br, .. }) |
- ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
+ ty::RePlaceholder(ty::PlaceholderRegion { name: br, .. }) => {
write!(f, "{}", br)
}
ty::ReScope(scope) if cx.identify_regions => {
match ty.sty {
ty::TyKind::Ref(ty::RegionKind::ReLateBound(_, br), _, _)
| ty::TyKind::Ref(
- ty::RegionKind::RePlaceholder(ty::Placeholder { name: br, .. }),
+ ty::RegionKind::RePlaceholder(ty::PlaceholderRegion { name: br, .. }),
_,
_,
) => with_highlight_region_for_bound_region(*br, counter, || ty.to_string()),
match ty.sty {
ty::TyKind::Ref(region, _, _) => match region {
ty::RegionKind::ReLateBound(_, br)
- | ty::RegionKind::RePlaceholder(ty::Placeholder { name: br, .. }) => {
+ | ty::RegionKind::RePlaceholder(ty::PlaceholderRegion { name: br, .. }) => {
with_highlight_region_for_bound_region(*br, counter, || region.to_string())
}
_ => region.to_string(),
mir: &Mir<'tcx>,
_mir_def_id: DefId,
longer_fr: RegionVid,
- placeholder: ty::Placeholder,
+ placeholder: ty::PlaceholderRegion,
) {
debug!(
"check_bound_universal_region(fr={:?}, placeholder={:?})",
/// A placeholder (e.g., instantiated from a `for<'a> fn(&'a u32)`
/// type).
- PlaceholderRegion(ty::Placeholder),
+ PlaceholderRegion(ty::PlaceholderRegion),
}
/// When we initially compute liveness, we use a bit matrix storing
}
}
-/// Maps from `ty::Placeholder` values that are used in the rest of
+/// Maps from `ty::PlaceholderRegion` values that are used in the rest of
/// rustc to the internal `PlaceholderIndex` values that are used in
/// NLL.
#[derive(Default)]
crate struct PlaceholderIndices {
- to_index: FxHashMap<ty::Placeholder, PlaceholderIndex>,
- from_index: IndexVec<PlaceholderIndex, ty::Placeholder>,
+ to_index: FxHashMap<ty::PlaceholderRegion, PlaceholderIndex>,
+ from_index: IndexVec<PlaceholderIndex, ty::PlaceholderRegion>,
}
impl PlaceholderIndices {
- crate fn insert(&mut self, placeholder: ty::Placeholder) -> PlaceholderIndex {
+ crate fn insert(&mut self, placeholder: ty::PlaceholderRegion) -> PlaceholderIndex {
let PlaceholderIndices {
to_index,
from_index,
.or_insert_with(|| from_index.push(placeholder))
}
- crate fn lookup_index(&self, placeholder: ty::Placeholder) -> PlaceholderIndex {
+ crate fn lookup_index(&self, placeholder: ty::PlaceholderRegion) -> PlaceholderIndex {
self.to_index[&placeholder]
}
- crate fn lookup_placeholder(&self, placeholder: PlaceholderIndex) -> ty::Placeholder {
+ crate fn lookup_placeholder(&self, placeholder: PlaceholderIndex) -> ty::PlaceholderRegion {
self.from_index[placeholder]
}
crate fn placeholders_contained_in<'a>(
&'a self,
r: N,
- ) -> impl Iterator<Item = ty::Placeholder> + 'a {
+ ) -> impl Iterator<Item = ty::PlaceholderRegion> + 'a {
self.placeholders
.row(r)
.into_iter()
}
}
-impl ToElementIndex for ty::Placeholder {
+impl ToElementIndex for ty::PlaceholderRegion {
fn add_to_row<N: Idx>(self, values: &mut RegionValues<N>, row: N) -> bool {
let index = values.placeholder_indices.lookup_index(self);
values.placeholders.insert(row, index)
fn placeholder_region(
&mut self,
infcx: &InferCtxt<'_, '_, 'tcx>,
- placeholder: ty::Placeholder,
+ placeholder: ty::PlaceholderRegion,
) -> ty::Region<'tcx> {
let placeholder_index = self.placeholder_indices.insert(placeholder);
match self.placeholder_index_to_region.get(placeholder_index) {
}
}
- fn next_placeholder_region(&mut self, placeholder: ty::Placeholder) -> ty::Region<'tcx> {
+ fn next_placeholder_region(
+ &mut self,
+ placeholder: ty::PlaceholderRegion
+ ) -> ty::Region<'tcx> {
if let Some(borrowck_context) = &mut self.borrowck_context {
borrowck_context.constraints.placeholder_region(self.infcx, placeholder)
} else {