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

False positive on enum_clike_unportable_variant #816

Open
llogiq opened this issue Mar 30, 2016 · 3 comments
Open

False positive on enum_clike_unportable_variant #816

llogiq opened this issue Mar 30, 2016 · 3 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types

Comments

@llogiq
Copy link
Contributor

llogiq commented Mar 30, 2016

x = 1isize << 31; 

is okay as long as the specific bit pattern is of the essence; the actual value may vary.

E.g. see https://github.com/ledbettj/wavefile/blob/master/src/speakers.rs#L20

@oli-obk
Copy link
Contributor

oli-obk commented Mar 31, 2016

shouldn't the type in the example rather be i32?

@oli-obk
Copy link
Contributor

oli-obk commented Mar 31, 2016

if you want the bit pattern in a portable way use (1usize << 31) as isize, which is more explicit to your intent nevermind, We're checking the final value...

oh well... I still argue it's unportable... but we can split the lint into three, one for enums that implement PartialOrd, where it still is warn-by-default, and two for enums that don't implement PartialOrd (one for values that require more than 32 bit (warn-by-default), and one for values that will yield different values on 32 bit (allow-by-default))

@llogiq
Copy link
Contributor Author

llogiq commented Mar 31, 2016

You are technically correct (which is after all the best kind of correct 😄). Still I think it may be useful to split the lint so we can give more relevant report messages.

@oli-obk oli-obk added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages T-middle Type: Probably requires verifiying types labels May 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types
Projects
None yet
Development

No branches or pull requests

2 participants