Releases: rust-lang/rust
Rust 1.82.0
Language
- Don't make statement nonterminals match pattern nonterminals
- Patterns matching empty types can now be omitted in common cases
- Enforce supertrait outlives obligations when using trait impls
addr_of(_mut)!
macros and the newly stabilized&raw (const|mut)
are now safe to use with all static items- size_of_val_raw: for length 0 this is safe to call
- Reorder trait bound modifiers after
for<...>
binder in trait bounds - Stabilize opaque type precise capturing (RFC 3617)
- Stabilize
&raw const
and&raw mut
operators (RFC 2582) - Stabilize unsafe extern blocks (RFC 3484)
- Stabilize nested field access in
offset_of!
- Do not require
T
to be live when dropping[T; 0]
- Stabilize
const
operands in inline assembly - Stabilize floating-point arithmetic in
const fn
- Stabilize explicit opt-in to unsafe attributes
- Document NaN bit patterns guarantees
Compiler
- Promote riscv64gc-unknown-linux-musl to tier 2
- Promote Mac Catalyst targets
aarch64-apple-ios-macabi
andx86_64-apple-ios-macabi
to Tier 2, and ship them with rustup - Add tier 3 NuttX based targets for RISC-V and ARM
- Add tier 3 powerpc-unknown-linux-muslspe target
- Improved diagnostics to explain why a pattern is unreachable
- The compiler now triggers the unreachable code warning properly for async functions that don't return/are
-> !
- Promote
aarch64-apple-darwin
to Tier 1 - Add Trusty OS target
aarch64-unknown-trusty
andarmv7-unknown-trusty
as tier 3 targets - Promote
wasm32-wasip2
to Tier 2.
Libraries
Stabilized APIs
std::thread::Builder::spawn_unchecked
std::str::CharIndices::offset
std::option::Option::is_none_or
[T]::is_sorted
[T]::is_sorted_by
[T]::is_sorted_by_key
Iterator::is_sorted
Iterator::is_sorted_by
Iterator::is_sorted_by_key
std::future::Ready::into_inner
std::iter::repeat_n
impl<T: Clone> DoubleEndedIterator for Take<Repeat<T>>
impl<T: Clone> ExactSizeIterator for Take<Repeat<T>>
impl<T: Clone> ExactSizeIterator for Take<RepeatWith<T>>
impl Default for std::collections::binary_heap::Iter
impl Default for std::collections::btree_map::RangeMut
impl Default for std::collections::btree_map::ValuesMut
impl Default for std::collections::vec_deque::Iter
impl Default for std::collections::vec_deque::IterMut
Rc<T>::new_uninit
Rc<MaybeUninit<T>>::assume_init
Rc<[T]>::new_uninit_slice
Rc<[MaybeUninit<T>]>::assume_init
Arc<T>::new_uninit
Arc<MaybeUninit<T>>::assume_init
Arc<[T]>::new_uninit_slice
Arc<[MaybeUninit<T>]>::assume_init
Box<T>::new_uninit
Box<MaybeUninit<T>>::assume_init
Box<[T]>::new_uninit_slice
Box<[MaybeUninit<T>]>::assume_init
core::arch::x86_64::_bextri_u64
core::arch::x86_64::_bextri_u32
core::arch::x86::_mm_broadcastsi128_si256
core::arch::x86::_mm256_stream_load_si256
core::arch::x86::_tzcnt_u16
core::arch::x86::_mm_extracti_si64
core::arch::x86::_mm_inserti_si64
core::arch::x86::_mm_storeu_si16
core::arch::x86::_mm_storeu_si32
core::arch::x86::_mm_storeu_si64
core::arch::x86::_mm_loadu_si16
core::arch::x86::_mm_loadu_si32
core::arch::wasm32::u8x16_relaxed_swizzle
core::arch::wasm32::i8x16_relaxed_swizzle
core::arch::wasm32::i32x4_relaxed_trunc_f32x4
core::arch::wasm32::u32x4_relaxed_trunc_f32x4
core::arch::wasm32::i32x4_relaxed_trunc_f64x2_zero
core::arch::wasm32::u32x4_relaxed_trunc_f64x2_zero
core::arch::wasm32::f32x4_relaxed_madd
core::arch::wasm32::f32x4_relaxed_nmadd
core::arch::wasm32::f64x2_relaxed_madd
core::arch::wasm32::f64x2_relaxed_nmadd
core::arch::wasm32::i8x16_relaxed_laneselect
core::arch::wasm32::u8x16_relaxed_laneselect
- [`core::arch::wasm32::i16x...
Rust 1.81.0
Language
- Abort on uncaught panics in
extern "C"
functions. - Fix ambiguous cases of multiple
&
in elided self lifetimes. - Stabilize
#[expect]
for lints (RFC 2383), like#[allow]
with a warning if the lint is not fulfilled. - Change method resolution to constrain hidden types instead of rejecting method candidates.
- Bump
elided_lifetimes_in_associated_constant
to deny. offset_from
: always allow pointers to point to the same address.- Allow constraining opaque types during subtyping in the trait system.
- Allow constraining opaque types during various unsizing casts.
- Deny keyword lifetimes pre-expansion.
Compiler
- Make casts of pointers to trait objects stricter.
- Check alias args for well-formedness even if they have escaping bound vars.
- Deprecate no-op codegen option
-Cinline-threshold=...
. - Re-implement a type-size based limit.
- Properly account for alignment in
transmute
size checks. - Remove the
box_pointers
lint. - Ensure the interpreter checks bool/char for validity when they are used in a cast.
- Improve coverage instrumentation for functions containing nested items.
- Target changes:
- Add Tier 3
no_std
Xtensa targets:xtensa-esp32-none-elf
,xtensa-esp32s2-none-elf
,xtensa-esp32s3-none-elf
- Add Tier 3
std
Xtensa targets:xtensa-esp32-espidf
,xtensa-esp32s2-espidf
,xtensa-esp32s3-espidf
- Add Tier 3 i686 Redox OS target:
i686-unknown-redox
- Promote
arm64ec-pc-windows-msvc
to Tier 2. - Promote
loongarch64-unknown-linux-musl
to Tier 2 with host tools. - Enable full tools and profiler for LoongArch Linux targets.
- Unconditionally warn on usage of
wasm32-wasi
. (see compatibility note below) - Refer to Rust's platform support page for more information on Rust's tiered platform support.
- Add Tier 3
Libraries
- Split core's
PanicInfo
and std'sPanicInfo
. (see compatibility note below) - Generalize
{Rc,Arc}::make_mut()
to unsized types. - Replace sort implementations with stable
driftsort
and unstableipnsort
. Allslice::sort*
andslice::select_nth*
methods are expected to see significant performance improvements. See the research project for more details. - Document behavior of
create_dir_all
with respect to empty paths. - Fix interleaved output in the default panic hook when multiple threads panic simultaneously.
Stabilized APIs
core::error
hint::assert_unchecked
fs::exists
AtomicBool::fetch_not
Duration::abs_diff
IoSlice::advance
IoSlice::advance_slices
IoSliceMut::advance
IoSliceMut::advance_slices
PanicHookInfo
PanicInfo::message
PanicMessage
These APIs are now stable in const contexts:
char::from_u32_unchecked
(function)char::from_u32_unchecked
(method)CStr::count_bytes
CStr::from_ptr
Cargo
- Generated
.cargo_vcs_info.json
is always included, even when--allow-dirty
is passed. - Disallow
package.license-file
andpackage.readme
pointing to non-existent files during packaging. - Disallow passing
--release
/--debug
flag along with the--profile
flag. - Remove
lib.plugin
key support inCargo.toml
. Rust plugin support has been deprecated for four years and was removed in 1.75.0.
Compatibility Notes
-
Usage of the
wasm32-wasi
target will now issue a compiler warning and request users switch to thewasm32-wasip1
target instead. Both targets are the same,wasm32-wasi
is only being renamed, and this change to the WASI target is being done to enable removingwasm32-wasi
in January 2025. -
We have renamed
std::panic::PanicInfo
tostd::panic::PanicHookInfo
. The old name will continue to work as an alias, but will result in a deprecation warning starting in Rust 1.82.0.core::panic::PanicInfo
will remain unchanged, however, as this is now a different type.The reason is that these types have different roles:
std::panic::PanicHookInfo
is the argument to the panic hook in std context (where panics can have an arbitrary payload), whilecore::panic::PanicInfo
is the argument to the#[panic_handler]
in no_std context (where panics always carry a formatted message). Separating these types allows us to add more useful methods to these types, such asstd::panic::PanicHookInfo::payload_as_str()
andcore::panic::PanicInfo::message()
. -
The new sort implementations may panic if a type's implementation of
Ord
(or the given comparison function) does not implement a total order as the trait requires.Ord
's supertraits (PartialOrd
,Eq
, andPartialEq
) must also be consistent. The previous implementations would not "notice" any problem, but the new implementations have a good chance of detecting inconsistencies, throwing a panic rather than returning knowingly unsorted data.
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.
Rust 1.80.1
Rust 1.80.0
Language
- Document maximum allocation size
- Allow zero-byte offsets and ZST read/writes on arbitrary pointers
- Support C23's variadics without a named parameter
- Stabilize
exclusive_range_pattern
feature - Guarantee layout and ABI of
Result
in some scenarios
Compiler
- Update cc crate to v1.0.97 allowing additional spectre mitigations on MSVC targets
- Allow field reordering on types marked
repr(packed(1))
- Add a lint against never type fallback affecting unsafe code
- Disallow cast with trailing braced macro in let-else
- Expand
for_loops_over_fallibles
lint to lint on fallibles behind references. - self-contained linker: retry linking without
-fuse-ld=lld
on CCs that don't support it - Do not parse CVarArgs (
...
) as a type in trait bounds - Improvements to LLDB formatting #124458 #124500
- For the wasm32-wasip2 target default to PIC and do not use
-fuse-ld=lld
- Add x86_64-unknown-linux-none as a tier 3 target
- Lint on
foo.into_iter()
resolving to&Box<[T]>: IntoIterator
Libraries
- Add
size_of
andsize_of_val
andalign_of
andalign_of_val
to the prelude - Abort a process when FD ownership is violated
- io::Write::write_fmt: panic if the formatter fails when the stream does not fail
- Panic if
PathBuf::set_extension
would add a path separator - Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods
- Update
c_char
on AIX to use the correct type offset_of!
no longer returns a temporary- Handle sigma in
str.to_lowercase
correctly - Raise
DEFAULT_MIN_STACK_SIZE
to at least 64KiB
Stabilized APIs
impl Default for Rc<CStr>
impl Default for Rc<str>
impl Default for Rc<[T]>
impl Default for Arc<str>
impl Default for Arc<CStr>
impl Default for Arc<[T]>
impl IntoIterator for Box<[T]>
impl FromIterator<String> for Box<str>
impl FromIterator<char> for Box<str>
LazyCell
LazyLock
Duration::div_duration_f32
Duration::div_duration_f64
Option::take_if
Seek::seek_relative
BinaryHeap::as_slice
NonNull::offset
NonNull::byte_offset
NonNull::add
NonNull::byte_add
NonNull::sub
NonNull::byte_sub
NonNull::offset_from
NonNull::byte_offset_from
NonNull::read
NonNull::read_volatile
NonNull::read_unaligned
NonNull::write
NonNull::write_volatile
NonNull::write_unaligned
NonNull::write_bytes
NonNull::copy_to
NonNull::copy_to_nonoverlapping
NonNull::copy_from
NonNull::copy_from_nonoverlapping
NonNull::replace
NonNull::swap
NonNull::drop_in_place
NonNull::align_offset
<[T]>::split_at_checked
<[T]>::split_at_mut_checked
str::split_at_checked
str::split_at_mut_checked
str::trim_ascii
str::trim_ascii_start
str::trim_ascii_end
<[u8]>::trim_ascii
<[u8]>::trim_ascii_start
<[u8]>::trim_ascii_end
Ipv4Addr::BITS
Ipv4Addr::to_bits
Ipv4Addr::from_bits
Ipv6Addr::BITS
Ipv6Addr::to_bits
Ipv6Addr::from_bits
Vec::<[T; N]>::into_flattened
<[[T; N]]>::as_flattened
<[[T; N]]>::as_flattened_mut
These APIs are now stable in const contexts:
Cargo
Rust 1.79.0
Language
- Stabilize inline
const {}
expressions. - Prevent opaque types being instantiated twice with different regions within the same function.
- Stabilize WebAssembly target features that are in phase 4 and 5.
- Add the
redundant_lifetimes
lint to detect lifetimes which are semantically redundant. - Stabilize the
unnameable_types
lint for public types that can't be named. - Enable debuginfo in macros, and stabilize
-C collapse-macro-debuginfo
and#[collapse_debuginfo]
. - Propagate temporary lifetime extension into
if
andmatch
expressions. - Restrict promotion of
const fn
calls. - Warn against refining impls of crate-private traits with
refining_impl_trait
lint. - Stabilize associated type bounds (RFC 2289).
- Stabilize importing
main
from other modules or crates. - Check return types of function types for well-formedness
- Rework
impl Trait
lifetime inference - Change inductive trait solver cycles to be ambiguous
Compiler
- Define
-C strip
to only affect binaries, not artifacts like.pdb
. - Stabilize
-Crelro-level
for controlling runtime link hardening. - Stabilize checking of
cfg
names and values at compile-time with--check-cfg
. Note that this only stabilizes the compiler part, the Cargo part is still unstable in this release. - Add
aarch64-apple-visionos
andaarch64-apple-visionos-sim
tier 3 targets. - Add
riscv32ima-unknown-none-elf
tier 3 target. - Promote several Windows targets to tier 2:
aarch64-pc-windows-gnullvm
,i686-pc-windows-gnullvm
, andx86_64-pc-windows-gnullvm
.
Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- Implement
FromIterator
for(impl Default + Extend, impl Default + Extend)
. - Implement
{Div,Rem}Assign<NonZero<X>>
onX
. - Document overrides of
clone_from()
in core/std. - Link MSVC default lib in core.
- Caution against using
transmute
between pointers and integers. - Enable frame pointers for the standard library.
Stabilized APIs
{integer}::unchecked_add
{integer}::unchecked_mul
{integer}::unchecked_sub
<[T]>::split_at_unchecked
<[T]>::split_at_mut_unchecked
<[u8]>::utf8_chunks
str::Utf8Chunks
str::Utf8Chunk
<*const T>::is_aligned
<*mut T>::is_aligned
NonNull::is_aligned
<*const [T]>::len
<*mut [T]>::len
<*const [T]>::is_empty
<*mut [T]>::is_empty
NonNull::<[T]>::is_empty
CStr::count_bytes
io::Error::downcast
num::NonZero<T>
path::absolute
proc_macro::Literal::byte_character
proc_macro::Literal::c_string
These APIs are now stable in const contexts:
Atomic*::into_inner
io::Cursor::new
io::Cursor::get_ref
io::Cursor::position
io::empty
io::repeat
io::sink
panic::Location::caller
panic::Location::file
panic::Location::line
panic::Location::column
Cargo
- Prevent dashes in
lib.name
, always normalizing to_
. - Stabilize MSRV-aware version requirement selection in
cargo add
. - Switch to using
gitoxide
by default for listing files.
Rustdoc
- Always display stability version even if it's the same as the containing item.
- Show a single search result for items with multiple paths.
- Support typing
/
in docs to begin a search.
Misc
Compatibility Notes
- Update the minimum external LLVM to 17.
RustcEncodable
andRustcDecodable
are soft-destabilized, to be removed from the prelude in next edition.- The
wasm_c_abi
future-incompatibility lint will warn about use of the non-spec-compliant C ABI. Usewasm-bindgen v0.2.88
to generate forward-compatible bindings. - Check return types of function types for well-formedness
Rust 1.78.0
Language
- Stabilize
#[cfg(target_abi = ...)]
- Stabilize the
#[diagnostic]
namespace and#[diagnostic::on_unimplemented]
attribute - Make async-fn-in-trait implementable with concrete signatures
- Make matching on NaN a hard error, and remove the rest of
illegal_floating_point_literal_pattern
- static mut: allow mutable reference to arbitrary types, not just slices and arrays
- Extend
invalid_reference_casting
to include references casting to bigger memory layout - Add
non_contiguous_range_endpoints
lint for singleton gaps after exclusive ranges - Add
wasm_c_abi
lint for use of older wasm-bindgen versions This lint currently only works when using Cargo. - Update
indirect_structural_match
andpointer_structural_match
lints to match RFC - Make non-
PartialEq
-typed consts as patterns a hard error - Split
refining_impl_trait
lint into_reachable
,_internal
variants - Remove unnecessary type inference when using associated types inside of higher ranked
where
-bounds - Weaken eager detection of cyclic types during type inference
trait Trait: Auto {}
: allow upcasting fromdyn Trait
todyn Trait + Auto
Compiler
- Made
INVALID_DOC_ATTRIBUTES
lint deny by default - Increase accuracy of redundant
use
checking - Suggest moving definition if non-found macro_rules! is defined later
- Lower transmutes from int to pointer type as gep on null
Target changes:
- Windows tier 1 targets now require at least Windows 10
- Add
wasm32-wasip1
tier 2 (without host tools) target - Add
wasm32-wasip2
tier 3 target - Rename
wasm32-wasi-preview1-threads
towasm32-wasip1-threads
- Add
arm64ec-pc-windows-msvc
tier 3 target - Add
armv8r-none-eabihf
tier 3 target for the Cortex-R52 - Add
loongarch64-unknown-linux-musl
tier 3 target
Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- Bump Unicode to version 15.1.0, regenerate tables
- Make align_offset, align_to well-behaved in all cases
- PartialEq, PartialOrd: document expectations for transitive chains
- Optimize away poison guards when std is built with panic=abort
- Replace pthread
RwLock
with custom implementation - Implement unwind safety for Condvar on all platforms
- Add ASCII fast-path for
char::is_grapheme_extended
Stabilized APIs
impl Read for &Stdin
- Accept non
'static
lifetimes for severalstd::error::Error
related implementations - Make
impl<Fd: AsFd>
impl take?Sized
impl From<TryReserveError> for io::Error
These APIs are now stable in const contexts:
Cargo
- Stabilize lockfile v4
- Respect
rust-version
when generating lockfile - Control
--charset
via auto-detecting config value - Support
target.<triple>.rustdocflags
officially - Stabilize global cache data tracking
Compatibility Notes
- Many unsafe precondition checks now run for user code with debug assertions enabled This change helps users catch undefined behavior in their code, though the details of how much is checked are generally not stable.
- riscv only supports split_debuginfo=off for now
- Consistently check bounds on hidden types of
impl Trait
- Change equality of higher ranked types to not rely on subtyping
- When called, additionally check bounds on normalized function return type
- Expand coverage for
arithmetic_overflow
lint - Fix detection of potential interior mutability in
const
initializers This code was accidentally accepted. The fix can break generic code that borrows a value of unknown type, as there is currently no way to declare "this type has no interior mutability". In the future, stabilizing theFreeze
trait will allow proper support for such code.
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.
Rust 1.77.2
Rust 1.77.1
- Revert stripping debuginfo by default for Windows This fixes a regression in 1.77 by reverting to the previous default. Platforms other than Windows are not affected.
- Internal: Fix heading anchor rendering in doc pages
Rust 1.77.0
Language
- Reveal opaque types within the defining body for exhaustiveness checking.
- Stabilize C-string literals.
- Stabilize THIR unsafeck.
- Add lint
static_mut_refs
to warn on references to mutable statics. - Support async recursive calls (as long as they have indirection).
- Undeprecate lint
unstable_features
and make use of it in the compiler. - Make inductive cycles in coherence ambiguous always.
- Get rid of type-driven traversal in const-eval interning, only as a future compatiblity lint for now.
- Deny braced macro invocations in let-else.
Compiler
- Include lint
soft_unstable
in future breakage reports. - Make
i128
andu128
16-byte aligned on x86-based targets. - Use
--verbose
in diagnostic output. - Improve spacing between printed tokens.
- Merge the
unused_tuple_struct_fields
lint intodead_code
. - Error on incorrect implied bounds in well-formedness check, with a temporary exception for Bevy.
- Fix coverage instrumentation/reports for non-ASCII source code.
- Fix
fn
/const
items implied bounds and well-formedness check. - Promote
riscv32{im|imafc}-unknown-none-elf
targets to tier 2. - Add several new tier 3 targets:
Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
Stabilized APIs
array::each_ref
array::each_mut
core::net
f32::round_ties_even
f64::round_ties_even
mem::offset_of!
slice::first_chunk
slice::first_chunk_mut
slice::split_first_chunk
slice::split_first_chunk_mut
slice::last_chunk
slice::last_chunk_mut
slice::split_last_chunk
slice::split_last_chunk_mut
slice::chunk_by
slice::chunk_by_mut
Bound::map
File::create_new
Mutex::clear_poison
RwLock::clear_poison
Cargo
- Extend the build directive syntax with
cargo::
. - Stabilize metadata
id
format asPackageIDSpec
. - Pull out
cargo-util-schemas
as a crate. - Strip all debuginfo when debuginfo is not requested.
- Inherit jobserver from env for all kinds of runners.
- Deprecate rustc plugin support in cargo.
Rustdoc
- Allows links in markdown headings.
- Search for tuples and unit by type with
()
. - Clean up the source sidebar's hide button.
- Prevent JS injection from
localStorage
.
Misc
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.
Rust 1.76.0
Language
- Document Rust ABI compatibility between various types
- Also: guarantee that char and u32 are ABI-compatible
- Add lint
ambiguous_wide_pointer_comparisons
that supersedesclippy::vtable_address_comparisons
Compiler
- Lint pinned
#[must_use]
pointers (in particular,Box<T>
whereT
is#[must_use]
) inunused_must_use
. - Soundness fix: fix computing the offset of an unsized field in a packed struct
- Soundness fix: fix dynamic size/align computation logic for packed types with dyn Trait tail
- Add
$message_type
field to distinguish json diagnostic outputs - Enable Rust to use the EHCont security feature of Windows
- Add tier 3 {x86_64,i686}-win7-windows-msvc targets
- Add tier 3 aarch64-apple-watchos target
- Add tier 3 arm64e-apple-ios & arm64e-apple-darwin targets
Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- Add a column number to
dbg!()
- Add
std::hash::{DefaultHasher, RandomState}
exports - Fix rounding issue with exponents in fmt
- Add T: ?Sized to
RwLockReadGuard
andRwLockWriteGuard
's Debug impls. - Windows: Allow
File::create
to work on hidden files
Stabilized APIs
Arc::unwrap_or_clone
Rc::unwrap_or_clone
Result::inspect
Result::inspect_err
Option::inspect
type_name_of_val
std::hash::{DefaultHasher, RandomState}
These were previously available only throughstd::collections::hash_map
.ptr::{from_ref, from_mut}
ptr::addr_eq
Cargo
See Cargo release notes.
Rustdoc
- Don't merge cfg and doc(cfg) attributes for re-exports
- rustdoc: allow resizing the sidebar / hiding the top bar
- rustdoc-search: add support for traits and associated types
- rustdoc: Add highlighting for comments in items declaration
Compatibility Notes
- Add allow-by-default lint for unit bindings This is expected to be upgraded to a warning by default in a future Rust release. Some macros emit bindings with type
()
with user-provided spans, which means that this lint will warn for user code. - Remove x86_64-sun-solaris target.
- Remove asmjs-unknown-emscripten target
- Report errors in jobserver inherited through environment variables This may warn on benign problems too.
- Update the minimum external LLVM to 16.
- Improve
print_tts
This change can break some naive manual parsing of token trees in proc macro code which expect a particular structure after.to_string()
, rather than just arbitrary Rust code. - Make
IMPLIED_BOUNDS_ENTAILMENT
into a hard error from a lint - Vec's allocation behavior was changed when collecting some iterators Allocation behavior is currently not specified, nevertheless changes can be surprising. See
impl FromIterator for Vec
for more details. - Properly reject
default
on free const items