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:
commit
2e65f7bc1f
2 changed files with 23 additions and 4 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
7
src/test/ui/regions/issue-72051-member-region-hang.rs
Normal file
7
src/test/ui/regions/issue-72051-member-region-hang.rs
Normal 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() {}
|
Loading…
Add table
Reference in a new issue