Skip to content

Commit dc41851

Browse files
committed
Fixed nits from PR review #49392
1 parent 4954e3e commit dc41851

File tree

1 file changed

+10
-6
lines changed
  • src/librustc_mir/borrow_check

1 file changed

+10
-6
lines changed

src/librustc_mir/borrow_check/mod.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
13061306
}
13071307
}
13081308

1309-
fn check_if_path_is_moved(
1309+
fn check_if_full_path_is_moved(
13101310
&mut self,
13111311
context: Context,
13121312
desired_action: InitializationRequiringAction,
@@ -1355,7 +1355,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
13551355
//
13561356
// This code covers scenarios 1, 2, and 3.
13571357

1358-
debug!("check_if_path_is_moved place: {:?}", place);
1358+
debug!("check_if_full_path_is_moved place: {:?}", place);
13591359
match self.move_path_closest_to(place) {
13601360
Ok(mpi) => {
13611361
if maybe_uninits.contains(&mpi) {
@@ -1399,7 +1399,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
13991399
// 1. Move of `a.b.c`, use of `a` or `a.b`
14001400
// partial initialization support, one might have `a.x`
14011401
// initialized but not `a.b`.
1402-
// 2. All bad scenarios from `check_if_path_is_moved`
1402+
// 2. All bad scenarios from `check_if_full_path_is_moved`
14031403
//
14041404
// OK scenarios:
14051405
//
@@ -1409,7 +1409,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
14091409
// must have been initialized for the use to be sound.
14101410
// 6. Move of `a.b.c` then reinit of `a.b.c.d`, use of `a.b.c.d`
14111411

1412-
self.check_if_path_is_moved(context, desired_action, place_span, flow_state);
1412+
self.check_if_full_path_is_moved(context, desired_action, place_span, flow_state);
14131413

14141414
// A move of any shallow suffix of `place` also interferes
14151415
// with an attempt to use `place`. This is scenario 3 above.
@@ -1494,17 +1494,21 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
14941494
match *elem {
14951495
ProjectionElem::Index(_/*operand*/) |
14961496
ProjectionElem::ConstantIndex { .. } |
1497-
// assigning to P[i] requires `P` initialized.
1497+
// assigning to P[i] requires P to be valid.
14981498
ProjectionElem::Downcast(_/*adt_def*/, _/*variant_idx*/) =>
14991499
// assigning to (P->variant) is okay if assigning to `P` is okay
15001500
//
15011501
// FIXME: is this true even if P is a adt with a dtor?
15021502
{ }
15031503

1504+
// assigning to (*P) requires P to be initialized
15041505
ProjectionElem::Deref => {
1505-
self.check_if_path_is_moved(
1506+
self.check_if_full_path_is_moved(
15061507
context, InitializationRequiringAction::Use,
15071508
(base, span), flow_state);
1509+
// (base initialized; no need to
1510+
// recur further)
1511+
break;
15081512
}
15091513

15101514
ProjectionElem::Subslice { .. } => {

0 commit comments

Comments
 (0)