Scrape extraneous regions from instantiate_nll_query_response_and_region_obligations

This commit is contained in:
Oli Scherer 2024-03-25 18:06:53 +00:00
parent 08e25e4536
commit dd72bf922a
2 changed files with 60 additions and 43 deletions

View File

@ -159,11 +159,19 @@ where
.0);
}
let mut error_info = None;
let mut region_constraints = QueryRegionConstraints::default();
let (output, error_info, mut obligations, _) =
Q::fully_perform_into(self, infcx, &mut region_constraints, span).map_err(|_| {
infcx.dcx().span_delayed_bug(span, format!("error performing {self:?}"))
})?;
// HACK(type_alias_impl_trait): When moving an opaque type to hidden type mapping from the query to the current inferctxt,
// we sometimes end up with `Opaque<'a> = Opaque<'b>` instead of an actual hidden type. In that case we don't register a
// hidden type but just equate the lifetimes. Thus we need to scrape the region constraints even though we're also manually
// collecting region constraints via `region_constraints`.
let (mut output, _) = scrape_region_constraints(
infcx,
|_ocx| {
let (output, ei, mut obligations, _) =
Q::fully_perform_into(self, infcx, &mut region_constraints, span)?;
error_info = ei;
// Typically, instantiating NLL query results does not
// create obligations. However, in some cases there
@ -192,20 +200,29 @@ where
}
}
if !progress {
infcx
.dcx()
.span_bug(span, format!("ambiguity processing {obligations:?} from {self:?}"));
infcx.dcx().span_bug(
span,
format!("ambiguity processing {obligations:?} from {self:?}"),
);
}
}
Ok(TypeOpOutput {
output,
constraints: if region_constraints.is_empty() {
Ok(output)
},
"fully_perform",
span,
)?;
output.error_info = error_info;
if let Some(constraints) = output.constraints {
region_constraints
.member_constraints
.extend(constraints.member_constraints.iter().cloned());
region_constraints.outlives.extend(constraints.outlives.iter().cloned());
}
output.constraints = if region_constraints.is_empty() {
None
} else {
Some(infcx.tcx.arena.alloc(region_constraints))
},
error_info,
})
};
Ok(output)
}
}

View File

@ -1,4 +1,4 @@
error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ImpliedOutlivesBounds { ty: &'?2 mut StateContext<'?3, usize> } }
error: internal compiler error: error performing operation: fully_perform
--> $DIR/issue-80409.rs:49:30
|
LL | builder.state().on_entry(|_| {});