Rust 1.45.0 to deal with ‘longstanding unsoundness’

rust logo

Developer darling Rust has hit version 1.45.0, replete with a fix for some long-standing “unsoundness” and stable support for Rocket.


Fresh from the fifth anniversary of its first stable release, the latest from the beloved language (if you believe the Stack Overflow survey and language indices), 1.45.0, deals with a vaguely surprising issue, considering the language’s chops when it comes to safety.

Careless casting between integers and floats in previous versions could result in what the team delicately described as “undefined behaviour.” In a nutshell, casting a large floating point to a small integer could see unpredictable things happen and somewhat undermine Rust’s assertion of being a safe language.

It has taken the gang a while to fix the problem, which was first noted back in October 2013. The problem lurked within the LLVM compiler, the fptoui instruction of which generated that “poison value”.

Advertisement

Rust prides itself on its safety and, after much deliberation, the gang has decided to make as perform a “saturating cast”. This will see floats that are too large turned into the largest possible value, those that are too small become the smallest possible value, and will see NaN produce zero.

Unsafe functionality has also been added for developers that require Rust to maintain the current behaviour, “which may be desirable in rare performance sensitive situations,” according to the team.

The other notable tweak in 1.45.0 is the ability to invoke function-like procedural macros in three new places. Attribute-like and function-like macros were stabilised back in Rust 1.30.0, and 1.45.0 allows procedural macros to be invoked in expression, pattern or statement positions.

It’s a handy change in itself, but will excite fans of the Rocket web framework, since it marks the final feature needed in the stable version of Rust for complete support. “Rocket,” explained the Rust team, “is a popular web framework for Rust often described as one of the best things the Rust ecosystem has to offer.”

The latest release of the Rocket framework currently stands at 0.4.5. It will now be possible to compile the next version with stable Rust (rather than the nightly incarnation.) ®

- Advertisement -