Skip to content
Permalink
Browse files

Explicit promotion is indistinguishable from explicit promotion

Implicit promotion on the other hand has very strict rules on what may be done
  • Loading branch information...
oli-obk committed Apr 8, 2019
1 parent 6b01844 commit ec5206588fe31e631d8f8b1d27400f18744b448e
Showing with 8 additions and 10 deletions.
  1. +8 −10 src/librustc_mir/transform/qualify_consts.rs
@@ -508,13 +508,11 @@ impl Qualif for IsNotConst {
}
}

// Refers to temporaries which cannot be promoted as
// promote_consts decided they weren't simple enough.
// FIXME(oli-obk,eddyb): Remove this flag entirely and
// solely process this information via `IsNotConst`.
struct IsNotPromotable;
/// Refers to temporaries which cannot be promoted *implicitly*.
/// Explicit promotion e.g. for constant arguments declared via `rustc_args_required_const`.
struct IsNotImplicitlyPromotable;

impl Qualif for IsNotPromotable {
impl Qualif for IsNotImplicitlyPromotable {
const IDX: usize = 3;

fn in_call(
@@ -550,15 +548,15 @@ macro_rules! static_assert_seq_qualifs {
static_assert!(SEQ_QUALIFS: QUALIF_COUNT == $i);
};
}
static_assert_seq_qualifs!(0 => HasMutInterior, NeedsDrop, IsNotConst, IsNotPromotable);
static_assert_seq_qualifs!(0 => HasMutInterior, NeedsDrop, IsNotConst, IsNotImplicitlyPromotable);

impl ConstCx<'_, 'tcx> {
fn qualifs_in_any_value_of_ty(&self, ty: Ty<'tcx>) -> PerQualif<bool> {
let mut qualifs = PerQualif::default();
qualifs[HasMutInterior] = HasMutInterior::in_any_value_of_ty(self, ty).unwrap_or(false);
qualifs[NeedsDrop] = NeedsDrop::in_any_value_of_ty(self, ty).unwrap_or(false);
qualifs[IsNotConst] = IsNotConst::in_any_value_of_ty(self, ty).unwrap_or(false);
qualifs[IsNotPromotable] = IsNotPromotable::in_any_value_of_ty(self, ty).unwrap_or(false);
qualifs[IsNotImplicitlyPromotable] = IsNotImplicitlyPromotable::in_any_value_of_ty(self, ty).unwrap_or(false);
qualifs
}

@@ -567,7 +565,7 @@ impl ConstCx<'_, 'tcx> {
qualifs[HasMutInterior] = HasMutInterior::in_local(self, local);
qualifs[NeedsDrop] = NeedsDrop::in_local(self, local);
qualifs[IsNotConst] = IsNotConst::in_local(self, local);
qualifs[IsNotPromotable] = IsNotPromotable::in_local(self, local);
qualifs[IsNotImplicitlyPromotable] = IsNotImplicitlyPromotable::in_local(self, local);
qualifs
}

@@ -576,7 +574,7 @@ impl ConstCx<'_, 'tcx> {
qualifs[HasMutInterior] = HasMutInterior::in_value(self, source);
qualifs[NeedsDrop] = NeedsDrop::in_value(self, source);
qualifs[IsNotConst] = IsNotConst::in_value(self, source);
qualifs[IsNotPromotable] = IsNotPromotable::in_value(self, source);
qualifs[IsNotImplicitlyPromotable] = IsNotImplicitlyPromotable::in_value(self, source);
qualifs
}
}

0 comments on commit ec52065

Please sign in to comment.
You can’t perform that action at this time.