Skip to content

Missing unnecessary parentheses warning in constant expressions #67942

Closed
@leonardo-m

Description

@leonardo-m
#![allow(dead_code, unused_variables)]
fn main() {
    const N1: f64 = (2.0 * 2.0);
    let n2: f64 = (2.0 * 2.0);
}

It doesn't give a warning for the unnecessary parentheses for N1:

warning: unnecessary parentheses around assigned value
 --> ...\test.rs:4:19
  |
4 |     let n2: f64 = (2.0 * 2.0);
  |                   ^^^^^^^^^^^ help: remove these parentheses
  |
  = note: `#[warn(unused_parens)]` on by default

This issue has been assigned to @Tyg13 via this comment.

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler 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