Skip to content

Commit 2298104

Browse files
committed
Call all Domain values state.
Currently they are called (most common) `state`, or `trans`, or (rare) `on_entry`. I think `trans` is short for "transfer function", which perhaps made more sense when `GenKillAnalysis` existed. Using `state` everywhere now is more consistent.
1 parent 086233e commit 2298104

File tree

5 files changed

+105
-105
lines changed

5 files changed

+105
-105
lines changed

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
506506
/// That means they went out of a nonlexical scope
507507
fn kill_loans_out_of_scope_at_location(
508508
&self,
509-
trans: &mut <Self as Analysis<'tcx>>::Domain,
509+
state: &mut <Self as Analysis<'tcx>>::Domain,
510510
location: Location,
511511
) {
512512
// NOTE: The state associated with a given `location`
@@ -521,14 +521,14 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
521521
// region, then setting that gen-bit will override any
522522
// potential kill introduced here.
523523
if let Some(indices) = self.borrows_out_of_scope_at_location.get(&location) {
524-
trans.kill_all(indices.iter().copied());
524+
state.kill_all(indices.iter().copied());
525525
}
526526
}
527527

528528
/// Kill any borrows that conflict with `place`.
529529
fn kill_borrows_on_place(
530530
&self,
531-
trans: &mut <Self as Analysis<'tcx>>::Domain,
531+
state: &mut <Self as Analysis<'tcx>>::Domain,
532532
place: Place<'tcx>,
533533
) {
534534
debug!("kill_borrows_on_place: place={:?}", place);
@@ -546,7 +546,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
546546
// `places_conflict` for every borrow.
547547
if place.projection.is_empty() {
548548
if !self.body.local_decls[place.local].is_ref_to_static() {
549-
trans.kill_all(other_borrows_of_local);
549+
state.kill_all(other_borrows_of_local);
550550
}
551551
return;
552552
}
@@ -565,7 +565,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
565565
)
566566
});
567567

568-
trans.kill_all(definitely_conflicting_borrows);
568+
state.kill_all(definitely_conflicting_borrows);
569569
}
570570
}
571571

@@ -595,16 +595,16 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
595595

596596
fn apply_before_statement_effect(
597597
&mut self,
598-
trans: &mut Self::Domain,
598+
state: &mut Self::Domain,
599599
_statement: &mir::Statement<'tcx>,
600600
location: Location,
601601
) {
602-
self.kill_loans_out_of_scope_at_location(trans, location);
602+
self.kill_loans_out_of_scope_at_location(state, location);
603603
}
604604

605605
fn apply_statement_effect(
606606
&mut self,
607-
trans: &mut Self::Domain,
607+
state: &mut Self::Domain,
608608
stmt: &mir::Statement<'tcx>,
609609
location: Location,
610610
) {
@@ -622,18 +622,18 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
622622
panic!("could not find BorrowIndex for location {location:?}");
623623
});
624624

625-
trans.gen_(index);
625+
state.gen_(index);
626626
}
627627

628628
// Make sure there are no remaining borrows for variables
629629
// that are assigned over.
630-
self.kill_borrows_on_place(trans, *lhs);
630+
self.kill_borrows_on_place(state, *lhs);
631631
}
632632

633633
mir::StatementKind::StorageDead(local) => {
634634
// Make sure there are no remaining borrows for locals that
635635
// are gone out of scope.
636-
self.kill_borrows_on_place(trans, Place::from(*local));
636+
self.kill_borrows_on_place(state, Place::from(*local));
637637
}
638638

639639
mir::StatementKind::FakeRead(..)
@@ -653,16 +653,16 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
653653

654654
fn apply_before_terminator_effect(
655655
&mut self,
656-
trans: &mut Self::Domain,
656+
state: &mut Self::Domain,
657657
_terminator: &mir::Terminator<'tcx>,
658658
location: Location,
659659
) {
660-
self.kill_loans_out_of_scope_at_location(trans, location);
660+
self.kill_loans_out_of_scope_at_location(state, location);
661661
}
662662

663663
fn apply_terminator_effect<'mir>(
664664
&mut self,
665-
trans: &mut Self::Domain,
665+
state: &mut Self::Domain,
666666
terminator: &'mir mir::Terminator<'tcx>,
667667
_location: Location,
668668
) -> TerminatorEdges<'mir, 'tcx> {
@@ -671,7 +671,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
671671
if let mir::InlineAsmOperand::Out { place: Some(place), .. }
672672
| mir::InlineAsmOperand::InOut { out_place: Some(place), .. } = *op
673673
{
674-
self.kill_borrows_on_place(trans, place);
674+
self.kill_borrows_on_place(state, place);
675675
}
676676
}
677677
}

compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ impl<'tcx> Analysis<'tcx> for MaybeBorrowedLocals {
3535

3636
fn apply_statement_effect(
3737
&mut self,
38-
trans: &mut Self::Domain,
38+
state: &mut Self::Domain,
3939
statement: &Statement<'tcx>,
4040
location: Location,
4141
) {
42-
Self::transfer_function(trans).visit_statement(statement, location);
42+
Self::transfer_function(state).visit_statement(statement, location);
4343
}
4444

4545
fn apply_terminator_effect<'mir>(
4646
&mut self,
47-
trans: &mut Self::Domain,
47+
state: &mut Self::Domain,
4848
terminator: &'mir Terminator<'tcx>,
4949
location: Location,
5050
) -> TerminatorEdges<'mir, 'tcx> {
51-
Self::transfer_function(trans).visit_terminator(terminator, location);
51+
Self::transfer_function(state).visit_terminator(terminator, location);
5252
terminator.edges()
5353
}
5454
}

compiler/rustc_mir_dataflow/src/impls/initialized.rs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -218,26 +218,26 @@ impl<'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'_, 'tcx> {
218218

219219
impl<'a, 'tcx> MaybeInitializedPlaces<'a, 'tcx> {
220220
fn update_bits(
221-
trans: &mut <Self as Analysis<'tcx>>::Domain,
221+
state: &mut <Self as Analysis<'tcx>>::Domain,
222222
path: MovePathIndex,
223-
state: DropFlagState,
223+
dfstate: DropFlagState,
224224
) {
225-
match state {
226-
DropFlagState::Absent => trans.kill(path),
227-
DropFlagState::Present => trans.gen_(path),
225+
match dfstate {
226+
DropFlagState::Absent => state.kill(path),
227+
DropFlagState::Present => state.gen_(path),
228228
}
229229
}
230230
}
231231

232232
impl<'tcx> MaybeUninitializedPlaces<'_, 'tcx> {
233233
fn update_bits(
234-
trans: &mut <Self as Analysis<'tcx>>::Domain,
234+
state: &mut <Self as Analysis<'tcx>>::Domain,
235235
path: MovePathIndex,
236-
state: DropFlagState,
236+
dfstate: DropFlagState,
237237
) {
238-
match state {
239-
DropFlagState::Absent => trans.gen_(path),
240-
DropFlagState::Present => trans.kill(path),
238+
match dfstate {
239+
DropFlagState::Absent => state.gen_(path),
240+
DropFlagState::Present => state.kill(path),
241241
}
242242
}
243243
}
@@ -265,12 +265,12 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
265265

266266
fn apply_statement_effect(
267267
&mut self,
268-
trans: &mut Self::Domain,
268+
state: &mut Self::Domain,
269269
statement: &mir::Statement<'tcx>,
270270
location: Location,
271271
) {
272272
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
273-
Self::update_bits(trans, path, s)
273+
Self::update_bits(state, path, s)
274274
});
275275

276276
// Mark all places as "maybe init" if they are mutably borrowed. See #90752.
@@ -282,7 +282,7 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
282282
&& let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref())
283283
{
284284
on_all_children_bits(self.move_data(), mpi, |child| {
285-
trans.gen_(child);
285+
state.gen_(child);
286286
})
287287
}
288288
}
@@ -309,7 +309,7 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
309309

310310
fn apply_call_return_effect(
311311
&mut self,
312-
trans: &mut Self::Domain,
312+
state: &mut Self::Domain,
313313
_block: mir::BasicBlock,
314314
return_places: CallReturnPlaces<'_, 'tcx>,
315315
) {
@@ -320,7 +320,7 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
320320
self.move_data(),
321321
self.move_data().rev_lookup.find(place.as_ref()),
322322
|mpi| {
323-
trans.gen_(mpi);
323+
state.gen_(mpi);
324324
},
325325
);
326326
});
@@ -345,7 +345,7 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
345345
};
346346

347347
let mut discriminants = enum_def.discriminants(self.tcx);
348-
edge_effects.apply(|trans, edge| {
348+
edge_effects.apply(|state, edge| {
349349
let Some(value) = edge.value else {
350350
return;
351351
};
@@ -363,7 +363,7 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
363363
self.move_data(),
364364
enum_place,
365365
variant,
366-
|mpi| trans.kill(mpi),
366+
|mpi| state.kill(mpi),
367367
);
368368
});
369369
}
@@ -383,7 +383,7 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
383383
MixedBitSet::new_empty(self.move_data().move_paths.len())
384384
}
385385

386-
// sets on_entry bits for Arg places
386+
// sets state bits for Arg places
387387
fn initialize_start_block(&self, _: &mir::Body<'tcx>, state: &mut Self::Domain) {
388388
// set all bits to 1 (uninit) before gathering counter-evidence
389389
state.insert_all();
@@ -396,12 +396,12 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
396396

397397
fn apply_statement_effect(
398398
&mut self,
399-
trans: &mut Self::Domain,
399+
state: &mut Self::Domain,
400400
_statement: &mir::Statement<'tcx>,
401401
location: Location,
402402
) {
403403
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
404-
Self::update_bits(trans, path, s)
404+
Self::update_bits(state, path, s)
405405
});
406406

