Remove unnecessary lifetimes in dataflow structs.

There are four related dataflow structs: `MaybeInitializedPlaces`,
`MaybeUninitializedPlaces`, and `EverInitializedPlaces`,
`DefinitelyInitializedPlaces`. They all have a `&Body` and a
`&MoveData<'tcx>` field. The first three use different lifetimes for the
two fields, but the last one uses the same lifetime for both.

This commit changes the first three to use the same lifetime, removing
the need for one of the lifetimes. Other structs that also lose a
lifetime as a result of this are `LivenessContext`, `LivenessResults`,
`InitializationData`.

It then does similar things in various other structs.
This commit is contained in:
Nicholas Nethercote 2024-09-06 09:18:17 +10:00
parent adf8d168af
commit 3fe7dd6893
20 changed files with 141 additions and 151 deletions

View File

@ -8,7 +8,7 @@ use rustc_middle::span_bug;
use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::Span; use rustc_span::Span;
impl<'infcx, 'tcx> crate::MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { impl<'infcx, 'tcx> crate::MirBorrowckCtxt<'_, 'infcx, 'tcx> {
pub(crate) fn dcx(&self) -> DiagCtxtHandle<'infcx> { pub(crate) fn dcx(&self) -> DiagCtxtHandle<'infcx> {
self.infcx.dcx() self.infcx.dcx()
} }

View File

@ -15,24 +15,24 @@ use tracing::debug;
use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext}; use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext};
/// The results of the dataflow analyses used by the borrow checker. /// The results of the dataflow analyses used by the borrow checker.
pub(crate) struct BorrowckResults<'a, 'mir, 'tcx> { pub(crate) struct BorrowckResults<'a, 'tcx> {
pub(crate) borrows: Results<'tcx, Borrows<'a, 'mir, 'tcx>>, pub(crate) borrows: Results<'tcx, Borrows<'a, 'tcx>>,
pub(crate) uninits: Results<'tcx, MaybeUninitializedPlaces<'a, 'mir, 'tcx>>, pub(crate) uninits: Results<'tcx, MaybeUninitializedPlaces<'a, 'tcx>>,
pub(crate) ever_inits: Results<'tcx, EverInitializedPlaces<'a, 'mir, 'tcx>>, pub(crate) ever_inits: Results<'tcx, EverInitializedPlaces<'a, 'tcx>>,
} }
/// The transient state of the dataflow analyses used by the borrow checker. /// The transient state of the dataflow analyses used by the borrow checker.
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct BorrowckFlowState<'a, 'mir, 'tcx> { pub(crate) struct BorrowckFlowState<'a, 'tcx> {
pub(crate) borrows: <Borrows<'a, 'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain, pub(crate) borrows: <Borrows<'a, 'tcx> as AnalysisDomain<'tcx>>::Domain,
pub(crate) uninits: <MaybeUninitializedPlaces<'a, 'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain, pub(crate) uninits: <MaybeUninitializedPlaces<'a, 'tcx> as AnalysisDomain<'tcx>>::Domain,
pub(crate) ever_inits: <EverInitializedPlaces<'a, 'mir, 'tcx> as AnalysisDomain<'tcx>>::Domain, pub(crate) ever_inits: <EverInitializedPlaces<'a, 'tcx> as AnalysisDomain<'tcx>>::Domain,
} }
impl<'a, 'mir, 'tcx> ResultsVisitable<'tcx> for BorrowckResults<'a, 'mir, 'tcx> { impl<'a, 'tcx> ResultsVisitable<'tcx> for BorrowckResults<'a, 'tcx> {
// All three analyses are forward, but we have to use just one here. // All three analyses are forward, but we have to use just one here.
type Direction = <Borrows<'a, 'mir, 'tcx> as AnalysisDomain<'tcx>>::Direction; type Direction = <Borrows<'a, 'tcx> as AnalysisDomain<'tcx>>::Direction;
type FlowState = BorrowckFlowState<'a, 'mir, 'tcx>; type FlowState = BorrowckFlowState<'a, 'tcx>;
fn new_flow_state(&self, body: &mir::Body<'tcx>) -> Self::FlowState { fn new_flow_state(&self, body: &mir::Body<'tcx>) -> Self::FlowState {
BorrowckFlowState { BorrowckFlowState {
@ -106,10 +106,9 @@ rustc_index::newtype_index! {
/// `BorrowIndex`, and maps each such index to a `BorrowData` /// `BorrowIndex`, and maps each such index to a `BorrowData`
/// describing the borrow. These indexes are used for representing the /// describing the borrow. These indexes are used for representing the
/// borrows in compact bitvectors. /// borrows in compact bitvectors.
pub struct Borrows<'a, 'mir, 'tcx> { pub struct Borrows<'a, 'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
body: &'mir Body<'tcx>, body: &'a Body<'tcx>,
borrow_set: &'a BorrowSet<'tcx>, borrow_set: &'a BorrowSet<'tcx>,
borrows_out_of_scope_at_location: FxIndexMap<Location, Vec<BorrowIndex>>, borrows_out_of_scope_at_location: FxIndexMap<Location, Vec<BorrowIndex>>,
} }
@ -389,10 +388,10 @@ impl<'tcx> PoloniusOutOfScopePrecomputer<'_, 'tcx> {
} }
} }
impl<'a, 'mir, 'tcx> Borrows<'a, 'mir, 'tcx> { impl<'a, 'tcx> Borrows<'a, 'tcx> {
pub fn new( pub fn new(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
body: &'mir Body<'tcx>, body: &'a Body<'tcx>,
regioncx: &RegionInferenceContext<'tcx>, regioncx: &RegionInferenceContext<'tcx>,
borrow_set: &'a BorrowSet<'tcx>, borrow_set: &'a BorrowSet<'tcx>,
) -> Self { ) -> Self {
@ -494,7 +493,7 @@ impl<'a, 'mir, 'tcx> Borrows<'a, 'mir, 'tcx> {
} }
} }
impl<'tcx> rustc_mir_dataflow::AnalysisDomain<'tcx> for Borrows<'_, '_, 'tcx> { impl<'tcx> rustc_mir_dataflow::AnalysisDomain<'tcx> for Borrows<'_, 'tcx> {
type Domain = BitSet<BorrowIndex>; type Domain = BitSet<BorrowIndex>;
const NAME: &'static str = "borrows"; const NAME: &'static str = "borrows";
@ -517,7 +516,7 @@ impl<'tcx> rustc_mir_dataflow::AnalysisDomain<'tcx> for Borrows<'_, '_, 'tcx> {
/// region stops containing the CFG points reachable from the issuing location. /// region stops containing the CFG points reachable from the issuing location.
/// - we also kill loans of conflicting places when overwriting a shared path: e.g. borrows of /// - we also kill loans of conflicting places when overwriting a shared path: e.g. borrows of
/// `a.b.c` when `a` is overwritten. /// `a.b.c` when `a` is overwritten.
impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, '_, 'tcx> { impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
type Idx = BorrowIndex; type Idx = BorrowIndex;
fn domain_size(&self, _: &mir::Body<'tcx>) -> usize { fn domain_size(&self, _: &mir::Body<'tcx>) -> usize {
@ -617,8 +616,8 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, '_, 'tcx> {
} }
} }
impl DebugWithContext<Borrows<'_, '_, '_>> for BorrowIndex { impl DebugWithContext<Borrows<'_, '_>> for BorrowIndex {
fn fmt_with(&self, ctxt: &Borrows<'_, '_, '_>, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt_with(&self, ctxt: &Borrows<'_, '_>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", ctxt.location(*self)) write!(f, "{:?}", ctxt.location(*self))
} }
} }

