|
| 1 | ++++ |
| 2 | +path = "2026/04/16/Rust-1.95.0" |
| 3 | +title = "Announcing Rust 1.95.0" |
| 4 | +authors = ["The Rust Release Team"] |
| 5 | +aliases = ["releases/1.95.0"] |
| 6 | + |
| 7 | +[extra] |
| 8 | +release = true |
| 9 | ++++ |
| 10 | + |
| 11 | +The Rust team is happy to announce a new version of Rust, 1.95.0. Rust is a programming language empowering everyone to build reliable and efficient software. |
| 12 | + |
| 13 | +If you have a previous version of Rust installed via `rustup`, you can get 1.95.0 with: |
| 14 | + |
| 15 | +```console |
| 16 | +$ rustup update stable |
| 17 | +``` |
| 18 | + |
| 19 | +If you don't have it already, you can [get `rustup`](https://www.rust-lang.org/install.html) from the appropriate page on our website, and check out the [detailed release notes for 1.95.0](https://doc.rust-lang.org/stable/releases.html#version-1950-2026-04-16). |
| 20 | + |
| 21 | +If you'd like to help us out by testing future releases, you might consider updating locally to use the beta channel (`rustup default beta`) or the nightly channel (`rustup default nightly`). Please [report](https://github.com/rust-lang/rust/issues/new/choose) any bugs you might come across! |
| 22 | + |
| 23 | +## What's in 1.95.0 stable |
| 24 | + |
| 25 | +### `cfg_select!` |
| 26 | + |
| 27 | +Rust 1.95 introduces a |
| 28 | +[`cfg_select!`](https://doc.rust-lang.org/stable/std/macro.cfg_select.html) |
| 29 | +macro that acts roughly similar to a compile-time `match` on `cfg`s. This |
| 30 | +fulfills the same purpose as the popular |
| 31 | +[`cfg-if`](https://crates.io/crates/cfg-if) crate, although with a different |
| 32 | +syntax. `cfg_select!` expands to the right-hand side of the first arm whose |
| 33 | +configuration predicate evaluates to `true`. Some examples: |
| 34 | + |
| 35 | +```rust |
| 36 | +cfg_select! { |
| 37 | + unix => { |
| 38 | + fn foo() { /* unix specific functionality */ } |
| 39 | + } |
| 40 | + target_pointer_width = "32" => { |
| 41 | + fn foo() { /* non-unix, 32-bit functionality */ } |
| 42 | + } |
| 43 | + _ => { |
| 44 | + fn foo() { /* fallback implementation */ } |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +let is_windows_str = cfg_select! { |
| 49 | + windows => "windows", |
| 50 | + _ => "not windows", |
| 51 | +}; |
| 52 | +``` |
| 53 | + |
| 54 | +### if-let guards in matches |
| 55 | + |
| 56 | +Rust 1.88 stabilized [let chains](https://blog.rust-lang.org/2025/06/26/Rust-1.88.0/#let-chains). Rust |
| 57 | +1.95 brings that capability into match expressions, allowing for conditionals |
| 58 | +based on pattern matching. |
| 59 | + |
| 60 | +```rust |
| 61 | +match value { |
| 62 | + Some(x) if let Ok(y) = compute(x) => { |
| 63 | + // Both `x` and `y` are available here |
| 64 | + println!("{}, {}", x, y); |
| 65 | + } |
| 66 | + _ => {} |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +Note that the compiler will not currently consider the patterns matched in `if |
| 71 | +let` guards as part of the exhaustiveness evaluation of the overall match, just |
| 72 | +like `if` guards. |
| 73 | + |
| 74 | +### Stabilized APIs |
| 75 | + |
| 76 | +- [`MaybeUninit<[T; N]>: From<[MaybeUninit<T>; N]>`](https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-From%3CMaybeUninit%3C%5BT;+N%5D%3E%3E-for-%5BMaybeUninit%3CT%3E;+N%5D) |
| 77 | +- [`MaybeUninit<[T; N]>: AsRef<[MaybeUninit<T>; N]>`](https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-AsRef%3C%5BMaybeUninit%3CT%3E;+N%5D%3E-for-MaybeUninit%3C%5BT;+N%5D%3E) |
| 78 | +- [`MaybeUninit<[T; N]>: AsRef<[MaybeUninit<T>]>`](https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-AsRef%3C%5BMaybeUninit%3CT%3E%5D%3E-for-MaybeUninit%3C%5BT;+N%5D%3E) |
| 79 | +- [`MaybeUninit<[T; N]>: AsMut<[MaybeUninit<T>; N]>`](https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-AsMut%3C%5BMaybeUninit%3CT%3E;+N%5D%3E-for-MaybeUninit%3C%5BT;+N%5D%3E) |
| 80 | +- [`MaybeUninit<[T; N]>: AsMut<[MaybeUninit<T>]>`](https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-AsMut%3C%5BMaybeUninit%3CT%3E%5D%3E-for-MaybeUninit%3C%5BT;+N%5D%3E) |
| 81 | +- [`[MaybeUninit<T>; N]: From<MaybeUninit<[T; N]>>`](https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#impl-From%3C%5BMaybeUninit%3CT%3E;+N%5D%3E-for-MaybeUninit%3C%5BT;+N%5D%3E) |
| 82 | +- [`Cell<[T; N]>: AsRef<[Cell<T>; N]>`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#impl-AsRef%3C%5BCell%3CT%3E;+N%5D%3E-for-Cell%3C%5BT;+N%5D%3E) |
| 83 | +- [`Cell<[T; N]>: AsRef<[Cell<T>]>`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#impl-AsRef%3C%5BCell%3CT%3E%5D%3E-for-Cell%3C%5BT;+N%5D%3E) |
| 84 | +- [`Cell<[T]>: AsRef<[Cell<T>]>`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#impl-AsRef%3C%5BCell%3CT%3E%5D%3E-for-Cell%3C%5BT%5D%3E) |
| 85 | +- [`bool: TryFrom<{integer}>`](https://doc.rust-lang.org/stable/std/primitive.bool.html#impl-TryFrom%3Cu128%3E-for-bool) |
| 86 | +- [`AtomicPtr::update`](https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicPtr.html#method.update) |
| 87 | +- [`AtomicPtr::try_update`](https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicPtr.html#method.try_update) |
| 88 | +- [`AtomicBool::update`](https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicBool.html#method.update) |
| 89 | +- [`AtomicBool::try_update`](https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicBool.html#method.try_update) |
| 90 | +- [`AtomicIn::update`](https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicIsize.html#method.update) |
| 91 | +- [`AtomicIn::try_update`](https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicIsize.html#method.try_update) |
| 92 | +- [`AtomicUn::update`](https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicUsize.html#method.update) |
| 93 | +- [`AtomicUn::try_update`](https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicUsize.html#method.try_update) |
| 94 | +- [`cfg_select!`](https://doc.rust-lang.org/stable/std/macro.cfg_select.html) |
| 95 | +- [`mod core::range`](https://doc.rust-lang.org/stable/core/range/index.html) |
| 96 | +- [`core::range::RangeInclusive`](https://doc.rust-lang.org/stable/core/range/struct.RangeInclusive.html) |
| 97 | +- [`core::range::RangeInclusiveIter`](https://doc.rust-lang.org/stable/core/range/struct.RangeInclusiveIter.html) |
| 98 | +- [`core::hint::cold_path`](https://doc.rust-lang.org/stable/core/hint/fn.cold_path.html) |
| 99 | +- [`<*const T>::as_ref_unchecked`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_ref_unchecked) |
| 100 | +- [`<*mut T>::as_ref_unchecked`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_ref_unchecked-1) |
| 101 | +- [`<*mut T>::as_mut_unchecked`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.as_mut_unchecked) |
| 102 | +- [`Vec::push_mut`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.push_mut) |
| 103 | +- [`Vec::insert_mut`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.insert_mut) |
| 104 | +- [`VecDeque::push_front_mut`](https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.push_front_mut) |
| 105 | +- [`VecDeque::push_back_mut`](https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.push_back_mut) |
| 106 | +- [`VecDeque::insert_mut`](https://doc.rust-lang.org/stable/std/collections/struct.VecDeque.html#method.insert_mut) |
| 107 | +- [`LinkedList::push_front_mut`](https://doc.rust-lang.org/stable/std/collections/struct.LinkedList.html#method.push_front_mut) |
| 108 | +- [`LinkedList::push_back_mut`](https://doc.rust-lang.org/stable/std/collections/struct.LinkedList.html#method.push_back_mut) |
| 109 | +- [`Layout::dangling_ptr`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.dangling_ptr) |
| 110 | +- [`Layout::repeat`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.repeat) |
| 111 | +- [`Layout::repeat_packed`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.repeat_packed) |
| 112 | +- [`Layout::extend_packed`](https://doc.rust-lang.org/stable/std/alloc/struct.Layout.html#method.extend_packed) |
| 113 | + |
| 114 | +These previously stable APIs are now stable in const contexts: |
| 115 | + |
| 116 | +- [`fmt::from_fn`](https://doc.rust-lang.org/stable/std/fmt/fn.from_fn.html) |
| 117 | +- [`ControlFlow::is_break`](https://doc.rust-lang.org/stable/core/ops/enum.ControlFlow.html#method.is_break) |
| 118 | +- [`ControlFlow::is_continue`](https://doc.rust-lang.org/stable/core/ops/enum.ControlFlow.html#method.is_continue) |
| 119 | + |
| 120 | +### Destabilized JSON target specs |
| 121 | + |
| 122 | +Rust 1.95 removes support on stable for passing a custom target specification |
| 123 | +to `rustc`. This should **not** affect any Rust users using a fully stable |
| 124 | +toolchain, as building the standard library (including just `core`) already |
| 125 | +required using nightly-only features. |
| 126 | + |
| 127 | +We're also gathering use cases for custom targets on the [tracking issue](https://github.com/rust-lang/rust/issues/151528) |
| 128 | +as we consider whether some form of this feature should eventually be stabilized. |
| 129 | + |
| 130 | +### Other changes |
| 131 | + |
| 132 | +Check out everything that changed in [Rust](https://github.com/rust-lang/rust/releases/tag/1.95.0), [Cargo](https://doc.rust-lang.org/nightly/cargo/CHANGELOG.html#cargo-195-2026-04-16), and [Clippy](https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-195). |
| 133 | + |
| 134 | +## Contributors to 1.95.0 |
| 135 | + |
| 136 | +Many people came together to create Rust 1.95.0. We couldn't have done it without all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.95.0/) |
| 137 | + |
| 138 | +[platform-support]: https://doc.rust-lang.org/rustc/platform-support.html |
0 commit comments