Separate the mir body lifetime from the other lifetimes

This commit is contained in:
Oli Scherer 2024-06-24 14:28:08 +00:00
parent 1c4d0ced58
commit 8fc6b3de19
13 changed files with 70 additions and 61 deletions

View File

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

View File

@ -52,7 +52,7 @@ pub(crate) fn relate(expected: Ty<'tcx>, found: Ty<'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( fn nice_error(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, '_, '_, '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 @@ fn nice_error(
#[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 @@ fn base_universe(&self) -> ty::UniverseIndex {
fn nice_error( fn nice_error(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, '_, '_, '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>>,
@ -270,7 +270,7 @@ fn base_universe(&self) -> ty::UniverseIndex {
fn nice_error( fn nice_error(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, '_, '_, '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>>,
@ -310,7 +310,7 @@ fn base_universe(&self) -> ty::UniverseIndex {
fn nice_error( fn nice_error(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, '_, '_, '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>>,
@ -336,7 +336,7 @@ fn base_universe(&self) -> ty::UniverseIndex {
fn nice_error( fn nice_error(
&self, &self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>, mbcx: &mut MirBorrowckCtxt<'_, '_, '_, '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

@ -73,7 +73,7 @@ enum StorageDeadOrDrop<'tcx> {
Destructor(Ty<'tcx>), Destructor(Ty<'tcx>),
} }
impl<'cx, 'tcx> MirBorrowckCtxt<'_, 'cx, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, '_, '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,
@ -4243,7 +4243,11 @@ 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(&self, cx: &MirBorrowckCtxt<'_, '_, 'tcx>, diag: &mut Diag<'_>) -> String { pub(crate) fn emit(
&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

@ -389,7 +389,7 @@ fn add_lifetime_bound_suggestion_to_diagnostic(
} }
} }
impl<'cx, 'tcx> MirBorrowckCtxt<'_, 'cx, '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

@ -69,7 +69,7 @@ pub(super) struct DescribePlaceOpt {
pub(super) struct IncludingTupleField(pub(super) bool); pub(super) struct IncludingTupleField(pub(super) bool);
impl<'cx, 'tcx> MirBorrowckCtxt<'_, 'cx, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, '_, '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.
/// ///
@ -771,7 +771,7 @@ struct CapturedMessageOpt {
maybe_reinitialized_locations_is_empty: bool, maybe_reinitialized_locations_is_empty: bool,
} }
impl<'cx, 'tcx> MirBorrowckCtxt<'_, 'cx, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, '_, '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<'a, 'tcx> MirBorrowckCtxt<'_, 'a, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, '_, '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

@ -30,7 +30,7 @@ pub(crate) enum AccessKind {
Mutate, Mutate,
} }
impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, '_, '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

@ -75,7 +75,7 @@ fn region_name_is_suggestable(name: &RegionName) -> bool {
/// 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)
@ -84,7 +84,7 @@ fn region_vid_to_name(
/// 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();
@ -160,7 +160,7 @@ pub(crate) fn collect_constraint(&mut self, fr: RegionVid, outlived_fr: RegionVi
/// 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<'_>,
) { ) {
@ -179,7 +179,7 @@ pub(crate) fn intermediate_suggestion(
/// 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

@ -160,7 +160,7 @@ pub struct ErrorConstraintInfo<'tcx> {
pub(super) span: Span, pub(super) span: Span,
} }
impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, '_, '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

@ -198,7 +198,7 @@ fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
} }
} }
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

@ -310,11 +310,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, 'cx, 'tcx> { struct MoveVisitor<'a, 'b, 'mir, 'cx, 'tcx> {
ctxt: &'a mut MirBorrowckCtxt<'b, 'cx, 'tcx>, ctxt: &'a mut MirBorrowckCtxt<'b, 'mir, 'cx, '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);
@ -528,10 +528,10 @@ fn deref(&self) -> &Self::Target {
} }
} }
struct MirBorrowckCtxt<'a, 'cx, 'tcx> { struct MirBorrowckCtxt<'a, 'mir, 'cx, 'tcx> {
infcx: &'cx BorrowckInferCtxt<'tcx>, infcx: &'cx BorrowckInferCtxt<'tcx>,
param_env: ParamEnv<'tcx>, param_env: ParamEnv<'tcx>,
body: &'a Body<'tcx>, body: &'mir 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
@ -605,16 +605,16 @@ struct MirBorrowckCtxt<'a, 'cx, '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<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> impl<'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R>
for MirBorrowckCtxt<'_, 'cx, 'tcx> for MirBorrowckCtxt<'_, 'mir, '_, 'tcx>
{ {
type FlowState = Flows<'cx, 'tcx>; type FlowState = Flows<'mir, '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<'cx, 'tcx>, flow_state: &Flows<'mir, 'tcx>,
stmt: &'cx Statement<'tcx>, stmt: &'mir Statement<'tcx>,
location: Location, location: Location,
) { ) {
debug!("MirBorrowckCtxt::process_statement({:?}, {:?}): {:?}", location, stmt, flow_state); debug!("MirBorrowckCtxt::process_statement({:?}, {:?}): {:?}", location, stmt, flow_state);
@ -683,8 +683,8 @@ fn visit_statement_before_primary_effect(
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<'cx, 'tcx>, flow_state: &Flows<'mir, 'tcx>,
term: &'cx Terminator<'tcx>, term: &'mir 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 @@ fn visit_terminator_before_primary_effect(
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<'cx, 'tcx>, flow_state: &Flows<'mir, 'tcx>,
term: &'cx Terminator<'tcx>, term: &'mir Terminator<'tcx>,
loc: Location, loc: Location,
) { ) {
let span = term.source_info.span; let span = term.source_info.span;
@ -971,8 +971,8 @@ fn as_general_verb_in_past_tense(self) -> &'static str {
} }
} }
impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
fn body(&self) -> &'a Body<'tcx> { fn body(&self) -> &'mir Body<'tcx> {
self.body self.body
} }
@ -988,7 +988,7 @@ fn access_place(
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<'cx, 'tcx>, flow_state: &Flows<'mir, 'tcx>,
) { ) {
let (sd, rw) = kind; let (sd, rw) = kind;
@ -1038,7 +1038,7 @@ fn check_access_for_conflict(
place_span: (Place<'tcx>, Span), place_span: (Place<'tcx>, Span),
sd: AccessDepth, sd: AccessDepth,
rw: ReadOrWrite, rw: ReadOrWrite,
flow_state: &Flows<'cx, 'tcx>, flow_state: &Flows<'mir, '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);
@ -1179,7 +1179,7 @@ fn mutate_place(
location: Location, location: Location,
place_span: (Place<'tcx>, Span), place_span: (Place<'tcx>, Span),
kind: AccessDepth, kind: AccessDepth,
flow_state: &Flows<'cx, 'tcx>, flow_state: &Flows<'mir, '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);
@ -1196,8 +1196,8 @@ fn mutate_place(
fn consume_rvalue( fn consume_rvalue(
&mut self, &mut self,
location: Location, location: Location,
(rvalue, span): (&'cx Rvalue<'tcx>, Span), (rvalue, span): (&'mir Rvalue<'tcx>, Span),
flow_state: &Flows<'cx, 'tcx>, flow_state: &Flows<'mir, 'tcx>,
) { ) {
match rvalue { match rvalue {
&Rvalue::Ref(_ /*rgn*/, bk, place) => { &Rvalue::Ref(_ /*rgn*/, bk, place) => {
@ -1454,8 +1454,8 @@ fn propagate_closure_used_mut_upvar(&mut self, operand: &Operand<'tcx>) {
fn consume_operand( fn consume_operand(
&mut self, &mut self,
location: Location, location: Location,
(operand, span): (&'cx Operand<'tcx>, Span), (operand, span): (&'mir Operand<'tcx>, Span),
flow_state: &Flows<'cx, 'tcx>, flow_state: &Flows<'mir, 'tcx>,
) { ) {
match *operand { match *operand {
Operand::Copy(place) => { Operand::Copy(place) => {
@ -1575,7 +1575,12 @@ fn check_for_local_borrow(&mut self, borrow: &BorrowData<'tcx>, yield_span: Span
} }
} }
fn check_activations(&mut self, location: Location, span: Span, flow_state: &Flows<'cx, 'tcx>) { fn check_activations(
&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.
@ -1738,7 +1743,7 @@ fn check_if_full_path_is_moved(
location: Location, location: Location,
desired_action: InitializationRequiringAction, desired_action: InitializationRequiringAction,
place_span: (PlaceRef<'tcx>, Span), place_span: (PlaceRef<'tcx>, Span),
flow_state: &Flows<'cx, 'tcx>, flow_state: &Flows<'mir, 'tcx>,
) { ) {
let maybe_uninits = &flow_state.uninits; let maybe_uninits = &flow_state.uninits;
@ -1843,7 +1848,7 @@ fn check_if_path_or_subpath_is_moved(
location: Location, location: Location,
desired_action: InitializationRequiringAction, desired_action: InitializationRequiringAction,
place_span: (PlaceRef<'tcx>, Span), place_span: (PlaceRef<'tcx>, Span),
flow_state: &Flows<'cx, 'tcx>, flow_state: &Flows<'mir, 'tcx>,
) { ) {
let maybe_uninits = &flow_state.uninits; let maybe_uninits = &flow_state.uninits;
@ -1942,7 +1947,7 @@ fn check_if_assigned_path_is_moved(
&mut self, &mut self,
location: Location, location: Location,
(place, span): (Place<'tcx>, Span), (place, span): (Place<'tcx>, Span),
flow_state: &Flows<'cx, 'tcx>, flow_state: &Flows<'mir, 'tcx>,
) { ) {
debug!("check_if_assigned_path_is_moved place: {:?}", place); debug!("check_if_assigned_path_is_moved place: {:?}", place);
@ -2003,12 +2008,12 @@ fn check_if_assigned_path_is_moved(
} }
} }
fn check_parent_of_field<'cx, 'tcx>( fn check_parent_of_field<'mir, 'tcx>(
this: &mut MirBorrowckCtxt<'_, 'cx, 'tcx>, this: &mut MirBorrowckCtxt<'_, 'mir, '_, 'tcx>,
location: Location, location: Location,
base: PlaceRef<'tcx>, base: PlaceRef<'tcx>,
span: Span, span: Span,
flow_state: &Flows<'cx, 'tcx>, flow_state: &Flows<'mir, '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
@ -2099,7 +2104,7 @@ fn check_access_permissions(
(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<'cx, 'tcx>, flow_state: &Flows<'mir, 'tcx>,
location: Location, location: Location,
) -> bool { ) -> bool {
debug!( debug!(
@ -2215,7 +2220,7 @@ fn check_access_permissions(
fn is_local_ever_initialized( fn is_local_ever_initialized(
&self, &self,
local: Local, local: Local,
flow_state: &Flows<'cx, 'tcx>, flow_state: &Flows<'mir, '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];
@ -2223,7 +2228,7 @@ fn is_local_ever_initialized(
} }
/// 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<'cx, 'tcx>) { fn add_used_mut(&mut self, root_place: RootPlace<'tcx>, flow_state: &Flows<'mir, '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
@ -2478,7 +2483,7 @@ pub fn buffer_non_error(&mut self, diag: Diag<'tcx, ()>) {
} }
} }
impl<'cx, 'tcx> MirBorrowckCtxt<'_, 'cx, 'tcx> { impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
pub fn buffer_error(&mut self, diag: Diag<'tcx>) { pub fn buffer_error(&mut self, diag: Diag<'tcx>) {
self.diags.buffer_error(diag); self.diags.buffer_error(diag);
} }

View File

@ -34,7 +34,7 @@ pub(super) enum PrefixSet {
Shallow, Shallow,
} }
impl<'cx, 'tcx> MirBorrowckCtxt<'_, 'cx, '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

@ -6,7 +6,7 @@
use crate::MirBorrowckCtxt; use crate::MirBorrowckCtxt;
impl<'cx, 'tcx> MirBorrowckCtxt<'_, 'cx, '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.
/// ///
@ -45,13 +45,13 @@ pub(crate) fn gather_used_muts(
/// 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, 'cx, 'tcx> { struct GatherUsedMutsVisitor<'visit, 'a, 'mir, 'cx, 'tcx> {
temporary_used_locals: FxIndexSet<Local>, temporary_used_locals: FxIndexSet<Local>,
never_initialized_mut_locals: &'visit mut FxIndexSet<Local>, never_initialized_mut_locals: &'visit mut FxIndexSet<Local>,
mbcx: &'visit mut MirBorrowckCtxt<'a, 'cx, 'tcx>, mbcx: &'visit mut MirBorrowckCtxt<'a, 'mir, 'cx, '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
@ -63,7 +63,7 @@ fn remove_never_initialized_mut_locals(&mut self, into: Place<'_>) {
} }
} }
impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, '_, 'cx, '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 {