You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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).
The text was updated successfully, but these errors were encountered:
(Despite the title of this bug, I suspect the ideal fix would be to have #[test] and libtest differentiate between panics and errors, so that the type-check guard for #[should_panic] is no longer needed. I haven't looked too deeply into what that would involve, though.
Reference to relevant previous issues: #48854, #49909.)
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:
Result:
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)
andrustc 1.50.0-nightly (eb4fc71dc 2020-12-17)
.The text was updated successfully, but these errors were encountered: