Closed
Description
Many times the docs mention an error message in non-compiling Rust code to illustrate a concept. For example, the move semantics chapter illustrates how moves can cause errors.
However, it's possible that the error message may update in the future, or that the code (which is marked as rust,ignore
and doesn't get fed to the doctests) will fall prey to a different error. Both (especially the latter) can be confusing to a newbie.
I propose we add a "cfail" mode to code blocks, which runs the code as a compile-fail test (via compiletest), and will fail the doctest if the error doesn't match. Something like this:
```rust,cfail
let v = vec![1, 2, 3];
let v2 = v;
println!("v[0] is: {}", v[0]);
//~^ ERROR use of moved value `v`
```
We could choose to make the inline error hidden, though it might actually be helpful and could be kept visible.