View File

@ -52,7 +52,7 @@ impl<'tcx> UniverseInfo<'tcx> {
pub(crate) fn report_error( pub(crate) fn report_error(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>,
placeholder: ty::PlaceholderRegion, placeholder: ty::PlaceholderRegion,
error_element: RegionElement, error_element: RegionElement,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
@ -151,7 +151,7 @@ trait TypeOpInfo<'tcx> {
fn nice_error<'infcx>( fn nice_error<'infcx>(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'infcx, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, 'infcx, 'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>, placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>, error_region: Option<ty::Region<'tcx>>,
@ -160,7 +160,7 @@ trait TypeOpInfo<'tcx> {
#[instrument(level = "debug", skip(self, mbcx))] #[instrument(level = "debug", skip(self, mbcx))]
fn report_error( fn report_error(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>,
placeholder: ty::PlaceholderRegion, placeholder: ty::PlaceholderRegion,
error_element: RegionElement, error_element: RegionElement,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
@ -233,7 +233,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
fn nice_error<'infcx>( fn nice_error<'infcx>(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'infcx, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, 'infcx, 'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>, placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>, error_region: Option<ty::Region<'tcx>>,
@ -277,7 +277,7 @@ where
fn nice_error<'infcx>( fn nice_error<'infcx>(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'infcx, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, 'infcx, 'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>, placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>, error_region: Option<ty::Region<'tcx>>,
@ -324,7 +324,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
fn nice_error<'infcx>( fn nice_error<'infcx>(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'infcx, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, 'infcx, 'tcx>,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>, placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>, error_region: Option<ty::Region<'tcx>>,
@ -357,7 +357,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
fn nice_error<'infcx>( fn nice_error<'infcx>(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'infcx, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, 'infcx, 'tcx>,
_cause: ObligationCause<'tcx>, _cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>, placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>, error_region: Option<ty::Region<'tcx>>,

View File

@ -69,7 +69,7 @@ enum StorageDeadOrDrop<'tcx> {
Destructor(Ty<'tcx>), Destructor(Ty<'tcx>),
} }
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
pub(crate) fn report_use_of_moved_or_uninitialized( pub(crate) fn report_use_of_moved_or_uninitialized(
&mut self, &mut self,
location: Location, location: Location,
@ -4358,11 +4358,7 @@ enum AnnotatedBorrowFnSignature<'tcx> {
impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
/// Annotate the provided diagnostic with information about borrow from the fn signature that /// Annotate the provided diagnostic with information about borrow from the fn signature that
/// helps explain. /// helps explain.
pub(crate) fn emit( pub(crate) fn emit(&self, cx: &MirBorrowckCtxt<'_, '_, 'tcx>, diag: &mut Diag<'_>) -> String {
&self,
cx: &MirBorrowckCtxt<'_, '_, '_, 'tcx>,
diag: &mut Diag<'_>,
) -> String {
match self { match self {
&AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => { &AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => {
diag.span_label( diag.span_label(

View File

@ -390,7 +390,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
} }
} }
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
fn free_region_constraint_info( fn free_region_constraint_info(
&self, &self,
borrow_region: RegionVid, borrow_region: RegionVid,

View File

@ -68,7 +68,7 @@ pub(super) struct DescribePlaceOpt {
pub(super) struct IncludingTupleField(pub(super) bool); pub(super) struct IncludingTupleField(pub(super) bool);
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// Adds a suggestion when a closure is invoked twice with a moved variable or when a closure /// Adds a suggestion when a closure is invoked twice with a moved variable or when a closure
/// is moved after being invoked. /// is moved after being invoked.
/// ///
@ -772,7 +772,7 @@ struct CapturedMessageOpt {
maybe_reinitialized_locations_is_empty: bool, maybe_reinitialized_locations_is_empty: bool,
} }
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// Finds the spans associated to a move or copy of move_place at location. /// Finds the spans associated to a move or copy of move_place at location.
pub(super) fn move_spans( pub(super) fn move_spans(
&self, &self,

View File

@ -93,7 +93,7 @@ enum GroupedMoveError<'tcx> {
}, },
} }
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
pub(crate) fn report_move_errors(&mut self) { pub(crate) fn report_move_errors(&mut self) {
let grouped_errors = self.group_move_errors(); let grouped_errors = self.group_move_errors();
for error in grouped_errors { for error in grouped_errors {

View File

@ -32,7 +32,7 @@ pub(crate) enum AccessKind {
Mutate, Mutate,
} }
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
pub(crate) fn report_mutability_error( pub(crate) fn report_mutability_error(
&mut self, &mut self,
access_place: Place<'tcx>, access_place: Place<'tcx>,

View File

@ -76,7 +76,7 @@ impl OutlivesSuggestionBuilder {
/// Returns a name for the region if it is suggestable. See `region_name_is_suggestable`. /// Returns a name for the region if it is suggestable. See `region_name_is_suggestable`.
fn region_vid_to_name( fn region_vid_to_name(
&self, &self,
mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>, mbcx: &MirBorrowckCtxt<'_, '_, '_>,
region: RegionVid, region: RegionVid,
) -> Option<RegionName> { ) -> Option<RegionName> {
mbcx.give_region_a_name(region).filter(Self::region_name_is_suggestable) mbcx.give_region_a_name(region).filter(Self::region_name_is_suggestable)
@ -85,7 +85,7 @@ impl OutlivesSuggestionBuilder {
/// Compiles a list of all suggestions to be printed in the final big suggestion. /// Compiles a list of all suggestions to be printed in the final big suggestion.
fn compile_all_suggestions( fn compile_all_suggestions(
&self, &self,
mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>, mbcx: &MirBorrowckCtxt<'_, '_, '_>,
) -> SmallVec<[SuggestedConstraint; 2]> { ) -> SmallVec<[SuggestedConstraint; 2]> {
let mut suggested = SmallVec::new(); let mut suggested = SmallVec::new();
@ -161,7 +161,7 @@ impl OutlivesSuggestionBuilder {
/// Emit an intermediate note on the given `Diag` if the involved regions are suggestable. /// Emit an intermediate note on the given `Diag` if the involved regions are suggestable.
pub(crate) fn intermediate_suggestion( pub(crate) fn intermediate_suggestion(
&mut self, &mut self,
mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>, mbcx: &MirBorrowckCtxt<'_, '_, '_>,
errci: &ErrorConstraintInfo<'_>, errci: &ErrorConstraintInfo<'_>,
diag: &mut Diag<'_>, diag: &mut Diag<'_>,
) { ) {
@ -180,7 +180,7 @@ impl OutlivesSuggestionBuilder {
/// If there is a suggestion to emit, add a diagnostic to the buffer. This is the final /// If there is a suggestion to emit, add a diagnostic to the buffer. This is the final
/// suggestion including all collected constraints. /// suggestion including all collected constraints.
pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_, '_, '_>) { pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_, '_>) {
// No constraints to add? Done. // No constraints to add? Done.
if self.constraints_to_add.is_empty() { if self.constraints_to_add.is_empty() {
debug!("No constraints to suggest."); debug!("No constraints to suggest.");

View File

@ -156,7 +156,7 @@ pub(crate) struct ErrorConstraintInfo<'tcx> {
pub(super) span: Span, pub(super) span: Span,
} }
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// Converts a region inference variable into a `ty::Region` that /// Converts a region inference variable into a `ty::Region` that
/// we can use for error reporting. If `r` is universally bound, /// we can use for error reporting. If `r` is universally bound,
/// then we use the name that we have on record for it. If `r` is /// then we use the name that we have on record for it. If `r` is

View File

@ -200,7 +200,7 @@ impl rustc_errors::IntoDiagArg for RegionName {
} }
} }
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
pub(crate) fn mir_def_id(&self) -> hir::def_id::LocalDefId { pub(crate) fn mir_def_id(&self) -> hir::def_id::LocalDefId {
self.body.source.def_id().expect_local() self.body.source.def_id().expect_local()
} }

View File

@ -304,11 +304,11 @@ fn do_mir_borrowck<'tcx>(
promoted_mbcx.report_move_errors(); promoted_mbcx.report_move_errors();
diags = promoted_mbcx.diags; diags = promoted_mbcx.diags;
struct MoveVisitor<'a, 'b, 'mir, 'infcx, 'tcx> { struct MoveVisitor<'a, 'b, 'infcx, 'tcx> {
ctxt: &'a mut MirBorrowckCtxt<'b, 'mir, 'infcx, 'tcx>, ctxt: &'a mut MirBorrowckCtxt<'b, 'infcx, 'tcx>,
} }
impl<'tcx> Visitor<'tcx> for MoveVisitor<'_, '_, '_, '_, 'tcx> { impl<'tcx> Visitor<'tcx> for MoveVisitor<'_, '_, '_, 'tcx> {
fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) { fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
if let Operand::Move(place) = operand { if let Operand::Move(place) = operand {
self.ctxt.check_movable_place(location, *place); self.ctxt.check_movable_place(location, *place);
@ -522,10 +522,10 @@ impl<'tcx> Deref for BorrowckInferCtxt<'tcx> {
} }
} }
struct MirBorrowckCtxt<'a, 'mir, 'infcx, 'tcx> { struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
infcx: &'infcx BorrowckInferCtxt<'tcx>, infcx: &'infcx BorrowckInferCtxt<'tcx>,
param_env: ParamEnv<'tcx>, param_env: ParamEnv<'tcx>,
body: &'mir Body<'tcx>, body: &'a Body<'tcx>,
move_data: &'a MoveData<'tcx>, move_data: &'a MoveData<'tcx>,
/// Map from MIR `Location` to `LocationIndex`; created /// Map from MIR `Location` to `LocationIndex`; created
@ -599,16 +599,16 @@ struct MirBorrowckCtxt<'a, 'mir, 'infcx, 'tcx> {
// 2. loans made in overlapping scopes do not conflict // 2. loans made in overlapping scopes do not conflict
// 3. assignments do not affect things loaned out as immutable // 3. assignments do not affect things loaned out as immutable
// 4. moves do not affect things loaned out in any way // 4. moves do not affect things loaned out in any way
impl<'a, 'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R> impl<'a, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'a, 'tcx, R>
for MirBorrowckCtxt<'a, 'mir, '_, 'tcx> for MirBorrowckCtxt<'a, '_, 'tcx>
{ {
type FlowState = Flows<'a, 'mir, 'tcx>; type FlowState = Flows<'a, 'tcx>;
fn visit_statement_before_primary_effect( fn visit_statement_before_primary_effect(
&mut self, &mut self,
_results: &mut R, _results: &mut R,
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
stmt: &'mir Statement<'tcx>, stmt: &'a Statement<'tcx>,
location: Location, location: Location,
) { ) {
debug!("MirBorrowckCtxt::process_statement({:?}, {:?}): {:?}", location, stmt, flow_state); debug!("MirBorrowckCtxt::process_statement({:?}, {:?}): {:?}", location, stmt, flow_state);
@ -677,8 +677,8 @@ impl<'a, 'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R>
fn visit_terminator_before_primary_effect( fn visit_terminator_before_primary_effect(
&mut self, &mut self,
_results: &mut R, _results: &mut R,
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
term: &'mir Terminator<'tcx>, term: &'a Terminator<'tcx>,
loc: Location, loc: Location,
) { ) {
debug!("MirBorrowckCtxt::process_terminator({:?}, {:?}): {:?}", loc, term, flow_state); debug!("MirBorrowckCtxt::process_terminator({:?}, {:?}): {:?}", loc, term, flow_state);
@ -794,8 +794,8 @@ impl<'a, 'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R>
fn visit_terminator_after_primary_effect( fn visit_terminator_after_primary_effect(
&mut self, &mut self,
_results: &mut R, _results: &mut R,
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
term: &'mir Terminator<'tcx>, term: &'a Terminator<'tcx>,
loc: Location, loc: Location,
) { ) {
let span = term.source_info.span; let span = term.source_info.span;
@ -972,8 +972,8 @@ impl InitializationRequiringAction {
} }
} }
impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> { impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
fn body(&self) -> &'mir Body<'tcx> { fn body(&self) -> &'a Body<'tcx> {
self.body self.body
} }
@ -989,7 +989,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
place_span: (Place<'tcx>, Span), place_span: (Place<'tcx>, Span),
kind: (AccessDepth, ReadOrWrite), kind: (AccessDepth, ReadOrWrite),
is_local_mutation_allowed: LocalMutationIsAllowed, is_local_mutation_allowed: LocalMutationIsAllowed,
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
) { ) {
let (sd, rw) = kind; let (sd, rw) = kind;
@ -1039,7 +1039,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
place_span: (Place<'tcx>, Span), place_span: (Place<'tcx>, Span),
sd: AccessDepth, sd: AccessDepth,
rw: ReadOrWrite, rw: ReadOrWrite,
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
) -> bool { ) -> bool {
let mut error_reported = false; let mut error_reported = false;
let borrow_set = Rc::clone(&self.borrow_set); let borrow_set = Rc::clone(&self.borrow_set);
@ -1180,7 +1180,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
location: Location, location: Location,
place_span: (Place<'tcx>, Span), place_span: (Place<'tcx>, Span),
kind: AccessDepth, kind: AccessDepth,
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
) { ) {
// Write of P[i] or *P requires P init'd. // Write of P[i] or *P requires P init'd.
self.check_if_assigned_path_is_moved(location, place_span, flow_state); self.check_if_assigned_path_is_moved(location, place_span, flow_state);
@ -1197,8 +1197,8 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
fn consume_rvalue( fn consume_rvalue(
&mut self, &mut self,
location: Location, location: Location,
(rvalue, span): (&'mir Rvalue<'tcx>, Span), (rvalue, span): (&'a Rvalue<'tcx>, Span),
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
) { ) {
match rvalue { match rvalue {
&Rvalue::Ref(_ /*rgn*/, bk, place) => { &Rvalue::Ref(_ /*rgn*/, bk, place) => {
@ -1455,8 +1455,8 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
fn consume_operand( fn consume_operand(
&mut self, &mut self,
location: Location, location: Location,
(operand, span): (&'mir Operand<'tcx>, Span), (operand, span): (&'a Operand<'tcx>, Span),
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
) { ) {
match *operand { match *operand {
Operand::Copy(place) => { Operand::Copy(place) => {
@ -1576,12 +1576,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
} }
} }
fn check_activations( fn check_activations(&mut self, location: Location, span: Span, flow_state: &Flows<'a, 'tcx>) {
&mut self,
location: Location,
span: Span,
flow_state: &Flows<'_, 'mir, 'tcx>,
) {
// Two-phase borrow support: For each activation that is newly // Two-phase borrow support: For each activation that is newly
// generated at this statement, check if it interferes with // generated at this statement, check if it interferes with
// another borrow. // another borrow.
@ -1744,7 +1739,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
location: Location, location: Location,
desired_action: InitializationRequiringAction, desired_action: InitializationRequiringAction,
place_span: (PlaceRef<'tcx>, Span), place_span: (PlaceRef<'tcx>, Span),
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
) { ) {
let maybe_uninits = &flow_state.uninits; let maybe_uninits = &flow_state.uninits;
@ -1849,7 +1844,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
location: Location, location: Location,
desired_action: InitializationRequiringAction, desired_action: InitializationRequiringAction,
place_span: (PlaceRef<'tcx>, Span), place_span: (PlaceRef<'tcx>, Span),
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
) { ) {
let maybe_uninits = &flow_state.uninits; let maybe_uninits = &flow_state.uninits;
@ -1948,7 +1943,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
&mut self, &mut self,
location: Location, location: Location,
(place, span): (Place<'tcx>, Span), (place, span): (Place<'tcx>, Span),
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
) { ) {
debug!("check_if_assigned_path_is_moved place: {:?}", place); debug!("check_if_assigned_path_is_moved place: {:?}", place);
@ -2009,12 +2004,12 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
} }
} }
fn check_parent_of_field<'mir, 'tcx>( fn check_parent_of_field<'a, 'tcx>(
this: &mut MirBorrowckCtxt<'_, 'mir, '_, 'tcx>, this: &mut MirBorrowckCtxt<'a, '_, 'tcx>,
location: Location, location: Location,
base: PlaceRef<'tcx>, base: PlaceRef<'tcx>,
span: Span, span: Span,
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
) { ) {
// rust-lang/rust#21232: Until Rust allows reads from the // rust-lang/rust#21232: Until Rust allows reads from the
// initialized parts of partially initialized structs, we // initialized parts of partially initialized structs, we
@ -2105,7 +2100,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
(place, span): (Place<'tcx>, Span), (place, span): (Place<'tcx>, Span),
kind: ReadOrWrite, kind: ReadOrWrite,
is_local_mutation_allowed: LocalMutationIsAllowed, is_local_mutation_allowed: LocalMutationIsAllowed,
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
location: Location, location: Location,
) -> bool { ) -> bool {
debug!( debug!(
@ -2221,7 +2216,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
fn is_local_ever_initialized( fn is_local_ever_initialized(
&self, &self,
local: Local, local: Local,
flow_state: &Flows<'_, 'mir, 'tcx>, flow_state: &Flows<'a, 'tcx>,
) -> Option<InitIndex> { ) -> Option<InitIndex> {
let mpi = self.move_data.rev_lookup.find_local(local)?; let mpi = self.move_data.rev_lookup.find_local(local)?;
let ii = &self.move_data.init_path_map[mpi]; let ii = &self.move_data.init_path_map[mpi];
@ -2229,7 +2224,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
} }
/// Adds the place into the used mutable variables set /// Adds the place into the used mutable variables set
fn add_used_mut(&mut self, root_place: RootPlace<'tcx>, flow_state: &Flows<'_, 'mir, 'tcx>) { fn add_used_mut(&mut self, root_place: RootPlace<'tcx>, flow_state: &Flows<'a, 'tcx>) {
match root_place { match root_place {
RootPlace { place_local: local, place_projection: [], is_local_mutation_allowed } => { RootPlace { place_local: local, place_projection: [], is_local_mutation_allowed } => {
// If the local may have been initialized, and it is now currently being // If the local may have been initialized, and it is now currently being
@ -2484,7 +2479,7 @@ mod diags {
} }
} }
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
pub(crate) fn buffer_error(&mut self, diag: Diag<'infcx>) { pub(crate) fn buffer_error(&mut self, diag: Diag<'infcx>) {
self.diags.buffer_error(diag); self.diags.buffer_error(diag);
} }

View File

@ -75,14 +75,14 @@ pub(crate) fn replace_regions_in_mir<'tcx>(
/// Computes the (non-lexical) regions from the input MIR. /// Computes the (non-lexical) regions from the input MIR.
/// ///
/// This may result in errors being reported. /// This may result in errors being reported.
pub(crate) fn compute_regions<'cx, 'tcx>( pub(crate) fn compute_regions<'a, 'tcx>(
infcx: &BorrowckInferCtxt<'tcx>, infcx: &BorrowckInferCtxt<'tcx>,
universal_regions: UniversalRegions<'tcx>, universal_regions: UniversalRegions<'tcx>,
body: &Body<'tcx>, body: &Body<'tcx>,
promoted: &IndexSlice<Promoted, Body<'tcx>>, promoted: &IndexSlice<Promoted, Body<'tcx>>,
location_table: &LocationTable, location_table: &LocationTable,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
flow_inits: &mut ResultsCursor<'cx, 'tcx, MaybeInitializedPlaces<'_, 'cx, 'tcx>>, flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
move_data: &MoveData<'tcx>, move_data: &MoveData<'tcx>,
borrow_set: &BorrowSet<'tcx>, borrow_set: &BorrowSet<'tcx>,
upvars: &[&ty::CapturedPlace<'tcx>], upvars: &[&ty::CapturedPlace<'tcx>],

View File

@ -34,7 +34,7 @@ pub(super) enum PrefixSet {
Shallow, Shallow,
} }
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
/// Returns an iterator over the prefixes of `place` /// Returns an iterator over the prefixes of `place`
/// (inclusive) from longest to smallest, potentially /// (inclusive) from longest to smallest, potentially
/// terminating the iteration early based on `kind`. /// terminating the iteration early based on `kind`.

View File

@ -30,11 +30,11 @@ mod trace;
/// ///
/// N.B., this computation requires normalization; therefore, it must be /// N.B., this computation requires normalization; therefore, it must be
/// performed before /// performed before
pub(super) fn generate<'mir, 'tcx>( pub(super) fn generate<'a, 'tcx>(
typeck: &mut TypeChecker<'_, 'tcx>, typeck: &mut TypeChecker<'_, 'tcx>,
body: &Body<'tcx>, body: &Body<'tcx>,
elements: &Rc<DenseLocationMap>, elements: &Rc<DenseLocationMap>,
flow_inits: &mut ResultsCursor<'mir, 'tcx, MaybeInitializedPlaces<'_, 'mir, 'tcx>>, flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
move_data: &MoveData<'tcx>, move_data: &MoveData<'tcx>,
) { ) {
debug!("liveness::generate"); debug!("liveness::generate");

View File

@ -37,11 +37,11 @@ use crate::type_check::{NormalizeLocation, TypeChecker};
/// DROP-LIVE set are to the liveness sets for regions found in the /// DROP-LIVE set are to the liveness sets for regions found in the
/// `dropck_outlives` result of the variable's type (in particular, /// `dropck_outlives` result of the variable's type (in particular,
/// this respects `#[may_dangle]` annotations). /// this respects `#[may_dangle]` annotations).
pub(super) fn trace<'mir, 'tcx>( pub(super) fn trace<'a, 'tcx>(
typeck: &mut TypeChecker<'_, 'tcx>, typeck: &mut TypeChecker<'_, 'tcx>,
body: &Body<'tcx>, body: &Body<'tcx>,
elements: &Rc<DenseLocationMap>, elements: &Rc<DenseLocationMap>,
flow_inits: &mut ResultsCursor<'mir, 'tcx, MaybeInitializedPlaces<'_, 'mir, 'tcx>>, flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
move_data: &MoveData<'tcx>, move_data: &MoveData<'tcx>,
relevant_live_locals: Vec<Local>, relevant_live_locals: Vec<Local>,
boring_locals: Vec<Local>, boring_locals: Vec<Local>,
@ -99,29 +99,29 @@ pub(super) fn trace<'mir, 'tcx>(
} }
/// Contextual state for the type-liveness coroutine. /// Contextual state for the type-liveness coroutine.
struct LivenessContext<'a, 'me, 'typeck, 'flow, 'tcx> { struct LivenessContext<'a, 'typeck, 'b, 'tcx> {
/// Current type-checker, giving us our inference context etc. /// Current type-checker, giving us our inference context etc.
typeck: &'me mut TypeChecker<'typeck, 'tcx>, typeck: &'a mut TypeChecker<'typeck, 'tcx>,
/// Defines the `PointIndex` mapping /// Defines the `PointIndex` mapping
elements: &'me DenseLocationMap, elements: &'a DenseLocationMap,
/// MIR we are analyzing. /// MIR we are analyzing.
body: &'me Body<'tcx>, body: &'a Body<'tcx>,
/// Mapping to/from the various indices used for initialization tracking. /// Mapping to/from the various indices used for initialization tracking.
move_data: &'me MoveData<'tcx>, move_data: &'a MoveData<'tcx>,
/// Cache for the results of `dropck_outlives` query. /// Cache for the results of `dropck_outlives` query.
drop_data: FxIndexMap<Ty<'tcx>, DropData<'tcx>>, drop_data: FxIndexMap<Ty<'tcx>, DropData<'tcx>>,
/// Results of dataflow tracking which variables (and paths) have been /// Results of dataflow tracking which variables (and paths) have been
/// initialized. /// initialized.
flow_inits: &'me mut ResultsCursor<'flow, 'tcx, MaybeInitializedPlaces<'a, 'flow, 'tcx>>, flow_inits: &'a mut ResultsCursor<'b, 'tcx, MaybeInitializedPlaces<'b, 'tcx>>,
/// Index indicating where each variable is assigned, used, or /// Index indicating where each variable is assigned, used, or
/// dropped. /// dropped.
local_use_map: &'me LocalUseMap, local_use_map: &'a LocalUseMap,
} }
struct DropData<'tcx> { struct DropData<'tcx> {
@ -129,8 +129,8 @@ struct DropData<'tcx> {
region_constraint_data: Option<&'tcx QueryRegionConstraints<'tcx>>, region_constraint_data: Option<&'tcx QueryRegionConstraints<'tcx>>,
} }
struct LivenessResults<'a, 'me, 'typeck, 'flow, 'tcx> { struct LivenessResults<'a, 'typeck, 'b, 'tcx> {
cx: LivenessContext<'a, 'me, 'typeck, 'flow, 'tcx>, cx: LivenessContext<'a, 'typeck, 'b, 'tcx>,
/// Set of points that define the current local. /// Set of points that define the current local.
defs: BitSet<PointIndex>, defs: BitSet<PointIndex>,
@ -151,8 +151,8 @@ struct LivenessResults<'a, 'me, 'typeck, 'flow, 'tcx> {
stack: Vec<PointIndex>, stack: Vec<PointIndex>,
} }
impl<'a, 'me, 'typeck, 'flow, 'tcx> LivenessResults<'a, 'me, 'typeck, 'flow, 'tcx> { impl<'a, 'typeck, 'b, 'tcx> LivenessResults<'a, 'typeck, 'b, 'tcx> {
fn new(cx: LivenessContext<'a, 'me, 'typeck, 'flow, 'tcx>) -> Self { fn new(cx: LivenessContext<'a, 'typeck, 'b, 'tcx>) -> Self {
let num_points = cx.elements.num_points(); let num_points = cx.elements.num_points();
LivenessResults { LivenessResults {
cx, cx,
@ -505,7 +505,7 @@ impl<'a, 'me, 'typeck, 'flow, 'tcx> LivenessResults<'a, 'me, 'typeck, 'flow, 'tc
} }
} }
impl<'tcx> LivenessContext<'_, '_, '_, '_, 'tcx> { impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
/// Returns `true` if the local variable (or some part of it) is initialized at the current /// Returns `true` if the local variable (or some part of it) is initialized at the current
/// cursor position. Callers should call one of the `seek` methods immediately before to point /// cursor position. Callers should call one of the `seek` methods immediately before to point
/// the cursor to the desired location. /// the cursor to the desired location.

View File

@ -116,7 +116,7 @@ mod relate_tys;
/// - `flow_inits` -- results of a maybe-init dataflow analysis /// - `flow_inits` -- results of a maybe-init dataflow analysis
/// - `move_data` -- move-data constructed when performing the maybe-init dataflow analysis /// - `move_data` -- move-data constructed when performing the maybe-init dataflow analysis
/// - `elements` -- MIR region map /// - `elements` -- MIR region map
pub(crate) fn type_check<'mir, 'tcx>( pub(crate) fn type_check<'a, 'tcx>(
infcx: &BorrowckInferCtxt<'tcx>, infcx: &BorrowckInferCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
body: &Body<'tcx>, body: &Body<'tcx>,
@ -125,7 +125,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
location_table: &LocationTable, location_table: &LocationTable,
borrow_set: &BorrowSet<'tcx>, borrow_set: &BorrowSet<'tcx>,
all_facts: &mut Option<AllFacts>, all_facts: &mut Option<AllFacts>,
flow_inits: &mut ResultsCursor<'mir, 'tcx, MaybeInitializedPlaces<'_, 'mir, 'tcx>>, flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
move_data: &MoveData<'tcx>, move_data: &MoveData<'tcx>,
elements: &Rc<DenseLocationMap>, elements: &Rc<DenseLocationMap>,
upvars: &[&ty::CapturedPlace<'tcx>], upvars: &[&ty::CapturedPlace<'tcx>],

View File

@ -7,7 +7,7 @@ use tracing::debug;
use crate::MirBorrowckCtxt; use crate::MirBorrowckCtxt;
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
/// Walks the MIR adding to the set of `used_mut` locals that will be ignored for the purposes /// Walks the MIR adding to the set of `used_mut` locals that will be ignored for the purposes
/// of the `unused_mut` lint. /// of the `unused_mut` lint.
/// ///
@ -46,13 +46,13 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
/// MIR visitor for collecting used mutable variables. /// MIR visitor for collecting used mutable variables.
/// The 'visit lifetime represents the duration of the MIR walk. /// The 'visit lifetime represents the duration of the MIR walk.
struct GatherUsedMutsVisitor<'visit, 'a, 'mir, 'infcx, 'tcx> { struct GatherUsedMutsVisitor<'a, 'b, 'infcx, 'tcx> {
temporary_used_locals: FxIndexSet<Local>, temporary_used_locals: FxIndexSet<Local>,
never_initialized_mut_locals: &'visit mut FxIndexSet<Local>, never_initialized_mut_locals: &'a mut FxIndexSet<Local>,
mbcx: &'visit mut MirBorrowckCtxt<'a, 'mir, 'infcx, 'tcx>, mbcx: &'a mut MirBorrowckCtxt<'b, 'infcx, 'tcx>,
} }
impl GatherUsedMutsVisitor<'_, '_, '_, '_, '_> { impl GatherUsedMutsVisitor<'_, '_, '_, '_> {
fn remove_never_initialized_mut_locals(&mut self, into: Place<'_>) { fn remove_never_initialized_mut_locals(&mut self, into: Place<'_>) {
// Remove any locals that we found were initialized from the // Remove any locals that we found were initialized from the
// `never_initialized_mut_locals` set. At the end, the only remaining locals will // `never_initialized_mut_locals` set. At the end, the only remaining locals will
@ -64,7 +64,7 @@ impl GatherUsedMutsVisitor<'_, '_, '_, '_, '_> {
} }
} }
impl<'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'_, '_, '_, '_, 'tcx> { impl<'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'_, '_, '_, 'tcx> {
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
debug!("visit_terminator: terminator={:?}", terminator); debug!("visit_terminator: terminator={:?}", terminator);
match &terminator.kind { match &terminator.kind {

View File

@ -51,15 +51,15 @@ use crate::{
/// Similarly, at a given `drop` statement, the set-intersection /// Similarly, at a given `drop` statement, the set-intersection
/// between this data and `MaybeUninitializedPlaces` yields the set of /// between this data and `MaybeUninitializedPlaces` yields the set of
/// places that would require a dynamic drop-flag at that statement. /// places that would require a dynamic drop-flag at that statement.
pub struct MaybeInitializedPlaces<'a, 'mir, 'tcx> { pub struct MaybeInitializedPlaces<'a, 'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
body: &'mir Body<'tcx>, body: &'a Body<'tcx>,
move_data: &'a MoveData<'tcx>, move_data: &'a MoveData<'tcx>,
skip_unreachable_unwind: bool, skip_unreachable_unwind: bool,
} }
impl<'a, 'mir, 'tcx> MaybeInitializedPlaces<'a, 'mir, 'tcx> { impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, body: &'mir Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self { pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
MaybeInitializedPlaces { tcx, body, move_data, skip_unreachable_unwind: false } MaybeInitializedPlaces { tcx, body, move_data, skip_unreachable_unwind: false }
} }
@ -85,7 +85,7 @@ impl<'a, 'mir, 'tcx> MaybeInitializedPlaces<'a, 'mir, 'tcx> {
} }
} }
impl<'a, 'mir, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'mir, 'tcx> { impl<'a, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'tcx> {
fn move_data(&self) -> &MoveData<'tcx> { fn move_data(&self) -> &MoveData<'tcx> {
self.move_data self.move_data
} }
@ -126,17 +126,17 @@ impl<'a, 'mir, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'mir, 'tcx
/// Similarly, at a given `drop` statement, the set-intersection /// Similarly, at a given `drop` statement, the set-intersection
/// between this data and `MaybeInitializedPlaces` yields the set of /// between this data and `MaybeInitializedPlaces` yields the set of
/// places that would require a dynamic drop-flag at that statement. /// places that would require a dynamic drop-flag at that statement.
pub struct MaybeUninitializedPlaces<'a, 'mir, 'tcx> { pub struct MaybeUninitializedPlaces<'a, 'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
body: &'mir Body<'tcx>, body: &'a Body<'tcx>,
move_data: &'a MoveData<'tcx>, move_data: &'a MoveData<'tcx>,
mark_inactive_variants_as_uninit: bool, mark_inactive_variants_as_uninit: bool,
skip_unreachable_unwind: BitSet<mir::BasicBlock>, skip_unreachable_unwind: BitSet<mir::BasicBlock>,
} }
impl<'a, 'mir, 'tcx> MaybeUninitializedPlaces<'a, 'mir, 'tcx> { impl<'a, 'tcx> MaybeUninitializedPlaces<'a, 'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, body: &'mir Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self { pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
MaybeUninitializedPlaces { MaybeUninitializedPlaces {
tcx, tcx,
body, body,
@ -165,7 +165,7 @@ impl<'a, 'mir, 'tcx> MaybeUninitializedPlaces<'a, 'mir, 'tcx> {
} }
} }
impl<'a, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, '_, 'tcx> { impl<'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
fn move_data(&self) -> &MoveData<'tcx> { fn move_data(&self) -> &MoveData<'tcx> {
self.move_data self.move_data
} }
@ -251,24 +251,24 @@ impl<'a, 'tcx> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> {
/// c = S; // {a, b, c, d } /// c = S; // {a, b, c, d }
/// } /// }
/// ``` /// ```
pub struct EverInitializedPlaces<'a, 'mir, 'tcx> { pub struct EverInitializedPlaces<'a, 'tcx> {
body: &'mir Body<'tcx>, body: &'a Body<'tcx>,
move_data: &'a MoveData<'tcx>, move_data: &'a MoveData<'tcx>,
} }
impl<'a, 'mir, 'tcx> EverInitializedPlaces<'a, 'mir, 'tcx> { impl<'a, 'tcx> EverInitializedPlaces<'a, 'tcx> {
pub fn new(body: &'mir Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self { pub fn new(body: &'a Body<'tcx>, move_data: &'a MoveData<'tcx>) -> Self {
EverInitializedPlaces { body, move_data } EverInitializedPlaces { body, move_data }
} }
} }
impl<'a, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, '_, 'tcx> { impl<'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'_, 'tcx> {
fn move_data(&self) -> &MoveData<'tcx> { fn move_data(&self) -> &MoveData<'tcx> {
self.move_data self.move_data
} }
} }
impl<'a, 'mir, 'tcx> MaybeInitializedPlaces<'a, 'mir, 'tcx> { impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
fn update_bits( fn update_bits(
trans: &mut impl GenKill<MovePathIndex>, trans: &mut impl GenKill<MovePathIndex>,
path: MovePathIndex, path: MovePathIndex,
@ -281,7 +281,7 @@ impl<'a, 'mir, 'tcx> MaybeInitializedPlaces<'a, 'mir, 'tcx> {
} }
} }
impl<'a, 'tcx> MaybeUninitializedPlaces<'a, '_, 'tcx> { impl<'tcx> MaybeUninitializedPlaces<'_, 'tcx> {
fn update_bits( fn update_bits(
trans: &mut impl GenKill<MovePathIndex>, trans: &mut impl GenKill<MovePathIndex>,
path: MovePathIndex, path: MovePathIndex,
@ -307,7 +307,7 @@ impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> {
} }
} }
impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> { impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
/// There can be many more `MovePathIndex` than there are locals in a MIR body. /// There can be many more `MovePathIndex` than there are locals in a MIR body.
/// We use a chunked bitset to avoid paying too high a memory footprint. /// We use a chunked bitset to avoid paying too high a memory footprint.
type Domain = MaybeReachable<ChunkedBitSet<MovePathIndex>>; type Domain = MaybeReachable<ChunkedBitSet<MovePathIndex>>;
@ -329,7 +329,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> {
} }
} }
impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> { impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
type Idx = MovePathIndex; type Idx = MovePathIndex;
fn domain_size(&self, _: &Body<'tcx>) -> usize { fn domain_size(&self, _: &Body<'tcx>) -> usize {
@ -442,7 +442,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, '_, 'tcx> {
} }
} }
impl<'tcx> AnalysisDomain<'tcx> for MaybeUninitializedPlaces<'_, '_, 'tcx> { impl<'tcx> AnalysisDomain<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
/// There can be many more `MovePathIndex` than there are locals in a MIR body. /// There can be many more `MovePathIndex` than there are locals in a MIR body.
/// We use a chunked bitset to avoid paying too high a memory footprint. /// We use a chunked bitset to avoid paying too high a memory footprint.
type Domain = ChunkedBitSet<MovePathIndex>; type Domain = ChunkedBitSet<MovePathIndex>;
@ -466,7 +466,7 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeUninitializedPlaces<'_, '_, 'tcx> {
} }
} }
impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, '_, 'tcx> { impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
type Idx = MovePathIndex; type Idx = MovePathIndex;
fn domain_size(&self, _: &Body<'tcx>) -> usize { fn domain_size(&self, _: &Body<'tcx>) -> usize {
@ -643,7 +643,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
} }
} }
impl<'tcx> AnalysisDomain<'tcx> for EverInitializedPlaces<'_, '_, 'tcx> { impl<'tcx> AnalysisDomain<'tcx> for EverInitializedPlaces<'_, 'tcx> {
/// There can be many more `InitIndex` than there are locals in a MIR body. /// There can be many more `InitIndex` than there are locals in a MIR body.
/// We use a chunked bitset to avoid paying too high a memory footprint. /// We use a chunked bitset to avoid paying too high a memory footprint.
type Domain = ChunkedBitSet<InitIndex>; type Domain = ChunkedBitSet<InitIndex>;
@ -662,7 +662,7 @@ impl<'tcx> AnalysisDomain<'tcx> for EverInitializedPlaces<'_, '_, 'tcx> {
} }
} }
impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, '_, 'tcx> { impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
type Idx = InitIndex; type Idx = InitIndex;
fn domain_size(&self, _: &Body<'tcx>) -> usize { fn domain_size(&self, _: &Body<'tcx>) -> usize {

View File

@ -98,9 +98,9 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateDrops {
/// Records unwind edges which are known to be unreachable, because they are in `drop` terminators /// Records unwind edges which are known to be unreachable, because they are in `drop` terminators
/// that can't drop anything. /// that can't drop anything.
#[instrument(level = "trace", skip(body, flow_inits), ret)] #[instrument(level = "trace", skip(body, flow_inits), ret)]
fn compute_dead_unwinds<'mir, 'tcx>( fn compute_dead_unwinds<'a, 'tcx>(
body: &'mir Body<'tcx>, body: &'a Body<'tcx>,
flow_inits: &mut ResultsCursor<'mir, 'tcx, MaybeInitializedPlaces<'_, 'mir, 'tcx>>, flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
) -> BitSet<BasicBlock> { ) -> BitSet<BasicBlock> {
// We only need to do this pass once, because unwind edges can only // We only need to do this pass once, because unwind edges can only
// reach cleanup blocks, which can't have unwind edges themselves. // reach cleanup blocks, which can't have unwind edges themselves.
@ -121,12 +121,12 @@ fn compute_dead_unwinds<'mir, 'tcx>(
dead_unwinds dead_unwinds
} }
struct InitializationData<'a, 'mir, 'tcx> { struct InitializationData<'a, 'tcx> {
inits: ResultsCursor<'mir, 'tcx, MaybeInitializedPlaces<'a, 'mir, 'tcx>>, inits: ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
uninits: ResultsCursor<'mir, 'tcx, MaybeUninitializedPlaces<'a, 'mir, 'tcx>>, uninits: ResultsCursor<'a, 'tcx, MaybeUninitializedPlaces<'a, 'tcx>>,
} }
impl InitializationData<'_, '_, '_> { impl InitializationData<'_, '_> {
fn seek_before(&mut self, loc: Location) { fn seek_before(&mut self, loc: Location) {
self.inits.seek_before_primary_effect(loc); self.inits.seek_before_primary_effect(loc);
self.uninits.seek_before_primary_effect(loc); self.uninits.seek_before_primary_effect(loc);
@ -137,24 +137,24 @@ impl InitializationData<'_, '_, '_> {
} }
} }
struct Elaborator<'a, 'b, 'mir, 'tcx> { struct Elaborator<'a, 'b, 'tcx> {
ctxt: &'a mut ElaborateDropsCtxt<'b, 'mir, 'tcx>, ctxt: &'a mut ElaborateDropsCtxt<'b, 'tcx>,
} }
impl fmt::Debug for Elaborator<'_, '_, '_, '_> { impl fmt::Debug for Elaborator<'_, '_, '_> {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
Ok(()) Ok(())
} }
} }
impl<'a, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, '_, '_, 'tcx> { impl<'b, 'tcx> DropElaborator<'b, 'tcx> for Elaborator<'_, 'b, 'tcx> {
type Path = MovePathIndex; type Path = MovePathIndex;
fn patch(&mut self) -> &mut MirPatch<'tcx> { fn patch(&mut self) -> &mut MirPatch<'tcx> {
&mut self.ctxt.patch &mut self.ctxt.patch
} }
fn body(&self) -> &'a Body<'tcx> { fn body(&self) -> &'b Body<'tcx> {
self.ctxt.body self.ctxt.body
} }
@ -241,17 +241,17 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, '_, '_, 'tcx> {
} }
} }
struct ElaborateDropsCtxt<'a, 'mir, 'tcx> { struct ElaborateDropsCtxt<'a, 'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
body: &'mir Body<'tcx>, body: &'a Body<'tcx>,
env: &'a MoveDataParamEnv<'tcx>, env: &'a MoveDataParamEnv<'tcx>,
init_data: InitializationData<'a, 'mir, 'tcx>, init_data: InitializationData<'a, 'tcx>,
drop_flags: IndexVec<MovePathIndex, Option<Local>>, drop_flags: IndexVec<MovePathIndex, Option<Local>>,
patch: MirPatch<'tcx>, patch: MirPatch<'tcx>,
} }
impl<'b, 'mir, 'tcx> ElaborateDropsCtxt<'b, 'mir, 'tcx> { impl<'a, 'tcx> ElaborateDropsCtxt<'a, 'tcx> {
fn move_data(&self) -> &'b MoveData<'tcx> { fn move_data(&self) -> &'a MoveData<'tcx> {
&self.env.move_data &self.env.move_data
} }