diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-06-24 14:28:08 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-06-24 14:28:14 +0000 |
| commit | 8fc6b3de190cc4b669082a094ed1cc5d89d8f9d7 (patch) | |
| tree | 5fc1750349542f9623e8484c4dd0069a2e786800 /compiler/rustc_borrowck/src/lib.rs | |
| parent | 1c4d0ced58ee9452b26efaac93af59f63fe109f2 (diff) | |
| download | rust-8fc6b3de190cc4b669082a094ed1cc5d89d8f9d7.tar.gz rust-8fc6b3de190cc4b669082a094ed1cc5d89d8f9d7.zip | |
Separate the mir body lifetime from the other lifetimes
Diffstat (limited to 'compiler/rustc_borrowck/src/lib.rs')
| -rw-r--r-- | compiler/rustc_borrowck/src/lib.rs | 73 |
1 files changed, 39 insertions, 34 deletions
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index ac845930004..69efee2fbdc 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -310,11 +310,11 @@ fn do_mir_borrowck<'tcx>( promoted_mbcx.report_move_errors(); diags = promoted_mbcx.diags; - struct MoveVisitor<'a, 'b, 'cx, 'tcx> { - ctxt: &'a mut MirBorrowckCtxt<'b, 'cx, 'tcx>, + struct MoveVisitor<'a, 'b, 'mir, '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) { if let Operand::Move(place) = operand { self.ctxt.check_movable_place(location, *place); @@ -528,10 +528,10 @@ impl<'tcx> Deref for BorrowckInferCtxt<'tcx> { } } -struct MirBorrowckCtxt<'a, 'cx, 'tcx> { +struct MirBorrowckCtxt<'a, 'mir, 'cx, 'tcx> { infcx: &'cx BorrowckInferCtxt<'tcx>, param_env: ParamEnv<'tcx>, - body: &'a Body<'tcx>, + body: &'mir Body<'tcx>, move_data: &'a MoveData<'tcx>, /// 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 // 3. assignments do not affect things loaned out as immutable // 4. moves do not affect things loaned out in any way -impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> - for MirBorrowckCtxt<'_, 'cx, 'tcx> +impl<'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R> + for MirBorrowckCtxt<'_, 'mir, '_, 'tcx> { - type FlowState = Flows<'cx, 'tcx>; + type FlowState = Flows<'mir, 'tcx>; fn visit_statement_before_primary_effect( &mut self, _results: &mut R, - flow_state: &Flows<'cx, 'tcx>, - stmt: &'cx Statement<'tcx>, + flow_state: &Flows<'mir, 'tcx>, + stmt: &'mir Statement<'tcx>, location: Location, ) { debug!("MirBorrowckCtxt::process_statement({:?}, {:?}): {:?}", location, stmt, flow_state); @@ -683,8 +683,8 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> fn visit_terminator_before_primary_effect( &mut self, _results: &mut R, - flow_state: &Flows<'cx, 'tcx>, - term: &'cx Terminator<'tcx>, + flow_state: &Flows<'mir, 'tcx>, + term: &'mir Terminator<'tcx>, loc: Location, ) { debug!("MirBorrowckCtxt::process_terminator({:?}, {:?}): {:?}", loc, term, flow_state); @@ -794,8 +794,8 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> fn visit_terminator_after_primary_effect( &mut self, _results: &mut R, - flow_state: &Flows<'cx, 'tcx>, - term: &'cx Terminator<'tcx>, + flow_state: &Flows<'mir, 'tcx>, + term: &'mir Terminator<'tcx>, loc: Location, ) { let span = term.source_info.span; @@ -971,8 +971,8 @@ impl InitializationRequiringAction { } } -impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { - fn body(&self) -> &'a Body<'tcx> { +impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> { + fn body(&self) -> &'mir Body<'tcx> { self.body } @@ -988,7 +988,7 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { place_span: (Place<'tcx>, Span), kind: (AccessDepth, ReadOrWrite), is_local_mutation_allowed: LocalMutationIsAllowed, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { let (sd, rw) = kind; @@ -1038,7 +1038,7 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { place_span: (Place<'tcx>, Span), sd: AccessDepth, rw: ReadOrWrite, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) -> bool { let mut error_reported = false; let borrow_set = Rc::clone(&self.borrow_set); @@ -1179,7 +1179,7 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { location: Location, place_span: (Place<'tcx>, Span), kind: AccessDepth, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { // Write of P[i] or *P requires P init'd. self.check_if_assigned_path_is_moved(location, place_span, flow_state); @@ -1196,8 +1196,8 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { fn consume_rvalue( &mut self, location: Location, - (rvalue, span): (&'cx Rvalue<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, + (rvalue, span): (&'mir Rvalue<'tcx>, Span), + flow_state: &Flows<'mir, 'tcx>, ) { match rvalue { &Rvalue::Ref(_ /*rgn*/, bk, place) => { @@ -1454,8 +1454,8 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { fn consume_operand( &mut self, location: Location, - (operand, span): (&'cx Operand<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, + (operand, span): (&'mir Operand<'tcx>, Span), + flow_state: &Flows<'mir, 'tcx>, ) { match *operand { Operand::Copy(place) => { @@ -1575,7 +1575,12 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { } } - 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 // generated at this statement, check if it interferes with // another borrow. @@ -1738,7 +1743,7 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { location: Location, desired_action: InitializationRequiringAction, place_span: (PlaceRef<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { let maybe_uninits = &flow_state.uninits; @@ -1843,7 +1848,7 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { location: Location, desired_action: InitializationRequiringAction, place_span: (PlaceRef<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { let maybe_uninits = &flow_state.uninits; @@ -1942,7 +1947,7 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { &mut self, location: Location, (place, span): (Place<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { debug!("check_if_assigned_path_is_moved place: {:?}", place); @@ -2003,12 +2008,12 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { } } - fn check_parent_of_field<'cx, 'tcx>( - this: &mut MirBorrowckCtxt<'_, 'cx, 'tcx>, + fn check_parent_of_field<'mir, 'tcx>( + this: &mut MirBorrowckCtxt<'_, 'mir, '_, 'tcx>, location: Location, base: PlaceRef<'tcx>, span: Span, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { // rust-lang/rust#21232: Until Rust allows reads from the // initialized parts of partially initialized structs, we @@ -2099,7 +2104,7 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { (place, span): (Place<'tcx>, Span), kind: ReadOrWrite, is_local_mutation_allowed: LocalMutationIsAllowed, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, location: Location, ) -> bool { debug!( @@ -2215,7 +2220,7 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { fn is_local_ever_initialized( &self, local: Local, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) -> Option<InitIndex> { let mpi = self.move_data.rev_lookup.find_local(local)?; let ii = &self.move_data.init_path_map[mpi]; @@ -2223,7 +2228,7 @@ impl<'a, 'cx, 'tcx> MirBorrowckCtxt<'a, 'cx, 'tcx> { } /// 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 { RootPlace { place_local: local, place_projection: [], is_local_mutation_allowed } => { // If the local may have been initialized, and it is now currently being @@ -2478,7 +2483,7 @@ mod diags { } } - impl<'cx, 'tcx> MirBorrowckCtxt<'_, 'cx, 'tcx> { + impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { pub fn buffer_error(&mut self, diag: Diag<'tcx>) { self.diags.buffer_error(diag); } |
