Skip to content

Commit

Permalink
Use cfg_if instead of if(cfg!()) (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
zgrannan authored May 13, 2024
1 parent 742ce2d commit 39c876f
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions vir/src/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ impl<'tcx> VirCtxt<'tcx> {
))
)
);
if cfg!(debug_assertions) {
check_expr_bindings(&mut HashMap::new(), let_expr);
cfg_if! {
if #[cfg(debug_assertions)] {
check_expr_bindings(&mut HashMap::new(), let_expr);
}
}
let_expr
}
Expand Down Expand Up @@ -442,12 +444,14 @@ impl<'tcx> VirCtxt<'tcx> {
// TODO: Typecheck pre and post conditions
if let Some(body) = expr {
assert!(body.ty() == ret);
if cfg!(debug_assertions) {
let mut m = HashMap::new();
for arg in args {
m.insert(arg.name, arg.ty);
cfg_if! {
if #[cfg(debug_assertions)] {
let mut m = HashMap::new();
for arg in args {
m.insert(arg.name, arg.ty);
}
check_expr_bindings(&mut m, body);
}
check_expr_bindings(&mut m, body);
}
}
self.alloc(FunctionGenData {
Expand Down Expand Up @@ -665,15 +669,17 @@ impl<'tcx> VirCtxt<'tcx> {
posts: &'vir [ExprGen<'vir, Curr, Next>],
blocks: Option<&'vir [CfgBlockGen<'vir, Curr, Next>]>, // first one is the entrypoint
) -> MethodGen<'vir, Curr, Next> {
if cfg!(debug_assertions) {
if let Some(blocks) = blocks {
let mut m = HashMap::new();
for arg in args {
m.insert(arg.name, arg.ty);
}
for block in blocks {
for stmt in block.stmts {
check_stmt_bindings(&mut m, stmt);
cfg_if! {
if #[cfg(debug_assertions)] {
if let Some(blocks) = blocks {
let mut m = HashMap::new();
for arg in args {
m.insert(arg.name, arg.ty);
}
for block in blocks {
for stmt in block.stmts {
check_stmt_bindings(&mut m, stmt);
}
}
}
}
Expand Down

0 comments on commit 39c876f

Please sign in to comment.