Releases: rust-lang/rust
Rust 1.56.0
Language
- The 2021 Edition is now stable. See the edition guide for more details.
- The pattern in
binding @ pattern
can 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-sim
to Tier 2*. - Add
powerpc-unknown-freebsd
at Tier 3*. - Add
riscv32imc-esp-espidf
at 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: Unpin
bound 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::chroot
UnsafeCell::raw_get
BufWriter::into_parts
core::panic::{UnwindSafe, RefUnwindSafe, AssertUnwindSafe}
These APIs were previously stable instd
, but are now also available incore
.Vec::shrink_to
String::shrink_to
OsString::shrink_to
PathBuf::shrink_to
BinaryHeap::shrink_to
VecDeque::shrink_to
HashMap::shrink_to
HashSet::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_MACROS
warn by default - Warn when an escaped newline skips multiple lines.
- Calls to
libc::getpid
/std::process::id
fromCommand::pre_exec
may return different values on glibc <= 2.24. Rust now invokes theclone3
system 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 cachegetpid
for 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 atX
and 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::Drain
now implementsAsRef<str>
andAsRef<[u8]>
.
Stabilised APIs
Bound::cloned
Drain::as_str
IntoInnerError::into_error
IntoInnerError::into_parts
MaybeUninit::assume_init_mut
MaybeUninit::assume_init_ref
MaybeUninit::write
array::map
ops::ControlFlow
x86::_bittest
x86::_bittestandcomplement
x86::_bittestandreset
x86::_bittestandset
x86_64::_bittest64
x86_64::_bittestandcomplement64
x86_64::_bittestandreset64
x86_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 metadata
now includes the"default_run"
field from the manifest. - Added
cargo d
as an alias forcargo doc
. - Added
{lib}
as formatting option forcargo tree
to 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+F
in 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::Error
will no longer use theErrorKind::Other
variant. This is to better reflect that these kinds of errors could be categorised into newer more specificErrorKind
variants, and that they do not represent a user error. - Using environment variable names with
process::Command
on Windows now behaves as expected. Previously using environment variables withCommand
would cause them to be ASCII-uppercased. - Rustdoc will now warn on using rustdoc lints that aren't prefixed with
rustdoc::
RUSTFLAGS
is no longer set for build scripts. Build scripts should useCARGO_ENCODED_RUSTFLAGS
instead. 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 Trait
where 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.json
where/
is the "sysroot" directory. You can find your sysroot directory by runningrustc --print sysroot
. - Added
wasm
as atarget_family
for 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-none
andbpfeb-unknown-none
. -Zmutable-noalias=yes
is 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_any
will now#[track_caller]
.- Added
OutOfMemory
as a variant ofio::ErrorKind
. -
proc_macro::Literal
now 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_keys
BTreeMap::into_values
HashMap::into_keys
HashMap::into_values
arch::wasm32
VecDeque::binary_search
VecDeque::binary_search_by
VecDeque::binary_search_by_key
VecDeque::partition_point
Cargo
- Added the
--prune <spec>
option tocargo-tree
to remove a package from the dependency graph. - Added the
--depth
option tocargo-tree
to print only to a certain depth in the tree - Added the
no-proc-macro
value tocargo-tree --edges
to hide procedural macro dependencies. - A new environment variable named
CARGO_TARGET_TMPDIR
is 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::arch
intrinsics now uses stricter const checking than before and may reject some previously accepted code. i128
multiplication 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_param
macro_rules!
matcher. This matcher has the same semantics as the:pat
matcher. This is to allow:pat
to 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-unknown
target. - 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_message
on 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 changeItem
toT
. CallingIntoIterator::into_iter
directly on arrays will provideimpl Iterator<Item=T>
as expected. leading_zeros
, andtrailing_zeros
are now available on allNonZero
integer types.{f32, f64}::from_str
now parse and print special values (NaN
,-0
) according to IEEE 754.- You can now index into slices using
(Bound<usize>, Bound<usize>)
. - Add the
BITS
associated constant to all numeric types.
Stabilised APIs
AtomicBool::fetch_update
AtomicPtr::fetch_update
BTreeMap::retain
BTreeSet::retain
BufReader::seek_relative
DebugStruct::non_exhaustive
Duration::MAX
Duration::ZERO
Duration::is_zero
Duration::saturating_add
Duration::saturating_mul
Duration::saturating_sub
ErrorKind::Unsupported
Option::insert
Ordering::is_eq
Ordering::is_ge
Ordering::is_gt
Ordering::is_le
Ordering::is_lt
Ordering::is_ne
OsStr::is_ascii
OsStr::make_ascii_lowercase
OsStr::make_ascii_uppercase
OsStr::to_ascii_lowercase
OsStr::to_ascii_uppercase
Peekable::peek_mut
Rc::decrement_strong_count
Rc::increment_strong_count
Vec::extend_from_within
array::from_mut
array::from_ref
cmp::max_by_key
cmp::max_by
cmp::min_by_key
cmp::min_by
f32::is_subnormal
f64::is_subnormal
Cargo
- Cargo now supports git repositories where the default
HEAD
branch is not "master". This also includes a switch to the version 3Cargo.lock
format which can handle default branches correctly. - macOS targets now default to
unpacked
split-debuginfo. - The
authors
field is no longer included inCargo.toml
for new projects.
Rustdoc
Compatibility Notes
- Implement token-based handling of attributes during expansion
Ipv4::from_str
will 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
BITS
constant may conflict with external definitions. In particular, this was known to be a problem in thelexical-core
crate, 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=1
environment 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.
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_fn
lint, which checks whether the unsafe code in anunsafe fn
is wrapped in aunsafe
block. 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-musl
riscv32gc-unknown-linux-musl
&riscv64gc-unknown-linux-musl
powerpc-unknown-openbsd
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
OsString
now implementsExtend
andFromIterator
.cmp::Reverse
now has#[repr(transparent)]
representation.Arc<impl Error>
now implementserror::Error
.- All integer division and remainder operations are now
const
.
Stabilised APIs
Arguments::as_str
char::MAX
char::REPLACEMENT_CHARACTER
char::UNICODE_VERSION
char::decode_utf16
char::from_digit
char::from_u32_unchecked
char::from_u32
slice::partition_point
str::rsplit_once
str::split_once
The following previously stable APIs are now const
.
char::len_utf8
char::len_utf16
char::to_ascii_uppercase
char::to_ascii_lowercase
char::eq_ignore_ascii_case
u8::to_ascii_uppercase
u8::to_ascii_lowercase
u8::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 bar
will run all tests that matchfoo
andbar
. - Rustup now distributes PDB symbols for the
std
library on Windows, allowing you to seestd
symbols 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-netbsd
target. - Deprecated the
x86_64-sun-solaris
target in favor ofx86_64-pc-solaris
. - Rustdoc now only accepts
,
,\t
as 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-hack
versions. Acargo update
should 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
struct
s 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
, orchar
types 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-debuginfo
codegen 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_ilp32
targets. - Added tier 3 support for
i386-unknown-linux-gnu
andi486-unknown-linux-gnu
targets. - The
target-cpu=native
option 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::downcast
is now also implemented for anydyn Any + Send + Sync
object.str
now implementsAsMut<str>
.u64
andu128
now implementFrom<char>
.Error
is now implemented for&T
whereT
implementsError
.Poll::{map_ok, map_err}
are now implemented forPoll<Option<Result<T, E>>>
.unsigned_abs
is now implemented for all signed integer types.io::Empty
now implementsio::Seek
.rc::Weak<T>
andsync::Weak<T>
's methods such asas_ptr
are now implemented forT: ?Sized
types.Div
andRem
by theirNonZero
variant is now implemented for all unsigned integers.
Stabilized APIs
Arc::decrement_strong_count
Arc::increment_strong_count
Once::call_once_force
Peekable::next_if_eq
Peekable::next_if
Seek::stream_position
array::IntoIter
panic::panic_any
ptr::addr_of!
ptr::addr_of_mut!
slice::fill_with
slice::split_inclusive_mut
slice::split_inclusive
slice::strip_prefix
slice::strip_suffix
str::split_inclusive
sync::OnceState
task::Wake
VecDeque::range
VecDeque::range_mut
Cargo
- Added the
split-debuginfo
profile option to control the -Csplit-debuginfo codegen option. - Added the
resolver
field toCargo.toml
to 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 astd
feature in a build scripts and proc-macros, while using theno-std
feature 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
Deref
traits. - You can now provide a
--default-theme
flag 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-bindgen
ABI, and instead use the wasm32 ABI. rustc
no longer promotes division, modulo and indexing operations toconst
that 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-gnueabi
sparc64-unknown-linux-gnu
thumbv7neon-unknown-linux-gnueabihf
armv7-unknown-linux-gnueabi
x86_64-unknown-linux-gnux32
atomic::spin_loop_hint
has been deprecated. It's recommended to usehint::spin_loop
instead.
Internal Only
Rust 1.50.0
Language
- You can now use
const
values forx
in[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-uclibceabi
target. - Added tier 3 support for the
aarch64-apple-ios-macabi
target. - The
x86_64-unknown-freebsd
is 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::Punct
now implementsPartialEq<char>
.ops::{Index, IndexMut}
are now implemented for fixed sized arrays of any length.- On Unix platforms, the
std::fs::File
type 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::then
btree_map::Entry::or_insert_with_key
f32::clamp
f64::clamp
hash_map::Entry::or_insert_with_key
Ord::clamp
RefCell::take
slice::fill
UnsafeCell::get_mut
The following previously stable methods are now const
.
IpAddr::is_ipv4
IpAddr::is_ipv6
IpAddr::is_unspecified
IpAddr::is_loopback
IpAddr::is_multicast
Ipv4Addr::octets
Ipv4Addr::is_loopback
Ipv4Addr::is_private
Ipv4Addr::is_link_local
Ipv4Addr::is_multicast
Ipv4Addr::is_broadcast
Ipv4Addr::is_documentation
Ipv4Addr::to_ipv6_compatible
Ipv4Addr::to_ipv6_mapped
Ipv6Addr::segments
Ipv6Addr::is_unspecified
Ipv6Addr::is_loopback
Ipv6Addr::is_multicast
Ipv6Addr::to_ipv4
Layout::size
Layout::align
Layout::from_size_align
pow
for all integer types.checked_pow
for all integer types.saturating_pow
for all integer types.wrapping_pow
for all integer types.next_power_of_two
for all unsigned integer types.checked_next_power_of_two
for 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-changed
will now, if provided a directory, scan the entire contents of that directory for changes.- Added the
--workspace
flag to thecargo update
command.
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_swap
method on atomics has been deprecated. It's recommended to use thecompare_exchange
andcompare_exchange_weak
methods instead. - Changes in how
TokenStream
s 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_unstable
lint.- Overriding a
forbid
lint 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
RangeInclusive
now checks for exhaustion when callingcontains
and indexing.ToString::to_string
now 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-package
should now be independently reproducible. cargo-tree
now marks proc-macro crates.- Added
CARGO_PRIMARY_PACKAGE
build-time environment variable. This variable will be set if the crate being built is one the user selected to build, either with-p
or through defaults. - You can now use glob patterns when specifying packages & targets.
Compatibility Notes
- Demoted
i686-unknown-freebsd
from 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
unsafe
keyword 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 tellsrustc
whether to link its own C runtime and libraries or to rely on a external linker to find them. (Supported only onwindows-gnu
,linux-musl
, andwasi
platforms.) - You can now use
-C target-feature=+crt-static
onlinux-gnu
targets. Note: If you're using cargo you must explicitly pass the--target
flag. - 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::Write
is 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_some
Option::is_none
Option::as_ref
Result::is_ok
Result::is_err
Result::as_ref
Ordering::reverse
Ordering::then
Cargo
Rustdoc
- You can now link to items in
rustdoc
using 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
'static
lifetime insideconst fn
now follows the same rules as inside afn
body. In particular,&foo()
will not be promoted to'static
lifetime any more insideconst fn
s. - 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.
&mut
references to non zero-sized types are no longer promoted.rustc
will now warn if you use attributes like#[link_name]
or#[cold]
in places where they have no effect.- Updated
_mm256_extract_epi8
and_mm256_extract_epi16
signatures inarch::{x86, x86_64}
to returni32
to match the vendor signatures. mem::uninitialized
will 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_unwind
and will cause an abort. Note: This behaviour is not guaranteed and is still considered undefined behaviour, see thecatch_unwind
documentation 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
rustc
from source now usesninja
by default overmake
. You can continue building withmake
by settingninja=false
in yourconfig.toml
. - cg_llvm:
fewer_names
inuncached_llvm_type
- Made
ensure_sufficient_stack()
non-generic