Rust 1.54 pushed out the door, presents niceties for wasm and docs

Rust 1.54

The team behind C++ challenger Rust has pushed out version 1.54 of the programming language, which brings a couple of minor though useful language additions and facilitates targeting WebAssembly.

Amongst other things, developers are now able to cast between unsized slice types in const fn, and use multiple generic lifetimes with impl Trait return types thanks to some stabilisation work. Rust has also been modified so that attributes can invoke function-like macros, so that macros can be nested inside attributes to include content generated by build scripts. This can also be used to add external documentation into Rust doc comments, should there be a need.

Speaking of macros, proc_macro::Literal now implements FromStr. Other library enhancements mean that panic locations can be reported from user code and OutOfMemory is now a type of io::ErrorKind. Package manager Cargo received some changes as part of the release as well, including new cargo-tree options --prune <spec> and --depth to remove packages from the dependency graph and print trees only to a certain depth respectively. 

The Rust compiler comes with a wasm target_family for WebAssembly platforms in v1.54 and learned to search for custom JSON targets in /lib/rustlib/<target-triple>/target.json where / is the sysroot directory. It’s also important to note that incremental compilation is the default again, since most of the issues that led to them being disabled have been taken care of.

Teams that have been using Rust for a while should read through the compatibility notes before upgrading, as the new version forbids a couple of previously legit things. For example, users aren’t permitted to mix Option and Result by use of ? in closures for inferred types anymore. They also should be aware that std::arch intrinsics now uses stricter const checking than before which could lead to rejections of code that was previously accepted.

APIs BTreeMap::into_keys, BTreeMap::into_values, HashMap::into_keys, HashMap::into_values, arch::wasm32, VecDeque::binary_search, VecDeque::binary_search_by, VecDeque::binary_search_by_key, and VecDeque::partition_point can now be safely built into production code, as their newly reached stable status suggests no sudden behavioural changes anymore. 

While the project had been independently governed for more than five years already, a freshly founded Rust Foundation took over governance for the language project earlier this year. The non-profit looks to fund development work, organise outreach initiatives, and ensure independence from individual sponsors. 

Necessity for the latter got especially apparent in 2020, when long-time supporter Mozilla introduced changes to its business model and terminated some Rust dev contracts in the process. It didn’t stop the company from staying a part of the project, however, which is why Mozilla joined Microsoft, AWS, Google and others as a founding member of the new governance body.