-
Notifications
You must be signed in to change notification settings - Fork 13.3k
trivial_numeric_casts warning incorrect when casting between type aliases #23739
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
Comments
cc @nrc |
The lint was added in #23630 |
the idea was that you could "allow" the lint in that case...? |
I personally agree that this is such a common use case that I would prefer to not have to |
@nikomatsakis There's poor interaction with macros in that case. I had a similar case for function pointer casting, which would require library users to use #![allow(..)] in their crates which use It's along the lines of http://is.gd/8ZfS1I |
What about an attribute (maybe |
This is correct behaviour (according to the RFC). We warn if it is a trivial cast, we don't take account of what type aliases might be under different configurations (I'm not even sure we could). If you are doing these kind of casts, you should just use Closing, since this is correct behaviour. Please file an RFC issue if you think the spec'ed behaviour is incorrect. |
I've opened an RFC issue about this: rust-lang/rfcs#1020 |
The new
trivial_numeric_casts
lint incorrectly warns when casting between two types that happen to be type aliases. This is incorrect because the types may not actually be type aliases under all build configurations. Case in point,libc::c_long
isi32
on some architectures andi64
on others. If I believe thetrivial_numeric_casts
warning when casting from ani64
to alibc::c_long
, that breaks compilation on 32-bit architectures.The text was updated successfully, but these errors were encountered: