Releases: rust-lang/rust
Rust 1.60.0
Language
- Stabilize
#[cfg(panic = "...")]for either"unwind"or"abort". - Stabilize
#[cfg(target_has_atomic = "...")]for each integer size and"ptr".
Compiler
- Enable combining
+crt-staticandrelocation-model=piconx86_64-unknown-linux-gnu - Fixes wrong
unreachable_publints on nested and glob public reexport - Stabilize
-Z instrument-coverageas-C instrument-coverage - Stabilize
-Z print-link-argsas--print link-args - Add new Tier 3 target
mips64-openwrt-linux-musl* - Add new Tier 3 target
armv7-unknown-linux-uclibceabi(softfloat)* - Fix invalid removal of newlines from doc comments
- Add kernel target for RustyHermit
- Deny mixing bin crate type with lib crate types
- Make rustc use
RUST_BACKTRACE=fullby default - Upgrade to LLVM 14
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- Guarantee call order for
sort_by_cached_key - Improve
Duration::try_from_secs_f32/f64accuracy by directly processing exponent and mantissa - Make
Instant::{duration_since, elapsed, sub}saturating - Remove non-monotonic clocks workarounds in
Instant::now - Make
BuildHasherDefault,iter::Emptyandfuture::Pendingcovariant
Stabilized APIs
Arc::new_cyclicRc::new_cyclicslice::EscapeAscii<[u8]>::escape_asciiu8::escape_asciiVec::spare_capacity_mutMaybeUninit::assume_init_dropMaybeUninit::assume_init_readi8::abs_diffi16::abs_diffi32::abs_diffi64::abs_diffi128::abs_diffisize::abs_diffu8::abs_diffu16::abs_diffu32::abs_diffu64::abs_diffu128::abs_diffusize::abs_diffDisplay for io::ErrorKindFrom<u8> for ExitCodeNot for !(the "never" type)- Op
Assign<$t> for Wrapping<$t> arch::is_aarch64_feature_detected!
Cargo
- Port cargo from
toml-rstotoml_edit - Stabilize
-Ztimingsas--timings - Stabilize namespaced and weak dependency features.
- Accept more
cargo:rustc-link-arg-*types from build script output. - cargo-new should not add ignore rule on Cargo.lock inside subdirs
Misc
- Ship docs on Tier 2 platforms by reusing the closest Tier 1 platform docs
- Drop rustc-docs from complete profile
- bootstrap: tidy up flag handling for llvm build
Compatibility Notes
- Remove compiler-rt linking hack on Android
- Mitigations for platforms with non-monotonic clocks have been removed from
Instant::now. On platforms that don't provide monotonic clocks, an instant is not guaranteed to be greater than an earlier instant anymore. Instant::{duration_since, elapsed, sub}do not panic anymore on underflow, saturating to0instead. In the real world the panic happened mostly on platforms with buggy monotonic clock implementations rather than catching programming errors like reversing the start and end times. Such programming errors will now result in0rather than a panic.- In a future release we're planning to increase the baseline requirements for the Linux kernel to version 3.2, and for glibc to version 2.17. We'd love your feedback in PR #95026.
Internal Changes
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.
Rust 1.59.0
Language
- Stabilize default arguments for const parameters and remove the ordering restriction for type and const parameters
- Stabilize destructuring assignment
- Relax private in public lint on generic bounds and where clauses of trait impls
- Stabilize asm! and global_asm! for x86, x86_64, ARM, Aarch64, and RISC-V
Compiler
- Stabilize new symbol mangling format, leaving it opt-in (-Csymbol-mangling-version=v0)
- Emit LLVM optimization remarks when enabled with
-Cremark - Fix sparc64 ABI for aggregates with floating point members
- Warn when a
#[test]-like built-in attribute macro is present multiple times. - Add support for riscv64gc-unknown-freebsd
- Stabilize
-Z emit-future-incompatas--json future-incompat - Soft disable incremental compilation
This release disables incremental compilation, unless the user has explicitly opted in via the newly added RUSTC_FORCE_INCREMENTAL=1 environment variable. This is due to a known and relatively frequently occurring bug in incremental compilation, which causes builds to issue internal compiler errors. This particular bug is already fixed on nightly, but that fix has not yet rolled out to stable and is deemed too risky for a direct stable backport.
As always, we encourage users to test with nightly and report bugs so that we can track failures and fix issues earlier.
See 94124 for more details.
Libraries
Stabilized APIs
std::thread::available_parallelismResult::copiedResult::clonedarch::asm!arch::global_asm!ops::ControlFlow::is_breakops::ControlFlow::is_continueTryFrom<char> for u8char::TryFromCharErrorimplementingClone,Debug,Display,PartialEq,Copy,Eq,Erroriter::zipNonZeroU8::is_power_of_twoNonZeroU16::is_power_of_twoNonZeroU32::is_power_of_twoNonZeroU64::is_power_of_twoNonZeroU128::is_power_of_twoNonZeroUsize::is_power_of_twoDoubleEndedIterator for ToLowercaseDoubleEndedIterator for ToUppercaseTryFrom<&mut [T]> for [T; N]UnwindSafe for OnceRefUnwindSafe for Once- armv8 neon intrinsics for aarch64
Const-stable:
mem::MaybeUninit::as_ptrmem::MaybeUninit::assume_initmem::MaybeUninit::assume_init_refffi::CStr::from_bytes_with_nul_unchecked
Cargo
- Stabilize the
stripprofile option - Stabilize future-incompat-report
- Support abbreviating
--releaseas-r - Support
term.quietconfiguration - Remove
--hostfrom cargo {publish,search,login}
Compatibility Notes
- Refactor weak symbols in std::sys::unix This may add new, versioned, symbols when building with a newer glibc, as the standard library uses weak linkage rather than dynamically attempting to load certain symbols at runtime.
- Deprecate crate_type and crate_name nested inside
#![cfg_attr]This adds a future compatibility lint to supporting the use of cfg_attr wrapping either crate_type or crate_name specification within Rust files; it is recommended that users migrate to setting the equivalent command line flags. - Remove effect of
#[no_link]attribute on name resolution This may expose new names, leading to conflicts with preexisting names in a given namespace and a compilation failure. - Cargo will document libraries before binaries.
- Respect doc=false in dependencies, not just the root crate
- Weaken guarantee around advancing underlying iterators in zip
- Make split_inclusive() on an empty slice yield an empty output
- Update std::env::temp_dir to use GetTempPath2 on Windows when available.
- unreachable! was updated to match other formatting macro behavior on Rust 2021
Internal Changes
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.
Rust 1.58.1
Rust 1.58.0
Language
- Format strings can now capture arguments simply by writing
{ident}in the string. This works in all macros accepting format strings. Support for this inpanic!(panic!("{ident}")) requires the 2021 edition; panic invocations in previous editions that appear to be trying to use this will result in a warning lint about not having the intended effect. *const Tpointers can now be dereferenced in const contexts.- The rules for when a generic struct implements
Unsizehave been relaxed.
Compiler
- Add LLVM CFI support to the Rust compiler
- Stabilize -Z strip as -C strip. Note that while release builds already don't add debug symbols for the code you compile, the compiled standard library that ships with Rust includes debug symbols, so you may want to use the
stripoption to remove these symbols to produce smaller release binaries. Note that this release only includes support in rustc, not directly in cargo. - Add support for LLVM coverage mapping format versions 5 and 6
- Emit LLVM optimization remarks when enabled with
-Cremark - Update the minimum external LLVM to 12
- Add
x86_64-unknown-noneat Tier 3* - Build musl dist artifacts with debuginfo enabled. When building release binaries using musl, you may want to use the newly stabilized strip option to remove these debug symbols, reducing the size of your binaries.
- Don't abort compilation after giving a lint error
- Error messages point at the source of trait bound obligations in more places
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- All remaining functions in the standard library have
#[must_use]annotations where appropriate, producing a warning when ignoring their return value. This helps catch mistakes such as expecting a function to mutate a value in place rather than return a new value. - Paths are automatically canonicalized on Windows for operations that support it
- Re-enable debug checks for
copyandcopy_nonoverlapping - Implement
RefUnwindSafeforRc<T> - Make RSplit<T, P>: Clone not require T: Clone
- Implement
TerminationforResult<Infallible, E>. This allows writingfn main() -> Result<Infallible, ErrorType>, for a program whose successful exits never involve returning frommain(for instance, a program that callsexit, or that usesexecto run another program).
Stabilized APIs
Metadata::is_symlinkPath::is_symlink{integer}::saturating_divOption::unwrap_uncheckedResult::unwrap_uncheckedResult::unwrap_err_uncheckedFile::options
These APIs are now usable in const contexts:
Duration::newDuration::checked_addDuration::saturating_addDuration::checked_subDuration::saturating_subDuration::checked_mulDuration::saturating_mulDuration::checked_div
Cargo
Rustdoc
Compatibility Notes
- Try all stable method candidates first before trying unstable ones. This change ensures that adding new nightly-only methods to the Rust standard library will not break code invoking methods of the same name from traits outside the standard library.
- Windows:
std::process::Commandwill no longer search the current directory for executables. - All proc-macro backward-compatibility lints are now deny-by-default.
- proc_macro: Append .0 to unsuffixed float if it would otherwise become int token
- Refactor weak symbols in std::sys::unix. This optimizes accesses to glibc functions, by avoiding the use of dlopen. This does not increase the minimum expected version of glibc. However, software distributions that use symbol versions to detect library dependencies, and which take weak symbols into account in that analysis, may detect rust binaries as requiring newer versions of glibc.
- rustdoc now rejects some unexpected semicolons in doctests
Internal Changes
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.
Rust 1.57.0
Language
- Macro attributes may follow
#[derive]and will see the original (pre-cfg) input. - Accept curly-brace macros in expressions, like
m!{ .. }.method()andm!{ .. }?. - Allow panicking in constant evaluation.
- Ignore derived
CloneandDebugimplementations during dead code analysis.
Compiler
- Create more accurate debuginfo for vtables.
- Add
armv6k-nintendo-3dsat Tier 3*. - Add
armv7-unknown-linux-uclibceabihfat Tier 3*. - Add
m68k-unknown-linux-gnuat Tier 3*. - Add SOLID targets at Tier 3*:
aarch64-kmc-solid_asp3,armv7a-kmc-solid_asp3-eabi,armv7a-kmc-solid_asp3-eabihf
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- Avoid allocations and copying in
Vec::leak - Add
#[repr(i8)]toOrdering - Optimize
File::read_to_endandread_to_string - Update to Unicode 14.0
- Many more functions are marked
#[must_use], producing a warning when ignoring their return value. This helps catch mistakes such as expecting a function to mutate a value in place rather than return a new value.
Stabilised APIs
[T; N]::as_mut_slice[T; N]::as_slicecollections::TryReserveErrorHashMap::try_reserveHashSet::try_reserveString::try_reserveString::try_reserve_exactVec::try_reserveVec::try_reserve_exactVecDeque::try_reserveVecDeque::try_reserve_exactIterator::map_whileiter::MapWhileproc_macro::is_availableCommand::get_programCommand::get_argsCommand::get_envsCommand::get_current_dirCommandArgsCommandEnvs
These APIs are now usable in const contexts:
Cargo
Compatibility notes
- Ignore derived
CloneandDebugimplementations during dead code analysis. This will break some builds that set#![deny(dead_code)].
Internal changes
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.
Rust 1.56.1
- New lints to detect the presence of bidirectional-override Unicode codepoints in the compiled source code (CVE-2021-42574)
Rust 1.56.0
Language
- The 2021 Edition is now stable. See the edition guide for more details.
- The pattern in
binding @ patterncan now also introduce new bindings. - Union field access is permitted in
const fn.
Compiler
- Upgrade to LLVM 13.
- Support memory, address, and thread sanitizers on aarch64-unknown-freebsd.
- Allow specifying a deployment target version for all iOS targets
- Warnings can be forced on with
--force-warn. This feature is primarily intended for usage bycargo fix, rather than end users. - Promote
aarch64-apple-ios-simto Tier 2*. - Add
powerpc-unknown-freebsdat Tier 3*. - Add
riscv32imc-esp-espidfat Tier 3*.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- Allow writing of incomplete UTF-8 sequences via stdout/stderr on Windows. The Windows console still requires valid Unicode, but this change allows splitting a UTF-8 character across multiple write calls. This allows, for instance, programs that just read and write data buffers (e.g. copying a file to stdout) without regard for Unicode or character boundaries.
- Prefer
AtomicU{64,128}over Mutex for Instant backsliding protection. For this use case, atomics scale much better under contention. - Implement
Extend<(A, B)>for(Extend<A>, Extend<B>) - impl Default, Copy, Clone for std::io::Sink and std::io::Empty
impl From<[(K, V); N]>for all collections.- Remove
P: Unpinbound on impl Future for Pin. - Treat invalid environment variable names as nonexistent. Previously, the environment functions would panic if given a variable name with an internal null character or equal sign (
=). Now, these functions will just treat such names as nonexistent variables, since the OS cannot represent the existence of a variable with such a name.
Stabilised APIs
std::os::unix::fs::chrootUnsafeCell::raw_getBufWriter::into_partscore::panic::{UnwindSafe, RefUnwindSafe, AssertUnwindSafe}These APIs were previously stable instd, but are now also available incore.Vec::shrink_toString::shrink_toOsString::shrink_toPathBuf::shrink_toBinaryHeap::shrink_toVecDeque::shrink_toHashMap::shrink_toHashSet::shrink_to
These APIs are now usable in const contexts:
Cargo
- Cargo supports specifying a minimum supported Rust version in Cargo.toml. This has no effect at present on dependency version selection. We encourage crates to specify their minimum supported Rust version, and we encourage CI systems that support Rust code to include a crate's specified minimum version in the test matrix for that crate by default.
Compatibility notes
- Update to new argument parsing rules on Windows. This adjusts Rust's standard library to match the behavior of the standard libraries for C/C++. The rules have changed slightly over time, and this PR brings us to the latest set of rules (changed in 2008).
- Disallow the aapcs calling convention on aarch64 This was already not supported by LLVM; this change surfaces this lack of support with a better error message.
- Make
SEMICOLON_IN_EXPRESSIONS_FROM_MACROSwarn by default - Warn when an escaped newline skips multiple lines.
- Calls to
libc::getpid/std::process::idfromCommand::pre_execmay return different values on glibc <= 2.24. Rust now invokes theclone3system call directly, when available, to use new functionality available via that system call. Older versions of glibc cache the result ofgetpid, and only update that cache when calling glibc's clone/fork functions, so a direct system call bypasses that cache update. glibc 2.25 and newer no longer cachegetpidfor exactly this reason.
Internal changes
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.
- LLVM is compiled with PGO in published x86_64-unknown-linux-gnu artifacts. This improves the performance of most Rust builds.
- Unify representation of macros in internal data structures. This change fixes a host of bugs with the handling of macros by the compiler, as well as rustdoc.
Rust 1.55.0
Language
- You can now write open "from" range patterns (
X..), which will start atXand will end at the maximum value of the integer. - You can now explicitly import the prelude of different editions through
std::prelude(e.g.use std::prelude::rust_2021::*;).
Compiler
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- Updated std's float parsing to use the Eisel-Lemire algorithm. These improvements should in general provide faster string parsing of floats, no longer reject certain valid floating point values, and reduce the produced code size for non-stripped artifacts.
string::Drainnow implementsAsRef<str>andAsRef<[u8]>.
Stabilised APIs
Bound::clonedDrain::as_strIntoInnerError::into_errorIntoInnerError::into_partsMaybeUninit::assume_init_mutMaybeUninit::assume_init_refMaybeUninit::writearray::mapops::ControlFlowx86::_bittestx86::_bittestandcomplementx86::_bittestandresetx86::_bittestandsetx86_64::_bittest64x86_64::_bittestandcomplement64x86_64::_bittestandreset64x86_64::_bittestandset64
The following previously stable functions are now const.
Cargo
- Cargo will now deduplicate compiler diagnostics to the terminal when invoking rustc in parallel such as when using
cargo test. - The package definition in
cargo metadatanow includes the"default_run"field from the manifest. - Added
cargo das an alias forcargo doc. - Added
{lib}as formatting option forcargo treeto print the"lib_name"of packages.
Rustdoc
- Added "Go to item on exact match" search option.
- The "Implementors" section on traits no longer shows redundant method definitions.
- Trait implementations are toggled open by default. This should make the implementations more searchable by tools like
CTRL+Fin your browser. - Intra-doc links should now correctly resolve associated items (e.g. methods) through type aliases.
- Traits which are marked with
#[doc(hidden)]will no longer appear in the "Trait Implementations" section.
Compatibility Notes
- std functions that return an
io::Errorwill no longer use theErrorKind::Othervariant. This is to better reflect that these kinds of errors could be categorised into newer more specificErrorKindvariants, and that they do not represent a user error. - Using environment variable names with
process::Commandon Windows now behaves as expected. Previously using environment variables withCommandwould cause them to be ASCII-uppercased. - Rustdoc will now warn on using rustdoc lints that aren't prefixed with
rustdoc:: RUSTFLAGSis no longer set for build scripts. Build scripts should useCARGO_ENCODED_RUSTFLAGSinstead. See the documentation for more details.
Rust 1.54.0
Language
-
You can now use macros for values in some built-in attributes. This primarily allows you to call macros within the
#[doc]attribute. For example, to include external documentation in your crate, you can now write the following:#![doc = include_str!("README.md")] -
You can now cast between unsized slice types (and types which contain unsized slices) in
const fn. -
You can now use multiple generic lifetimes with
impl Traitwhere the lifetimes don't explicitly outlive another. In code this means that you can now haveimpl Trait<'a, 'b>where as before you could only haveimpl Trait<'a, 'b> where 'b: 'a.
Compiler
- Rustc will now search for custom JSON targets in
/lib/rustlib/<target-triple>/target.jsonwhere/is the "sysroot" directory. You can find your sysroot directory by runningrustc --print sysroot. - Added
wasmas atarget_familyfor WebAssembly platforms. - You can now use
#[target_feature]on safe functions when targeting WebAssembly platforms. - Improved debugger output for enums on Windows MSVC platforms.
- Added tier 3* support for
bpfel-unknown-noneandbpfeb-unknown-none. -Zmutable-noalias=yesis enabled by default when using LLVM 12 or above.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
panic::panic_anywill now#[track_caller].- Added
OutOfMemoryas a variant ofio::ErrorKind. -
proc_macro::Literalnow implementsFromStr. - The implementations of vendor intrinsics in core::arch have been significantly refactored. The main user-visible changes are a 50% reduction in the size of libcore.rlib and stricter validation of constant operands passed to intrinsics. The latter is technically a breaking change, but allows Rust to more closely match the C vendor intrinsics API.
Stabilized APIs
BTreeMap::into_keysBTreeMap::into_valuesHashMap::into_keysHashMap::into_valuesarch::wasm32VecDeque::binary_searchVecDeque::binary_search_byVecDeque::binary_search_by_keyVecDeque::partition_point
Cargo
- Added the
--prune <spec>option tocargo-treeto remove a package from the dependency graph. - Added the
--depthoption tocargo-treeto print only to a certain depth in the tree - Added the
no-proc-macrovalue tocargo-tree --edgesto hide procedural macro dependencies. - A new environment variable named
CARGO_TARGET_TMPDIRis available. This variable points to a directory that integration tests and benches can use as a "scratchpad" for testing filesystem operations.
Compatibility Notes
- Mixing Option and Result via
?is no longer permitted in closures for inferred types. - Previously unsound code is no longer permitted where different constructors in branches could require different lifetimes.
- As previously mentioned the
std::archintrinsics now uses stricter const checking than before and may reject some previously accepted code. i128multiplication on Cortex M0+ platforms currently unconditionally causes overflow when compiled withcodegen-units = 1.
Rust 1.53.0
Language
- You can now use unicode for identifiers. This allows multilingual identifiers but still doesn't allow glyphs that are not considered characters such as
◆or🦀. More specifically you can now use any identifier that matches the UAX #31 "Unicode Identifier and Pattern Syntax" standard. This is the same standard as languages like Python, however Rust uses NFC normalization which may be different from other languages. - You can now specify "or patterns" inside pattern matches. Previously you could only use
|(OR) on complete patterns. E.g.let x = Some(2u8); // Before matches!(x, Some(1) | Some(2)); // Now matches!(x, Some(1 | 2));
- Added the
:pat_parammacro_rules!matcher. This matcher has the same semantics as the:patmatcher. This is to allow:patto change semantics to being a pattern fragment in a future edition.
Compiler
- Updated the minimum external LLVM version to LLVM 10.
- Added Tier 3* support for the
wasm64-unknown-unknowntarget. - Improved debuginfo for closures and async functions on Windows MSVC.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- Abort messages will now forward to
android_set_abort_messageon Android platforms when available. slice::IterMut<'_, T>now implementsAsRef<[T]>- Arrays of any length now implement
IntoIterator. Currently calling.into_iter()as a method on an array will returnimpl Iterator<Item=&T>, but this may change in a future edition to changeItemtoT. CallingIntoIterator::into_iterdirectly on arrays will provideimpl Iterator<Item=T>as expected. leading_zeros, andtrailing_zerosare now available on allNonZerointeger types.{f32, f64}::from_strnow parse and print special values (NaN,-0) according to IEEE 754.- You can now index into slices using
(Bound<usize>, Bound<usize>). - Add the
BITSassociated constant to all numeric types.
Stabilised APIs
AtomicBool::fetch_updateAtomicPtr::fetch_updateBTreeMap::retainBTreeSet::retainBufReader::seek_relativeDebugStruct::non_exhaustiveDuration::MAXDuration::ZERODuration::is_zeroDuration::saturating_addDuration::saturating_mulDuration::saturating_subErrorKind::UnsupportedOption::insertOrdering::is_eqOrdering::is_geOrdering::is_gtOrdering::is_leOrdering::is_ltOrdering::is_neOsStr::is_asciiOsStr::make_ascii_lowercaseOsStr::make_ascii_uppercaseOsStr::to_ascii_lowercaseOsStr::to_ascii_uppercasePeekable::peek_mutRc::decrement_strong_countRc::increment_strong_countVec::extend_from_withinarray::from_mutarray::from_refcmp::max_by_keycmp::max_bycmp::min_by_keycmp::min_byf32::is_subnormalf64::is_subnormal
Cargo
- Cargo now supports git repositories where the default
HEADbranch is not "master". This also includes a switch to the version 3Cargo.lockformat which can handle default branches correctly. - macOS targets now default to
unpackedsplit-debuginfo. - The
authorsfield is no longer included inCargo.tomlfor new projects.
Rustdoc
Compatibility Notes
- Implement token-based handling of attributes during expansion
Ipv4::from_strwill now reject octal format IP addresses in addition to rejecting hexadecimal IP addresses. The octal format can lead to confusion and potential security vulnerabilities and is no longer recommended.- The added
BITSconstant may conflict with external definitions. In particular, this was known to be a problem in thelexical-corecrate, but they have published fixes for semantic versions 0.4 through 0.7. To update this dependency alone, usecargo update -p lexical-core. - Incremental compilation remains off by default, unless one uses the
RUSTC_FORCE_INCREMENTAL=1environment variable added in 1.52.1.
Internal Only
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.