/// 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`.
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);
}
}
}