Rust versions / 1.76
Rust release · Feb 8, 2024
Rust 1.76: what's new, what was stabilized
Short answerRust 1.76 was released on Feb 8, 2024: 9 newly stable APIs (Arc::unwrap_or_clone, Rc::unwrap_or_clone, Result::inspect, Result::inspect_err, ...); 9 compatibility notes that can affect existing code.
← Rust 1.75All versionsRust 1.77 →
9 APIs stabilized
Arc::unwrap_or_clone, Rc::unwrap_or_clone, Result::inspect, Result::inspect_err, Option::inspect, type_name_of_val, std::hash::{DefaultHasher, RandomState}, ptr::{from_ref, from_mut}, ptr::addr_eq
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:
- Add allow-by-default lint for unit bindings
- Remove x86_64-sun-solaris target.
- Remove asmjs-unknown-emscripten target
- Report errors in jobserver inherited through environment variables
- Update the minimum external LLVM to 16.
- Improve
print_tts - Make
IMPLIED_BOUNDS_ENTAILMENTinto a hard error from a lint - Vec's allocation behavior was changed when collecting some iterators
- Properly reject
defaulton free const items
Use it
rustup update stable # get the newest release
rustup install 1.76 # or exactly this one
rustup override set 1.76 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.76" 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 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
<a id="1.76.0-Compiler"></a>
Compiler
- [Lint pinned
#[must_use]pointers (in particular,Box<T>whereTis#[must_use]) inunused_must_use.](https://github.com/rust-lang/rust/pull/118054/) - 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][platform-support-doc] for more information on Rust's tiered platform support.
<a id="1.76.0-Libraries"></a>
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
<a id="1.76.0-Stabilized-APIs"></a>
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
<a id="1.76.0-Cargo"></a>
Cargo
See Cargo release notes.
<a id="1.76.0-Rustdoc"></a>
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
<a id="1.76.0-Compatibility-Notes"></a>
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
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.77Released Mar 21, 2024.Read it next →Also worth your time
Did this answer your question?