Skip to content

Commit ec52065

Browse files
committed
Explicit promotion is indistinguishable from explicit promotion
Implicit promotion on the other hand has very strict rules on what may be done
1 parent 6b01844 commit ec52065

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,11 @@ impl Qualif for IsNotConst {
508508
}
509509
}
510510

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

517-
impl Qualif for IsNotPromotable {
515+
impl Qualif for IsNotImplicitlyPromotable {
518516
const IDX: usize = 3;
519517

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

555553
impl ConstCx<'_, 'tcx> {
556554
fn qualifs_in_any_value_of_ty(&self, ty: Ty<'tcx>) -> PerQualif<bool> {
557555
let mut qualifs = PerQualif::default();
558556
qualifs[HasMutInterior] = HasMutInterior::in_any_value_of_ty(self, ty).unwrap_or(false);
559557
qualifs[NeedsDrop] = NeedsDrop::in_any_value_of_ty(self, ty).unwrap_or(false);
560558
qualifs[IsNotConst] = IsNotConst::in_any_value_of_ty(self, ty).unwrap_or(false);
561-
qualifs[IsNotPromotable] = IsNotPromotable::in_any_value_of_ty(self, ty).unwrap_or(false);
559+
qualifs[IsNotImplicitlyPromotable] = IsNotImplicitlyPromotable::in_any_value_of_ty(self, ty).unwrap_or(false);
562560
qualifs
563561
}
564562

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

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

0 commit comments

Comments
 (0)