Rust versions / 1.80
Rust release · Jul 25, 2024
Rust 1.80: what's new, what was stabilized
Short answerRust 1.80 was released on Jul 25, 2024: 1 language stabilization (Stabilize exclusive_range_pattern feature); 60 newly stable APIs (impl Default for Rc<CStr>, impl Default for Rc<str>, impl Default for Rc<[T]>, impl Default for Arc<str>, ...); 11 compatibility notes that can affect existing code. Point release: 1.80.1 (Aug 8, 2024).
← Rust 1.79All versionsRust 1.81 →
Language features stabilized
- Stabilize exclusive_range_pattern feature
60 APIs stabilized
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, <[T]>::last_chunk, BinaryHeap::new
Can it break my build?
The release lists these compatibility notes. Most only affect rare code, but read them before you raise your toolchain in CI:
- rustfmt estimates line lengths differently when using non-ascii characters
- Type aliases are now handled correctly in orphan check
- Allow instructing rustdoc to read from stdin via
- std::env::{set_var, remove_var}can no longer be converted to safe function pointers and no longer implement theFnfamily of traits- Warn (or error) when
Selfconstructor from outer item is referenced in inner nested item - Turn
indirect_structural_matchandpointer_structural_matchlints into hard errors - Make
where_clause_object_safetylint a regular object safety violation - Turn
proc_macro_back_compatlint into a hard error. - Detect unused structs even when implementing private traits
std::sync::ReentrantLockGuard<T>is no longerSyncifT: !Syncwhich meansstd::io::StdoutLockandstd::io::StderrLockare no longer Sync- Type inference will fail in some cases due to new implementations of
FromIterator for Box<str>.
Use it
rustup update stable # get the newest release
rustup install 1.80 # or exactly this one
rustup override set 1.80 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.80" under [package] in Cargo.toml. Cargo then refuses to build it on older compilers with a clear message, and with resolver 3 (the default on the 2024 edition, Rust 1.85+) it also prefers dependency versions that support it.
Full release notes
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
<a id="1.80-Compiler"></a>
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](https://github.com/rust-lang/rust/pull/124097/)
<a id="1.80-Libraries"></a>
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
<a id="1.80-Stabilized-APIs"></a>
Stabilized APIs
impl Default for Rc<CStr>impl Default for Rc<str>- [
impl Default for Rc<[T]>](https://doc.rust-lang.org/beta/alloc/rc/struct.Rc.html#impl-Default-for-Rc%3C%5BT%5D%3E) impl Default for Arc<str>impl Default for Arc<CStr>- [
impl Default for Arc<[T]>](https://doc.rust-lang.org/beta/alloc/sync/struct.Arc.html#impl-Default-for-Arc%3C%5BT%5D%3E) - [
impl IntoIterator for Box<[T]>](https://doc.rust-lang.org/beta/alloc/boxed/struct.Box.html#impl-IntoIterator-for-Box%3C%5BI%5D,+A%3E) 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](https://doc.rust-lang.org/beta/std/primitive.slice.html#method.split_at_checked) - [
<[T]>::split_at_mut_checked](https://doc.rust-lang.org/beta/std/primitive.slice.html#method.split_at_mut_checked) str::split_at_checkedstr::split_at_mut_checkedstr::trim_asciistr::trim_ascii_startstr::trim_ascii_end- [
<[u8]>::trim_ascii](https://doc.rust-lang.org/beta/core/primitive.slice.html#method.trim_ascii) - [
<[u8]>::trim_ascii_start](https://doc.rust-lang.org/beta/core/primitive.slice.html#method.trim_ascii_start) - [
<[u8]>::trim_ascii_end](https://doc.rust-lang.org/beta/core/primitive.slice.html#method.trim_ascii_end) Ipv4Addr::BITSIpv4Addr::to_bitsIpv4Addr::from_bitsIpv6Addr::BITSIpv6Addr::to_bitsIpv6Addr::from_bits- [
Vec::<[T; N]>::into_flattened](https://doc.rust-lang.org/beta/alloc/vec/struct.Vec.html#method.into_flattened) - [
<[[T; N]]>::as_flattened](https://doc.rust-lang.org/beta/core/primitive.slice.html#method.as_flattened) - [
<[[T; N]]>::as_flattened_mut](https://doc.rust-lang.org/beta/core/primitive.slice.html#method.as_flattened_mut)
These APIs are now stable in const contexts:
- [
<[T]>::last_chunk](https://doc.rust-lang.org/beta/core/primitive.slice.html#method.last_chunk) BinaryHeap::new
<a id="1.80-Cargo"></a>
Cargo
- Stabilize
-Zcheck-cfgas always enabled - Warn, rather than fail publish, if a target is excluded
- Add special
check-cfglint config for theunexpected_cfgslint - Stabilize
cargo update --precise <yanked> - Don't change file permissions on
Cargo.tomlwhen usingcargo add - Support using
cargo fixon IPv6-only networks
<a id="1.80-Rustdoc"></a>
Rustdoc
- Allow searching for references
- Stabilize
custom_code_classes_in_docsfeature - fix: In cross-crate scenarios show enum variants on type aliases of enums
<a id="1.80-Compatibility-Notes"></a>
Compatibility Notes
- rustfmt estimates line lengths differently when using non-ascii characters
- Type aliases are now handled correctly in orphan check
- Allow instructing rustdoc to read from stdin via
- std::env::{set_var, remove_var}can no longer be converted to safe function pointers and no longer implement theFnfamily of traits- Warn (or error) when
Selfconstructor from outer item is referenced in inner nested item - Turn
indirect_structural_matchandpointer_structural_matchlints into hard errors - Make
where_clause_object_safetylint a regular object safety violation - Turn
proc_macro_back_compatlint into a hard error. - Detect unused structs even when implementing private traits
std::sync::ReentrantLockGuard<T>is no longerSyncifT: !Syncwhich meansstd::io::StdoutLockandstd::io::StderrLockare no longer Sync- Type inference will fail in some cases due to new implementations of
FromIterator for Box<str>. Notably, this breaks versions of thetimecrate before 0.3.35, due to no longer inferring the implementation forBox<[_]>.
<a id="1.80-Internal-Changes"></a>
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.
- Misc improvements to size of generated html by rustdoc e.g. #124738 and #123734
- MSVC targets no longer depend on libc
1.80.1 (Aug 8, 2024)
<a id="1.80.1"></a>
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.81Released Sep 5, 2024.Read it next →Also worth your time
Did this answer your question?