Skip to content

Commit b27f307

Browse files
committed
Use AssertKind::fmt_assert_args now that it's pub
See viperproject#467 and rust-lang/rust#84392 for context.
1 parent 575c319 commit b27f307

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

prusti-viper/src/encoder/procedure_encoder.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,14 +2158,8 @@ impl<'p, 'v: 'p, 'tcx: 'v> ProcedureEncoder<'p, 'v, 'tcx> {
21582158
};
21592159

21602160
// Check or assume the assertion
2161-
let assert_msg = if let AssertKind::BoundsCheck{ .. } = msg {
2162-
// Use the debug impl for BoundsCheck, as it is supposed to be handled before
2163-
// calling display() according to the docs
2164-
// TODO: use fmt_assert_args once https://github.com/rust-lang/rust/pull/84392 is merged
2165-
format!("{:?}", msg)
2166-
} else {
2167-
msg.description().to_string()
2168-
};
2161+
let mut assert_msg = String::new();
2162+
msg.fmt_assert_args(&mut assert_msg).unwrap();
21692163

21702164
stmts.push(vir::Stmt::comment(format!("Rust assertion: {}", assert_msg)));
21712165
if self.check_panics {

prusti-viper/src/encoder/pure_function_encoder.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -948,14 +948,9 @@ impl<'p, 'v: 'p, 'tcx: 'v> BackwardMirInterpreter<'tcx>
948948
vir::Expr::not(cond_val)
949949
};
950950

951-
let assert_msg = if let mir::AssertKind::BoundsCheck{ .. } = msg {
952-
// Use the debug impl for BoundsCheck, as it is supposed to be handled before
953-
// calling display() according to the docs
954-
// TODO: use fmt_assert_args once https://github.com/rust-lang/rust/pull/84392 is merged
955-
format!("{:?}", msg)
956-
} else {
957-
msg.description().to_string()
958-
};
951+
let mut assert_msg = String::new();
952+
msg.fmt_assert_args(&mut assert_msg).unwrap();
953+
959954
let pos = self.encoder.error_manager().register(
960955
term.source_info.span,
961956
ErrorCtxt::PureFunctionAssertTerminator(assert_msg),

0 commit comments

Comments
 (0)