Make move_path_children_matching closure take a PlaceElem instead of a slice
This commit is contained in:
parent
7efee8dd05
commit
b04e6c7344
2 changed files with 16 additions and 16 deletions
|
@ -10,14 +10,17 @@ pub fn move_path_children_matching<'tcx, F>(move_data: &MoveData<'tcx>,
|
|||
path: MovePathIndex,
|
||||
mut cond: F)
|
||||
-> Option<MovePathIndex>
|
||||
where F: FnMut(&[mir::PlaceElem<'tcx>]) -> bool
|
||||
where F: FnMut(&mir::PlaceElem<'tcx>) -> bool
|
||||
{
|
||||
let mut next_child = move_data.move_paths[path].first_child;
|
||||
while let Some(child_index) = next_child {
|
||||
if cond(&move_data.move_paths[child_index].place.projection) {
|
||||
return Some(child_index)
|
||||
let move_path_children = &move_data.move_paths[child_index];
|
||||
if let Some(elem) = move_path_children.place.projection.last() {
|
||||
if cond(elem) {
|
||||
return Some(child_index)
|
||||
}
|
||||
}
|
||||
next_child = move_data.move_paths[child_index].next_sibling;
|
||||
next_child = move_path_children.next_sibling;
|
||||
}
|
||||
|
||||
None
|
||||
|
|
|
@ -236,18 +236,18 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> {
|
|||
}
|
||||
|
||||
fn field_subpath(&self, path: Self::Path, field: Field) -> Option<Self::Path> {
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |p| match p {
|
||||
[.., ProjectionElem::Field(idx, _)] => *idx == field,
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| match e {
|
||||
ProjectionElem::Field(idx, _) => *idx == field,
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
||||
fn array_subpath(&self, path: Self::Path, index: u32, size: u32) -> Option<Self::Path> {
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |p| match p {
|
||||
[.., ProjectionElem::ConstantIndex { offset, min_length: _, from_end: false }] => {
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| match e {
|
||||
ProjectionElem::ConstantIndex { offset, min_length: _, from_end: false } => {
|
||||
*offset == index
|
||||
}
|
||||
[.., ProjectionElem::ConstantIndex { offset, min_length: _, from_end: true }] => {
|
||||
ProjectionElem::ConstantIndex { offset, min_length: _, from_end: true } => {
|
||||
size - offset == index
|
||||
}
|
||||
_ => false,
|
||||
|
@ -255,17 +255,14 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> {
|
|||
}
|
||||
|
||||
fn deref_subpath(&self, path: Self::Path) -> Option<Self::Path> {
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |p| {
|
||||
match p {
|
||||
[.., ProjectionElem::Deref] => true,
|
||||
_ => false
|
||||
}
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| {
|
||||
*e == ProjectionElem::Deref
|
||||
})
|
||||
}
|
||||
|
||||
fn downcast_subpath(&self, path: Self::Path, variant: VariantIdx) -> Option<Self::Path> {
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |p| match p {
|
||||
[.., ProjectionElem::Downcast(_, idx)] => *idx == variant,
|
||||
dataflow::move_path_children_matching(self.ctxt.move_data(), path, |e| match e {
|
||||
ProjectionElem::Downcast(_, idx) => *idx == variant,
|
||||
_ => false
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue