Use BoundTy and BoundRegion instead of kind of PlaceholderTy and PlaceholderRegion
This commit is contained in:
parent
c934ce9e0a
commit
4646b3df6a
20 changed files with 121 additions and 75 deletions
|
@ -155,9 +155,11 @@ impl<'tcx> CanonicalVarInfo<'tcx> {
|
|||
| CanonicalVarKind::Region(_)
|
||||
| CanonicalVarKind::Const(_, _) => bug!("expected placeholder: {self:?}"),
|
||||
|
||||
CanonicalVarKind::PlaceholderRegion(placeholder) => placeholder.name.expect_anon(),
|
||||
CanonicalVarKind::PlaceholderTy(placeholder) => placeholder.name.expect_anon(),
|
||||
CanonicalVarKind::PlaceholderConst(placeholder, _) => placeholder.name.as_u32(),
|
||||
CanonicalVarKind::PlaceholderRegion(placeholder) => {
|
||||
placeholder.bound.kind.expect_anon()
|
||||
}
|
||||
CanonicalVarKind::PlaceholderTy(placeholder) => placeholder.bound.kind.expect_anon(),
|
||||
CanonicalVarKind::PlaceholderConst(placeholder, _) => placeholder.bound.as_u32(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1454,12 +1454,12 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
|
|||
#[derive(HashStable, TyEncodable, TyDecodable)]
|
||||
pub struct Placeholder<T> {
|
||||
pub universe: UniverseIndex,
|
||||
pub name: T,
|
||||
pub bound: T,
|
||||
}
|
||||
|
||||
pub type PlaceholderRegion = Placeholder<BoundRegionKind>;
|
||||
pub type PlaceholderRegion = Placeholder<BoundRegion>;
|
||||
|
||||
pub type PlaceholderType = Placeholder<BoundTyKind>;
|
||||
pub type PlaceholderType = Placeholder<BoundTy>;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
|
||||
#[derive(TyEncodable, TyDecodable, PartialOrd, Ord)]
|
||||
|
|
|
@ -739,7 +739,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||
p!(print(data))
|
||||
}
|
||||
}
|
||||
ty::Placeholder(placeholder) => match placeholder.name {
|
||||
ty::Placeholder(placeholder) => match placeholder.bound.kind {
|
||||
ty::BoundTyKind::Anon(_) => p!(write("Placeholder({:?})", placeholder)),
|
||||
ty::BoundTyKind::Param(_, name) => p!(write("{}", name)),
|
||||
},
|
||||
|
@ -2104,7 +2104,9 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
|
|||
|
||||
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
|
||||
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
|
||||
| ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
|
||||
| ty::RePlaceholder(ty::Placeholder {
|
||||
bound: ty::BoundRegion { kind: br, .. }, ..
|
||||
}) => {
|
||||
if br.is_named() {
|
||||
return true;
|
||||
}
|
||||
|
@ -2181,7 +2183,9 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
|||
}
|
||||
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
|
||||
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
|
||||
| ty::RePlaceholder(ty::Placeholder { name: br, .. }) => {
|
||||
| ty::RePlaceholder(ty::Placeholder {
|
||||
bound: ty::BoundRegion { kind: br, .. }, ..
|
||||
}) => {
|
||||
if let ty::BrNamed(_, name) = br && br.is_named() {
|
||||
p!(write("{}", name));
|
||||
return Ok(self);
|
||||
|
@ -2259,7 +2263,10 @@ impl<'a, 'tcx> ty::TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
|
|||
ty::ReLateBound(db, br) if db >= self.current_index => {
|
||||
*self.region_map.entry(br).or_insert_with(|| name(Some(db), self.current_index, br))
|
||||
}
|
||||
ty::RePlaceholder(ty::PlaceholderRegion { name: kind, .. }) => {
|
||||
ty::RePlaceholder(ty::PlaceholderRegion {
|
||||
bound: ty::BoundRegion { kind, .. },
|
||||
..
|
||||
}) => {
|
||||
// If this is an anonymous placeholder, don't rename. Otherwise, in some
|
||||
// async fns, we get a `for<'r> Send` bound
|
||||
match kind {
|
||||
|
|
|
@ -254,8 +254,8 @@ TrivialTypeTraversalAndLiftImpls! {
|
|||
crate::ty::AssocKind,
|
||||
crate::ty::AliasKind,
|
||||
crate::ty::AliasRelationDirection,
|
||||
crate::ty::Placeholder<crate::ty::BoundRegionKind>,
|
||||
crate::ty::Placeholder<crate::ty::BoundTyKind>,
|
||||
crate::ty::Placeholder<crate::ty::BoundRegion>,
|
||||
crate::ty::Placeholder<crate::ty::BoundTy>,
|
||||
crate::ty::ClosureKind,
|
||||
crate::ty::FreeRegion,
|
||||
crate::ty::InferTy,
|
||||
|
|
|
@ -1632,7 +1632,7 @@ impl<'tcx> Region<'tcx> {
|
|||
ty::ReLateBound(_, br) => br.kind.get_name(),
|
||||
ty::ReFree(fr) => fr.bound_region.get_name(),
|
||||
ty::ReStatic => Some(kw::StaticLifetime),
|
||||
ty::RePlaceholder(placeholder) => placeholder.name.get_name(),
|
||||
ty::RePlaceholder(placeholder) => placeholder.bound.kind.get_name(),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
@ -1650,7 +1650,7 @@ impl<'tcx> Region<'tcx> {
|
|||
ty::ReFree(fr) => fr.bound_region.is_named(),
|
||||
ty::ReStatic => true,
|
||||
ty::ReVar(..) => false,
|
||||
ty::RePlaceholder(placeholder) => placeholder.name.is_named(),
|
||||
ty::RePlaceholder(placeholder) => placeholder.bound.kind.is_named(),
|
||||
ty::ReErased => false,
|
||||
ty::ReError(_) => false,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue