Skip to content

logic_bug lint should understand cfg! #1932

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

Closed
ipetkov opened this issue Aug 7, 2017 · 3 comments
Closed

logic_bug lint should understand cfg! #1932

ipetkov opened this issue Aug 7, 2017 · 3 comments

Comments

@ipetkov
Copy link

ipetkov commented Aug 7, 2017

Had a use case where a certain input parameter must trigger some fallback behavior for a specific OS, but clippy reported it as a logical bug:

let v: Vec<_> = ...;

if cfg!(windows) && v.is_empty() {
   // fallback behavior
} else {
   // default behavior for Unix/non-empty param
}

Clippy is correctly reporting that this is equivalent to false && ... on unix systems, but removing the first check (as per the suggestion) does not reflect the actual programmer intent

@oli-obk
Copy link
Contributor

oli-obk commented Aug 7, 2017

Dupe of #1885

Rustc isn't telling us about macros anymore... we can't do much on our end

@llogiq
Copy link
Contributor

llogiq commented Aug 7, 2017

Is there a rustic bug about this?

@oli-obk
Copy link
Contributor

oli-obk commented Aug 7, 2017

rust-lang/rust#43268

@oli-obk oli-obk closed this as completed Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants