Skip to content

Unnecssary parenthesis lint #10557

Open
Open
@bilelmoussaoui

Description

@bilelmoussaoui

What it does

Currently, if the code contains unnecessary parenthesis, clippy doesn't warn the user about it. It would be nice if there was some new lint to detect these cases and warn the user about them.

Lint Name

No response

Category

style

Advantage

  • Remove unnecessary parenthesis in the code

Drawbacks

No response

Example

fn new_rect(x: f64, y: f64, width: f64, height: f64) {
    println!("I am a rectangle ({x},{y}) ({width}, {height})");
}

fn main() {
    let x = 0f32;
    let y = 0f32;
    let width = 100f32;
    let height = 100f32;

    new_rect((x) as f64, (y) as f64, (width) as f64, (height) as f64);
}

Could be written as:

fn new_rect(x: f64, y: f64, width: f64, height: f64) {
    println!("I am a rectangle ({x},{y}) ({width}, {height})");
}

fn main() {
    let x = 0f32;
    let y = 0f32;
    let width = 100f32;
    let height = 100f32;

    new_rect(x as f64, y as f64, width as f64, height as f64);
}

Metadata

Metadata

Labels

A-lintArea: New lints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions