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
+ use<'lt>opaque type precise capturing (RFC 3617) - Stabilize
&raw constand&raw mutoperators (RFC 2582) - Stabilize unsafe extern blocks (RFC 3484)
- Stabilize nested field access in
offset_of! - Do not require
Tto be live when dropping[T; 0] - Stabilize
constoperands 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-macabiandx86_64-apple-ios-macabito 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-darwinto Tier 1 - Add Trusty OS target
aarch64-unknown-trustyandarmv7-unknown-trustyas tier 3 targets - Promote
wasm32-wasip2to Tier 2.
Libraries
Stabilized APIs
std::thread::Builder::spawn_uncheckedstd::str::CharIndices::offsetstd::option::Option::is_none_or[T]::is_sorted[T]::is_sorted_by[T]::is_sorted_by_keyIterator::is_sortedIterator::is_sorted_byIterator::is_sorted_by_keystd::future::Ready::into_innerstd::iter::repeat_nimpl<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::Iterimpl Default for std::collections::btree_map::RangeMutimpl Default for std::collections::btree_map::ValuesMutimpl Default for std::collections::vec_deque::Iterimpl Default for std::collections::vec_deque::IterMutRc<T>::new_uninitRc<MaybeUninit<T>>::assume_initRc<[T]>::new_uninit_sliceRc<[MaybeUninit<T>]>::assume_initArc<T>::new_uninitArc<MaybeUninit<T>>::assume_initArc<[T]>::new_uninit_sliceArc<[MaybeUninit<T>]>::assume_initBox<T>::new_uninitBox<MaybeUninit<T>>::assume_initBox<[T]>::new_uninit_sliceBox<[MaybeUninit<T>]>::assume_initcore::arch::x86_64::_bextri_u64core::arch::x86_64::_bextri_u32core::arch::x86::_mm_broadcastsi128_si256core::arch::x86::_mm256_stream_load_si256core::arch::x86::_tzcnt_u16core::arch::x86::_mm_extracti_si64core::arch::x86::_mm_inserti_si64core::arch::x86::_mm_storeu_si16core::arch::x86::_mm_storeu_si32core::arch::x86::_mm_storeu_si64core::arch::x86::_mm_loadu_si16core::arch::x86::_mm_loadu_si32core::arch::wasm32::u8x16_relaxed_swizzlecore::arch::wasm32::i8x16_relaxed_swizzlecore::arch::wasm32::i32x4_relaxed_trunc_f32x4core::arch::wasm32::u32x4_relaxed_trunc_f32x4core::arch::wasm32::i32x4_relaxed_trunc_f64x2_zerocore::arch::wasm32::u32x4_relaxed_trunc_f64x2_zerocore::arch::wasm32::f32x4_relaxed_maddcore::arch::wasm32::f32x4_relaxed_nmaddcore::arch::wasm32::f64x2_relaxed_maddcore::arch::wasm32::f64x2_relaxed_nmaddcore::arch::wasm32::i8x16_relaxed_laneselectcore::arch::wasm32::u8x16_relaxed_laneselect- [`core::arch:...
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_constantto 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
transmutesize checks. - Remove the
box_pointerslint. - 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_stdXtensa targets:xtensa-esp32-none-elf,xtensa-esp32s2-none-elf,xtensa-esp32s3-none-elf - Add Tier 3
stdXtensa targets:xtensa-esp32-espidf,xtensa-esp32s2-espidf,xtensa-esp32s3-espidf - Add Tier 3 i686 Redox OS target:
i686-unknown-redox - Promote
arm64ec-pc-windows-msvcto Tier 2. - Promote
loongarch64-unknown-linux-muslto 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
PanicInfoand std'sPanicInfo. (see compatibility note below) - Generalize
{Rc,Arc}::make_mut()to unsized types. - Replace sort implementations with stable
driftsortand 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_allwith respect to empty paths. - Fix interleaved output in the default panic hook when multiple threads panic simultaneously.
- Fix
Command's batch files argument escaping not working when file name has trailing whitespace or periods (CVE-2024-43402).
Stabilized APIs
core::errorhint::assert_uncheckedfs::existsAtomicBool::fetch_notDuration::abs_diffIoSlice::advanceIoSlice::advance_slicesIoSliceMut::advanceIoSliceMut::advance_slicesPanicHookInfoPanicInfo::messagePanicMessage
These APIs are now stable in const contexts:
char::from_u32_unchecked(function)char::from_u32_unchecked(method)CStr::count_bytesCStr::from_ptr
Cargo
- Generated
.cargo_vcs_info.jsonis always included, even when--allow-dirtyis passed. - Disallow
package.license-fileandpackage.readmepointing to non-existent files during packaging. - Disallow passing
--release/--debugflag along with the--profileflag. - Remove
lib.pluginkey 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-wasitarget will now issue a compiler warning and request users switch to thewasm32-wasip1target instead. Both targets are the same,wasm32-wasiis only being renamed, and this change to the WASI target is being done to enable removingwasm32-wasiin January 2025. -
We have renamed
std::panic::PanicInfotostd::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::PanicInfowill remain unchanged, however, as this is now a different type.The reason is that these types have different roles:
std::panic::PanicHookInfois the argument to the panic hook in std context (where panics can have an arbitrary payload), whilecore::panic::PanicInfois 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_patternfeature - Guarantee layout and ABI of
Resultin 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_fallibleslint to lint on fallibles behind references. - self-contained linker: retry linking without
-fuse-ld=lldon 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_ofandsize_of_valandalign_ofandalign_of_valto 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_extensionwould add a path separator - Add assert_unsafe_precondition to unchecked_{add,sub,neg,mul,shl,shr} methods
- Update
c_charon AIX to use the correct type offset_of!no longer returns a temporary- Handle sigma in
str.to_lowercasecorrectly - Raise
DEFAULT_MIN_STACK_SIZEto 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>LazyCellLazyLockDuration::div_duration_f32Duration::div_duration_f64Option::take_ifSeek::seek_relativeBinaryHeap::as_sliceNonNull::offsetNonNull::byte_offsetNonNull::addNonNull::byte_addNonNull::subNonNull::byte_subNonNull::offset_fromNonNull::byte_offset_fromNonNull::readNonNull::read_volatileNonNull::read_unalignedNonNull::writeNonNull::write_volatileNonNull::write_unalignedNonNull::write_bytesNonNull::copy_toNonNull::copy_to_nonoverlappingNonNull::copy_fromNonNull::copy_from_nonoverlappingNonNull::replaceNonNull::swapNonNull::drop_in_placeNonNull::align_offset<[T]>::split_at_checked<[T]>::split_at_mut_checkedstr::split_at_checkedstr::split_at_mut_checkedstr::trim_asciistr::trim_ascii_startstr::trim_ascii_end<[u8]>::trim_ascii<[u8]>::trim_ascii_start<[u8]>::trim_ascii_endIpv4Addr::BITSIpv4Addr::to_bitsIpv4Addr::from_bitsIpv6Addr::BITSIpv6Addr::to_bitsIpv6Addr::from_bitsVec::<[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_lifetimeslint to detect lifetimes which are semantically redundant. - Stabilize the
unnameable_typeslint for public types that can't be named. - Enable debuginfo in macros, and stabilize
-C collapse-macro-debuginfoand#[collapse_debuginfo]. - Propagate temporary lifetime extension into
ifandmatchexpressions. - Restrict promotion of
const fncalls. - Warn against refining impls of crate-private traits with
refining_impl_traitlint. - Stabilize associated type bounds (RFC 2289).
- Stabilize importing
mainfrom other modules or crates. - Check return types of function types for well-formedness
- Rework
impl Traitlifetime inference - Change inductive trait solver cycles to be ambiguous
Compiler
- Define
-C stripto only affect binaries, not artifacts like.pdb. - Stabilize
-Crelro-levelfor controlling runtime link hardening. - Stabilize checking of
cfgnames 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-visionosandaarch64-apple-visionos-simtier 3 targets. - Add
riscv32ima-unknown-none-elftier 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
FromIteratorfor(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
transmutebetween 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_chunksstr::Utf8Chunksstr::Utf8Chunk<*const T>::is_aligned<*mut T>::is_alignedNonNull::is_aligned<*const [T]>::len<*mut [T]>::len<*const [T]>::is_empty<*mut [T]>::is_emptyNonNull::<[T]>::is_emptyCStr::count_bytesio::Error::downcastnum::NonZero<T>path::absoluteproc_macro::Literal::byte_characterproc_macro::Literal::c_string
These APIs are now stable in const contexts:
Atomic*::into_innerio::Cursor::newio::Cursor::get_refio::Cursor::positionio::emptyio::repeatio::sinkpanic::Location::callerpanic::Location::filepanic::Location::linepanic::Location::column
Cargo
- Prevent dashes in
lib.name, always normalizing to_. - Stabilize MSRV-aware version requirement selection in
cargo add. - Switch to using
gitoxideby 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.
RustcEncodableandRustcDecodableare soft-destabilized, to be removed from the prelude in next edition.- The
wasm_c_abifuture-incompatibility lint will warn about use of the non-spec-compliant C ABI. Usewasm-bindgen v0.2.88to 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_castingto include references casting to bigger memory layout - Add
non_contiguous_range_endpointslint for singleton gaps after exclusive ranges - Add
wasm_c_abilint for use of older wasm-bindgen versions This lint currently only works when using Cargo. - Update
indirect_structural_matchandpointer_structural_matchlints to match RFC - Make non-
PartialEq-typed consts as patterns a hard error - Split
refining_impl_traitlint into_reachable,_internalvariants - 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 Traittodyn Trait + Auto
Compiler
- Made
INVALID_DOC_ATTRIBUTESlint deny by default - Increase accuracy of redundant
usechecking - 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-wasip1tier 2 (without host tools) target - Add
wasm32-wasip2tier 3 target - Rename
wasm32-wasi-preview1-threadstowasm32-wasip1-threads - Add
arm64ec-pc-windows-msvctier 3 target - Add
armv8r-none-eabihftier 3 target for the Cortex-R52 - Add
loongarch64-unknown-linux-musltier 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
RwLockwith 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
'staticlifetimes for severalstd::error::Errorrelated 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-versionwhen generating lockfile - Control
--charsetvia auto-detecting config value - Support
target.<triple>.rustdocflagsofficially - 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_overflowlint - Fix detection of potential interior mutability in
constinitializers 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 theFreezetrait 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_refsto warn on references to mutable statics. - Support async recursive calls (as long as they have indirection).
- Undeprecate lint
unstable_featuresand 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 compatibility lint for now.
- Deny braced macro invocations in let-else.
Compiler
- Include lint
soft_unstablein future breakage reports. - Make
i128andu12816-byte aligned on x86-based targets. - Use
--verbosein diagnostic output. - Improve spacing between printed tokens.
- Merge the
unused_tuple_struct_fieldslint 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/constitems implied bounds and well-formedness check. - Promote
riscv32{im|imafc}-unknown-none-elftargets 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_refarray::each_mutcore::netf32::round_ties_evenf64::round_ties_evenmem::offset_of!slice::first_chunkslice::first_chunk_mutslice::split_first_chunkslice::split_first_chunk_mutslice::last_chunkslice::last_chunk_mutslice::split_last_chunkslice::split_last_chunk_mutslice::chunk_byslice::chunk_by_mutBound::mapFile::create_newMutex::clear_poisonRwLock::clear_poison
Cargo
- Extend the build directive syntax with
cargo::. - Stabilize metadata
idformat asPackageIDSpec. - Pull out
cargo-util-schemasas 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_comparisonsthat supersedesclippy::vtable_address_comparisons
Compiler
- Lint pinned
#[must_use]pointers (in particular,Box<T>whereTis#[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_typefield 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
RwLockReadGuardandRwLockWriteGuard's Debug impls. - Windows: Allow
File::createto work on hidden files
Stabilized APIs
Arc::unwrap_or_cloneRc::unwrap_or_cloneResult::inspectResult::inspect_errOption::inspecttype_name_of_valstd::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_ttsThis 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_ENTAILMENTinto 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 Vecfor more details. - Properly reject
defaulton free const items