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

Always true expressions in if expressions #1593

Open
leonardo-m opened this issue Mar 3, 2017 · 3 comments · May be fixed by #14434
Open

Always true expressions in if expressions #1593

leonardo-m opened this issue Mar 3, 2017 · 3 comments · May be fixed by #14434
Assignees
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-correctness Lint: Belongs in the correctness lint group T-middle Type: Probably requires verifiying types

Comments

@leonardo-m
Copy link

leonardo-m commented Mar 3, 2017

I'd like Clippy to find this problem in the code, this expression is always true, and Clippy should also suggest the usage of && here instead:

fn foo1a(name: &str) {
    if name != "Min" || name != "Max" {}
}

Another example:

fn foo1b(x: i32) -> bool {
    x > 10 || x < 25
}
@mcarton
Copy link
Member

mcarton commented Mar 3, 2017

The other example could be done at the same time as #1180.
The first example is something I though we had 😱

@mcarton mcarton added L-correctness Lint: Belongs in the correctness lint group good-first-issue These issues are a good way to get started with Clippy A-lint Area: New lints T-middle Type: Probably requires verifiying types labels Mar 3, 2017
@clippered
Copy link
Contributor

Hi, I would like to take a stab at this one. If anyone could point to which file I should take a look at or base the solution from, it would be a big help. Also, will this be a new lint? If so, how do I go adding new lints? Thanks.

@Dominic-Moser
Copy link

@rustbot claim

@Dominic-Moser Dominic-Moser linked a pull request Mar 18, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints good-first-issue These issues are a good way to get started with Clippy L-correctness Lint: Belongs in the correctness lint group T-middle Type: Probably requires verifiying types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants