Skip to content
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

Consider extending unused_parens to {}, particularly in const generics #68387

Closed
varkor opened this issue Jan 20, 2020 · 1 comment · Fixed by #70081
Closed

Consider extending unused_parens to {}, particularly in const generics #68387

varkor opened this issue Jan 20, 2020 · 1 comment · Fixed by #70081
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@varkor
Copy link
Member

varkor commented Jan 20, 2020

In const generics, {} are required for complex expressions in const generic arguments (e.g. {M + N}). They are not required, however, for literals and standalone parameters (in most cases). However, at least at the moment, it is quite common to see curly brackets in user code for all generic arguments. This may be a passing phase, as generic arguments only recently started being disambiguated; however, if it is not, we might want to lint on extraneous {} to inform users.

This might be useful outside of const generis too, such as in:

let _ = (5); // lints about unnecessary parens
let _ = {5}; // does not lint
@varkor varkor added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. A-const-generics Area: const generics (parameters and arguments) labels Jan 20, 2020
@eddyb
Copy link
Member

eddyb commented Jan 21, 2020

I think it makes sense to lint any leaf expressions wrapped in braces.

@JohnTitor JohnTitor added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jan 26, 2020
@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Feb 5, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 30, 2020
add `unused_braces` lint

Add the lint `unused_braces` which is warn by default.

`unused_parens` is also extended and now checks anon consts.

closes rust-lang#68387

r? @varkor
Centril added a commit to Centril/rust that referenced this issue Mar 31, 2020
add `unused_braces` lint

Add the lint `unused_braces` which is warn by default.

`unused_parens` is also extended and now checks anon consts.

closes rust-lang#68387

r? @varkor
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 31, 2020
add `unused_braces` lint

Add the lint `unused_braces` which is warn by default.

`unused_parens` is also extended and now checks anon consts.

closes rust-lang#68387

r? @varkor
@bors bors closed this as completed in 8993358 Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants