Paul Krill
Editor at Large

Rust 1.89 underscores arguments to const generics

news
Aug 11, 20252 mins

Latest version of fast and safe programming language supports ‘_’ as an argument to const generic parameters, inferring the value from surrounding context.

shutterstock 77260183 rusty old woodworking tools on the wall of an old workshop
Credit: Mihai Simonia / Shutterstock

The Rust team has released Rust 1.89.0 stable, an update to the fast and safe programming language that features support for explicitly inferred arguments to const generics.

The Rust release team announced the new version on August 7. Developers who have a previous version of Rust installed via rustup can get Rust 1.89 by running the command rustup update stable.

With Rust 1.89, Rust now supports _ as an argument to const generic parameters, inferring the value from surrounding context. The Rust release team provided an example in its announcement of the release:


pub fn all_false() -> [bool; LEN] {
  [false; _]
}

Similar to the rules for when _ is permitted as a type, _ is not permitted as an argument to const generics when in a signature, the team wrote:


// This is not allowed
pub const fn all_false() -> [bool; _] {
  [false; LEN]
}

// Neither is this
pub const ALL_FALSE: [bool; _] = all_false::();

Also in Rust 1.89,  doctests now will be tested when running cargo test --doc --target other_target. This may result in some amount of breakage due to “would-be-failing” doctests now being tested. Failing tests can be disabled by annotating the doctest with ignore-<target>. The team provided this example:


/// ```ignore-x86_64
/// panic!("something")
/// ```
pub fn my_function() { }

Rust 1.89 follows the June 26 release of Rust 1.88, which featured support for naked functions. Additional features in Rust 1.89 include:

  • i128 and u128no longer trigger the improper_ctypes_definitionslint, meaning these types may be used in extern "C"functions without warning.
  • extern "C" functions on the wasm32-unknown-unknowntarget now have a standards compliant ABI.
  • For platforms, x86_64-apple-darwinis being demoted from Tier 1 with host tools to Tier 2 with host tools.
  • A mismatched_lifetime_syntaxes lint has been added which detects when the same lifetime is referred to by different syntax categories between function arguments and return values.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author