1
Fork 0

Add Ty::is_union predicate and use it

This commit is contained in:
Tomasz Miąsko 2021-06-02 00:00:00 +00:00
parent 012c323467
commit c898681a86
10 changed files with 31 additions and 55 deletions

View file

@ -519,10 +519,8 @@ 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 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 = place_base;
}
if place_base.ty(self.builder.body, self.builder.tcx).ty.is_union() {
place = place_base;
}
}