Rollup merge of #137302 - compiler-errors:stray-drop-regions, r=matthewjasper
Use a probe to avoid registering stray region obligations when re-checking drops in MIR typeck Fixes #137288. See the comment I left on the probe. I'm not totally sure why this depends on *both* an unconstrained type parameter in the impl and a type error for the self type, but I think the fix is at least theoretically well motivated. r? ```@matthewjasper```
This commit is contained in:
commit
3a04ec8c56
4 changed files with 42 additions and 9 deletions
|
@ -613,9 +613,14 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
|
|||
// types, so there's no guarantee that it succeeds. We also
|
||||
// can't rely on the the `ErrorGuaranteed` from `fully_perform` here
|
||||
// because it comes from delay_span_bug.
|
||||
let ocx = ObligationCtxt::new_with_diagnostics(&typeck.infcx);
|
||||
let errors =
|
||||
match dropck_outlives::compute_dropck_outlives_with_errors(&ocx, op, span) {
|
||||
//
|
||||
// Do this inside of a probe because we don't particularly care (or want)
|
||||
// any region side-effects of this operation in our infcx.
|
||||
typeck.infcx.probe(|_| {
|
||||
let ocx = ObligationCtxt::new_with_diagnostics(&typeck.infcx);
|
||||
let errors = match dropck_outlives::compute_dropck_outlives_with_errors(
|
||||
&ocx, op, span,
|
||||
) {
|
||||
Ok(_) => ocx.select_all_or_error(),
|
||||
Err(e) => {
|
||||
if e.is_empty() {
|
||||
|
@ -626,11 +631,12 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
if !errors.is_empty() {
|
||||
typeck.infcx.err_ctxt().report_fulfillment_errors(errors);
|
||||
} else {
|
||||
span_bug!(span, "Rerunning drop data query produced no error.");
|
||||
}
|
||||
if !errors.is_empty() {
|
||||
typeck.infcx.err_ctxt().report_fulfillment_errors(errors);
|
||||
} else {
|
||||
span_bug!(span, "Rerunning drop data query produced no error.");
|
||||
}
|
||||
});
|
||||
DropData { dropck_result: Default::default(), region_constraint_data: None }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue