Documentation tests can now compile-fail
You can now create compile-fail
tests in Rustdoc, like this:
/// ```compile_fail
/// let x = 5;
/// x += 2; // shouldn't compile!
/// ```
# fn foo() {}
Please note that these kinds of tests can be more fragile than others, asadditions to Rust may cause code to compile when it previously would not.Consider the first release with ?
, for example: code using ?
would failto compile on Rust 1.21, but compile successfully on Rust 1.22, causing yourtest suite to start failing.