diff options
| author | Eric Mark Martin <ericmarkmartin@gmail.com> | 2023-06-25 20:38:01 -0400 |
|---|---|---|
| committer | Eric Mark Martin <ericmarkmartin@gmail.com> | 2023-06-25 20:38:01 -0400 |
| commit | c07c10d1e424d01e61c5900ec0700dd4c3caadb6 (patch) | |
| tree | 7b57baa9e2151db389cf81f49ed03065788e3990 /compiler/rustc_mir_dataflow/src | |
| parent | 0c2c243342ec2a2427f0624fac5ac59f0ee6fbcd (diff) | |
| download | rust-c07c10d1e424d01e61c5900ec0700dd4c3caadb6.tar.gz rust-c07c10d1e424d01e61c5900ec0700dd4c3caadb6.zip | |
use PlaceRef abstractions more consistently
Diffstat (limited to 'compiler/rustc_mir_dataflow/src')
| -rw-r--r-- | compiler/rustc_mir_dataflow/src/move_paths/builder.rs | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs index 096bc0acfcc..7cdd3a21aca 100644 --- a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs +++ b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs @@ -113,22 +113,16 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { // from `*(u.f: &_)` isn't allowed. let mut union_path = None; - for (i, elem) in place.projection.iter().enumerate() { - let proj_base = &place.projection[..i]; + for (place_ref, elem) in place.as_ref().iter_projections() { let body = self.builder.body; let tcx = self.builder.tcx; - let place_ty = Place::ty_from(place.local, proj_base, body, tcx).ty; + let place_ty = place_ref.ty(body, tcx).ty; + match place_ty.kind() { ty::Ref(..) | ty::RawPtr(..) => { - let proj = &place.projection[..i + 1]; return Err(MoveError::cannot_move_out_of( self.loc, - BorrowedContent { - target_place: Place { - local: place.local, - projection: tcx.mk_place_elems(proj), - }, - }, + BorrowedContent { target_place: place_ref.project_deeper(&[elem], tcx) }, )); } ty::Adt(adt, _) if adt.has_dtor(tcx) && !adt.is_box() => { @@ -163,10 +157,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { }; if union_path.is_none() { - base = self.add_move_path(base, elem, |tcx| Place { - local: place.local, - projection: tcx.mk_place_elems(&place.projection[..i + 1]), - }); + base = self.add_move_path(base, elem, |tcx| place_ref.project_deeper(&[elem], tcx)); } } |
