Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 36ea00c

Browse files
committed
rename AllFacts to PoloniusFacts
This is another strangely named struct (and associated fields) that is hard to see was related to datalog polonius.
1 parent 3a1a621 commit 36ea00c

File tree

9 files changed

+47
-45
lines changed

9 files changed

+47
-45
lines changed

compiler/rustc_borrowck/src/consumers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub use super::dataflow::{BorrowIndex, Borrows, calculate_borrows_out_of_scope_a
1111
pub use super::place_ext::PlaceExt;
1212
pub use super::places_conflict::{PlaceConflictBias, places_conflict};
1313
pub use super::polonius::legacy::{
14-
AllFacts as PoloniusInput, PoloniusLocationTable, PoloniusOutput, PoloniusRegionVid,
14+
PoloniusFacts as PoloniusInput, PoloniusLocationTable, PoloniusOutput, PoloniusRegionVid,
1515
RichLocation, RustcFacts,
1616
};
1717
pub use super::region_infer::RegionInferenceContext;

compiler/rustc_borrowck/src/nll.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ use crate::borrow_set::BorrowSet;
2828
use crate::consumers::ConsumerOptions;
2929
use crate::diagnostics::{BorrowckDiagnosticsBuffer, RegionErrors};
3030
use crate::polonius::LocalizedOutlivesConstraintSet;
31-
use crate::polonius::legacy::{AllFacts, AllFactsExt, PoloniusLocationTable, PoloniusOutput};
31+
use crate::polonius::legacy::{
32+
PoloniusFacts, PoloniusFactsExt, PoloniusLocationTable, PoloniusOutput,
33+
};
3234
use crate::region_infer::RegionInferenceContext;
3335
use crate::type_check::{self, MirTypeckResults};
3436
use crate::universal_regions::UniversalRegions;
@@ -39,7 +41,7 @@ use crate::{BorrowckInferCtxt, polonius, renumber};
3941
pub(crate) struct NllOutput<'tcx> {
4042
pub regioncx: RegionInferenceContext<'tcx>,
4143
pub opaque_type_values: FxIndexMap<LocalDefId, OpaqueHiddenType<'tcx>>,
42-
pub polonius_input: Option<Box<AllFacts>>,
44+
pub polonius_input: Option<Box<PoloniusFacts>>,
4345
pub polonius_output: Option<Box<PoloniusOutput>>,
4446
pub opt_closure_req: Option<ClosureRegionRequirements<'tcx>>,
4547
pub nll_errors: RegionErrors<'tcx>,
@@ -91,8 +93,8 @@ pub(crate) fn compute_regions<'a, 'tcx>(
9193
|| is_polonius_legacy_enabled;
9294
let polonius_output = consumer_options.map(|c| c.polonius_output()).unwrap_or_default()
9395
|| is_polonius_legacy_enabled;
94-
let mut all_facts =
95-
(polonius_input || AllFacts::enabled(infcx.tcx)).then_some(AllFacts::default());
96+
let mut polonius_facts =
97+
(polonius_input || PoloniusFacts::enabled(infcx.tcx)).then_some(PoloniusFacts::default());
9698

9799
let location_map = Rc::new(DenseLocationMap::new(body));
98100

@@ -109,7 +111,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
109111
universal_regions,
110112
location_table,
111113
borrow_set,
112-
&mut all_facts,
114+
&mut polonius_facts,
113115
flow_inits,
114116
move_data,
115117
Rc::clone(&location_map),
@@ -122,7 +124,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
122124

123125
// If requested, emit legacy polonius facts.
124126
polonius::legacy::emit_facts(
125-
&mut all_facts,
127+
&mut polonius_facts,
126128
infcx.tcx,
127129
location_table,
128130
body,
@@ -147,13 +149,13 @@ pub(crate) fn compute_regions<'a, 'tcx>(
147149
});
148150

149151
// If requested: dump NLL facts, and run legacy polonius analysis.
150-
let polonius_output = all_facts.as_ref().and_then(|all_facts| {
152+
let polonius_output = polonius_facts.as_ref().and_then(|polonius_facts| {
151153
if infcx.tcx.sess.opts.unstable_opts.nll_facts {
152154
let def_id = body.source.def_id();
153155
let def_path = infcx.tcx.def_path(def_id);
154156
let dir_path = PathBuf::from(&infcx.tcx.sess.opts.unstable_opts.nll_facts_dir)
155157
.join(def_path.to_filename_friendly_no_crate());
156-
all_facts.write_to_dir(dir_path, location_table).unwrap();
158+
polonius_facts.write_to_dir(dir_path, location_table).unwrap();
157159
}
158160

159161
if polonius_output {
@@ -162,7 +164,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
162164
let algorithm = Algorithm::from_str(&algorithm).unwrap();
163165
debug!("compute_regions: using polonius algorithm {:?}", algorithm);
164166
let _prof_timer = infcx.tcx.prof.generic_activity("polonius_analysis");
165-
Some(Box::new(Output::compute(all_facts, algorithm, false)))
167+
Some(Box::new(Output::compute(polonius_facts, algorithm, false)))
166168
} else {
167169
None
168170
}
@@ -182,7 +184,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
182184
NllOutput {
183185
regioncx,
184186
opaque_type_values: remapped_opaque_tys,
185-
polonius_input: all_facts.map(Box::new),
187+
polonius_input: polonius_facts.map(Box::new),
186188
polonius_output,
187189
opt_closure_req: closure_region_requirements,
188190
nll_errors,

compiler/rustc_borrowck/src/polonius/legacy/accesses.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use rustc_middle::ty::TyCtxt;
44
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData};
55
use tracing::debug;
66

7-
use super::{AllFacts, LocationIndex, PoloniusLocationTable};
7+
use super::{LocationIndex, PoloniusFacts, PoloniusLocationTable};
88
use crate::def_use::{self, DefUse};
99
use crate::universal_regions::UniversalRegions;
1010

1111
/// Emit polonius facts for variable defs, uses, drops, and path accesses.
1212
pub(crate) fn emit_access_facts<'tcx>(
1313
tcx: TyCtxt<'tcx>,
14-
facts: &mut AllFacts,
14+
facts: &mut PoloniusFacts,
1515
body: &Body<'tcx>,
1616
location_table: &PoloniusLocationTable,
1717
move_data: &MoveData<'tcx>,
@@ -31,7 +31,7 @@ pub(crate) fn emit_access_facts<'tcx>(
3131

3232
/// MIR visitor extracting point-wise facts about accesses.
3333
struct AccessFactsExtractor<'a, 'tcx> {
34-
facts: &'a mut AllFacts,
34+
facts: &'a mut PoloniusFacts,
3535
move_data: &'a MoveData<'tcx>,
3636
location_table: &'a PoloniusLocationTable,
3737
}

compiler/rustc_borrowck/src/polonius/legacy/facts.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fs::{self, File};
44
use std::io::Write;
55
use std::path::Path;
66

7-
use polonius_engine::{AllFacts as PoloniusFacts, Atom, Output};
7+
use polonius_engine::{AllFacts, Atom, Output};
88
use rustc_macros::extension;
99
use rustc_middle::mir::Local;
1010
use rustc_middle::ty::{RegionVid, TyCtxt};
@@ -49,11 +49,11 @@ impl polonius_engine::FactTypes for RustcFacts {
4949
type Path = MovePathIndex;
5050
}
5151

52-
pub type AllFacts = PoloniusFacts<RustcFacts>;
52+
pub type PoloniusFacts = AllFacts<RustcFacts>;
5353

54-
#[extension(pub(crate) trait AllFactsExt)]
55-
impl AllFacts {
56-
/// Returns `true` if there is a need to gather `AllFacts` given the
54+
#[extension(pub(crate) trait PoloniusFactsExt)]
55+
impl PoloniusFacts {
56+
/// Returns `true` if there is a need to gather `PoloniusFacts` given the
5757
/// current `-Z` flags.
5858
fn enabled(tcx: TyCtxt<'_>) -> bool {
5959
tcx.sess.opts.unstable_opts.nll_facts

compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_middle::mir::{
1111
use rustc_middle::ty::TyCtxt;
1212
use tracing::debug;
1313

14-
use super::{AllFacts, PoloniusLocationTable};
14+
use super::{PoloniusFacts, PoloniusLocationTable};
1515
use crate::borrow_set::BorrowSet;
1616
use crate::path_utils::*;
1717
use crate::{
@@ -22,7 +22,7 @@ use crate::{
2222
/// Emit `loan_invalidated_at` facts.
2323
pub(super) fn emit_loan_invalidations<'tcx>(
2424
tcx: TyCtxt<'tcx>,
25-
facts: &mut AllFacts,
25+
facts: &mut PoloniusFacts,
2626
body: &Body<'tcx>,
2727
location_table: &PoloniusLocationTable,
2828
borrow_set: &BorrowSet<'tcx>,
@@ -35,7 +35,7 @@ pub(super) fn emit_loan_invalidations<'tcx>(
3535

3636
struct LoanInvalidationsGenerator<'a, 'tcx> {
3737
tcx: TyCtxt<'tcx>,
38-
facts: &'a mut AllFacts,
38+
facts: &'a mut PoloniusFacts,
3939
body: &'a Body<'tcx>,
4040
location_table: &'a PoloniusLocationTable,
4141
dominators: &'a Dominators<BasicBlock>,

compiler/rustc_borrowck/src/polonius/legacy/loan_kills.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ use rustc_middle::mir::{
66
use rustc_middle::ty::TyCtxt;
77
use tracing::debug;
88

9-
use super::{AllFacts, PoloniusLocationTable};
9+
use super::{PoloniusFacts, PoloniusLocationTable};
1010
use crate::borrow_set::BorrowSet;
1111
use crate::places_conflict;
1212

1313
/// Emit `loan_killed_at` and `cfg_edge` facts at the same time.
1414
pub(super) fn emit_loan_kills<'tcx>(
1515
tcx: TyCtxt<'tcx>,
16-
facts: &mut AllFacts,
16+
facts: &mut PoloniusFacts,
1717
body: &Body<'tcx>,
1818
location_table: &PoloniusLocationTable,
1919
borrow_set: &BorrowSet<'tcx>,
@@ -26,7 +26,7 @@ pub(super) fn emit_loan_kills<'tcx>(
2626

2727
struct LoanKillsGenerator<'a, 'tcx> {
2828
tcx: TyCtxt<'tcx>,
29-
facts: &'a mut AllFacts,
29+
facts: &'a mut PoloniusFacts,
3030
location_table: &'a PoloniusLocationTable,
3131
borrow_set: &'a BorrowSet<'tcx>,
3232
body: &'a Body<'tcx>,

compiler/rustc_borrowck/src/polonius/legacy/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub use self::facts::*;
3636
///
3737
/// The rest of the facts are emitted during typeck and liveness.
3838
pub(crate) fn emit_facts<'tcx>(
39-
all_facts: &mut Option<AllFacts>,
39+
facts: &mut Option<PoloniusFacts>,
4040
tcx: TyCtxt<'tcx>,
4141
location_table: &PoloniusLocationTable,
4242
body: &Body<'tcx>,
@@ -45,7 +45,7 @@ pub(crate) fn emit_facts<'tcx>(
4545
universal_region_relations: &UniversalRegionRelations<'tcx>,
4646
constraints: &MirTypeckRegionConstraints<'tcx>,
4747
) {
48-
let Some(facts) = all_facts else {
48+
let Some(facts) = facts else {
4949
// We don't do anything if there are no facts to fill.
5050
return;
5151
};
@@ -67,7 +67,7 @@ pub(crate) fn emit_facts<'tcx>(
6767

6868
/// Emit facts needed for move/init analysis: moves and assignments.
6969
fn emit_move_facts(
70-
facts: &mut AllFacts,
70+
facts: &mut PoloniusFacts,
7171
body: &Body<'_>,
7272
location_table: &PoloniusLocationTable,
7373
move_data: &MoveData<'_>,
@@ -139,7 +139,7 @@ fn emit_move_facts(
139139

140140
/// Emit universal regions facts, and their relations.
141141
fn emit_universal_region_facts(
142-
facts: &mut AllFacts,
142+
facts: &mut PoloniusFacts,
143143
borrow_set: &BorrowSet<'_>,
144144
universal_region_relations: &UniversalRegionRelations<'_>,
145145
) {
@@ -187,10 +187,10 @@ pub(crate) fn emit_drop_facts<'tcx>(
187187
local: Local,
188188
kind: &GenericArg<'tcx>,
189189
universal_regions: &UniversalRegions<'tcx>,
190-
all_facts: &mut Option<AllFacts>,
190+
facts: &mut Option<PoloniusFacts>,
191191
) {
192192
debug!("emit_drop_facts(local={:?}, kind={:?}", local, kind);
193-
let Some(facts) = all_facts.as_mut() else { return };
193+
let Some(facts) = facts.as_mut() else { return };
194194
let _prof_timer = tcx.prof.generic_activity("polonius_fact_generation");
195195
tcx.for_each_free_region(kind, |drop_live_region| {
196196
let region_vid = universal_regions.to_region_vid(drop_live_region);
@@ -201,7 +201,7 @@ pub(crate) fn emit_drop_facts<'tcx>(
201201
/// Emit facts about the outlives constraints: the `subset` base relation, i.e. not a transitive
202202
/// closure.
203203
fn emit_outlives_facts<'tcx>(
204-
facts: &mut AllFacts,
204+
facts: &mut PoloniusFacts,
205205
location_table: &PoloniusLocationTable,
206206
constraints: &MirTypeckRegionConstraints<'tcx>,
207207
) {

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,14 @@ impl<'a, 'typeck, 'b, 'tcx> LivenessResults<'a, 'typeck, 'b, 'tcx> {
213213
fn add_extra_drop_facts(&mut self, relevant_live_locals: &[Local]) {
214214
// This collect is more necessary than immediately apparent
215215
// because these facts go into `add_drop_live_facts_for()`,
216-
// which also writes to `all_facts`, and so this is genuinely
216+
// which also writes to `polonius_facts`, and so this is genuinely
217217
// a simultaneous overlapping mutable borrow.
218218
// FIXME for future hackers: investigate whether this is
219219
// actually necessary; these facts come from Polonius
220220
// and probably maybe plausibly does not need to go back in.
221221
// It may be necessary to just pick out the parts of
222222
// `add_drop_live_facts_for()` that make sense.
223-
let Some(facts) = self.cx.typeck.all_facts.as_ref() else { return };
223+
let Some(facts) = self.cx.typeck.polonius_facts.as_ref() else { return };
224224
let facts_to_add: Vec<_> = {
225225
let relevant_live_locals: FxIndexSet<_> =
226226
relevant_live_locals.iter().copied().collect();
@@ -583,7 +583,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
583583
dropped_local,
584584
&kind,
585585
self.typeck.universal_regions,
586-
self.typeck.all_facts,
586+
self.typeck.polonius_facts,
587587
);
588588
}
589589
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use crate::constraints::{OutlivesConstraint, OutlivesConstraintSet};
4949
use crate::diagnostics::UniverseInfo;
5050
use crate::member_constraints::MemberConstraintSet;
5151
use crate::polonius::PoloniusContext;
52-
use crate::polonius::legacy::{AllFacts, PoloniusLocationTable};
52+
use crate::polonius::legacy::{PoloniusFacts, PoloniusLocationTable};
5353
use crate::region_infer::TypeTest;
5454
use crate::region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderIndices};
5555
use crate::renumber::RegionCtxt;
@@ -100,7 +100,7 @@ mod relate_tys;
100100
/// - `universal_regions` -- the universal regions from `body`s function signature
101101
/// - `location_table` -- for datalog polonius, the map between `Location`s and `RichLocation`s
102102
/// - `borrow_set` -- information about borrows occurring in `body`
103-
/// - `all_facts` -- when using Polonius, this is the generated set of Polonius facts
103+
/// - `polonius_facts` -- when using Polonius, this is the generated set of Polonius facts
104104
/// - `flow_inits` -- results of a maybe-init dataflow analysis
105105
/// - `move_data` -- move-data constructed when performing the maybe-init dataflow analysis
106106
/// - `location_map` -- map between MIR `Location` and `PointIndex`
@@ -111,7 +111,7 @@ pub(crate) fn type_check<'a, 'tcx>(
111111
universal_regions: UniversalRegions<'tcx>,
112112
location_table: &PoloniusLocationTable,
113113
borrow_set: &BorrowSet<'tcx>,
114-
all_facts: &mut Option<AllFacts>,
114+
polonius_facts: &mut Option<PoloniusFacts>,
115115
flow_inits: ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
116116
move_data: &MoveData<'tcx>,
117117
location_map: Rc<DenseLocationMap>,
@@ -165,7 +165,7 @@ pub(crate) fn type_check<'a, 'tcx>(
165165
reported_errors: Default::default(),
166166
universal_regions: &universal_region_relations.universal_regions,
167167
location_table,
168-
all_facts,
168+
polonius_facts,
169169
borrow_set,
170170
constraints: &mut constraints,
171171
polonius_context: &mut polonius_context,
@@ -495,14 +495,14 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
495495

496496
// Use new sets of constraints and closure bounds so that we can
497497
// modify their locations.
498-
let all_facts = &mut None;
498+
let polonius_facts = &mut None;
499499
let mut constraints = Default::default();
500500
let mut liveness_constraints =
501501
LivenessValues::without_specific_points(Rc::new(DenseLocationMap::new(promoted_body)));
502502
// Don't try to add borrow_region facts for the promoted MIR
503503

504504
let mut swap_constraints = |this: &mut Self| {
505-
mem::swap(this.typeck.all_facts, all_facts);
505+
mem::swap(this.typeck.polonius_facts, polonius_facts);
506506
mem::swap(&mut this.typeck.constraints.outlives_constraints, &mut constraints);
507507
mem::swap(&mut this.typeck.constraints.liveness_constraints, &mut liveness_constraints);
508508
};
@@ -561,7 +561,7 @@ struct TypeChecker<'a, 'tcx> {
561561
reported_errors: FxIndexSet<(Ty<'tcx>, Span)>,
562562
universal_regions: &'a UniversalRegions<'tcx>,
563563
location_table: &'a PoloniusLocationTable,
564-
all_facts: &'a mut Option<AllFacts>,
564+
polonius_facts: &'a mut Option<PoloniusFacts>,
565565
borrow_set: &'a BorrowSet<'tcx>,
566566
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
567567
/// When using `-Zpolonius=next`, the helper data used to create polonius constraints.
@@ -2327,18 +2327,18 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
23272327
borrowed_place: &Place<'tcx>,
23282328
) {
23292329
// These constraints are only meaningful during borrowck:
2330-
let Self { borrow_set, location_table, all_facts, constraints, .. } = self;
2330+
let Self { borrow_set, location_table, polonius_facts, constraints, .. } = self;
23312331

23322332
// In Polonius mode, we also push a `loan_issued_at` fact
23332333
// linking the loan to the region (in some cases, though,
23342334
// there is no loan associated with this borrow expression --
23352335
// that occurs when we are borrowing an unsafe place, for
23362336
// example).
2337-
if let Some(all_facts) = all_facts {
2337+
if let Some(polonius_facts) = polonius_facts {
23382338
let _prof_timer = self.infcx.tcx.prof.generic_activity("polonius_fact_generation");
23392339
if let Some(borrow_index) = borrow_set.get_index_of(&location) {
23402340
let region_vid = borrow_region.as_var();
2341-
all_facts.loan_issued_at.push((
2341+
polonius_facts.loan_issued_at.push((
23422342
region_vid.into(),
23432343
borrow_index,
23442344
location_table.mid_index(location),

0 commit comments

Comments
 (0)