Skip to content

Commit

Permalink
Prefer if cfg!.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Mar 19, 2023
1 parent 0e866af commit e5a55dc
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions compiler/rustc_mir_transform/src/const_prop.rs
Original file line number Diff line number Diff line change
@@ -989,12 +989,13 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
self.ecx.machine.written_only_inside_own_block_locals =
written_only_inside_own_block_locals;

#[cfg(debug_assertions)]
for (local, &mode) in self.ecx.machine.can_const_prop.iter_enumerated() {
match mode {
ConstPropMode::FullConstProp => {}
ConstPropMode::NoPropagation | ConstPropMode::OnlyInsideOwnBlock => {
self.ensure_not_propagated(local);
if cfg!(debug_assertions) {
for (local, &mode) in self.ecx.machine.can_const_prop.iter_enumerated() {
match mode {
ConstPropMode::FullConstProp => {}
ConstPropMode::NoPropagation | ConstPropMode::OnlyInsideOwnBlock => {
self.ensure_not_propagated(local);
}
}
}
}
13 changes: 7 additions & 6 deletions compiler/rustc_mir_transform/src/const_prop_lint.rs
Original file line number Diff line number Diff line change
@@ -708,12 +708,13 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
self.ecx.machine.written_only_inside_own_block_locals =
written_only_inside_own_block_locals;

#[cfg(debug_assertions)]
for (local, &mode) in self.ecx.machine.can_const_prop.iter_enumerated() {
match mode {
ConstPropMode::FullConstProp => {}
ConstPropMode::NoPropagation | ConstPropMode::OnlyInsideOwnBlock => {
self.ensure_not_propagated(local);
if cfg!(debug_assertions) {
for (local, &mode) in self.ecx.machine.can_const_prop.iter_enumerated() {
match mode {
ConstPropMode::FullConstProp => {}
ConstPropMode::NoPropagation | ConstPropMode::OnlyInsideOwnBlock => {
self.ensure_not_propagated(local);
}
}
}
}

0 comments on commit e5a55dc

Please sign in to comment.