|
2 | 2 |
|
3 | 3 | ## [Unreleased]
|
4 | 4 |
|
| 5 | +## [1.4.26] 2020-11-14 |
| 6 | + |
| 7 | +### Changed |
| 8 | + |
| 9 | +- Original comment indentation for trailing comments within an `if` is now taken into account when determining the indentation level to use for the trailing comment in formatted code. This does not modify any existing code formatted with rustfmt; it simply gives the programmer discretion to specify whether the comment is associated to the `else` block, or if the trailing comment is just a member of the `if` block. ([#1575](https://github.com/rust-lang/rustfmt/issues/1575), [#4120](https://github.com/rust-lang/rustfmt/issues/4120), [#4506](https://github.com/rust-lang/rustfmt/issues/4506)) |
| 10 | + |
| 11 | +In this example the `// else comment` refers to the `else`: |
| 12 | +```rust |
| 13 | +// if comment |
| 14 | +if cond { |
| 15 | + "if" |
| 16 | +// else comment |
| 17 | +} else { |
| 18 | + "else" |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +Whereas in this case the `// continue` comments are members of their respective blocks and do not refer to the `else` below. |
| 23 | +```rust |
| 24 | +if toks.eat_token(Token::Word("modify"))? && toks.eat_token(Token::Word("labels"))? { |
| 25 | + if toks.eat_token(Token::Colon)? { |
| 26 | + // ate the token |
| 27 | + } else if toks.eat_token(Token::Word("to"))? { |
| 28 | + // optionally eat the colon after to, e.g.: |
| 29 | + // @rustbot modify labels to: -S-waiting-on-author, +S-waiting-on-review |
| 30 | + toks.eat_token(Token::Colon)?; |
| 31 | + } else { |
| 32 | + // It's okay if there's no to or colon, we can just eat labels |
| 33 | + // afterwards. |
| 34 | + } |
| 35 | + 1 + 2; |
| 36 | + // continue |
| 37 | +} else if toks.eat_token(Token::Word("label"))? { |
| 38 | + // continue |
| 39 | +} else { |
| 40 | + return Ok(None); |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +### Fixed |
| 45 | +- Formatting of empty blocks with attributes which only contained comments is no longer butchered.([#4475](https://github.com/rust-lang/rustfmt/issues/4475), [#4467](https://github.com/rust-lang/rustfmt/issues/4467), [#4452](https://github.com/rust-lang/rustfmt/issues/4452#issuecomment-705886282), [#4522](https://github.com/rust-lang/rustfmt/issues/4522)) |
| 46 | +- Indentation of trailing comments in non-empty extern blocks is now correct. ([#4120](https://github.com/rust-lang/rustfmt/issues/4120#issuecomment-696491872)) |
| 47 | + |
| 48 | +### Install/Download Options |
| 49 | +- **crates.io package** - *pending* |
| 50 | +- **rustup (nightly)** - *pending* |
| 51 | +- **GitHub Release Binaries** - [Release v1.4.26](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.26) |
| 52 | +- **Build from source** - [Tag v1.4.26](https://github.com/rust-lang/rustfmt/tree/v1.4.26), see instructions for how to [install rustfmt from source][install-from-source] |
| 53 | + |
5 | 54 | ## [1.4.25] 2020-11-10
|
6 | 55 |
|
7 | 56 | ### Changed
|
|
10 | 59 |
|
11 | 60 | ### Install/Download Options
|
12 | 61 | - **crates.io package** - *pending*
|
13 |
| -- **rustup (nightly)** - *pending* |
| 62 | +- **rustup (nightly)** - Starting in `2020-11-14` |
14 | 63 | - **GitHub Release Binaries** - [Release v1.4.25](https://github.com/rust-lang/rustfmt/releases/tag/v1.4.25)
|
15 | 64 | - **Build from source** - [Tag v1.4.25](https://github.com/rust-lang/rustfmt/tree/v1.4.25), see instructions for how to [install rustfmt from source][install-from-source]
|
16 | 65 |
|
|
0 commit comments