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

lint of unnecessary parentheses around if condition may case error #63156

Closed
bravomikekilo opened this issue Jul 31, 2019 · 2 comments · Fixed by #63163
Closed

lint of unnecessary parentheses around if condition may case error #63156

bravomikekilo opened this issue Jul 31, 2019 · 2 comments · Fixed by #63163
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bravomikekilo
Copy link
Contributor

when unnecessary parentheses is removed, may lack a whitespace between if and expr.

example
if(is_prime) {println!("hello")};
while be replaced to
ifis_prime {println!("hello")};

Maybe we should replare (expr) with a pair of whitespace around expr, instead of just expr;

@oli-obk oli-obk added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Jul 31, 2019
@bravomikekilo
Copy link
Contributor Author

I am working on it.

@Centril Centril added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-diagnostics Area: Messages for errors, warnings, and lints labels Jul 31, 2019
Centril added a commit to Centril/rust that referenced this issue Aug 6, 2019
add a pair of whitespace after remove parentheses

fix [issue-63156](rust-lang#63156).
add a pair of whitespace after remove parentheses.
@0xgooroo
Copy link

0xgooroo commented Apr 23, 2024

Previous code
if (fee > 4) {
stake_pool.fee = 4;
} else {
stake_pool.fee = fee;
}

Updated code

if fee > 4 {
stake_pool.fee = 4;
} else {
stake_pool.fee = fee;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants