Skip to content

Commit

Permalink
rename LocationTable to PoloniusLocationTable
Browse files Browse the repository at this point in the history
Its original naming hides the fact that it's related to datalog
polonius, and bound to be deleted in the near future.

It also conflicts with the expected name for the actual NLL location
map, and prefixing it with its use will make the differentiation
possible.
  • Loading branch information
lqd committed Jan 8, 2025
1 parent 6f1c417 commit 921e407
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 43 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/consumers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub use super::dataflow::{BorrowIndex, Borrows, calculate_borrows_out_of_scope_a
pub use super::place_ext::PlaceExt;
pub use super::places_conflict::{PlaceConflictBias, places_conflict};
pub use super::polonius::legacy::{
AllFacts as PoloniusInput, LocationTable, PoloniusOutput, PoloniusRegionVid, RichLocation,
RustcFacts,
AllFacts as PoloniusInput, PoloniusLocationTable, PoloniusOutput, PoloniusRegionVid,
RichLocation, RustcFacts,
};
pub use super::region_infer::RegionInferenceContext;

Expand Down Expand Up @@ -71,7 +71,7 @@ pub struct BodyWithBorrowckFacts<'tcx> {
/// The table that maps Polonius points to locations in the table.
/// Populated when using [`ConsumerOptions::PoloniusInputFacts`]
/// or [`ConsumerOptions::PoloniusOutputFacts`].
pub location_table: Option<LocationTable>,
pub location_table: Option<PoloniusLocationTable>,
/// Polonius input facts.
/// Populated when using [`ConsumerOptions::PoloniusInputFacts`]
/// or [`ConsumerOptions::PoloniusOutputFacts`].
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use crate::diagnostics::{
use crate::path_utils::*;
use crate::place_ext::PlaceExt;
use crate::places_conflict::{PlaceConflictBias, places_conflict};
use crate::polonius::legacy::{LocationTable, PoloniusOutput};
use crate::polonius::legacy::{PoloniusLocationTable, PoloniusOutput};
use crate::prefixes::PrefixSet;
use crate::region_infer::RegionInferenceContext;
use crate::renumber::RegionCtxt;
Expand Down Expand Up @@ -175,7 +175,7 @@ fn do_mir_borrowck<'tcx>(
infcx.register_predefined_opaques_for_next_solver(def);
}

let location_table = LocationTable::new(body);
let location_table = PoloniusLocationTable::new(body);

let move_data = MoveData::gather_moves(body, tcx, |_| true);
let promoted_move_data = promoted
Expand Down Expand Up @@ -246,7 +246,8 @@ fn do_mir_borrowck<'tcx>(
infcx: &infcx,
body: promoted_body,
move_data: &move_data,
location_table: &location_table, // no need to create a real one for the promoted, it is not used
// no need to create a real location table for the promoted, it is not used
location_table: &location_table,
movable_coroutine,
fn_self_span_reported: Default::default(),
locals_are_invalidated_at_exit,
Expand Down Expand Up @@ -512,7 +513,7 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {

/// Map from MIR `Location` to `LocationIndex`; created
/// when MIR borrowck begins.
location_table: &'a LocationTable,
location_table: &'a PoloniusLocationTable,

movable_coroutine: bool,
/// This keeps track of whether local variables are free-ed when the function
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::borrow_set::BorrowSet;
use crate::consumers::ConsumerOptions;
use crate::diagnostics::{BorrowckDiagnosticsBuffer, RegionErrors};
use crate::polonius::LocalizedOutlivesConstraintSet;
use crate::polonius::legacy::{AllFacts, AllFactsExt, LocationTable, PoloniusOutput};
use crate::polonius::legacy::{AllFacts, AllFactsExt, PoloniusLocationTable, PoloniusOutput};
use crate::region_infer::RegionInferenceContext;
use crate::type_check::{self, MirTypeckResults};
use crate::universal_regions::UniversalRegions;
Expand Down Expand Up @@ -80,7 +80,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
universal_regions: UniversalRegions<'tcx>,
body: &Body<'tcx>,
promoted: &IndexSlice<Promoted, Body<'tcx>>,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
flow_inits: ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
move_data: &MoveData<'tcx>,
borrow_set: &BorrowSet<'tcx>,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/polonius/legacy/accesses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData};
use tracing::debug;

use super::{AllFacts, LocationIndex, LocationTable};
use super::{AllFacts, LocationIndex, PoloniusLocationTable};
use crate::def_use::{self, DefUse};
use crate::universal_regions::UniversalRegions;

Expand All @@ -13,7 +13,7 @@ pub(crate) fn emit_access_facts<'tcx>(
tcx: TyCtxt<'tcx>,
facts: &mut AllFacts,
body: &Body<'tcx>,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
move_data: &MoveData<'tcx>,
universal_regions: &UniversalRegions<'tcx>,
) {
Expand All @@ -33,7 +33,7 @@ pub(crate) fn emit_access_facts<'tcx>(
struct AccessFactsExtractor<'a, 'tcx> {
facts: &'a mut AllFacts,
move_data: &'a MoveData<'tcx>,
location_table: &'a LocationTable,
location_table: &'a PoloniusLocationTable,
}

impl<'tcx> AccessFactsExtractor<'_, 'tcx> {
Expand Down
32 changes: 16 additions & 16 deletions compiler/rustc_borrowck/src/polonius/legacy/facts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_middle::mir::Local;
use rustc_middle::ty::{RegionVid, TyCtxt};
use rustc_mir_dataflow::move_paths::MovePathIndex;

use super::{LocationIndex, LocationTable};
use super::{LocationIndex, PoloniusLocationTable};
use crate::BorrowIndex;

#[derive(Copy, Clone, Debug)]
Expand Down Expand Up @@ -63,7 +63,7 @@ impl AllFacts {
fn write_to_dir(
&self,
dir: impl AsRef<Path>,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
) -> Result<(), Box<dyn Error>> {
let dir: &Path = dir.as_ref();
fs::create_dir_all(dir)?;
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Atom for LocationIndex {
}

struct FactWriter<'w> {
location_table: &'w LocationTable,
location_table: &'w PoloniusLocationTable,
dir: &'w Path,
}

Expand All @@ -141,15 +141,15 @@ trait FactRow {
fn write(
&self,
out: &mut dyn Write,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
) -> Result<(), Box<dyn Error>>;
}

impl FactRow for PoloniusRegionVid {
fn write(
&self,
out: &mut dyn Write,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[self])
}
Expand All @@ -163,7 +163,7 @@ where
fn write(
&self,
out: &mut dyn Write,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[&self.0, &self.1])
}
Expand All @@ -178,7 +178,7 @@ where
fn write(
&self,
out: &mut dyn Write,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[&self.0, &self.1, &self.2])
}
Expand All @@ -194,15 +194,15 @@ where
fn write(
&self,
out: &mut dyn Write,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
) -> Result<(), Box<dyn Error>> {
write_row(out, location_table, &[&self.0, &self.1, &self.2, &self.3])
}
}

