Rust 1.87.0
Released on May 15, 2025
What's Changed
- Stabilize
asm_gotofeature - Allow parsing open beginning ranges (
..EXPR) after unary operators!,-, and*. - Don't require method impls for methods with
Self: Sizedbounds inimpls for unsized types - Stabilize
feature(precise_capturing_in_traits)allowinguse<...>bounds on return positionimpl Traitintraits
- Stabilize the anonymous pipe API
- Add support for unbounded left/right shift operations
- Print pointer metadata in
Debugimpl of raw pointers Vec::with_capacityguarantees it allocates with the amount requested, even ifVec::capacityreturns a different number.- Most
std::archintrinsics which don't take pointer arguments can now be called from safe code if the caller has the appropriate target features already enabled (https://github.com/rust-lang/stdarch/pull/1714, https://github.com/rust-lang/stdarch/pull/1716, https://github.com/rust-lang/stdarch/pull/1717) - Undeprecate
env::home_dir - Denote
ControlFlowas#[must_use] - Macros such as
assert_eq!andvec!now supportconst {...}expressions Vec::extract_ifvec::ExtractIfLinkedList::extract_iflinked_list::ExtractIf<[T]>::split_off<[T]>::split_off_mut<[T]>::split_off_first<[T]>::split_off_first_mut<[T]>::split_off_last<[T]>::split_off_last_mutString::extend_from_withinos_str::DisplayOsString::displayOsStr::displayio::pipeio::PipeReaderio::PipeWriterimpl Fromfor OwnedHandle impl Fromfor OwnedHandle impl Fromfor Stdio impl Fromfor Stdio impl Fromfor OwnedFd impl Fromfor OwnedFd Box>::write impl TryFrom> for String <*const T>::offset_from_unsigned<*const T>::byte_offset_from_unsigned<*mut T>::offset_from_unsigned<*mut T>::byte_offset_from_unsignedNonNull::offset_from_unsignedNonNull::byte_offset_from_unsigned::cast_signed NonZero::.::cast_signed .::cast_unsigned NonZero::.::cast_unsigned ::is_multiple_of ::unbounded_shl ::unbounded_shr ::unbounded_shl ::unbounded_shr ::midpoint ::from_utf8 ::from_utf8_mut ::from_utf8_unchecked ::from_utf8_unchecked_mut core::str::from_utf8_mut<[T]>::copy_from_sliceSocketAddr::set_ipSocketAddr::set_port,SocketAddrV4::set_ipSocketAddrV4::set_port,SocketAddrV6::set_ipSocketAddrV6::set_portSocketAddrV6::set_flowinfoSocketAddrV6::set_scope_idchar::is_digitchar::is_whitespace- [
<[[T; N]]>::as_flattened](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_flattened) - [
<[[T; N]]>::as_flattened_mut](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_flattened_mut) String::into_bytesString::as_strString::capacityString::as_bytesString::lenString::is_emptyString::as_mut_strString::as_mut_vecVec::as_ptrVec::as_sliceVec::capacityVec::lenVec::is_emptyVec::as_mut_sliceVec::as_mut_ptr
- Rust now raises an error for macro invocations inside the
#![crate_name]attribute - Unstable fields are now always considered to be inhabited
- Macro arguments of unary operators followed by open beginning ranges may now be matched differently
- Make
Debugimpl of raw pointers print metadata if present - Warn against function pointers using unsupported ABI strings in dependencies
- Associated types on
dyntypes are no longer deduplicated - Forbid attributes on
..inside of struct patterns (let Struct { #[attribute] .. }) = - Make
ptr_cast_add_auto_to_objectlint into hard error - Many
std::archintrinsics are now safe to call in some contexts, there may now be newunused_unsafewarnings in existing codebases. - Limit
widthandprecisionformatting options to 16 bits on all targets - Turn order dependent trait objects future incompat warning into a hard error
- Denote
ControlFlowas#[must_use] - Windows: The standard library no longer links
advapi32, except on win7. Code such as C libraries that were relying on this assumption may need to explicitly link advapi32. - Proc macros can no longer observe expanded
cfg(true)attributes. - Start changing the internal representation of pasted tokens. Certain invalid declarative macros that were previously accepted in obscure circumstances are now correctly rejected by the compiler. Use of a
ttfragment specifier can often fix these macros. - Don't allow flattened format_args in const.
Full Changelog
Language
--------
- Allow parsing open beginning ranges (..EXPR) after unary operators !, -, and *.
- Don't require method impls for methods with Self: Sized bounds in impls for unsized types
Compiler
--------
- x86: make SSE2 required for i686 targets and use it to pass SIMD types
Platform Support
----------------
- Remove i586-pc-windows-msvc target
Refer to Rust's [platform support page][platform-support-doc]
for more information on Rust's tiered platform support.
[platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html
Libraries
---------
- Stabilize the anonymous pipe API
- Add support for unbounded left/right shift operations
- Print pointer metadata in Debug impl of raw pointers
- Most std::arch intrinsics which don't take pointer arguments can now be called from safe code if the caller has the appropriate target features already enabled (https://github.com/rust-lang/stdarch/pull/1714, https://github.com/rust-lang/stdarch/pull/1716, https://github.com/rust-lang/stdarch/pull/1717)
- Denote ControlFlow as #[must_use]
- Macros such as assert_eq! and vec! now support const {...} expressions
Stabilized APIs
---------------
- io::pipe
- <*const T>::offset_from_unsigned
- <*const T>::byte_offset_from_unsigned
- <*mut T>::offset_from_unsigned
- <*mut T>::byte_offset_from_unsigned
- NonNull::offset_from_unsigned
- NonNull::byte_offset_from_unsigned
These previously stable APIs are now stable in const contexts:
- [<[[T; N]]>::as_flattened](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_flattened)
- [<[[T; N]]>::as_flattened_mut](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_flattened_mut)
- Vec::len
Cargo
-----
- Add terminal integration via ANSI OSC 9;4 sequences
- feat(package): add --exclude-lockfile flag
Compatibility Notes
-------------------
- Rust now raises an error for macro invocations inside the #![crate_name] attribute
- Unstable fields are now always considered to be inhabited
- Macro arguments of unary operators followed by open beginning ranges may now be matched differently
- Make Debug impl of raw pointers print metadata if present
- Warn against function pointers using unsupported ABI strings in dependencies
- Associated types on dyn types are no longer deduplicated
- Forbid attributes on .. inside of struct patterns (let Struct { #[attribute] .. }) =
- Make ptr_cast_add_auto_to_object lint into hard error
- Many std::arch intrinsics are now safe to call in some contexts, there may now be new unused_unsafe warnings in existing codebases.
- Limit width and precision formatting options to 16 bits on all targets
- Turn order dependent trait objects future incompat warning into a hard error
- Denote ControlFlow as #[must_use]
- Windows: The standard library no longer links advapi32, except on win7. Code such as C libraries that were relying on this assumption may need to explicitly link advapi32.
- Proc macros can no longer observe expanded cfg(true) attributes.
- Start changing the internal representation of pasted tokens. Certain invalid declarative macros that were previously accepted in obscure circumstances are now correctly rejected by the compiler. Use of a tt fragment specifier can often fix these macros.
- Don't allow flattened format_args in const.
Internal Changes
----------------
These changes do not affect any public interfaces of Rust, but they represent
significant improvements to the performance or internals of rustc and related
tools.