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

Clippy suggests incorrect fix #11732

Closed
he-thinks opened this issue Oct 29, 2023 · 2 comments
Closed

Clippy suggests incorrect fix #11732

he-thinks opened this issue Oct 29, 2023 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@he-thinks
Copy link

he-thinks commented Oct 29, 2023

Summary

Clippy suggests incorrect fixes for #[warn(unused_parens)] for these patterns (the same issue with the stable 1.73.0 rustc):

let(mut _x): i8 = 0;
let( mut _x): i8 = 0;
let(_x): i8 = 0;

Reproducer

I tried this code:

fn main() {
    let(mut _x): i8 = 0;
}

I expected to see this happen:

warning: unnecessary parentheses around pattern
 --> src/main.rs:2:8
  |
2 |     let(mut _x): i8 = 0;
  |        ^      ^
  |
  = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
  |
2 -     let(mut _x): i8 = 0;
2 +     let mut _x: i8 = 0;
  |

Instead, this happened:

warning: unnecessary parentheses around pattern
 --> src/main.rs:2:8
  |
2 |     let(mut _x): i8 = 0;
  |        ^      ^
  |
  = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
  |
2 -     let(mut _x): i8 = 0;
2 +     letmut _x: i8 = 0;
  |

Version

rustc 1.75.0-nightly (e5cfc5547 2023-10-28)
binary: rustc
commit-hash: e5cfc55477eceed1317a02189fdf77a4a98f2124
commit-date: 2023-10-28
host: x86_64-pc-windows-gnu
release: 1.75.0-nightly
LLVM version: 17.0.3

Additional Labels

No response

@he-thinks he-thinks added the C-bug Category: Clippy is not doing the correct thing label Oct 29, 2023
@he-thinks he-thinks changed the title Clippy suggest incorrect fix Clippy suggests incorrect fix Oct 29, 2023
@Alexendoo Alexendoo added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Oct 29, 2023
@y21
Copy link
Member

y21 commented Oct 29, 2023

Shouldn't this be on the rust-lang/rust repo? unused_parens is a rustc lint, not a clippy lint.

@he-thinks
Copy link
Author

he-thinks commented Oct 30, 2023

Shouldn't this be on the rust-lang/rust repo? unused_parens is a rustc lint, not a clippy lint.

Thanks, I reopened this issue in the rust-lang/rust repo. #117380

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

No branches or pull requests

3 participants