-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
unused_braces
] Lint multiline blocks as long as not in arms
Currently the lint faces a severe limitation: since it only catches single-line block, running rustfmt beforehand will remove all occurences of it, because it breaks them into multiline blocks. We do not check match `Arm` for two reasons: - In case it does not use commas to separate arms, removing the block would result in a compilation error Example: ``` match expr { pat => {()} _ => println!("foo") } ``` - Do not lint multiline match arms used for formatting reasons ``` match expr { pat => { somewhat_long_expression } // ... } ``` Delete `unused-braces-lint` test The modified lint correctly provide a span in its suggestion. ```shell error: unnecessary braces around block return value --> /rust/src/test/rustdoc-ui/unused-braces-lint.rs:9:5 | LL | / { LL | | { | |________^ LL | use std; LL | } | __________^ LL | | } | |_____^ | note: the lint level is defined here --> /rust/src/test/rustdoc-ui/unused-braces-lint.rs:6:9 | LL | #![deny(unused_braces)] | ^^^^^^^^^^^^^ help: remove these braces | LL ~ { LL | use std; LL ~ } | ``` It is unclear to which extend #70814 is still an issue, as the inital MCVE does not trigger the lint on stable either,[rust playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b6ff31a449c0b73a08daac8ee43b1fa6) Fix code with expanded `unused_braces` lint Also allow `unused_braces` on tests Mute `unused_braces` on `match_ast!`
- Loading branch information
Showing
32 changed files
with
193 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.