Releases: rust-lang/rust
Rust 1.52.1
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 the widespread, and frequently occurring, breakage encountered by Rust users due to newly enabled incremental verification in 1.52.0. Notably, Rust users should upgrade to 1.52.0 or 1.52.1: the bugs that are detected by newly added incremental verification are still present in past stable versions, and are not yet fixed on any channel. These bugs can lead to miscompilation of Rust binaries.
These problems only affect incremental builds, so release builds with Cargo should not be affected unless the user has explicitly opted into incremental. Debug and check builds are affected.
See 84970 for more details.
Rust 1.52.0
Language
- Added the
unsafe_op_in_unsafe_fnlint, which checks whether the unsafe code in anunsafe fnis wrapped in aunsafeblock. This lint is allowed by default, and may become a warning or hard error in a future edition. - You can now cast mutable references to arrays to a pointer of the same type as the element.
Compiler
Added tier 3* support for the following targets.
s390x-unknown-linux-muslriscv32gc-unknown-linux-musl&riscv64gc-unknown-linux-muslpowerpc-unknown-openbsd
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
OsStringnow implementsExtendandFromIterator.cmp::Reversenow has#[repr(transparent)]representation.Arc<impl Error>now implementserror::Error.- All integer division and remainder operations are now
const.
Stabilised APIs
Arguments::as_strchar::MAXchar::REPLACEMENT_CHARACTERchar::UNICODE_VERSIONchar::decode_utf16char::from_digitchar::from_u32_uncheckedchar::from_u32slice::partition_pointstr::rsplit_oncestr::split_once
The following previously stable APIs are now const.
char::len_utf8char::len_utf16char::to_ascii_uppercasechar::to_ascii_lowercasechar::eq_ignore_ascii_caseu8::to_ascii_uppercaseu8::to_ascii_lowercaseu8::eq_ignore_ascii_case
Rustdoc
- Rustdoc lints are now treated as a tool lint, meaning that lints are now prefixed with
rustdoc::(e.g.#[warn(rustdoc::broken_intra_doc_links)]). Using the old style is still allowed, and will become a warning in a future release. - Rustdoc now supports argument files.
- Rustdoc now generates smart punctuation for documentation.
- You can now use "task lists" in Rustdoc Markdown. E.g.
- [x] Complete - [ ] Todo
Misc
- You can now pass multiple filters to tests. E.g.
cargo test -- foo barwill run all tests that matchfooandbar. - Rustup now distributes PDB symbols for the
stdlibrary on Windows, allowing you to seestdsymbols when debugging.
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.
- Check the result cache before the DepGraph when ensuring queries
- Try fast_reject::simplify_type in coherence before doing full check
- Only store a LocalDefId in some HIR nodes
- Store HIR attributes in a side table
Compatibility Notes
- Cargo build scripts are now forbidden from setting
RUSTC_BOOTSTRAP. - Removed support for the
x86_64-rumprun-netbsdtarget. - Deprecated the
x86_64-sun-solaristarget in favor ofx86_64-pc-solaris. - Rustdoc now only accepts
,,, and\tas delimiters for specifying languages in code blocks. - Rustc now catches more cases of
pub_use_of_private_extern_crate - Changes in how proc macros handle whitespace may lead to panics when used with older
proc-macro-hackversions. Acargo updateshould be sufficient to fix this in all cases. - Turn
#[derive]into a regular macro attribute
Rust 1.51.0
Language
- You can now parameterize items such as functions, traits, and
structs by constant values in addition to by types and lifetimes. Also known as "const generics" E.g. you can now write the following. Note: Only values of primitive integers,bool, orchartypes are currently permitted.struct GenericArray<T, const LENGTH: usize> { inner: [T; LENGTH] } impl<T, const LENGTH: usize> GenericArray<T, LENGTH> { const fn last(&self) -> Option<&T> { if LENGTH == 0 { None } else { Some(&self.inner[LENGTH - 1]) } } }
Compiler
- Added the
-Csplit-debuginfocodegen option for macOS platforms. This option controls whether debug information is split across multiple files or packed into a single file. Note This option is unstable on other platforms. - Added tier 3* support for
aarch64_be-unknown-linux-gnu,aarch64-unknown-linux-gnu_ilp32, andaarch64_be-unknown-linux-gnu_ilp32targets. - Added tier 3 support for
i386-unknown-linux-gnuandi486-unknown-linux-gnutargets. - The
target-cpu=nativeoption will now detect individual features of CPUs.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
Box::downcastis now also implemented for anydyn Any + Send + Syncobject.strnow implementsAsMut<str>.u64andu128now implementFrom<char>.Erroris now implemented for&TwhereTimplementsError.Poll::{map_ok, map_err}are now implemented forPoll<Option<Result<T, E>>>.unsigned_absis now implemented for all signed integer types.io::Emptynow implementsio::Seek.rc::Weak<T>andsync::Weak<T>'s methods such asas_ptrare now implemented forT: ?Sizedtypes.DivandRemby theirNonZerovariant is now implemented for all unsigned integers.
Stabilized APIs
Arc::decrement_strong_countArc::increment_strong_countOnce::call_once_forcePeekable::next_if_eqPeekable::next_ifSeek::stream_positionarray::IntoIterpanic::panic_anyptr::addr_of!ptr::addr_of_mut!slice::fill_withslice::split_inclusive_mutslice::split_inclusiveslice::strip_prefixslice::strip_suffixstr::split_inclusivesync::OnceStatetask::WakeVecDeque::rangeVecDeque::range_mut
Cargo
- Added the
split-debuginfoprofile option to control the -Csplit-debuginfo codegen option. - Added the
resolverfield toCargo.tomlto enable the new feature resolver and CLI option behavior. Version 2 of the feature resolver will try to avoid unifying features of dependencies where that unification could be unwanted. Such as using the same dependency with astdfeature in a build scripts and proc-macros, while using theno-stdfeature in the final binary. See the Cargo book documentation for more information on the feature.
Rustdoc
- Rustdoc will now include documentation for methods available from nested
Dereftraits. - You can now provide a
--default-themeflag which sets the default theme to use for documentation.
Various improvements to intra-doc links:
- You can link to non-path primitives such as
slice. - You can link to associated items.
- You can now include generic parameters when linking to items, like
Vec<T>.
Misc
Compatibility Notes
- WASI platforms no longer use the
wasm-bindgenABI, and instead use the wasm32 ABI. rustcno longer promotes division, modulo and indexing operations toconstthat could fail.- The minimum version of glibc for the following platforms has been bumped to version 2.31 for the distributed artifacts.
armv5te-unknown-linux-gnueabisparc64-unknown-linux-gnuthumbv7neon-unknown-linux-gnueabihfarmv7-unknown-linux-gnueabix86_64-unknown-linux-gnux32
atomic::spin_loop_hinthas been deprecated. It's recommended to usehint::spin_loopinstead.
Internal Only
Rust 1.50.0
Language
- You can now use
constvalues forxin[x; N]array expressions. This has been technically possible since 1.38.0, as it was unintentionally stabilized. - Assignments to
ManuallyDrop<T>union fields are now considered safe.
Compiler
- Added tier 3* support for the
armv5te-unknown-linux-uclibceabitarget. - Added tier 3 support for the
aarch64-apple-ios-macabitarget. - The
x86_64-unknown-freebsdis now built with the full toolset. - Dropped support for all cloudabi targets.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
proc_macro::Punctnow implementsPartialEq<char>.ops::{Index, IndexMut}are now implemented for fixed sized arrays of any length.- On Unix platforms, the
std::fs::Filetype now has a "niche" of-1. This value cannot be a valid file descriptor, and now meansOption<File>takes up the same amount of space asFile.
Stabilized APIs
bool::thenbtree_map::Entry::or_insert_with_keyf32::clampf64::clamphash_map::Entry::or_insert_with_keyOrd::clampRefCell::takeslice::fillUnsafeCell::get_mut
The following previously stable methods are now const.
IpAddr::is_ipv4IpAddr::is_ipv6IpAddr::is_unspecifiedIpAddr::is_loopbackIpAddr::is_multicastIpv4Addr::octetsIpv4Addr::is_loopbackIpv4Addr::is_privateIpv4Addr::is_link_localIpv4Addr::is_multicastIpv4Addr::is_broadcastIpv4Addr::is_documentationIpv4Addr::to_ipv6_compatibleIpv4Addr::to_ipv6_mappedIpv6Addr::segmentsIpv6Addr::is_unspecifiedIpv6Addr::is_loopbackIpv6Addr::is_multicastIpv6Addr::to_ipv4Layout::sizeLayout::alignLayout::from_size_alignpowfor all integer types.checked_powfor all integer types.saturating_powfor all integer types.wrapping_powfor all integer types.next_power_of_twofor all unsigned integer types.checked_next_power_of_twofor all unsigned integer types.
Cargo
- Added the
[build.rustc-workspace-wrapper]option. This option sets a wrapper to execute instead ofrustc, for workspace members only. cargo:rerun-if-changedwill now, if provided a directory, scan the entire contents of that directory for changes.- Added the
--workspaceflag to thecargo updatecommand.
Misc
- The search results tab and the help button are focusable with keyboard in rustdoc.
- Running tests will now print the total time taken to execute.
Compatibility Notes
- The
compare_and_swapmethod on atomics has been deprecated. It's recommended to use thecompare_exchangeandcompare_exchange_weakmethods instead. - Changes in how
TokenStreams are checked have fixed some cases where you could write unhygenicmacro_rules!macros. #![test]as an inner attribute is now considered unstable like other inner macro attributes, and reports an error by default through thesoft_unstablelint.- Overriding a
forbidlint at the same level that it was set is now a hard error. - You can no longer intercept
panic!calls by supplying your own macro. It's recommended to use the#[panic_handler]attribute to provide your own implementation. - Semi-colons after item statements (e.g.
struct Foo {};) now produce a warning.
Rust 1.49.0
Language
- Unions can now implement
Drop, and you can now have a field in a union withManuallyDrop<T>. - You can now cast uninhabited enums to integers.
- You can now bind by reference and by move in patterns. This allows you to selectively borrow individual components of a type. E.g.
#[derive(Debug)] struct Person { name: String, age: u8, } let person = Person { name: String::from("Alice"), age: 20, }; // `name` is moved out of person, but `age` is referenced. let Person { name, ref age } = person; println!("{} {}", name, age);
Compiler
- Added tier 1* support for
aarch64-unknown-linux-gnu. - Added tier 2 support for
aarch64-apple-darwin. - Added tier 2 support for
aarch64-pc-windows-msvc. - Added tier 3 support for
mipsel-unknown-none. - Raised the minimum supported LLVM version to LLVM 9.
- Output from threads spawned in tests is now captured.
- Change os and vendor values to "none" and "unknown" for some targets
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
RangeInclusivenow checks for exhaustion when callingcontainsand indexing.ToString::to_stringnow no longer shrinks the internal buffer in the default implementation.
Stabilized APIs
The following previously stable methods are now const.
Cargo
- Building a crate with
cargo-packageshould now be independently reproducible. cargo-treenow marks proc-macro crates.- Added
CARGO_PRIMARY_PACKAGEbuild-time environment variable. This variable will be set if the crate being built is one the user selected to build, either with-por through defaults. - You can now use glob patterns when specifying packages & targets.
Compatibility Notes
- Demoted
i686-unknown-freebsdfrom host tier 2 to target tier 2 support. - Macros that end with a semi-colon are now treated as statements even if they expand to nothing.
- Rustc will now check for the validity of some built-in attributes on enum variants. Previously such invalid or unused attributes could be ignored.
- Leading whitespace is stripped more uniformly in documentation comments, which may change behavior. You read this post about the changes for more details.
- Trait bounds are no longer inferred for associated types.
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.
Rust 1.48.0
Language
- The
unsafekeyword is now syntactically permitted on modules. This is still rejected semantically, but can now be parsed by procedural macros.
Compiler
- Stabilised the
-C link-self-contained=<yes|no>compiler flag. This tellsrustcwhether to link its own C runtime and libraries or to rely on a external linker to find them. (Supported only onwindows-gnu,linux-musl, andwasiplatforms.) - You can now use
-C target-feature=+crt-staticonlinux-gnutargets. Note: If you're using cargo you must explicitly pass the--targetflag. - Added tier 2* support for
aarch64-unknown-linux-musl.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
io::Writeis now implemented for&ChildStdin&Sink,&Stdout, and&Stderr.- All arrays of any length now implement
TryFrom<Vec<T>>. - The
matches!macro now supports having a trailing comma. Vec<A>now implementsPartialEq<[B]>whereA: PartialEq<B>.- The
RefCell::{replace, replace_with, clone}methods now all use#[track_caller].
Stabilized APIs
The following previously stable methods are now const fn's:
Option::is_someOption::is_noneOption::as_refResult::is_okResult::is_errResult::as_refOrdering::reverseOrdering::then
Cargo
Rustdoc
- You can now link to items in
rustdocusing the intra-doc link syntax. E.g./// Uses [`std::future`]will automatically generate a link tostd::future's documentation. See "Linking to items by name" for more information. - You can now specify
#[doc(alias = "<alias>")]on items to add search aliases when searching throughrustdoc's UI.
Compatibility Notes
- Promotion of references to
'staticlifetime insideconst fnnow follows the same rules as inside afnbody. In particular,&foo()will not be promoted to'staticlifetime any more insideconst fns. - Associated type bindings on trait objects are now verified to meet the bounds declared on the trait when checking that they implement the trait.
- When trait bounds on associated types or opaque types are ambiguous, the compiler no longer makes an arbitrary choice on which bound to use.
- Fixed recursive nonterminals not being expanded in macros during pretty-print/reparse check. This may cause errors if your macro wasn't correctly handling recursive nonterminal tokens.
&mutreferences to non zero-sized types are no longer promoted.rustcwill now warn if you use attributes like#[link_name]or#[cold]in places where they have no effect.- Updated
_mm256_extract_epi8and_mm256_extract_epi16signatures inarch::{x86, x86_64}to returni32to match the vendor signatures. mem::uninitializedwill now panic if any inner types inside a struct or enum disallow zero-initialization.#[target_feature]will now error if used in a place where it has no effect.- Foreign exceptions are now caught by
catch_unwindand will cause an abort. Note: This behaviour is not guaranteed and is still considered undefined behaviour, see thecatch_unwinddocumentation for further information.
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.
- Building
rustcfrom source now usesninjaby default overmake. You can continue building withmakeby settingninja=falsein yourbootstrap.toml. - cg_llvm:
fewer_namesinuncached_llvm_type - Made
ensure_sufficient_stack()non-generic
Rust 1.47.0
Language
Compiler
- Stabilized the
-C control-flow-guardcodegen option, which enables Control Flow Guard for Windows platforms, and is ignored on other platforms. - Upgraded to LLVM 11.
- Added tier 3* support for the
thumbv4t-none-eabitarget. - Upgrade the FreeBSD toolchain to version 11.4
RUST_BACKTRACE's output is now more compact.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
CStrnow implementsIndex<RangeFrom<usize>>.- Traits in
std/coreare now implemented for arrays of any length, not just those of length less than 33. ops::RangeFullandops::Rangenow implement Default.panic::Locationnow implementsCopy,Clone,Eq,Hash,Ord,PartialEq, andPartialOrd.
Stabilized APIs
Ident::new_rawRange::is_emptyRangeInclusive::is_emptyResult::as_derefResult::as_deref_mutVec::leakpointer::offset_fromf32::TAUf64::TAU
The following previously stable APIs have now been made const.
- The
newmethod for allNonZerointegers. - The
checked_add,checked_sub,checked_mul,checked_neg,checked_shl,checked_shr,saturating_add,saturating_sub, andsaturating_mulmethods for all integers. - The
checked_abs,saturating_abs,saturating_neg, andsignumfor all signed integers. - The
is_ascii_alphabetic,is_ascii_uppercase,is_ascii_lowercase,is_ascii_alphanumeric,is_ascii_digit,is_ascii_hexdigit,is_ascii_punctuation,is_ascii_graphic,is_ascii_whitespace, andis_ascii_controlmethods forcharandu8.
Cargo
build-dependenciesare now built with opt-level 0 by default. You can override this by setting the following in yourCargo.toml.[profile.release.build-override] opt-level = 3
cargo-helpwill now display man pages for commands rather just the--helptext.cargo-metadatanow emits atestfield indicating if a target has tests enabled.workspace.default-membersnow respectsworkspace.exclude.cargo-publishwill now use an alternative registry by default if it's the only registry specified inpackage.publish.
Misc
- Added a help button beside Rustdoc's searchbar that explains rustdoc's type based search.
- Added the Ayu theme to rustdoc.
Compatibility Notes
- Bumped the minimum supported Emscripten version to 1.39.20.
- Fixed a regression parsing
{} && falsein tail expressions. - Added changes to how proc-macros are expanded in
macro_rules!that should help to preserve more span information. These changes may cause compilation errors if your macro was unhygenic or didn't correctly handleDelimiter::None. - Moved support for the CloudABI target to tier 3.
linux-gnutargets now require minimum kernel 2.6.32 and glibc 2.11.- Added the
rustc-docscomponent. This allows you to install and read the documentation for the compiler internal APIs. (Currently only available forx86_64-unknown-linux-gnu.)
Internal Only
- Improved default settings for bootstrapping in
x.py. You can read details about this change in the "Changes tox.pydefaults" post on the Inside Rust blog.
Rust 1.46.0
Language
if,match, andloopexpressions can now be used in const functions.- Additionally you are now also able to coerce and cast to slices (
&[T]) in const functions. - The
#[track_caller]attribute can now be added to functions to use the function's caller's location information for panic messages. - Recursively indexing into tuples no longer needs parentheses. E.g.
x.0.0over(x.0).0. mem::transmutecan now be used in statics and constants. Note You currently can't usemem::transmutein constant functions.
Compiler
- You can now use the
cdylibtarget on Apple iOS and tvOS platforms. - Enabled static "Position Independent Executables" by default for
x86_64-unknown-linux-musl.
Libraries
mem::forgetis now aconst fn.Stringnow implementsFrom<char>.- The
leading_ones, andtrailing_onesmethods have been stabilised for all integer types. vec::IntoIter<T>now implementsAsRef<[T]>.- All non-zero integer types (
NonZeroU8) now implementTryFromfor their zero-able equivalent (e.g.TryFrom<u8>). &[T]and&mut [T]now implementPartialEq<Vec<T>>.(String, u16)now implementsToSocketAddrs.vec::Drain<'_, T>now implementsAsRef<[T]>.
Stabilized APIs
Cargo
Added a number of new environment variables that are now available when compiling your crate.
CARGO_BIN_NAMEandCARGO_CRATE_NAMEProviding the name of the specific binary being compiled and the name of the crate.CARGO_PKG_LICENSEThe license from the manifest of the package.CARGO_PKG_LICENSE_FILEThe path to the license file.
Compatibility Notes
- The target configuration option
abi_blacklisthas been renamed tounsupported_abis. The old name will still continue to work. - Rustc will now warn if you cast a C-like enum that implements
Drop. This was previously accepted but will become a hard error in a future release. - Rustc will fail to compile if you have a struct with
#[repr(i128)]or#[repr(u128)]. This representation is currently only allowed onenums. - Tokens passed to
macro_rules!are now always captured. This helps ensure that spans have the correct information, and may cause breakage if you were relying on receiving spans with dummy information. - The InnoSetup installer for Windows is no longer available. This was a legacy installer that was replaced by a MSI installer a few years ago but was still being built.
{f32, f64}::asinhnow returns the correct values for negative numbers.- Rustc will no longer accept overlapping trait implementations that only differ in how the lifetime was bound.
- Rustc now correctly relates the lifetime of an existential associated type. This fixes some edge cases where
rustcwould erroneously allow you to pass a shorter lifetime than expected. - Rustc now dynamically links to
libz(also calledzlib) on Linux. The library will need to be installed forrustcto work, even though we expect it to be already available on most systems. - Tests annotated with
#[should_panic]are broken on ARMv7 while running under QEMU. - Pretty printing of some tokens in procedural macros changed. The exact output returned by rustc's pretty printing is an unstable implementation detail: we recommend any macro relying on it to switch to a more robust parsing system.