Skip to content

Commit

Permalink
Revert "lub: don't bail out due to empty binders"
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr authored Jun 29, 2022
1 parent 116edb6 commit a5c0525
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 209 deletions.
20 changes: 6 additions & 14 deletions compiler/rustc_infer/src/infer/glb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,12 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
T: Relate<'tcx>,
{
debug!("binders(a={:?}, b={:?})", a, b);
if a.skip_binder().has_escaping_bound_vars() || b.skip_binder().has_escaping_bound_vars() {
// When higher-ranked types are involved, computing the GLB is
// very challenging, switch to invariance. This is obviously
// overly conservative but works ok in practice.
self.relate_with_variance(
ty::Variance::Invariant,
ty::VarianceDiagInfo::default(),
a,
b,
)?;
Ok(a)
} else {
Ok(ty::Binder::dummy(self.relate(a.skip_binder(), b.skip_binder())?))
}

// When higher-ranked types are involved, computing the LUB is
// very challenging, switch to invariance. This is obviously
// overly conservative but works ok in practice.
self.relate_with_variance(ty::Variance::Invariant, ty::VarianceDiagInfo::default(), a, b)?;
Ok(a)
}
}

Expand Down
20 changes: 6 additions & 14 deletions compiler/rustc_infer/src/infer/lub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,12 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> {
T: Relate<'tcx>,
{
debug!("binders(a={:?}, b={:?})", a, b);
if a.skip_binder().has_escaping_bound_vars() || b.skip_binder().has_escaping_bound_vars() {
// When higher-ranked types are involved, computing the LUB is
// very challenging, switch to invariance. This is obviously
// overly conservative but works ok in practice.
self.relate_with_variance(
ty::Variance::Invariant,
ty::VarianceDiagInfo::default(),
a,
b,
)?;
Ok(a)
} else {
Ok(ty::Binder::dummy(self.relate(a.skip_binder(), b.skip_binder())?))
}

// When higher-ranked types are involved, computing the LUB is
// very challenging, switch to invariance. This is obviously
// overly conservative but works ok in practice.
self.relate_with_variance(ty::Variance::Invariant, ty::VarianceDiagInfo::default(), a, b)?;
Ok(a)
}
}

Expand Down
22 changes: 0 additions & 22 deletions src/test/ui/lub-glb/empty-binder-future-compat.rs

This file was deleted.

55 changes: 0 additions & 55 deletions src/test/ui/lub-glb/empty-binders-err.rs

This file was deleted.

59 changes: 0 additions & 59 deletions src/test/ui/lub-glb/empty-binders-err.stderr

This file was deleted.

45 changes: 0 additions & 45 deletions src/test/ui/lub-glb/empty-binders.rs

This file was deleted.

0 comments on commit a5c0525

Please sign in to comment.