fn write_row(
out: &mut dyn Write,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
columns: &[&dyn FactCell],
) -> Result<(), Box<dyn Error>> {
for (index, c) in columns.iter().enumerate() {
Expand All @@ -213,41 +213,41 @@ fn write_row(
}

trait FactCell {
fn to_string(&self, location_table: &LocationTable) -> String;
fn to_string(&self, location_table: &PoloniusLocationTable) -> String;
}

impl FactCell for BorrowIndex {
fn to_string(&self, _location_table: &LocationTable) -> String {
fn to_string(&self, _location_table: &PoloniusLocationTable) -> String {
format!("{self:?}")
}
}

impl FactCell for Local {
fn to_string(&self, _location_table: &LocationTable) -> String {
fn to_string(&self, _location_table: &PoloniusLocationTable) -> String {
format!("{self:?}")
}
}

impl FactCell for MovePathIndex {
fn to_string(&self, _location_table: &LocationTable) -> String {
fn to_string(&self, _location_table: &PoloniusLocationTable) -> String {
format!("{self:?}")
}
}

impl FactCell for PoloniusRegionVid {
fn to_string(&self, _location_table: &LocationTable) -> String {
fn to_string(&self, _location_table: &PoloniusLocationTable) -> String {
format!("{self:?}")
}
}

impl FactCell for RegionVid {
fn to_string(&self, _location_table: &LocationTable) -> String {
fn to_string(&self, _location_table: &PoloniusLocationTable) -> String {
format!("{self:?}")
}
}

impl FactCell for LocationIndex {
fn to_string(&self, location_table: &LocationTable) -> String {
fn to_string(&self, location_table: &PoloniusLocationTable) -> String {
format!("{:?}", location_table.to_rich_location(*self))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_middle::mir::{
use rustc_middle::ty::TyCtxt;
use tracing::debug;

use super::{AllFacts, LocationTable};
use super::{AllFacts, PoloniusLocationTable};
use crate::borrow_set::BorrowSet;
use crate::path_utils::*;
use crate::{
Expand All @@ -24,7 +24,7 @@ pub(super) fn emit_loan_invalidations<'tcx>(
tcx: TyCtxt<'tcx>,
facts: &mut AllFacts,
body: &Body<'tcx>,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
borrow_set: &BorrowSet<'tcx>,
) {
let dominators = body.basic_blocks.dominators();
Expand All @@ -37,7 +37,7 @@ struct LoanInvalidationsGenerator<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
facts: &'a mut AllFacts,
body: &'a Body<'tcx>,
location_table: &'a LocationTable,
location_table: &'a PoloniusLocationTable,
dominators: &'a Dominators<BasicBlock>,
borrow_set: &'a BorrowSet<'tcx>,
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/polonius/legacy/loan_kills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_middle::mir::{
use rustc_middle::ty::TyCtxt;
use tracing::debug;

use super::{AllFacts, LocationTable};
use super::{AllFacts, PoloniusLocationTable};
use crate::borrow_set::BorrowSet;
use crate::places_conflict;

Expand All @@ -15,7 +15,7 @@ pub(super) fn emit_loan_kills<'tcx>(
tcx: TyCtxt<'tcx>,
facts: &mut AllFacts,
body: &Body<'tcx>,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
borrow_set: &BorrowSet<'tcx>,
) {
let mut visitor = LoanKillsGenerator { borrow_set, tcx, location_table, facts, body };
Expand All @@ -27,7 +27,7 @@ pub(super) fn emit_loan_kills<'tcx>(
struct LoanKillsGenerator<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
facts: &'a mut AllFacts,
location_table: &'a LocationTable,
location_table: &'a PoloniusLocationTable,
borrow_set: &'a BorrowSet<'tcx>,
body: &'a Body<'tcx>,
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/polonius/legacy/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tracing::debug;
/// granularity through outlives relations; however, the rich location
/// table serves another purpose: it compresses locations from
/// multiple words into a single u32.
pub struct LocationTable {
pub struct PoloniusLocationTable {
num_points: usize,
statements_before_block: IndexVec<BasicBlock, usize>,
}
Expand All @@ -30,7 +30,7 @@ pub enum RichLocation {
Mid(Location),
}

impl LocationTable {
impl PoloniusLocationTable {
pub(crate) fn new(body: &Body<'_>) -> Self {
let mut num_points = 0;
let statements_before_block = body
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/polonius/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub use self::facts::*;
pub(crate) fn emit_facts<'tcx>(
all_facts: &mut Option<AllFacts>,
tcx: TyCtxt<'tcx>,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
body: &Body<'tcx>,
borrow_set: &BorrowSet<'tcx>,
move_data: &MoveData<'tcx>,
Expand Down Expand Up @@ -69,7 +69,7 @@ pub(crate) fn emit_facts<'tcx>(
fn emit_move_facts(
facts: &mut AllFacts,
body: &Body<'_>,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
move_data: &MoveData<'_>,
) {
facts.path_is_var.extend(move_data.rev_lookup.iter_locals_enumerated().map(|(l, r)| (r, l)));
Expand Down Expand Up @@ -202,7 +202,7 @@ pub(crate) fn emit_drop_facts<'tcx>(
/// closure.
fn emit_outlives_facts<'tcx>(
facts: &mut AllFacts,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
constraints: &MirTypeckRegionConstraints<'tcx>,
) {
facts.subset_base.extend(constraints.outlives_constraints.outlives().iter().flat_map(
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use crate::constraints::{OutlivesConstraint, OutlivesConstraintSet};
use crate::diagnostics::UniverseInfo;
use crate::member_constraints::MemberConstraintSet;
use crate::polonius::PoloniusContext;
use crate::polonius::legacy::{AllFacts, LocationTable};
use crate::polonius::legacy::{AllFacts, PoloniusLocationTable};
use crate::region_infer::TypeTest;
use crate::region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderIndices};
use crate::renumber::RegionCtxt;
Expand Down Expand Up @@ -98,7 +98,7 @@ mod relate_tys;
/// - `body` -- MIR body to type-check
/// - `promoted` -- map of promoted constants within `body`
/// - `universal_regions` -- the universal regions from `body`s function signature
/// - `location_table` -- MIR location map of `body`
/// - `location_table` -- for datalog polonius, the map between `Location`s and `RichLocation`s
/// - `borrow_set` -- information about borrows occurring in `body`
/// - `all_facts` -- when using Polonius, this is the generated set of Polonius facts
/// - `flow_inits` -- results of a maybe-init dataflow analysis
Expand All @@ -109,7 +109,7 @@ pub(crate) fn type_check<'a, 'tcx>(
body: &Body<'tcx>,
promoted: &IndexSlice<Promoted, Body<'tcx>>,
universal_regions: UniversalRegions<'tcx>,
location_table: &LocationTable,
location_table: &PoloniusLocationTable,
borrow_set: &BorrowSet<'tcx>,
all_facts: &mut Option<AllFacts>,
flow_inits: ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
Expand Down Expand Up @@ -560,7 +560,7 @@ struct TypeChecker<'a, 'tcx> {
implicit_region_bound: ty::Region<'tcx>,
reported_errors: FxIndexSet<(Ty<'tcx>, Span)>,
universal_regions: &'a UniversalRegions<'tcx>,
location_table: &'a LocationTable,
location_table: &'a PoloniusLocationTable,
all_facts: &'a mut Option<AllFacts>,
borrow_set: &'a BorrowSet<'tcx>,
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
Expand Down

0 comments on commit 921e407

Please sign in to comment.