Rollup merge of #136299 - lqd:polonius-next-episode-9, r=jackh726
Ignore NLL boring locals in polonius diagnostics Another easy one ``@jackh726`` (the diff is inflated by blessed test expectations don't worry :) NLLs don't compute liveness for boring locals, and therefore cannot find them in causes explaining borrows. In polonius, we don't have this liveness optimization (we may be able to do something partially similar in the future, e.g. for function parameters and the like), so we do encounter these in diagnostics even though we don't want to. This PR: - restructures the polonius context into per-phase data, in spirit as you requested in an earlier review - stores the locals NLLs would consider boring into the errors/diagnostics data - ignores these if a boring local is found when trying to explain borrows This PR fixes around 80 cases of diagnostics differences between `-Zpolonius=next` and NLLs. I've also added explicit revisions to a few polonius tests (both for the in-tree implementation as well as the datalog implementation -- even if we'll eventually remove them). I didn't do this for all the "dead" expectations that were removed from #136112 for that same reason, it's fine. I'll soon/eventually add explicit revisions where they're needed: there's only a handful of tests left to fix. r? ``@jackh726``
This commit is contained in:
@@ -60,6 +60,7 @@ use crate::diagnostics::{
|
||||
use crate::path_utils::*;
|
||||
use crate::place_ext::PlaceExt;
|
||||
use crate::places_conflict::{PlaceConflictBias, places_conflict};
|
||||
use crate::polonius::PoloniusDiagnosticsContext;
|
||||
use crate::polonius::legacy::{PoloniusLocationTable, PoloniusOutput};
|
||||
use crate::prefixes::PrefixSet;
|
||||
use crate::region_infer::RegionInferenceContext;
|
||||
@@ -198,7 +199,7 @@ fn do_mir_borrowck<'tcx>(
|
||||
polonius_output,
|
||||
opt_closure_req,
|
||||
nll_errors,
|
||||
localized_outlives_constraints,
|
||||
polonius_diagnostics,
|
||||
} = nll::compute_regions(
|
||||
&infcx,
|
||||
free_regions,
|
||||
@@ -270,6 +271,7 @@ fn do_mir_borrowck<'tcx>(
|
||||
polonius_output: None,
|
||||
move_errors: Vec::new(),
|
||||
diags_buffer,
|
||||
polonius_diagnostics: polonius_diagnostics.as_ref(),
|
||||
};
|
||||
struct MoveVisitor<'a, 'b, 'infcx, 'tcx> {
|
||||
ctxt: &'a mut MirBorrowckCtxt<'b, 'infcx, 'tcx>,
|
||||
@@ -308,6 +310,7 @@ fn do_mir_borrowck<'tcx>(
|
||||
polonius_output,
|
||||
move_errors: Vec::new(),
|
||||
diags_buffer,
|
||||
polonius_diagnostics: polonius_diagnostics.as_ref(),
|
||||
};
|
||||
|
||||
// Compute and report region errors, if any.
|
||||
@@ -329,7 +332,7 @@ fn do_mir_borrowck<'tcx>(
|
||||
body,
|
||||
®ioncx,
|
||||
&borrow_set,
|
||||
localized_outlives_constraints,
|
||||
polonius_diagnostics.as_ref(),
|
||||
&opt_closure_req,
|
||||
);
|
||||
|
||||
@@ -579,6 +582,9 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
|
||||
|
||||
diags_buffer: &'a mut BorrowckDiagnosticsBuffer<'infcx, 'tcx>,
|
||||
move_errors: Vec<MoveError<'tcx>>,
|
||||
|
||||
/// When using `-Zpolonius=next`: the data used to compute errors and diagnostics.
|
||||
polonius_diagnostics: Option<&'a PoloniusDiagnosticsContext>,
|
||||
}
|
||||
|
||||
// Check that:
|
||||
|
||||
Reference in New Issue
Block a user