407407
// Unlike in `MaybeInitializedPlaces` above, we don't need to change the state when a
@@ -410,12 +410,12 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
410410

411411
fn apply_terminator_effect<'mir>(
412412
&mut self,
413-
trans: &mut Self::Domain,
413+
state: &mut Self::Domain,
414414
terminator: &'mir mir::Terminator<'tcx>,
415415
location: Location,
416416
) -> TerminatorEdges<'mir, 'tcx> {
417417
drop_flag_effects_for_location(self.body, self.move_data, location, |path, s| {
418-
Self::update_bits(trans, path, s)
418+
Self::update_bits(state, path, s)
419419
});
420420
if self.skip_unreachable_unwind.contains(location.block) {
421421
let mir::TerminatorKind::Drop { target, unwind, .. } = terminator.kind else { bug!() };
@@ -428,7 +428,7 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
428428

429429
fn apply_call_return_effect(
430430
&mut self,
431-
trans: &mut Self::Domain,
431+
state: &mut Self::Domain,
432432
_block: mir::BasicBlock,
433433
return_places: CallReturnPlaces<'_, 'tcx>,
434434
) {
@@ -439,7 +439,7 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
439439
self.move_data(),
440440
self.move_data().rev_lookup.find(place.as_ref()),
441441
|mpi| {
442-
trans.kill(mpi);
442+
state.kill(mpi);
443443
},
444444
);
445445
});
@@ -468,7 +468,7 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
468468
};
469469

470470
let mut discriminants = enum_def.discriminants(self.tcx);
471-
edge_effects.apply(|trans, edge| {
471+
edge_effects.apply(|state, edge| {
472472
let Some(value) = edge.value else {
473473
return;
474474
};
@@ -486,7 +486,7 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
486486
self.move_data(),
487487
enum_place,
488488
variant,
489-
|mpi| trans.gen_(mpi),
489+
|mpi| state.gen_(mpi),
490490
);
491491
});
492492
}
@@ -512,10 +512,10 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
512512
}
513513
}
514514

515-
#[instrument(skip(self, trans), level = "debug")]
515+
#[instrument(skip(self, state), level = "debug")]
516516
fn apply_statement_effect(
517517
&mut self,
518-
trans: &mut Self::Domain,
518+
state: &mut Self::Domain,
519519
stmt: &mir::Statement<'tcx>,
520520
location: Location,
521521
) {
@@ -525,7 +525,7 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
525525
let rev_lookup = &move_data.rev_lookup;
526526

527527
debug!("initializes move_indexes {:?}", init_loc_map[location]);
528-
trans.gen_all(init_loc_map[location].iter().copied());
528+
state.gen_all(init_loc_map[location].iter().copied());
529529

530530
if let mir::StatementKind::StorageDead(local) = stmt.kind {
531531
// End inits for StorageDead, so that an immutable variable can
@@ -535,15 +535,15 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
535535
"clears the ever initialized status of {:?}",
536536
init_path_map[move_path_index]
537537
);
538-
trans.kill_all(init_path_map[move_path_index].iter().copied());
538+
state.kill_all(init_path_map[move_path_index].iter().copied());
539539
}
540540
}
541541
}
542542

543-
#[instrument(skip(self, trans, terminator), level = "debug")]
543+
#[instrument(skip(self, state, terminator), level = "debug")]
544544
fn apply_terminator_effect<'mir>(
545545
&mut self,
546-
trans: &mut Self::Domain,
546+
state: &mut Self::Domain,
547547
terminator: &'mir mir::Terminator<'tcx>,
548548
location: Location,
549549
) -> TerminatorEdges<'mir, 'tcx> {
@@ -552,7 +552,7 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
552552
let init_loc_map = &move_data.init_loc_map;
553553
debug!(?term);
554554
debug!("initializes move_indexes {:?}", init_loc_map[location]);
555-
trans.gen_all(
555+
state.gen_all(
556556
init_loc_map[location]
557557
.iter()
558558
.filter(|init_index| {
@@ -565,7 +565,7 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
565565

566566
fn apply_call_return_effect(
567567
&mut self,
568-
trans: &mut Self::Domain,
568+
state: &mut Self::Domain,
569569
block: mir::BasicBlock,
570570
_return_places: CallReturnPlaces<'_, 'tcx>,
571571
) {
@@ -574,7 +574,7 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
574574

575575
let call_loc = self.body.terminator_loc(block);
576576
for init_index in &init_loc_map[call_loc] {
577-
trans.gen_(*init_index);
577+
state.gen_(*init_index);
578578
}
579579
}
580580
}

0 commit comments

Comments
 (0)