Skip to content

Commit 552a935

Browse files
committed
guarantee has_no_projection in uniform_array_moveout
1 parent ba7feb1 commit 552a935

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/librustc_mir/transform/uniform_array_move_out.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,19 @@ impl MirPass for RestoreSubsliceArrayMoveOut {
210210
let items : Vec<_> = items.iter().map(|item| {
211211
if let Operand::Move(place) = item {
212212
if let PlaceBase::Local(local) = place.base {
213-
let local_use = &visitor.locals_use[local];
214-
let opt_index_and_place = Self::try_get_item_source(
215-
tcx,
216-
local_use,
217-
mir
218-
);
219-
// each local should be used twice:
220-
// in assign and in aggregate statments
221-
if local_use.use_count == 2 && opt_index_and_place.is_some() {
222-
let (index, src_place) = opt_index_and_place.unwrap();
223-
return Some((local_use, index, src_place));
213+
if place.has_no_projection() {
214+
let local_use = &visitor.locals_use[local];
215+
let opt_index_and_place = Self::try_get_item_source(
216+
tcx,
217+
local_use,
218+
mir
219+
);
220+
// each local should be used twice:
221+
// in assign and in aggregate statments
222+
if local_use.use_count == 2 && opt_index_and_place.is_some() {
223+
let (index, src_place) = opt_index_and_place.unwrap();
224+
return Some((local_use, index, src_place));
225+
}
224226
}
225227
}
226228
}

0 commit comments

Comments
 (0)