Skip to content

Commit

Permalink
various small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zgrannan committed Aug 28, 2024
1 parent 03b324f commit d7f0a40
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/borrows/borrows_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,15 @@ impl<'tcx> BorrowsGraph<'tcx> {
});
}

fn mut_maybe_old_places(&mut self, mut f: impl FnMut(&mut MaybeOldPlace<'tcx>) -> bool) -> bool {
fn mut_maybe_old_places(
&mut self,
mut f: impl FnMut(&mut MaybeOldPlace<'tcx>) -> bool,
) -> bool {
self.mut_edges(|edge| {
let maybe_old_places: Vec<&mut MaybeOldPlace<'tcx>> = match edge.mut_kind() {
BorrowsEdgeKind::Reborrow(reborrow) => vec![&mut reborrow.blocked_place, &mut reborrow.assigned_place],
BorrowsEdgeKind::Reborrow(reborrow) => {
vec![&mut reborrow.blocked_place, &mut reborrow.assigned_place]
}
BorrowsEdgeKind::DerefExpansion(de) => vec![de.mut_base()],
BorrowsEdgeKind::RegionAbstraction(ra) => ra.maybe_old_places(),
BorrowsEdgeKind::RegionProjectionMember(_) => todo!(),
Expand Down Expand Up @@ -385,7 +390,6 @@ impl<'tcx, T: ToJsonWithRepacker<'tcx>> ToJsonWithRepacker<'tcx> for Conditioned
}

impl<'tcx> BorrowsEdge<'tcx> {

/// true iff any of the blocked places can be mutated via the blocking places
pub fn is_shared_borrow(&self) -> bool {
self.kind.is_shared_borrow()
Expand Down Expand Up @@ -495,7 +499,9 @@ impl<'tcx> BorrowsEdgeKind<'tcx> {
BorrowsEdgeKind::DerefExpansion(de) => de.expansion(repacker).into_iter().collect(),
BorrowsEdgeKind::RegionAbstraction(ra) => ra.blocked_by_places(),
BorrowsEdgeKind::RegionProjectionMember(member) => match member.direction {
RegionProjectionMemberDirection::PlaceIsRegionInput => FxHashSet::default(),
RegionProjectionMemberDirection::PlaceIsRegionInput => {
vec![member.projection.place].into_iter().collect()
}
RegionProjectionMemberDirection::PlaceIsRegionOutput => {
vec![member.place].into_iter().collect()
}
Expand Down
7 changes: 6 additions & 1 deletion src/borrows/borrows_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,24 @@ pub enum RegionProjectionMemberDirection {
pub struct RegionProjectionMember<'tcx> {
pub place: MaybeOldPlace<'tcx>,
pub projection: RegionProjection<'tcx>,
pub location: Location,
location: Location,
pub direction: RegionProjectionMemberDirection,
}

impl<'tcx> RegionProjectionMember<'tcx> {
pub fn make_place_old(&mut self, place: Place<'tcx>, latest: &Latest<'tcx>) {
self.place.make_place_old(place, latest);
self.projection.make_place_old(place, latest);
}

pub fn projection_index(&self, repacker: PlaceRepacker<'_, 'tcx>) -> usize {
self.projection.index(repacker)
}

pub fn location(&self) -> Location {
self.location
}

pub fn new(
place: MaybeOldPlace<'tcx>,
projection: RegionProjection<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion src/borrows/borrows_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ impl<'tcx, 'mir, 'state> Visitor<'tcx> for BorrowsVisitor<'tcx, 'mir, 'state> {
self.state.after.set_latest((*target).into(), location);
match rvalue {
Rvalue::Aggregate(box kind, fields) => match kind {
AggregateKind::Adt(_def_id, _variant_idx, _substs, _, _) => {
AggregateKind::Adt(..) | AggregateKind::Tuple => {
let target: utils::Place<'tcx> = (*target).into();
for (_idx, field) in fields.iter_enumerated() {
match field.ty(self.body, self.tcx).kind() {
Expand Down
1 change: 1 addition & 0 deletions src/borrows/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ impl<'tcx> RegionProjection<'tcx> {
Self { place, region }
}
pub fn make_place_old(&mut self, place: Place<'tcx>, latest: &Latest<'tcx>) {
eprintln!("[projection] make_place_old {:?} {:?}", place, self.place);
self.place.make_place_old(place, latest);
}
pub fn index(&self, repacker: PlaceRepacker<'_, 'tcx>) -> usize {
Expand Down

0 comments on commit d7f0a40

Please sign in to comment.