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

FN implicit if_same_then_else #3030

Open
matthiaskrgr opened this issue Aug 11, 2018 · 0 comments
Open

FN implicit if_same_then_else #3030

matthiaskrgr opened this issue Aug 11, 2018 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@matthiaskrgr
Copy link
Member

fn main() {
	println!("{:?}", func(4));
}

fn func(n: i32) -> bool {
	if n < 2 {
		return true;
	} else if  n > 2 {
		return false;
	}
	return false; // return outside of conditions
}

this code is basically identical to

fn main() {
	println!("{:?}", func(4));
}

fn func(n: i32) -> bool {
	if n < 2 {
		return true;
	} else if  n > 2 {
		return false;
	} else { // return moved into else {}
		return false;
	}
}

but only the latter triggers the if_same_then_else warning.
Should the first example trigger a warning as well?

@phansch phansch added the C-bug Category: Clippy is not doing the correct thing label Dec 11, 2018
@matthiaskrgr matthiaskrgr added the I-false-negative Issue: The lint should have been triggered on code, but wasn't label Dec 18, 2020
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-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

No branches or pull requests

2 participants