Skip to content

Commit

Permalink
Check for ConstantIndex move paths correctly in borrowck
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed Dec 9, 2019
1 parent 96dc03b commit cab7af9
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1738,25 +1738,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
/// static variable, as we do not track those in the MoveData.
fn move_path_closest_to(
&mut self,
place: PlaceRef<'cx, 'tcx>,
place: PlaceRef<'_, 'tcx>,
) -> Result<(PlaceRef<'cx, 'tcx>, MovePathIndex), NoMovePathFound> {
let mut last_prefix = place.base;

for prefix in self.prefixes(place, PrefixSet::All) {
if let Some(mpi) = self.move_path_for_place(prefix) {
return Ok((prefix, mpi));
}

last_prefix = prefix.base;
}

match last_prefix {
PlaceBase::Local(_) => panic!("should have move path for every Local"),
PlaceBase::Static(_) => Err(NoMovePathFound::ReachedStatic),
match self.move_data.rev_lookup.find(place) {
LookupResult::Parent(Some(mpi))
| LookupResult::Exact(mpi) => Ok((self.move_data.move_paths[mpi].place.as_ref(), mpi)),
LookupResult::Parent(None) => Err(NoMovePathFound::ReachedStatic),
}
}

fn move_path_for_place(&mut self, place: PlaceRef<'cx, 'tcx>) -> Option<MovePathIndex> {
fn move_path_for_place(&mut self, place: PlaceRef<'_, 'tcx>) -> Option<MovePathIndex> {
// If returns None, then there is no move path corresponding
// to a direct owner of `place` (which means there is nothing
// that borrowck tracks for its analysis).
Expand Down

0 comments on commit cab7af9

Please sign in to comment.