prusti-dev
prusti-dev copied to clipboard
`prusti_assert` macros incorrect expansion during normal compilation
The following example works when verified by Prusti, but fails when compiled with rustc:
use prusti_contracts::*;
fn test(x: i32) {
match x {
0 => prusti_assert!(x == 0), // <== Error here
_ => assert!(x != 0)
}
}
The error is:
expected expression, found end of macro arguments
prusti_assert_eq and prusti_assert_ne seem to have the similar problem:
fn test_2(x: i32) {
match x {
0 => prusti_assert_eq!(x, 0),
_ => prusti_assert_ne!(x, 0)
}
}
macro expansion ends with an incomplete expression: expected expression
the macro call doesn't expand to an expression, but it can expand to a statement.
add `;` to interpret the expansion as a statement: `;`
Expanding the macros to () should fix this.