The basic idea is this:
-```rust,ignore
+```ignore
/// # Examples
///
/// ```
```text
First, we set `x` to five:
- ```rust
+ ```
let x = 5;
# let y = 6;
# println!("{}", x + y);
Next, we set `y` to six:
- ```rust
+ ```
# let x = 5;
let y = 6;
# println!("{}", x + y);
Finally, we print the sum of `x` and `y`:
- ```rust
+ ```
# let x = 5;
# let y = 6;
println!("{}", x + y);
Another case where the use of `#` is handy is when you want to ignore
error handling. Lets say you want the following,
-```rust,ignore
+```ignore
/// use std::io;
/// let mut input = String::new();
/// io::stdin().read_line(&mut input)?;
The problem is that `?` returns a `Result<T, E>` and test functions
don't return anything so this will give a mismatched types error.
-```rust,ignore
+```ignore
/// A doc test using ?
///
/// ```
/// # }
/// ```
///
-/// ```rust,should_panic
+/// ```should_panic
/// # #[macro_use] extern crate foo;
/// # fn main() {
/// panic_unless!(true == false, “I’m broken.”);
`should_panic` tells `rustdoc` that the code should compile correctly, but
not actually pass as a test.
-```rust
+```text
/// ```no_run
/// loop {
/// println!("Hello, world");
# fn foo() {}
```
+`compile_fail` tells `rustdoc` that the compilation should fail. If it
+compiles, then the test will fail. However please note that code failing
+with the current Rust release may work in a future release, as new features
+are added.
+
+```text
+/// ```compile_fail
+/// let x = 5;
+/// x += 2; // shouldn't compile!
+/// ```
+```
+
The `no_run` attribute will compile your code, but not run it. This is
important for examples such as "Here's how to retrieve a web page,"
which you would want to ensure compiles, but might be run in a test