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
|
@ -181,8 +181,8 @@ trait TypeOpInfo<'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let placeholder_region = tcx.mk_re_placeholder(ty::Placeholder {
|
let placeholder_region = tcx.mk_re_placeholder(ty::Placeholder {
|
||||||
name: placeholder.name,
|
|
||||||
universe: adjusted_universe.into(),
|
universe: adjusted_universe.into(),
|
||||||
|
bound: placeholder.bound,
|
||||||
});
|
});
|
||||||
|
|
||||||
let error_region =
|
let error_region =
|
||||||
|
@ -191,8 +191,8 @@ trait TypeOpInfo<'tcx> {
|
||||||
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
|
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
|
||||||
adjusted_universe.map(|adjusted| {
|
adjusted_universe.map(|adjusted| {
|
||||||
tcx.mk_re_placeholder(ty::Placeholder {
|
tcx.mk_re_placeholder(ty::Placeholder {
|
||||||
name: error_placeholder.name,
|
|
||||||
universe: adjusted.into(),
|
universe: adjusted.into(),
|
||||||
|
bound: error_placeholder.bound,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -467,9 +467,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
if let ty::Ref(region, ..) = ty.kind() {
|
if let ty::Ref(region, ..) = ty.kind() {
|
||||||
match **region {
|
match **region {
|
||||||
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
|
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
|
||||||
| ty::RePlaceholder(ty::PlaceholderRegion { name: br, .. }) => {
|
| ty::RePlaceholder(ty::PlaceholderRegion {
|
||||||
printer.region_highlight_mode.highlighting_bound_region(br, counter)
|
bound: ty::BoundRegion { kind: br, .. },
|
||||||
}
|
..
|
||||||
|
}) => printer.region_highlight_mode.highlighting_bound_region(br, counter),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,9 +486,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
let region = if let ty::Ref(region, ..) = ty.kind() {
|
let region = if let ty::Ref(region, ..) = ty.kind() {
|
||||||
match **region {
|
match **region {
|
||||||
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
|
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
|
||||||
| ty::RePlaceholder(ty::PlaceholderRegion { name: br, .. }) => {
|
| ty::RePlaceholder(ty::PlaceholderRegion {
|
||||||
printer.region_highlight_mode.highlighting_bound_region(br, counter)
|
bound: ty::BoundRegion { kind: br, .. },
|
||||||
}
|
..
|
||||||
|
}) => printer.region_highlight_mode.highlighting_bound_region(br, counter),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
region
|
region
|
||||||
|
|
|
@ -207,7 +207,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
.regioncx
|
.regioncx
|
||||||
.placeholders_contained_in(lower_bound)
|
.placeholders_contained_in(lower_bound)
|
||||||
.map(|placeholder| {
|
.map(|placeholder| {
|
||||||
if let Some(id) = placeholder.name.get_id()
|
if let Some(id) = placeholder.bound.kind.get_id()
|
||||||
&& let Some(placeholder_id) = id.as_local()
|
&& let Some(placeholder_id) = id.as_local()
|
||||||
&& let gat_hir_id = hir.local_def_id_to_hir_id(placeholder_id)
|
&& let gat_hir_id = hir.local_def_id_to_hir_id(placeholder_id)
|
||||||
&& let Some(generics_impl) = hir.get_parent(gat_hir_id).generics()
|
&& let Some(generics_impl) = hir.get_parent(gat_hir_id).generics()
|
||||||
|
|
|
@ -123,7 +123,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
|
||||||
.constraints
|
.constraints
|
||||||
.placeholder_region(self.type_checker.infcx, placeholder);
|
.placeholder_region(self.type_checker.infcx, placeholder);
|
||||||
|
|
||||||
let reg_info = match placeholder.name {
|
let reg_info = match placeholder.bound.kind {
|
||||||
ty::BoundRegionKind::BrAnon(_, Some(span)) => BoundRegionInfo::Span(span),
|
ty::BoundRegionKind::BrAnon(_, Some(span)) => BoundRegionInfo::Span(span),
|
||||||
ty::BoundRegionKind::BrAnon(..) => BoundRegionInfo::Name(Symbol::intern("anon")),
|
ty::BoundRegionKind::BrAnon(..) => BoundRegionInfo::Name(Symbol::intern("anon")),
|
||||||
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
|
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
|
||||||
|
|
|
@ -2336,10 +2336,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
FnMutDelegate {
|
FnMutDelegate {
|
||||||
regions: &mut |_| tcx.lifetimes.re_erased,
|
regions: &mut |_| tcx.lifetimes.re_erased,
|
||||||
types: &mut |bv| {
|
types: &mut |bv| {
|
||||||
tcx.mk_placeholder(ty::PlaceholderType { universe, name: bv.kind })
|
tcx.mk_placeholder(ty::PlaceholderType { universe, bound: bv })
|
||||||
},
|
},
|
||||||
consts: &mut |bv, ty| {
|
consts: &mut |bv, ty| {
|
||||||
tcx.mk_const(ty::PlaceholderConst { universe, name: bv }, ty)
|
tcx.mk_const(ty::PlaceholderConst { universe, bound: bv }, ty)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -2525,11 +2525,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
regions: &mut |_| tcx.lifetimes.re_erased,
|
regions: &mut |_| tcx.lifetimes.re_erased,
|
||||||
types: &mut |bv| tcx.mk_placeholder(ty::PlaceholderType {
|
types: &mut |bv| tcx.mk_placeholder(ty::PlaceholderType {
|
||||||
universe,
|
universe,
|
||||||
name: bv.kind,
|
bound: bv,
|
||||||
}),
|
}),
|
||||||
consts: &mut |bv, ty| tcx.mk_const(ty::PlaceholderConst {
|
consts: &mut |bv, ty| tcx.mk_const(ty::PlaceholderConst {
|
||||||
universe,
|
universe,
|
||||||
name: bv
|
bound: bv,
|
||||||
}, ty),
|
}, ty),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
|
@ -125,9 +125,9 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
ty.into()
|
ty.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
CanonicalVarKind::PlaceholderTy(ty::PlaceholderType { universe, name }) => {
|
CanonicalVarKind::PlaceholderTy(ty::PlaceholderType { universe, bound }) => {
|
||||||
let universe_mapped = universe_map(universe);
|
let universe_mapped = universe_map(universe);
|
||||||
let placeholder_mapped = ty::PlaceholderType { universe: universe_mapped, name };
|
let placeholder_mapped = ty::PlaceholderType { universe: universe_mapped, bound };
|
||||||
self.tcx.mk_placeholder(placeholder_mapped).into()
|
self.tcx.mk_placeholder(placeholder_mapped).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,9 +138,9 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
)
|
)
|
||||||
.into(),
|
.into(),
|
||||||
|
|
||||||
CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion { universe, name }) => {
|
CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion { universe, bound }) => {
|
||||||
let universe_mapped = universe_map(universe);
|
let universe_mapped = universe_map(universe);
|
||||||
let placeholder_mapped = ty::PlaceholderRegion { universe: universe_mapped, name };
|
let placeholder_mapped = ty::PlaceholderRegion { universe: universe_mapped, bound };
|
||||||
self.tcx.mk_re_placeholder(placeholder_mapped).into()
|
self.tcx.mk_re_placeholder(placeholder_mapped).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,9 +152,9 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
)
|
)
|
||||||
.into(),
|
.into(),
|
||||||
|
|
||||||
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, name }, ty) => {
|
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, bound }, ty) => {
|
||||||
let universe_mapped = universe_map(universe);
|
let universe_mapped = universe_map(universe);
|
||||||
let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, name };
|
let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, bound };
|
||||||
self.tcx.mk_const(placeholder_mapped, ty).into()
|
self.tcx.mk_const(placeholder_mapped, ty).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,15 +170,15 @@ fn msg_span_from_named_region<'tcx>(
|
||||||
}
|
}
|
||||||
ty::ReStatic => ("the static lifetime".to_owned(), alt_span),
|
ty::ReStatic => ("the static lifetime".to_owned(), alt_span),
|
||||||
ty::RePlaceholder(ty::PlaceholderRegion {
|
ty::RePlaceholder(ty::PlaceholderRegion {
|
||||||
name: ty::BoundRegionKind::BrNamed(def_id, name),
|
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, name), .. },
|
||||||
..
|
..
|
||||||
}) => (format!("the lifetime `{name}` as defined here"), Some(tcx.def_span(def_id))),
|
}) => (format!("the lifetime `{name}` as defined here"), Some(tcx.def_span(def_id))),
|
||||||
ty::RePlaceholder(ty::PlaceholderRegion {
|
ty::RePlaceholder(ty::PlaceholderRegion {
|
||||||
name: ty::BoundRegionKind::BrAnon(_, Some(span)),
|
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon(_, Some(span)), .. },
|
||||||
..
|
..
|
||||||
}) => (format!("the anonymous lifetime defined here"), Some(span)),
|
}) => (format!("the anonymous lifetime defined here"), Some(span)),
|
||||||
ty::RePlaceholder(ty::PlaceholderRegion {
|
ty::RePlaceholder(ty::PlaceholderRegion {
|
||||||
name: ty::BoundRegionKind::BrAnon(_, None),
|
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon(_, None), .. },
|
||||||
..
|
..
|
||||||
}) => (format!("an anonymous lifetime"), None),
|
}) => (format!("an anonymous lifetime"), None),
|
||||||
_ => bug!("{:?}", region),
|
_ => bug!("{:?}", region),
|
||||||
|
|
|
@ -16,8 +16,20 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
|
||||||
match &self.error {
|
match &self.error {
|
||||||
Some(RegionResolutionError::ConcreteFailure(
|
Some(RegionResolutionError::ConcreteFailure(
|
||||||
SubregionOrigin::RelateRegionParamBound(span),
|
SubregionOrigin::RelateRegionParamBound(span),
|
||||||
Region(Interned(RePlaceholder(ty::Placeholder { name: sub_name, .. }), _)),
|
Region(Interned(
|
||||||
Region(Interned(RePlaceholder(ty::Placeholder { name: sup_name, .. }), _)),
|
RePlaceholder(ty::Placeholder {
|
||||||
|
bound: ty::BoundRegion { kind: sub_name, .. },
|
||||||
|
..
|
||||||
|
}),
|
||||||
|
_,
|
||||||
|
)),
|
||||||
|
Region(Interned(
|
||||||
|
RePlaceholder(ty::Placeholder {
|
||||||
|
bound: ty::BoundRegion { kind: sup_name, .. },
|
||||||
|
..
|
||||||
|
}),
|
||||||
|
_,
|
||||||
|
)),
|
||||||
)) => {
|
)) => {
|
||||||
let span = *span;
|
let span = *span;
|
||||||
let (sub_span, sub_symbol) = match sub_name {
|
let (sub_span, sub_symbol) = match sub_name {
|
||||||
|
|
|
@ -82,20 +82,20 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||||
|
|
||||||
let delegate = FnMutDelegate {
|
let delegate = FnMutDelegate {
|
||||||
regions: &mut |br: ty::BoundRegion| {
|
regions: &mut |br: ty::BoundRegion| {
|
||||||
self.tcx.mk_re_placeholder(ty::PlaceholderRegion {
|
self.tcx
|
||||||
universe: next_universe,
|
.mk_re_placeholder(ty::PlaceholderRegion { universe: next_universe, bound: br })
|
||||||
name: br.kind,
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
types: &mut |bound_ty: ty::BoundTy| {
|
types: &mut |bound_ty: ty::BoundTy| {
|
||||||
self.tcx.mk_placeholder(ty::PlaceholderType {
|
self.tcx.mk_placeholder(ty::PlaceholderType {
|
||||||
universe: next_universe,
|
universe: next_universe,
|
||||||
name: bound_ty.kind,
|
bound: bound_ty,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
consts: &mut |bound_var: ty::BoundVar, ty| {
|
consts: &mut |bound_var: ty::BoundVar, ty| {
|
||||||
self.tcx
|
self.tcx.mk_const(
|
||||||
.mk_const(ty::PlaceholderConst { universe: next_universe, name: bound_var }, ty)
|
ty::PlaceholderConst { universe: next_universe, bound: bound_var },
|
||||||
|
ty,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2130,13 +2130,17 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
|
||||||
|
|
||||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
if let ty::Infer(_) = t.kind() {
|
if let ty::Infer(_) = t.kind() {
|
||||||
|
let idx = {
|
||||||
|
let idx = self.idx;
|
||||||
|
self.idx += 1;
|
||||||
|
idx
|
||||||
|
};
|
||||||
self.tcx.mk_placeholder(ty::PlaceholderType {
|
self.tcx.mk_placeholder(ty::PlaceholderType {
|
||||||
universe: ty::UniverseIndex::ROOT,
|
universe: ty::UniverseIndex::ROOT,
|
||||||
name: ty::BoundTyKind::Anon({
|
bound: ty::BoundTy {
|
||||||
let idx = self.idx;
|
var: ty::BoundVar::from_u32(idx),
|
||||||
self.idx += 1;
|
kind: ty::BoundTyKind::Anon(idx),
|
||||||
idx
|
},
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
t.super_fold_with(self)
|
t.super_fold_with(self)
|
||||||
|
@ -2153,7 +2157,7 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
|
||||||
self.tcx.mk_const(
|
self.tcx.mk_const(
|
||||||
ty::PlaceholderConst {
|
ty::PlaceholderConst {
|
||||||
universe: ty::UniverseIndex::ROOT,
|
universe: ty::UniverseIndex::ROOT,
|
||||||
name: ty::BoundVar::from_u32({
|
bound: ty::BoundVar::from_u32({
|
||||||
let idx = self.idx;
|
let idx = self.idx;
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
idx
|
idx
|
||||||
|
|
|
@ -296,7 +296,7 @@ where
|
||||||
universe
|
universe
|
||||||
});
|
});
|
||||||
|
|
||||||
let placeholder = ty::PlaceholderRegion { universe, name: br.kind };
|
let placeholder = ty::PlaceholderRegion { universe, bound: br };
|
||||||
debug!(?placeholder);
|
debug!(?placeholder);
|
||||||
let placeholder_reg = nll_delegate.next_placeholder_region(placeholder);
|
let placeholder_reg = nll_delegate.next_placeholder_region(placeholder);
|
||||||
debug!(?placeholder_reg);
|
debug!(?placeholder_reg);
|
||||||
|
|
|
@ -290,9 +290,9 @@ impl<'me, 'tcx> LeakCheck<'me, 'tcx> {
|
||||||
) -> TypeError<'tcx> {
|
) -> TypeError<'tcx> {
|
||||||
debug!("error: placeholder={:?}, other_region={:?}", placeholder, other_region);
|
debug!("error: placeholder={:?}, other_region={:?}", placeholder, other_region);
|
||||||
if self.overly_polymorphic {
|
if self.overly_polymorphic {
|
||||||
TypeError::RegionsOverlyPolymorphic(placeholder.name, other_region)
|
TypeError::RegionsOverlyPolymorphic(placeholder.bound.kind, other_region)
|
||||||
} else {
|
} else {
|
||||||
TypeError::RegionsInsufficientlyPolymorphic(placeholder.name, other_region)
|
TypeError::RegionsInsufficientlyPolymorphic(placeholder.bound.kind, other_region)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,9 +155,11 @@ impl<'tcx> CanonicalVarInfo<'tcx> {
|
||||||
| CanonicalVarKind::Region(_)
|
| CanonicalVarKind::Region(_)
|
||||||
| CanonicalVarKind::Const(_, _) => bug!("expected placeholder: {self:?}"),
|
| CanonicalVarKind::Const(_, _) => bug!("expected placeholder: {self:?}"),
|
||||||
|
|
||||||
CanonicalVarKind::PlaceholderRegion(placeholder) => placeholder.name.expect_anon(),
|
CanonicalVarKind::PlaceholderRegion(placeholder) => {
|
||||||
CanonicalVarKind::PlaceholderTy(placeholder) => placeholder.name.expect_anon(),
|
placeholder.bound.kind.expect_anon()
|
||||||
CanonicalVarKind::PlaceholderConst(placeholder, _) => placeholder.name.as_u32(),
|
}
|
||||||
|
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)]
|
#[derive(HashStable, TyEncodable, TyDecodable)]
|
||||||
pub struct Placeholder<T> {
|
pub struct Placeholder<T> {
|
||||||
pub universe: UniverseIndex,
|
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(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
|
||||||
#[derive(TyEncodable, TyDecodable, PartialOrd, Ord)]
|
#[derive(TyEncodable, TyDecodable, PartialOrd, Ord)]
|
||||||
|
|
|
@ -739,7 +739,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
p!(print(data))
|
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::Anon(_) => p!(write("Placeholder({:?})", placeholder)),
|
||||||
ty::BoundTyKind::Param(_, name) => p!(write("{}", name)),
|
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::ReLateBound(_, ty::BoundRegion { kind: br, .. })
|
||||||
| ty::ReFree(ty::FreeRegion { bound_region: 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() {
|
if br.is_named() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2181,7 +2183,9 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
|
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
|
||||||
| ty::ReFree(ty::FreeRegion { bound_region: 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() {
|
if let ty::BrNamed(_, name) = br && br.is_named() {
|
||||||
p!(write("{}", name));
|
p!(write("{}", name));
|
||||||
return Ok(self);
|
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 => {
|
ty::ReLateBound(db, br) if db >= self.current_index => {
|
||||||
*self.region_map.entry(br).or_insert_with(|| name(Some(db), self.current_index, br))
|
*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
|
// If this is an anonymous placeholder, don't rename. Otherwise, in some
|
||||||
// async fns, we get a `for<'r> Send` bound
|
// async fns, we get a `for<'r> Send` bound
|
||||||
match kind {
|
match kind {
|
||||||
|
|
|
@ -254,8 +254,8 @@ TrivialTypeTraversalAndLiftImpls! {
|
||||||
crate::ty::AssocKind,
|
crate::ty::AssocKind,
|
||||||
crate::ty::AliasKind,
|
crate::ty::AliasKind,
|
||||||
crate::ty::AliasRelationDirection,
|
crate::ty::AliasRelationDirection,
|
||||||
crate::ty::Placeholder<crate::ty::BoundRegionKind>,
|
crate::ty::Placeholder<crate::ty::BoundRegion>,
|
||||||
crate::ty::Placeholder<crate::ty::BoundTyKind>,
|
crate::ty::Placeholder<crate::ty::BoundTy>,
|
||||||
crate::ty::ClosureKind,
|
crate::ty::ClosureKind,
|
||||||
crate::ty::FreeRegion,
|
crate::ty::FreeRegion,
|
||||||
crate::ty::InferTy,
|
crate::ty::InferTy,
|
||||||
|
|
|
@ -1632,7 +1632,7 @@ impl<'tcx> Region<'tcx> {
|
||||||
ty::ReLateBound(_, br) => br.kind.get_name(),
|
ty::ReLateBound(_, br) => br.kind.get_name(),
|
||||||
ty::ReFree(fr) => fr.bound_region.get_name(),
|
ty::ReFree(fr) => fr.bound_region.get_name(),
|
||||||
ty::ReStatic => Some(kw::StaticLifetime),
|
ty::ReStatic => Some(kw::StaticLifetime),
|
||||||
ty::RePlaceholder(placeholder) => placeholder.name.get_name(),
|
ty::RePlaceholder(placeholder) => placeholder.bound.kind.get_name(),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1650,7 +1650,7 @@ impl<'tcx> Region<'tcx> {
|
||||||
ty::ReFree(fr) => fr.bound_region.is_named(),
|
ty::ReFree(fr) => fr.bound_region.is_named(),
|
||||||
ty::ReStatic => true,
|
ty::ReStatic => true,
|
||||||
ty::ReVar(..) => false,
|
ty::ReVar(..) => false,
|
||||||
ty::RePlaceholder(placeholder) => placeholder.name.is_named(),
|
ty::RePlaceholder(placeholder) => placeholder.bound.kind.is_named(),
|
||||||
ty::ReErased => false,
|
ty::ReErased => false,
|
||||||
ty::ReError(_) => false,
|
ty::ReError(_) => false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,14 +300,20 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
||||||
ty::Placeholder(placeholder) => match self.canonicalize_mode {
|
ty::Placeholder(placeholder) => match self.canonicalize_mode {
|
||||||
CanonicalizeMode::Input => CanonicalVarKind::PlaceholderTy(ty::Placeholder {
|
CanonicalizeMode::Input => CanonicalVarKind::PlaceholderTy(ty::Placeholder {
|
||||||
universe: placeholder.universe,
|
universe: placeholder.universe,
|
||||||
name: BoundTyKind::Anon(self.variables.len() as u32),
|
bound: ty::BoundTy {
|
||||||
|
var: ty::BoundVar::from_usize(self.variables.len()),
|
||||||
|
kind: ty::BoundTyKind::Anon(self.variables.len() as u32),
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
CanonicalizeMode::Response { .. } => CanonicalVarKind::PlaceholderTy(placeholder),
|
CanonicalizeMode::Response { .. } => CanonicalVarKind::PlaceholderTy(placeholder),
|
||||||
},
|
},
|
||||||
ty::Param(_) => match self.canonicalize_mode {
|
ty::Param(_) => match self.canonicalize_mode {
|
||||||
CanonicalizeMode::Input => CanonicalVarKind::PlaceholderTy(ty::Placeholder {
|
CanonicalizeMode::Input => CanonicalVarKind::PlaceholderTy(ty::Placeholder {
|
||||||
universe: ty::UniverseIndex::ROOT,
|
universe: ty::UniverseIndex::ROOT,
|
||||||
name: ty::BoundTyKind::Anon(self.variables.len() as u32),
|
bound: ty::BoundTy {
|
||||||
|
var: ty::BoundVar::from_usize(self.variables.len()),
|
||||||
|
kind: ty::BoundTyKind::Anon(self.variables.len() as u32),
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
CanonicalizeMode::Response { .. } => bug!("param ty in response: {t:?}"),
|
CanonicalizeMode::Response { .. } => bug!("param ty in response: {t:?}"),
|
||||||
},
|
},
|
||||||
|
@ -373,7 +379,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
||||||
CanonicalizeMode::Input => CanonicalVarKind::PlaceholderConst(
|
CanonicalizeMode::Input => CanonicalVarKind::PlaceholderConst(
|
||||||
ty::Placeholder {
|
ty::Placeholder {
|
||||||
universe: placeholder.universe,
|
universe: placeholder.universe,
|
||||||
name: ty::BoundVar::from(self.variables.len()),
|
bound: ty::BoundVar::from(self.variables.len()),
|
||||||
},
|
},
|
||||||
c.ty(),
|
c.ty(),
|
||||||
),
|
),
|
||||||
|
@ -385,7 +391,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
||||||
CanonicalizeMode::Input => CanonicalVarKind::PlaceholderConst(
|
CanonicalizeMode::Input => CanonicalVarKind::PlaceholderConst(
|
||||||
ty::Placeholder {
|
ty::Placeholder {
|
||||||
universe: ty::UniverseIndex::ROOT,
|
universe: ty::UniverseIndex::ROOT,
|
||||||
name: ty::BoundVar::from(self.variables.len()),
|
bound: ty::BoundVar::from(self.variables.len()),
|
||||||
},
|
},
|
||||||
c.ty(),
|
c.ty(),
|
||||||
),
|
),
|
||||||
|
|
|
@ -772,7 +772,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
ty::ReLateBound(debruijn, br) if debruijn >= self.current_index => {
|
ty::ReLateBound(debruijn, br) if debruijn >= self.current_index => {
|
||||||
let universe = self.universe_for(debruijn);
|
let universe = self.universe_for(debruijn);
|
||||||
let p = ty::PlaceholderRegion { universe, name: br.kind };
|
let p = ty::PlaceholderRegion { universe, bound: br };
|
||||||
self.mapped_regions.insert(p, br);
|
self.mapped_regions.insert(p, br);
|
||||||
self.infcx.tcx.mk_re_placeholder(p)
|
self.infcx.tcx.mk_re_placeholder(p)
|
||||||
}
|
}
|
||||||
|
@ -790,7 +790,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
ty::Bound(debruijn, bound_ty) if debruijn >= self.current_index => {
|
ty::Bound(debruijn, bound_ty) if debruijn >= self.current_index => {
|
||||||
let universe = self.universe_for(debruijn);
|
let universe = self.universe_for(debruijn);
|
||||||
let p = ty::PlaceholderType { universe, name: bound_ty.kind };
|
let p = ty::PlaceholderType { universe, bound: bound_ty };
|
||||||
self.mapped_types.insert(p, bound_ty);
|
self.mapped_types.insert(p, bound_ty);
|
||||||
self.infcx.tcx.mk_placeholder(p)
|
self.infcx.tcx.mk_placeholder(p)
|
||||||
}
|
}
|
||||||
|
@ -809,7 +809,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
ty::ConstKind::Bound(debruijn, bound_const) if debruijn >= self.current_index => {
|
ty::ConstKind::Bound(debruijn, bound_const) if debruijn >= self.current_index => {
|
||||||
let universe = self.universe_for(debruijn);
|
let universe = self.universe_for(debruijn);
|
||||||
let p = ty::PlaceholderConst { universe, name: bound_const };
|
let p = ty::PlaceholderConst { universe, bound: bound_const };
|
||||||
self.mapped_consts.insert(p, bound_const);
|
self.mapped_consts.insert(p, bound_const);
|
||||||
self.infcx.tcx.mk_const(p, ct.ty())
|
self.infcx.tcx.mk_const(p, ct.ty())
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,7 +376,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
||||||
ty::Placeholder(_placeholder) => {
|
ty::Placeholder(_placeholder) => {
|
||||||
chalk_ir::TyKind::Placeholder(chalk_ir::PlaceholderIndex {
|
chalk_ir::TyKind::Placeholder(chalk_ir::PlaceholderIndex {
|
||||||
ui: chalk_ir::UniverseIndex { counter: _placeholder.universe.as_usize() },
|
ui: chalk_ir::UniverseIndex { counter: _placeholder.universe.as_usize() },
|
||||||
idx: _placeholder.name.expect_anon() as usize,
|
idx: _placeholder.bound.var.as_usize(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ty::Infer(_infer) => unimplemented!(),
|
ty::Infer(_infer) => unimplemented!(),
|
||||||
|
@ -484,7 +484,10 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
||||||
),
|
),
|
||||||
TyKind::Placeholder(placeholder) => ty::Placeholder(ty::Placeholder {
|
TyKind::Placeholder(placeholder) => ty::Placeholder(ty::Placeholder {
|
||||||
universe: ty::UniverseIndex::from_usize(placeholder.ui.counter),
|
universe: ty::UniverseIndex::from_usize(placeholder.ui.counter),
|
||||||
name: ty::BoundTyKind::Anon(placeholder.idx as u32),
|
bound: ty::BoundTy {
|
||||||
|
var: ty::BoundVar::from_usize(placeholder.idx),
|
||||||
|
kind: ty::BoundTyKind::Anon(placeholder.idx as u32),
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
TyKind::InferenceVar(_, _) => unimplemented!(),
|
TyKind::InferenceVar(_, _) => unimplemented!(),
|
||||||
TyKind::Dyn(_) => unimplemented!(),
|
TyKind::Dyn(_) => unimplemented!(),
|
||||||
|
@ -536,7 +539,10 @@ impl<'tcx> LowerInto<'tcx, Region<'tcx>> for &chalk_ir::Lifetime<RustInterner<'t
|
||||||
chalk_ir::LifetimeData::InferenceVar(_var) => unimplemented!(),
|
chalk_ir::LifetimeData::InferenceVar(_var) => unimplemented!(),
|
||||||
chalk_ir::LifetimeData::Placeholder(p) => tcx.mk_re_placeholder(ty::Placeholder {
|
chalk_ir::LifetimeData::Placeholder(p) => tcx.mk_re_placeholder(ty::Placeholder {
|
||||||
universe: ty::UniverseIndex::from_usize(p.ui.counter),
|
universe: ty::UniverseIndex::from_usize(p.ui.counter),
|
||||||
name: ty::BoundRegionKind::BrAnon(p.idx as u32, None),
|
bound: ty::BoundRegion {
|
||||||
|
var: ty::BoundVar::from_usize(p.idx),
|
||||||
|
kind: ty::BoundRegionKind::BrAnon(p.idx as u32, None),
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
chalk_ir::LifetimeData::Static => tcx.lifetimes.re_static,
|
chalk_ir::LifetimeData::Static => tcx.lifetimes.re_static,
|
||||||
chalk_ir::LifetimeData::Erased => tcx.lifetimes.re_erased,
|
chalk_ir::LifetimeData::Erased => tcx.lifetimes.re_erased,
|
||||||
|
@ -1090,7 +1096,10 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamsSubstitutor<'tcx> {
|
||||||
ty::Param(param) => match self.list.iter().position(|r| r == ¶m) {
|
ty::Param(param) => match self.list.iter().position(|r| r == ¶m) {
|
||||||
Some(idx) => self.tcx.mk_placeholder(ty::PlaceholderType {
|
Some(idx) => self.tcx.mk_placeholder(ty::PlaceholderType {
|
||||||
universe: ty::UniverseIndex::from_usize(0),
|
universe: ty::UniverseIndex::from_usize(0),
|
||||||
name: ty::BoundTyKind::Anon(idx as u32),
|
bound: ty::BoundTy {
|
||||||
|
var: ty::BoundVar::from_usize(idx),
|
||||||
|
kind: ty::BoundTyKind::Anon(idx as u32),
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
None => {
|
None => {
|
||||||
self.list.push(param);
|
self.list.push(param);
|
||||||
|
@ -1098,7 +1107,10 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ParamsSubstitutor<'tcx> {
|
||||||
self.params.insert(idx as u32, param);
|
self.params.insert(idx as u32, param);
|
||||||
self.tcx.mk_placeholder(ty::PlaceholderType {
|
self.tcx.mk_placeholder(ty::PlaceholderType {
|
||||||
universe: ty::UniverseIndex::from_usize(0),
|
universe: ty::UniverseIndex::from_usize(0),
|
||||||
name: ty::BoundTyKind::Anon(idx as u32),
|
bound: ty::BoundTy {
|
||||||
|
var: ty::BoundVar::from_usize(idx),
|
||||||
|
kind: ty::BoundTyKind::Anon(idx as u32),
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1156,12 +1168,13 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseParamsSubstitutor<'tcx> {
|
||||||
|
|
||||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
match *t.kind() {
|
match *t.kind() {
|
||||||
ty::Placeholder(ty::PlaceholderType { universe: ty::UniverseIndex::ROOT, name }) => {
|
ty::Placeholder(ty::PlaceholderType {
|
||||||
match self.params.get(&name.expect_anon()) {
|
universe: ty::UniverseIndex::ROOT,
|
||||||
Some(&ty::ParamTy { index, name }) => self.tcx.mk_ty_param(index, name),
|
bound: ty::BoundTy { kind: name, .. },
|
||||||
None => t,
|
}) => match self.params.get(&name.expect_anon()) {
|
||||||
}
|
Some(&ty::ParamTy { index, name }) => self.tcx.mk_ty_param(index, name),
|
||||||
}
|
None => t,
|
||||||
|
},
|
||||||
|
|
||||||
_ => t.super_fold_with(self),
|
_ => t.super_fold_with(self),
|
||||||
}
|
}
|
||||||
|
@ -1190,7 +1203,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for PlaceholdersCollector {
|
||||||
match t.kind() {
|
match t.kind() {
|
||||||
ty::Placeholder(p) if p.universe == self.universe_index => {
|
ty::Placeholder(p) if p.universe == self.universe_index => {
|
||||||
self.next_ty_placeholder =
|
self.next_ty_placeholder =
|
||||||
self.next_ty_placeholder.max(p.name.expect_anon() as usize + 1);
|
self.next_ty_placeholder.max(p.bound.kind.expect_anon() as usize + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
|
@ -1202,7 +1215,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for PlaceholdersCollector {
|
||||||
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
match *r {
|
match *r {
|
||||||
ty::RePlaceholder(p) if p.universe == self.universe_index => {
|
ty::RePlaceholder(p) if p.universe == self.universe_index => {
|
||||||
if let ty::BoundRegionKind::BrAnon(anon, _) = p.name {
|
if let ty::BoundRegionKind::BrAnon(anon, _) = p.bound.kind {
|
||||||
self.next_anon_region_placeholder = self.next_anon_region_placeholder.max(anon);
|
self.next_anon_region_placeholder = self.next_anon_region_placeholder.max(anon);
|
||||||
}
|
}
|
||||||
// FIXME: This doesn't seem to handle BrNamed at all?
|
// FIXME: This doesn't seem to handle BrNamed at all?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue