Skip to content

Commit d03518e

Browse files
committed
nyaaa
1 parent 7cb8557 commit d03518e

File tree

11 files changed

+531
-1125
lines changed

11 files changed

+531
-1125
lines changed

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,8 @@ impl<'tcx> PoloniusOutOfScopePrecomputer<'_, 'tcx> {
317317
loans_out_of_scope_at_location: FxIndexMap::default(),
318318
};
319319
for (loan_idx, loan_data) in borrow_set.iter_enumerated() {
320-
let issuing_region = loan_data.region;
321320
let loan_issued_at = loan_data.reserve_location;
322-
prec.precompute_loans_out_of_scope(loan_idx, issuing_region, loan_issued_at);
321+
prec.precompute_loans_out_of_scope(loan_idx, loan_issued_at);
323322
}
324323

325324
prec.loans_out_of_scope_at_location
@@ -328,45 +327,7 @@ impl<'tcx> PoloniusOutOfScopePrecomputer<'_, 'tcx> {
328327
/// Loans are in scope while they are live: whether they are contained within any live region.
329328
/// In the location-insensitive analysis, a loan will be contained in a region if the issuing
330329
/// region can reach it in the subset graph. So this is a reachability problem.
331-
fn precompute_loans_out_of_scope(
332-
&mut self,
333-
loan_idx: BorrowIndex,
334-
issuing_region: RegionVid,
335-
loan_issued_at: Location,
336-
) {
337-
let sccs = self.regioncx.constraint_sccs();
338-
let universal_regions = self.regioncx.universal_regions();
339-
340-
// The loop below was useful for the location-insensitive analysis but shouldn't be
341-
// impactful in the location-sensitive case. It seems that it does, however, as without it a
342-
// handful of tests fail. That likely means some liveness or outlives data related to choice
343-
// regions is missing
344-
// FIXME: investigate the impact of loans traversing applied member constraints and why some
345-
// tests fail otherwise.
346-
//
347-
// We first handle the cases where the loan doesn't go out of scope, depending on the
348-
// issuing region's successors.
349-
for successor in graph::depth_first_search(&self.regioncx.region_graph(), issuing_region) {
350-
// Via applied member constraints
351-
//
352-
// The issuing region can flow into the choice regions, and they are either:
353-
// - placeholders or free regions themselves,
354-
// - or also transitively outlive a free region.
355-
//
356-
// That is to say, if there are applied member constraints here, the loan escapes the
357-
// function and cannot go out of scope. We could early return here.
358-
//
359-
// For additional insurance via fuzzing and crater, we verify that the constraint's min
360-
// choice indeed escapes the function. In the future, we could e.g. turn this check into
361-
// a debug assert and early return as an optimization.
362-
let scc = sccs.scc(successor);
363-
for constraint in self.regioncx.applied_member_constraints(scc) {
364-
if universal_regions.is_universal_region(constraint.min_choice) {
365-
return;
366-
}
367-
}
368-
}
369-
330+
fn precompute_loans_out_of_scope(&mut self, loan_idx: BorrowIndex, loan_issued_at: Location) {
370331
let first_block = loan_issued_at.block;
371332
let first_bb_data = &self.body.basic_blocks[first_block];
372333

compiler/rustc_borrowck/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ mod constraints;
7272
mod dataflow;
7373
mod def_use;
7474
mod diagnostics;
75-
mod member_constraints;
7675
mod nll;
7776
mod path_utils;
7877
mod place_ext;

compiler/rustc_borrowck/src/member_constraints.rs

Lines changed: 0 additions & 226 deletions
This file was deleted.

compiler/rustc_borrowck/src/nll.rs

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::rc::Rc;
66
use std::str::FromStr;
77

88
use polonius_engine::{Algorithm, Output};
9-
use rustc_index::IndexSlice;
9+
use rustc_index::{IndexSlice, IndexVec};
1010
use rustc_middle::mir::pretty::{PrettyPrintMirOptions, dump_mir_with_options};
1111
use rustc_middle::mir::{Body, PassWhere, Promoted, create_dump_file, dump_enabled, dump_mir};
1212
use rustc_middle::ty::print::with_no_trimmed_paths;
@@ -26,7 +26,8 @@ use crate::polonius::PoloniusDiagnosticsContext;
2626
use crate::polonius::legacy::{
2727
PoloniusFacts, PoloniusFactsExt, PoloniusLocationTable, PoloniusOutput,
2828
};
29-
use crate::region_infer::RegionInferenceContext;
29+
use crate::region_infer::opaque_types::handle_opaque_type_uses;
30+
use crate::region_infer::{RegionDefinition, RegionInferenceContext};
3031
use crate::type_check::{self, MirTypeckResults};
3132
use crate::universal_regions::UniversalRegions;
3233
use crate::{
@@ -98,30 +99,29 @@ pub(crate) fn compute_regions<'a, 'tcx>(
9899
let location_map = Rc::new(DenseLocationMap::new(body));
99100

100101
// Run the MIR type-checker.
101-
let MirTypeckResults {
102-
constraints,
103-
universal_region_relations,
104-
opaque_type_values,
105-
polonius_context,
106-
} = type_check::type_check(
102+
let MirTypeckResults { constraints, universal_region_relations, polonius_context } =
103+
type_check::type_check(
104+
root_cx,
105+
infcx,
106+
body,
107+
promoted,
108+
universal_regions,
109+
location_table,
110+
borrow_set,
111+
&mut polonius_facts,
112+
flow_inits,
113+
move_data,
114+
Rc::clone(&location_map),
115+
);
116+
117+
let constraints = handle_opaque_type_uses(
107118
root_cx,
108119
infcx,
109-
body,
110-
promoted,
111-
universal_regions,
112-
location_table,
113-
borrow_set,
114-
&mut polonius_facts,
115-
flow_inits,
116-
move_data,
120+
constraints,
121+
&universal_region_relations,
117122
Rc::clone(&location_map),
118123
);
119124

120-
// Create the region inference context, taking ownership of the
121-
// region inference data that was contained in `infcx`, and the
122-
// base constraints generated by the type-check.
123-
let var_infos = infcx.get_region_var_infos();
124-
125125
// If requested, emit legacy polonius facts.
126126
polonius::legacy::emit_facts(
127127
&mut polonius_facts,
@@ -134,13 +134,8 @@ pub(crate) fn compute_regions<'a, 'tcx>(
134134
&constraints,
135135
);
136136

137-
let mut regioncx = RegionInferenceContext::new(
138-
infcx,
139-
var_infos,
140-
constraints,
141-
universal_region_relations,
142-
location_map,
143-
);
137+
let mut regioncx =
138+
RegionInferenceContext::new(infcx, constraints, universal_region_relations, location_map);
144139

145140
// If requested for `-Zpolonius=next`, convert NLL constraints to localized outlives constraints
146141
// and use them to compute loan liveness.
@@ -173,13 +168,12 @@ pub(crate) fn compute_regions<'a, 'tcx>(
173168
let (closure_region_requirements, nll_errors) =
174169
regioncx.solve(infcx, body, polonius_output.clone());
175170

171+
// TODO: TRY YEET
176172
if let Some(guar) = nll_errors.has_errors() {
177173
// Suppress unhelpful extra errors in `infer_opaque_types`.
178174
infcx.set_tainted_by_errors(guar);
179175
}
180176

181-
regioncx.infer_opaque_types(root_cx, infcx, opaque_type_values);
182-
183177
NllOutput {
184178
regioncx,
185179
polonius_input: polonius_facts.map(Box::new),

0 commit comments

Comments
 (0)