1
Fork 0

simply the IfEq bound -- we only ever use a region

the excessive generality becomes annoying later because
it wouldn't implement type folding etc
This commit is contained in:
Niko Matsakis 2022-06-14 20:18:46 -04:00
parent 1f34da9ec8
commit d203c13db2
4 changed files with 14 additions and 10 deletions

View file

@ -818,9 +818,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
min: ty::Region<'tcx>,
) -> bool {
match bound {
VerifyBound::IfEq(k, b) => {
VerifyBound::IfEq(k, r) => {
(var_values.normalize(self.region_rels.tcx, *k) == generic_ty)
&& self.bound_is_met(b, var_values, generic_ty, min)
&& self.bound_is_met(&VerifyBound::OutlivedBy(*r), var_values, generic_ty, min)
}
VerifyBound::OutlivedBy(r) => {

View file

@ -160,14 +160,13 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
.projection_approx_declared_bounds_from_env(projection_ty)
.into_iter()
.map(|ty::OutlivesPredicate(ty, r)| {
let vb = VerifyBound::OutlivedBy(r);
if ty == projection_ty_as_ty {
// Micro-optimize if this is an exact match (this
// occurs often when there are no region variables
// involved).
vb
VerifyBound::OutlivedBy(r)
} else {
VerifyBound::IfEq(ty, Box::new(vb))
VerifyBound::IfEq(ty, r)
}
});

View file

@ -224,7 +224,7 @@ pub enum VerifyBound<'tcx> {
///
/// meaning, if the subject G is equal to `<T as Trait<'a>>::Item`
/// (after inference), and `'a: min`, then `G: min`.
IfEq(Ty<'tcx>, Box<VerifyBound<'tcx>>),
IfEq(Ty<'tcx>, Region<'tcx>),
/// Given a region `R`, expands to the function:
///
@ -770,7 +770,7 @@ impl<'tcx> VerifyBound<'tcx> {
pub fn cannot_hold(&self) -> bool {
match self {
VerifyBound::IfEq(_, b) => b.cannot_hold(),
VerifyBound::IfEq(_, _) => false,
VerifyBound::IsEmpty => false,
VerifyBound::OutlivedBy(_) => false,
VerifyBound::AnyBound(bs) => bs.iter().all(|b| b.cannot_hold()),