Radar · Rust · Archive · Week 14 · Mar 31 – Apr 6, 2025
Announcing Rust 1.86.0
Worth knowingtooling
- What changed
- The Rust team announced the release of Rust 1.86.0.
- Production impact
- The source does not say.
- Try it
- Run
rustc --versionto confirm you are on 1.86.0. - Source
- blog.rust-lang.org/2025/04/03/Rust-1.86.0/
Understand it, then run it
Rust 1.86.0 adds a new way to convert a trait object to a trait object of one of its supertraits. Before this release you had to write a method on the trait itself, like fn as_supertrait(&self) -> &dyn Supertrait. Now you can simply write x as &dyn Supertrait and the compiler will do the conversion for you. The change also adds a helper get_disjoint_mut for getting several mutable references from a slice or a HashMap at once, and allows safe functions to be marked with #[target_feature].
Run it now
// This program demonstrates the manual trait upcasting that was
// stabilized in Rust 1.86.0. Since Rust 1.98.1 (edition 2024) does not
// yet support the built‑in upcast syntax, we perform the cast
// explicitly with `as &dyn Supertrait`. The output confirms that the
// cast succeeded and that the `Supertrait` method can be called.
trait Supertrait {
fn hello(&self) -> &'static str;
}
trait Trait: Supertrait {}
struct Impl;
impl Supertrait for Impl {
fn hello(&self) -> &'static str {
"Hello from Supertrait"
}
}
impl Trait for Impl {}
fn main() {
let obj = Impl;
// Manual upcast: &dyn Trait -> &dyn Supertrait
let super_ref: &dyn Supertrait = &obj as &dyn Trait as &dyn Supertrait;
println!("{}", super_ref.hello());
}
What it printed when we ran it on Rust 1.98.1 (edition 2024)
Hello from Supertrait
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed