Added a new rustc lint which will hopefully prevent a lot of very wrong casts: function_casts_as_integer.

In short, if you convert a function to an integer, it will now warn.

Why? Because of cases like:

let _ = [0; u8::max as usize];

u8::max is a function, not a constant (u8::MAX is the constant). Now you get a surprising amount of allocation (and potentially different) every time. :)

So many potential other cases where the end code is NOT the expected one. Well, not anymore!

PR: github.com/rust-lang/rust/pull

0
0
0

If you have a fediverse account, you can quote this note from your own instance. Search https://toot.cat/users/imperio/statuses/115532094224595470 on your instance and quote it. (Note that quoting is not supported in Mastodon.)