-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add unnecessary_import_braces lint. #16931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
could it check for unneccessary brackets around closures? fn do_a_thing() -> || -> int {
|| { 2 } // This warns
} |
@sinistersnare No, I've never be aware of such unnecessary brackets. |
that actually does not compile, but something like that. hopefully someone can give a working example, i just wanted to throw in my 2 cents. |
I'll try to check such expressions if it is also desired. Any working example should be nice. I wrote this lint because I always search commas when I see |
I agree that this might be useful, but it can have more uses that originally intended too! |
Indeed. I'll dig into libsyntax to find more and more unnecessary brackets... |
The name of this lint is slightly confusing— I also think that this shouldn’t detect unnecessary braces around closures. I’ve seen a lot of code that uses braces when it doesn’t strictly need to, but it really does make it clearer and easier to add more statements, especially if it spans multiple lines. If such a lint were to be added, it should be part of the But overall, this is a good idea. I see unnecessary |
'Brackets' are I vote for allow-by-default. With globs being discouraged I've reflexively started using braces anticipating that I'll need to add imports as I go. |
I'm sorry for inaccurate wording. The lint is renamed to |
@sinistersnare After a minute of thought, I have an opinion that redundant braces around expressions and ones in use statements are different kinds of style issue. |
The lint checks any unnecessary braces around one imported item like `use std::num::{abs};`. Signed-off-by: OGINO Masanori <[email protected]>
I decided to purge the second commit and make the lint allow-by-default for now. r? |
This PR adds a lint path checking unnecessary brackets around single imported item. (ex.
use std::num::{abs};
)I was unsure whether the lint should be allow-by-default or warn-by-default, so I split changes into two commits. If the lint itself is OK but it shouldn't be warn-by-default, then I'll purge the second one. What do you think?