Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Guillaume Gomez
@imperio@toot.cat  ·  activity timestamp 5 days ago

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: https://github.com/rust-lang/rust/pull/141470

#rust #rustlang

  • Copy link
  • Flag this post
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login