X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_mir%2Fsrc%2Ftransform%2Fpromote_consts.rs;h=78e84419c62cde8cf85337cb23d6b42725c1d7ba;hb=cc77ba46fcb2d288aa01554b48cd586c5827c3dd;hp=f6b1323e107977445a81679dbf846e3afe430d97;hpb=fc81ad22c453776de16acf9938976930cf8c9401;p=rust.git diff --git a/compiler/rustc_mir/src/transform/promote_consts.rs b/compiler/rustc_mir/src/transform/promote_consts.rs index f6b1323e107..78e84419c62 100644 --- a/compiler/rustc_mir/src/transform/promote_consts.rs +++ b/compiler/rustc_mir/src/transform/promote_consts.rs @@ -415,11 +415,9 @@ fn validate_place(&self, place: PlaceRef<'tcx>) -> Result<(), Unpromotable> { ProjectionElem::Field(..) => { let base_ty = place_base.ty(self.body, self.tcx).ty; - if let Some(def) = base_ty.ty_adt_def() { + if base_ty.is_union() { // No promotion of union field accesses. - if def.is_union() { - return Err(Unpromotable); - } + return Err(Unpromotable); } } }