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

@ -753,12 +753,8 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
| ProjectionElem::Field(..)
| ProjectionElem::Index(_) => {
let base_ty = Place::ty_from(place_local, proj_base, self.body, self.tcx).ty;
match base_ty.ty_adt_def() {
Some(def) if def.is_union() => {
self.check_op(ops::UnionAccess);
}
_ => {}
if base_ty.is_union() {
self.check_op(ops::UnionAccess);
}
}
}