Auto merge of #105350 - compiler-errors:faster-binder-relate, r=oli-obk
Fast-path some binder relations A simpler approach than #104598 Fixes #104583 r? types
This commit is contained in:
commit
109cccbe4f
9 changed files with 63 additions and 5 deletions
|
@ -178,6 +178,11 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
|
|||
where
|
||||
T: Relate<'tcx>,
|
||||
{
|
||||
// A binder is equal to itself if it's structually equal to itself
|
||||
if a == b {
|
||||
return Ok(a);
|
||||
}
|
||||
|
||||
if a.skip_binder().has_escaping_bound_vars() || b.skip_binder().has_escaping_bound_vars() {
|
||||
self.fields.higher_ranked_sub(a, b, self.a_is_expected)?;
|
||||
self.fields.higher_ranked_sub(b, a, self.a_is_expected)?;
|
||||
|
|
|
@ -103,6 +103,11 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
|
|||
where
|
||||
T: Relate<'tcx>,
|
||||
{
|
||||
// GLB of a binder and itself is just itself
|
||||
if a == b {
|
||||
return Ok(a);
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -103,6 +103,11 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> {
|
|||
where
|
||||
T: Relate<'tcx>,
|
||||
{
|
||||
// LUB of a binder and itself is just itself
|
||||
if a == b {
|
||||
return Ok(a);
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -213,6 +213,11 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
|
|||
where
|
||||
T: Relate<'tcx>,
|
||||
{
|
||||
// A binder is always a subtype of itself if it's structually equal to itself
|
||||
if a == b {
|
||||
return Ok(a);
|
||||
}
|
||||
|
||||
self.fields.higher_ranked_sub(a, b, self.a_is_expected)?;
|
||||
Ok(a)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue