Rollup merge of #72087 - matthewjasper:regionck-hang, r=nikomatsakis

Fix hang in lexical_region_resolve

Regionck was stuck in a loop where a region value was changing between two equal regions.

Closes #72051
This commit is contained in:
Dylan DPC 2020-05-14 18:21:48 +02:00 committed by GitHub
commit 2e65f7bc1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 4 deletions

View file

@ -325,8 +325,21 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
}
}
debug!("enforce_member_constraint: final least choice = {:?}", least_choice);
if least_choice != member_lower_bound {
// (#72087) Different `ty::Regions` can be known to be equal, for
// example, we know that `'a` and `'static` are equal in a function
// with a parameter of type `&'static &'a ()`.
//
// When we have two equal regions like this `expansion` will use
// `lub_concrete_regions` to pick a canonical representative. The same
// choice is needed here so that we don't end up in a cycle of
// `expansion` changing the region one way and the code here changing
// it back.
let lub = self.lub_concrete_regions(least_choice, member_lower_bound);
debug!(
"enforce_member_constraint: final least choice = {:?}\nlub = {:?}",
least_choice, lub
);
if lub != member_lower_bound {
*var_values.value_mut(member_vid) = VarValue::Value(least_choice);
true
} else {
@ -578,8 +591,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
self.tcx().mk_region(ReScope(lub))
}
(&ReEarlyBound(_), &ReEarlyBound(_) | &ReFree(_))
| (&ReFree(_), &ReEarlyBound(_) | &ReFree(_)) => {
(&ReEarlyBound(_) | &ReFree(_), &ReEarlyBound(_) | &ReFree(_)) => {
self.region_rels.lub_free_regions(a, b)
}

View file

@ -0,0 +1,7 @@
// Regression test for #72051, hang when resolving regions.
// check-pass
// edition:2018
pub async fn query<'a>(_: &(), _: &(), _: (&(dyn std::any::Any + 'a),) ) {}
fn main() {}