Remove impl ToRegionVid for RegionVid.

It's weird and unnecessary.
This commit is contained in:
Nicholas Nethercote 2023-04-12 15:26:05 +10:00
parent c802694bda
commit 411422f2b9
4 changed files with 12 additions and 23 deletions

View file

@ -11,9 +11,7 @@ use rustc_mir_dataflow::{self, fmt::DebugWithContext, CallReturnPlaces, GenKill}
use rustc_mir_dataflow::{Analysis, Direction, Results}; use rustc_mir_dataflow::{Analysis, Direction, Results};
use std::fmt; use std::fmt;
use crate::{ use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext};
places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext, ToRegionVid,
};
/// A tuple with named fields that can hold either the results or the transient state of the /// A tuple with named fields that can hold either the results or the transient state of the
/// dataflow analyses used by the borrow checker. /// dataflow analyses used by the borrow checker.
@ -242,7 +240,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
) -> Self { ) -> Self {
let mut prec = OutOfScopePrecomputer::new(body, nonlexical_regioncx); let mut prec = OutOfScopePrecomputer::new(body, nonlexical_regioncx);
for (borrow_index, borrow_data) in borrow_set.iter_enumerated() { for (borrow_index, borrow_data) in borrow_set.iter_enumerated() {
let borrow_region = borrow_data.region.to_region_vid(); let borrow_region = borrow_data.region;
let location = borrow_data.reserve_location; let location = borrow_data.reserve_location;
prec.precompute_borrows_out_of_scope(borrow_index, borrow_region, location); prec.precompute_borrows_out_of_scope(borrow_index, borrow_region, location);

View file

@ -94,7 +94,7 @@ pub mod consumers;
use borrow_set::{BorrowData, BorrowSet}; use borrow_set::{BorrowData, BorrowSet};
use dataflow::{BorrowIndex, BorrowckFlowState as Flows, BorrowckResults, Borrows}; use dataflow::{BorrowIndex, BorrowckFlowState as Flows, BorrowckResults, Borrows};
use nll::{PoloniusOutput, ToRegionVid}; use nll::PoloniusOutput;
use place_ext::PlaceExt; use place_ext::PlaceExt;
use places_conflict::{places_conflict, PlaceConflictBias}; use places_conflict::{places_conflict, PlaceConflictBias};
use region_infer::RegionInferenceContext; use region_infer::RegionInferenceContext;

View file

@ -459,12 +459,6 @@ impl<'tcx> ToRegionVid for Region<'tcx> {
} }
} }
impl ToRegionVid for RegionVid {
fn to_region_vid(self) -> RegionVid {
self
}
}
pub(crate) trait ConstraintDescription { pub(crate) trait ConstraintDescription {
fn description(&self) -> &'static str; fn description(&self) -> &'static str;
} }

View file

@ -27,7 +27,7 @@ use crate::{
}, },
diagnostics::{RegionErrorKind, RegionErrors, UniverseInfo}, diagnostics::{RegionErrorKind, RegionErrors, UniverseInfo},
member_constraints::{MemberConstraintSet, NllMemberConstraintIndex}, member_constraints::{MemberConstraintSet, NllMemberConstraintIndex},
nll::{PoloniusOutput, ToRegionVid}, nll::PoloniusOutput,
region_infer::reverse_sccs::ReverseSccGraph, region_infer::reverse_sccs::ReverseSccGraph,
region_infer::values::{ region_infer::values::{
LivenessValues, PlaceholderIndices, RegionElement, RegionValueElements, RegionValues, LivenessValues, PlaceholderIndices, RegionElement, RegionValueElements, RegionValues,
@ -593,14 +593,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
/// Returns `true` if the region `r` contains the point `p`. /// Returns `true` if the region `r` contains the point `p`.
/// ///
/// Panics if called before `solve()` executes, /// Panics if called before `solve()` executes,
pub(crate) fn region_contains(&self, r: impl ToRegionVid, p: impl ToElementIndex) -> bool { pub(crate) fn region_contains(&self, r: RegionVid, p: impl ToElementIndex) -> bool {
let scc = self.constraint_sccs.scc(r.to_region_vid()); let scc = self.constraint_sccs.scc(r);
self.scc_values.contains(scc, p) self.scc_values.contains(scc, p)
} }
/// Returns access to the value of `r` for debugging purposes. /// Returns access to the value of `r` for debugging purposes.
pub(crate) fn region_value_str(&self, r: RegionVid) -> String { pub(crate) fn region_value_str(&self, r: RegionVid) -> String {
let scc = self.constraint_sccs.scc(r.to_region_vid()); let scc = self.constraint_sccs.scc(r);
self.scc_values.region_value_str(scc) self.scc_values.region_value_str(scc)
} }
@ -608,24 +608,21 @@ impl<'tcx> RegionInferenceContext<'tcx> {
&'a self, &'a self,
r: RegionVid, r: RegionVid,
) -> impl Iterator<Item = ty::PlaceholderRegion> + 'a { ) -> impl Iterator<Item = ty::PlaceholderRegion> + 'a {
let scc = self.constraint_sccs.scc(r.to_region_vid()); let scc = self.constraint_sccs.scc(r);
self.scc_values.placeholders_contained_in(scc) self.scc_values.placeholders_contained_in(scc)
} }
/// Returns access to the value of `r` for debugging purposes. /// Returns access to the value of `r` for debugging purposes.
pub(crate) fn region_universe(&self, r: RegionVid) -> ty::UniverseIndex { pub(crate) fn region_universe(&self, r: RegionVid) -> ty::UniverseIndex {
let scc = self.constraint_sccs.scc(r.to_region_vid()); let scc = self.constraint_sccs.scc(r);
self.scc_universes[scc] self.scc_universes[scc]
} }
/// Once region solving has completed, this function will return /// Once region solving has completed, this function will return
/// the member constraints that were applied to the value of a given /// the member constraints that were applied to the value of a given
/// region `r`. See `AppliedMemberConstraint`. /// region `r`. See `AppliedMemberConstraint`.
pub(crate) fn applied_member_constraints( pub(crate) fn applied_member_constraints(&self, r: RegionVid) -> &[AppliedMemberConstraint] {
&self, let scc = self.constraint_sccs.scc(r);
r: impl ToRegionVid,
) -> &[AppliedMemberConstraint] {
let scc = self.constraint_sccs.scc(r.to_region_vid());
binary_search_util::binary_search_slice( binary_search_util::binary_search_slice(
&self.member_constraints_applied, &self.member_constraints_applied,
|applied| applied.member_region_scc, |applied| applied.member_region_scc,
@ -2234,7 +2231,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
r: RegionVid, r: RegionVid,
body: &Body<'_>, body: &Body<'_>,
) -> Option<Location> { ) -> Option<Location> {
let scc = self.constraint_sccs.scc(r.to_region_vid()); let scc = self.constraint_sccs.scc(r);
let locations = self.scc_values.locations_outlived_by(scc); let locations = self.scc_values.locations_outlived_by(scc);
for location in locations { for location in locations {
let bb = &body[location.block]; let bb = &body[location.block];