Use PlaceRef more consistently in rustc_mir

This commit is contained in:
Olivia Crain 2021-01-09 23:33:38 -06:00
parent 410a546fc5
commit 65b5e4386b
10 changed files with 103 additions and 124 deletions

View file

@ -518,14 +518,10 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
// Check if we are assigning into a field of a union, if so, lookup the place
// of the union so it is marked as initialized again.
if let [proj_base @ .., ProjectionElem::Field(_, _)] = place.projection {
if let ty::Adt(def, _) =
Place::ty_from(place.local, proj_base, self.builder.body, self.builder.tcx)
.ty
.kind()
{
if let Some((place_base, ProjectionElem::Field(_, _))) = place.last_projection() {
if let ty::Adt(def, _) = place_base.ty(self.builder.body, self.builder.tcx).ty.kind() {
if def.is_union() {
place = PlaceRef { local: place.local, projection: proj_base }
place = place_base;
}
}
}