Use a probe to avoid registering stray region obligations when re-che… · rust-lang/rust@d4609f8 (original) (raw)

Original file line number Diff line number Diff line change
@@ -613,9 +613,14 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
613 613 // types, so there's no guarantee that it succeeds. We also
614 614 // can't rely on the the `ErrorGuaranteed` from `fully_perform` here
615 615 // because it comes from delay_span_bug.
616 -let ocx = ObligationCtxt::new_with_diagnostics(&typeck.infcx);
617 -let errors =
618 -match dropck_outlives::compute_dropck_outlives_with_errors(&ocx, op, span) {
616 +//
617 +// Do this inside of a probe because we don't particularly care (or want)
618 +// any region side-effects of this operation in our infcx.
619 + typeck.infcx.probe(|_
620 +let ocx = ObligationCtxt::new_with_diagnostics(&typeck.infcx);
621 +let errors = match dropck_outlives::compute_dropck_outlives_with_errors(
622 +&ocx, op, span,
623 +) {
619 624 Ok(_) => ocx.select_all_or_error(),
620 625 Err(e) => {
621 626 if e.is_empty() {
@@ -626,11 +631,12 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
626 631 }
627 632 };
628 633
629 -if !errors.is_empty() {
630 - typeck.infcx.err_ctxt().report_fulfillment_errors(errors);
631 -} else {
632 -span_bug!(span, "Rerunning drop data query produced no error.");
633 -}
634 +if !errors.is_empty() {
635 + typeck.infcx.err_ctxt().report_fulfillment_errors(errors);
636 +} else {
637 +span_bug!(span, "Rerunning drop data query produced no error.");
638 +}
639 +});
634 640 DropData { dropck_result: Default::default(), region_constraint_data: None }
635 641 }
636 642 }