Open
Description
When a procedural macro which transforms the return type of a function from ... -> SomeType
to -> ()
is applied, the resulting function can be used with the attribute #[test]
as expected. However, adding the attribute #[should_panic]
to that test results in a compile-time error.
A (slightly simplified) motivating example:
#[test]
#[should_panic]
#[test_utils::matches_image("tests/data/blue_pixel.png")]
fn fails_on_mismatching_data() -> Box<[u32]> {
Box::new([0; 1])
}
Result:
error: functions using `#[should_panic]` must return `()`
As a simple workaround, the transformed function can be wrapped with a separate #[test] #[should_panic]
function returning ()
and invoked manually within that.
Tested on rustc 1.48.0 (7eac88abb 2020-11-16)
and rustc 1.50.0-nightly (eb4fc71dc 2020-12-17)
.