Skip to content

Commit e5a55dc

Browse files
committed
Prefer if cfg!.
1 parent 0e866af commit e5a55dc

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

compiler/rustc_mir_transform/src/const_prop.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -989,12 +989,13 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
989989
self.ecx.machine.written_only_inside_own_block_locals =
990990
written_only_inside_own_block_locals;
991991

992-
#[cfg(debug_assertions)]
993-
for (local, &mode) in self.ecx.machine.can_const_prop.iter_enumerated() {
994-
match mode {
995-
ConstPropMode::FullConstProp => {}
996-
ConstPropMode::NoPropagation | ConstPropMode::OnlyInsideOwnBlock => {
997-
self.ensure_not_propagated(local);
992+
if cfg!(debug_assertions) {
993+
for (local, &mode) in self.ecx.machine.can_const_prop.iter_enumerated() {
994+
match mode {
995+
ConstPropMode::FullConstProp => {}
996+
ConstPropMode::NoPropagation | ConstPropMode::OnlyInsideOwnBlock => {
997+
self.ensure_not_propagated(local);
998+
}
998999
}
9991000
}
10001001
}

compiler/rustc_mir_transform/src/const_prop_lint.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -708,12 +708,13 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
708708
self.ecx.machine.written_only_inside_own_block_locals =
709709
written_only_inside_own_block_locals;
710710

711-
#[cfg(debug_assertions)]
712-
for (local, &mode) in self.ecx.machine.can_const_prop.iter_enumerated() {
713-
match mode {
714-
ConstPropMode::FullConstProp => {}
715-
ConstPropMode::NoPropagation | ConstPropMode::OnlyInsideOwnBlock => {
716-
self.ensure_not_propagated(local);
711+
if cfg!(debug_assertions) {
712+
for (local, &mode) in self.ecx.machine.can_const_prop.iter_enumerated() {
713+
match mode {
714+
ConstPropMode::FullConstProp => {}
715+
ConstPropMode::NoPropagation | ConstPropMode::OnlyInsideOwnBlock => {
716+
self.ensure_not_propagated(local);
717+
}
717718
}
718719
}
719720
}

0 commit comments

Comments
 (0)