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

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, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions