@@ -1306,7 +1306,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1306
1306
}
1307
1307
}
1308
1308
1309
- fn check_if_path_is_moved (
1309
+ fn check_if_full_path_is_moved (
1310
1310
& mut self ,
1311
1311
context : Context ,
1312
1312
desired_action : InitializationRequiringAction ,
@@ -1355,7 +1355,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1355
1355
//
1356
1356
// This code covers scenarios 1, 2, and 3.
1357
1357
1358
- debug ! ( "check_if_path_is_moved place: {:?}" , place) ;
1358
+ debug ! ( "check_if_full_path_is_moved place: {:?}" , place) ;
1359
1359
match self . move_path_closest_to ( place) {
1360
1360
Ok ( mpi) => {
1361
1361
if maybe_uninits. contains ( & mpi) {
@@ -1399,7 +1399,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1399
1399
// 1. Move of `a.b.c`, use of `a` or `a.b`
1400
1400
// partial initialization support, one might have `a.x`
1401
1401
// 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 `
1403
1403
//
1404
1404
// OK scenarios:
1405
1405
//
@@ -1409,7 +1409,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1409
1409
// must have been initialized for the use to be sound.
1410
1410
// 6. Move of `a.b.c` then reinit of `a.b.c.d`, use of `a.b.c.d`
1411
1411
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) ;
1413
1413
1414
1414
// A move of any shallow suffix of `place` also interferes
1415
1415
// with an attempt to use `place`. This is scenario 3 above.
@@ -1494,17 +1494,21 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1494
1494
match * elem {
1495
1495
ProjectionElem :: Index ( _/*operand*/ ) |
1496
1496
ProjectionElem :: ConstantIndex { .. } |
1497
- // assigning to P[i] requires `P` initialized .
1497
+ // assigning to P[i] requires P to be valid .
1498
1498
ProjectionElem :: Downcast ( _/*adt_def*/ , _/*variant_idx*/ ) =>
1499
1499
// assigning to (P->variant) is okay if assigning to `P` is okay
1500
1500
//
1501
1501
// FIXME: is this true even if P is a adt with a dtor?
1502
1502
{ }
1503
1503
1504
+ // assigning to (*P) requires P to be initialized
1504
1505
ProjectionElem :: Deref => {
1505
- self . check_if_path_is_moved (
1506
+ self . check_if_full_path_is_moved (
1506
1507
context, InitializationRequiringAction :: Use ,
1507
1508
( base, span) , flow_state) ;
1509
+ // (base initialized; no need to
1510
+ // recur further)
1511
+ break ;
1508
1512
}
1509
1513
1510
1514
ProjectionElem :: Subslice { .. } => {
0 commit comments