Skip to content

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

Closed
@varkor

Description

@varkor

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

Activity

added
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
A-const-genericsArea: const generics (parameters and arguments)
on Jan 20, 2020
eddyb

eddyb commented on Jan 21, 2020

@eddyb
Member

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

added
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
on Jan 26, 2020
added a commit that references this issue on Mar 30, 2020

Rollup merge of rust-lang#70081 - lcnr:issue68387, r=varkor

a652732
added a commit that references this issue on Mar 31, 2020

Rollup merge of rust-lang#70081 - lcnr:issue68387, r=varkor

5853adc
added a commit that references this issue on Mar 31, 2020

Rollup merge of rust-lang#70081 - lcnr:issue68387, r=varkor

0eb52b0

2 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @eddyb@Centril@varkor@JohnTitor

      Issue actions

        Consider extending `unused_parens` to `{}`, particularly in const generics · Issue #68387 · rust-lang/rust