Doctests were disabled globally because up until #2456, they were just
formatting examples which were not supposed to compile. Now that there
is one runnable doctest, I disabled the other ones individually (by
adding the ignore directive).
I also added some empty lines around the code blocks to avoid the
following warning and instead ignore the code blocks cleanly:
WARNING: ... Code block is not currently run as a test, but will in
future versions of rustdoc. Please ensure this code block is a runnable
test, or use the `ignore` directive.
See rust-lang/rust#28712 for further details.
Previously, cargo fmt invoked without parameters would
only format the crate in the current directory, even if
the crate was part of a workspace. This patch restores
that behavior.
`format_code_block` formats the given `code_snippet` by enclosing it inside
`fn main` block. Previously we did not add indentation to the `code_snippet`
before formatting it. This works fine as long as we can format the given
`code_snippet`, but when the code block has unformattable macro, they gets
unindented. This commit fixes it by adding proper indentation before formatting
the `code_snippet`.
For example, when formatting the following code block,
```rust
some_macro!(pub fn foo() {
println!("Don't unindent me!");
});
```
previously we enclosed it like this:
```rust
fn main() {
some_macro!(pub fn foo() {
println!("Don't unindent me!");
});
}
```
with this PR, we will enclose it like this:
```rust
fn main() {
some_macro!(pub fn foo() {
println!("Don't unindent me!");
});
}
```
Closes#2523.
This commit adds `overflow` module. This module provides two APIs.
`rewrite_with_parens` is basically the same as `rewrite_call_inner`.
`rewrite_with_angle_brackets` is used for rewriting generics and types.
For example, with the following config file, rustfmt will ignore `src/types.rs`,
`src/foo/bar.rs` and every file under `examples/` directory.
```toml
[ignore]
files = [
"src/types.rs",
"src/foo/bar.rs",
]
directories = [
"examples",
]
```