Do not flatten derefs with ProjectionElem::Index.
This commit is contained in:
parent
8a87857320
commit
ebd60b9b8f
3 changed files with 15 additions and 6 deletions
|
|
@ -756,7 +756,13 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
|||
&& let Some(v) = self.simplify_place_value(&mut pointee, location)
|
||||
{
|
||||
value = v;
|
||||
place_ref = pointee.project_deeper(&place.projection[index..], self.tcx).as_ref();
|
||||
// `pointee` holds a `Place`, so `ProjectionElem::Index` holds a `Local`.
|
||||
// That local is SSA, but we otherwise have no guarantee on that local's value at
|
||||
// the current location compared to its value where `pointee` was borrowed.
|
||||
if pointee.projection.iter().all(|elem| !matches!(elem, ProjectionElem::Index(_))) {
|
||||
place_ref =
|
||||
pointee.project_deeper(&place.projection[index..], self.tcx).as_ref();
|
||||
}
|
||||
}
|
||||
if let Some(local) = self.try_as_local(value, location) {
|
||||
// Both `local` and `Place { local: place.local, projection: projection[..index] }`
|
||||
|
|
@ -774,7 +780,12 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
|||
&& let Some(v) = self.simplify_place_value(&mut pointee, location)
|
||||
{
|
||||
value = v;
|
||||
place_ref = pointee.project_deeper(&[], self.tcx).as_ref();
|
||||
// `pointee` holds a `Place`, so `ProjectionElem::Index` holds a `Local`.
|
||||
// That local is SSA, but we otherwise have no guarantee on that local's value at
|
||||
// the current location compared to its value where `pointee` was borrowed.
|
||||
if pointee.projection.iter().all(|elem| !matches!(elem, ProjectionElem::Index(_))) {
|
||||
place_ref = pointee.project_deeper(&[], self.tcx).as_ref();
|
||||
}
|
||||
}
|
||||
if let Some(new_local) = self.try_as_local(value, location) {
|
||||
place_ref = PlaceRef { local: new_local, projection: &[] };
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@
|
|||
+ nop;
|
||||
StorageLive(_8);
|
||||
StorageLive(_9);
|
||||
- _9 = copy (*_3);
|
||||
+ _9 = copy _1[_4];
|
||||
_9 = copy (*_3);
|
||||
_8 = opaque::<u8>(move _9) -> [return: bb2, unwind unreachable];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@
|
|||
+ nop;
|
||||
StorageLive(_8);
|
||||
StorageLive(_9);
|
||||
- _9 = copy (*_3);
|
||||
+ _9 = copy _1[_4];
|
||||
_9 = copy (*_3);
|
||||
_8 = opaque::<u8>(move _9) -> [return: bb2, unwind continue];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue