X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_mir%2Fsrc%2Ftransform%2Fpromote_consts.rs;h=78e84419c62cde8cf85337cb23d6b42725c1d7ba;hb=cc77ba46fcb2d288aa01554b48cd586c5827c3dd;hp=f786f327ba2f503e894b064047b5b9d79d9499ad;hpb=22e1778ec0e7fc77ae465bd0f69ead91447be742;p=rust.git diff --git a/compiler/rustc_mir/src/transform/promote_consts.rs b/compiler/rustc_mir/src/transform/promote_consts.rs index f786f327ba2..78e84419c62 100644 --- a/compiler/rustc_mir/src/transform/promote_consts.rs +++ b/compiler/rustc_mir/src/transform/promote_consts.rs @@ -32,8 +32,8 @@ /// A `MirPass` for promotion. /// -/// Promotion is the extraction of promotable temps into separate MIR bodies. This pass also emits -/// errors when promotion of `#[rustc_args_required_const]` arguments fails. +/// Promotion is the extraction of promotable temps into separate MIR bodies so they can have +/// `'static` lifetime. /// /// After this pass is run, `promoted_fragments` will hold the MIR body corresponding to each /// newly created `Constant`. @@ -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); } } }