diff options
| author | Peter Hrvola <peter.hrvola@hotmail.com> | 2018-04-01 10:01:51 +0200 |
|---|---|---|
| committer | Peter Hrvola <peter.hrvola@hotmail.com> | 2018-04-01 10:01:51 +0200 |
| commit | dc41851882b4d847308badc7fbb0da4975023bb2 (patch) | |
| tree | cc82435d467062440b97567bf574ae0cf0c92a76 | |
| parent | 4954e3e828377a1034d5e434e0a2b69426497ea4 (diff) | |
| download | rust-dc41851882b4d847308badc7fbb0da4975023bb2.tar.gz rust-dc41851882b4d847308badc7fbb0da4975023bb2.zip | |
Fixed nits from PR review #49392
| -rw-r--r-- | src/librustc_mir/borrow_check/mod.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 46b01f823a9..0e41ede6aa5 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1306,7 +1306,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } - fn check_if_path_is_moved( + fn check_if_full_path_is_moved( &mut self, context: Context, desired_action: InitializationRequiringAction, @@ -1355,7 +1355,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // // This code covers scenarios 1, 2, and 3. - debug!("check_if_path_is_moved place: {:?}", place); + debug!("check_if_full_path_is_moved place: {:?}", place); match self.move_path_closest_to(place) { Ok(mpi) => { if maybe_uninits.contains(&mpi) { @@ -1399,7 +1399,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // 1. Move of `a.b.c`, use of `a` or `a.b` // partial initialization support, one might have `a.x` // initialized but not `a.b`. - // 2. All bad scenarios from `check_if_path_is_moved` + // 2. All bad scenarios from `check_if_full_path_is_moved` // // OK scenarios: // @@ -1409,7 +1409,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // must have been initialized for the use to be sound. // 6. Move of `a.b.c` then reinit of `a.b.c.d`, use of `a.b.c.d` - self.check_if_path_is_moved(context, desired_action, place_span, flow_state); + self.check_if_full_path_is_moved(context, desired_action, place_span, flow_state); // A move of any shallow suffix of `place` also interferes // with an attempt to use `place`. This is scenario 3 above. @@ -1494,17 +1494,21 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { match *elem { ProjectionElem::Index(_/*operand*/) | ProjectionElem::ConstantIndex { .. } | - // assigning to P[i] requires `P` initialized. + // assigning to P[i] requires P to be valid. ProjectionElem::Downcast(_/*adt_def*/, _/*variant_idx*/) => // assigning to (P->variant) is okay if assigning to `P` is okay // // FIXME: is this true even if P is a adt with a dtor? { } + // assigning to (*P) requires P to be initialized ProjectionElem::Deref => { - self.check_if_path_is_moved( + self.check_if_full_path_is_moved( context, InitializationRequiringAction::Use, (base, span), flow_state); + // (base initialized; no need to + // recur further) + break; } ProjectionElem::Subslice { .. } => { |
