Skip to content

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

9 files changed

Lines changed: 47 additions & 45 deletions

File tree

‎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
pubusesuper::place_ext::PlaceExt;
1212
pubusesuper::places_conflict::{PlaceConflictBias, places_conflict};
1313
pubusesuper::polonius::legacy::{
14-
AllFactsasPoloniusInput,PoloniusLocationTable,PoloniusOutput,PoloniusRegionVid,
14+
PoloniusFactsasPoloniusInput,PoloniusLocationTable,PoloniusOutput,PoloniusRegionVid,
1515
RichLocation,RustcFacts,
1616
};
1717
pubusesuper::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
usecrate::consumers::ConsumerOptions;
2929
usecrate::diagnostics::{BorrowckDiagnosticsBuffer,RegionErrors};
3030
usecrate::polonius::LocalizedOutlivesConstraintSet;
31-
usecrate::polonius::legacy::{AllFacts,AllFactsExt,PoloniusLocationTable,PoloniusOutput};
31+
usecrate::polonius::legacy::{
32+
PoloniusFacts,PoloniusFactsExt,PoloniusLocationTable,PoloniusOutput,
33+
};
3234
usecrate::region_infer::RegionInferenceContext;
3335
usecrate::type_check::{self,MirTypeckResults};
3436
usecrate::universal_regions::UniversalRegions;
@@ -39,7 +41,7 @@ use crate::{BorrowckInferCtxt, polonius, renumber};
3941
pub(crate)structNllOutput<'tcx>{
4042
pubregioncx:RegionInferenceContext<'tcx>,
4143
pubopaque_type_values:FxIndexMap<LocalDefId,OpaqueHiddenType<'tcx>>,
42-
pubpolonius_input:Option<Box<AllFacts>>,
44+
pubpolonius_input:Option<Box<PoloniusFacts>>,
4345
pubpolonius_output:Option<Box<PoloniusOutput>>,
4446
pubopt_closure_req:Option<ClosureRegionRequirements<'tcx>>,
4547
pubnll_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-
letmutall_facts =
95-
(polonius_input || AllFacts::enabled(infcx.tcx)).then_some(AllFacts::default());
96+
letmutpolonius_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-
&mutall_facts,
114+
&mutpolonius_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-
&mutall_facts,
127+
&mutpolonius_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-
usesuper::{AllFacts,LocationIndex,PoloniusLocationTable};
7+
usesuper::{LocationIndex,PoloniusFacts,PoloniusLocationTable};
88
usecrate::def_use::{self,DefUse};
99
usecrate::universal_regions::UniversalRegions;
1010

1111
/// Emit polonius facts for variable defs, uses, drops, and path accesses.
1212
pub(crate)fnemit_access_facts<'tcx>(
1313
tcx:TyCtxt<'tcx>,
14-
facts:&mutAllFacts,
14+
facts:&mutPoloniusFacts,
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
structAccessFactsExtractor<'a,'tcx>{
34-
facts:&'amutAllFacts,
34+
facts:&'amutPoloniusFacts,
3535
move_data:&'aMoveData<'tcx>,
3636
location_table:&'aPoloniusLocationTable,
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::{AllFactsasPoloniusFacts,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
typePath = MovePathIndex;
5050
}
5151

52-
pubtypeAllFacts = PoloniusFacts<RustcFacts>;
52+
pubtypePoloniusFacts = AllFacts<RustcFacts>;
5353

54-
#[extension(pub(crate)traitAllFactsExt)]
55-
implAllFacts{
56-
/// Returns `true` if there is a need to gather `AllFacts` given the
54+
#[extension(pub(crate)traitPoloniusFactsExt)]
55+
implPoloniusFacts{
56+
/// Returns `true` if there is a need to gather `PoloniusFacts` given the
5757
/// current `-Z` flags.
5858
fnenabled(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-
usesuper::{AllFacts,PoloniusLocationTable};
14+
usesuper::{PoloniusFacts,PoloniusLocationTable};
1515
usecrate::borrow_set::BorrowSet;
1616
usecrate::path_utils::*;
1717
usecrate::{
@@ -22,7 +22,7 @@ use crate::{
2222
/// Emit `loan_invalidated_at` facts.
2323
pub(super)fnemit_loan_invalidations<'tcx>(
2424
tcx:TyCtxt<'tcx>,
25-
facts:&mutAllFacts,
25+
facts:&mutPoloniusFacts,
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
structLoanInvalidationsGenerator<'a,'tcx>{
3737
tcx:TyCtxt<'tcx>,
38-
facts:&'amutAllFacts,
38+
facts:&'amutPoloniusFacts,
3939
body:&'aBody<'tcx>,
4040
location_table:&'aPoloniusLocationTable,
4141
dominators:&'aDominators<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-
usesuper::{AllFacts,PoloniusLocationTable};
9+
usesuper::{PoloniusFacts,PoloniusLocationTable};
1010
usecrate::borrow_set::BorrowSet;
1111
usecrate::places_conflict;
1212

1313
/// Emit `loan_killed_at` and `cfg_edge` facts at the same time.
1414
pub(super)fnemit_loan_kills<'tcx>(
1515
tcx:TyCtxt<'tcx>,
16-
facts:&mutAllFacts,
16+
facts:&mutPoloniusFacts,
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
structLoanKillsGenerator<'a,'tcx>{
2828
tcx:TyCtxt<'tcx>,
29-
facts:&'amutAllFacts,
29+
facts:&'amutPoloniusFacts,
3030
location_table:&'aPoloniusLocationTable,
3131
borrow_set:&'aBorrowSet<'tcx>,
3232
body:&'aBody<'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)fnemit_facts<'tcx>(
39-
all_facts:&mutOption<AllFacts>,
39+
facts:&mutOption<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-
letSome(facts) = all_factselse{
48+
letSome(facts) = factselse{
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
fnemit_move_facts(
70-
facts:&mutAllFacts,
70+
facts:&mutPoloniusFacts,
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
fnemit_universal_region_facts(
142-
facts:&mutAllFacts,
142+
facts:&mutPoloniusFacts,
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:&mutOption<AllFacts>,
190+
facts:&mutOption<PoloniusFacts>,
191191
){
192192
debug!("emit_drop_facts(local={:?}, kind={:?}", local, kind);
193-
letSome(facts) = all_facts.as_mut()else{return};
193+
letSome(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
fnemit_outlives_facts<'tcx>(
204-
facts:&mutAllFacts,
204+
facts:&mutPoloniusFacts,
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
fnadd_extra_drop_facts(&mutself,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-
letSome(facts) = self.cx.typeck.all_facts.as_ref()else{return};
223+
letSome(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
usecrate::diagnostics::UniverseInfo;
5050
usecrate::member_constraints::MemberConstraintSet;
5151
usecrate::polonius::PoloniusContext;
52-
usecrate::polonius::legacy::{AllFacts,PoloniusLocationTable};
52+
usecrate::polonius::legacy::{PoloniusFacts,PoloniusLocationTable};
5353
usecrate::region_infer::TypeTest;
5454
usecrate::region_infer::values::{LivenessValues,PlaceholderIndex,PlaceholderIndices};
5555
usecrate::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:&mutOption<AllFacts>,
114+
polonius_facts:&mutOption<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-
letall_facts = &mutNone;
498+
letpolonius_facts = &mutNone;
499499
letmut constraints = Default::default();
500500
letmut 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
letmut swap_constraints = |this:&mutSelf| {
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:&'aUniversalRegions<'tcx>,
563563
location_table:&'aPoloniusLocationTable,
564-
all_facts:&'amutOption<AllFacts>,
564+
polonius_facts:&'amutOption<PoloniusFacts>,
565565
borrow_set:&'aBorrowSet<'tcx>,
566566
constraints:&'amutMirTypeckRegionConstraints<'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-
letSelf{ borrow_set, location_table,all_facts, constraints, .. } = self;
2330+
letSelf{ 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-
ifletSome(all_facts) = all_facts{
2337+
ifletSome(polonius_facts) = polonius_facts{
23382338
let _prof_timer = self.infcx.tcx.prof.generic_activity("polonius_fact_generation");
23392339
ifletSome(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)