Best practices around verification
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
In the readme it notes:
>Panic detection happens at link time across the entire dependency graph, so any Cargo commands that do not invoke a linker will not trigger panic detection. This includes cargo build of library crates and cargo check of binary and library crates.
This can be frustrating when developing a library as running the linker is not part of normal work flow.
I've found a good way to ensure this does not get overlooked. A good way to do this is rather than annotating the actual code, creating a wrapper function that is annotated with:
```
#[inline(never)]
#[no_panic]
#[cfg(test)]
```
And then have a test that calls it passing whatever parameters are needed. The inline(never) should prevent any constants from the test from getting inlined, which might not cover the panicking code path. The build will then fail any time `cargo test` is run.
It might be good to show an example working this way using a test rather than a main() because it is easy to not end up running the linker when developing a library.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.