Version 1.62.0 (2022-06-30)
Language
- Stabilize
#[derive(Default)]
on enums with a#[default]
variant - Stop validating some checks in dead code after functions with uninhabited return types
- Fix constants not getting dropped if part of a diverging expression
- Support unit struct/enum variant in destructuring assignment
- Remove mutable_borrow_reservation_conflict lint and allow the code pattern
Compiler
- linker: Stop using whole-archive on dependencies of dylibs
- Make
unaligned_references
lint deny-by-default This lint is also a future compatibility lint, and is expected to eventually become a hard error. - Only add codegen backend to dep info if -Zbinary-dep-depinfo is used
- Reject
#[thread_local]
attribute on non-static items - Add tier 3
aarch64-pc-windows-gnullvm
andx86_64-pc-windows-gnullvm
targets* - Implement a lint to warn about unused macro rules
- Promote
x86_64-unknown-none
target to Tier 2*
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- Move
CStr
to libcore, andCString
to liballoc - Windows: Use a pipe relay for chaining pipes
- Replace Linux Mutex and Condvar with futex based ones.
- Replace RwLock by a futex based one on Linux
- std: directly use pthread in UNIX parker implementation
Stabilized APIs
bool::then_some
f32::total_cmp
f64::total_cmp
Stdin::lines
windows::CommandExt::raw_arg
impl<T: Default> Default for AssertUnwindSafe<T>
From<Rc<str>> for Rc<[u8]>
From<Arc<str>> for Arc<[u8]>
FusedIterator for EncodeWide
- RDM intrinsics on aarch64
Clippy
Cargo
- Added the
cargo add
command for adding dependencies toCargo.toml
from the command-line. docs - Package ID specs now support
name@version
syntax in addition to the previousname:version
to align with the behavior incargo add
and other tools.cargo install
andcargo yank
also now support this syntax so the version does not need to passed as a separate flag. - The
git
andregistry
directories in Cargo's home directory (usually~/.cargo
) are now marked as cache directories so that they are not included in backups or content indexing (on Windows). - Added automatic
@
argfile support, which will use "response files" if the command-line torustc
exceeds the operating system's limit.
Compatibility Notes
cargo test
now passes--target
torustdoc
if the specified target is the same as the host target. #10594- rustdoc: Remove .woff font files
- Enforce Copy bounds for repeat elements while considering lifetimes
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.
Version 1.61.0 (2022-05-19)
Language
const fn
signatures can now include generic trait boundsconst fn
signatures can now useimpl Trait
in argument and return position- Function pointers can now be created, cast, and passed around in a
const fn
- Recursive calls can now set the value of a function's opaque
impl Trait
return type
Compiler
- Linking modifier syntax in
#[link]
attributes and on the command line, as well as thewhole-archive
modifier specifically, are now supported - The
char
type is now described as UTF-32 in debuginfo - The
#[target_feature]
attribute can now be used with aarch64 features - X86
#[target_feature = "adx"]
is now stable
Libraries
ManuallyDrop<T>
is now documented to have the same layout asT
#[ignore = "…"]
messages are printed when running tests- Consistently show absent stdio handles on Windows as NULL handles
- Make
std::io::stdio::lock()
return'static
handles. Previously, the creation of locked handles to stdin/stdout/stderr would borrow the handles being locked, which prevented writinglet out = std::io::stdout().lock();
becauseout
would outlive the return value ofstdout()
. Such code now works, eliminating a common pitfall that affected many Rust users. Vec::from_raw_parts
is now less restrictive about its inputsstd::thread::available_parallelism
now takes cgroup quotas into account. Sinceavailable_parallelism
is often used to create a thread pool for parallel computation, which may be CPU-bound for performance,available_parallelism
will return a value consistent with the ability to use that many threads continuously, if possible. For instance, in a container with 8 virtual CPUs but quotas only allowing for 50% usage,available_parallelism
will return 4.
Stabilized APIs
Pin::static_mut
Pin::static_ref
Vec::retain_mut
VecDeque::retain_mut
Write
forCursor<[u8; N]>
std::os::unix::net::SocketAddr::from_pathname
std::process::ExitCode
andstd::process::Termination
. The stabilization of these two APIs now makes it possible for programs to return errors frommain
with custom exit codes.std::thread::JoinHandle::is_finished
These APIs are now usable in const contexts:
<*const T>::offset
and<*mut T>::offset
<*const T>::wrapping_offset
and<*mut T>::wrapping_offset
<*const T>::add
and<*mut T>::add
<*const T>::sub
and<*mut T>::sub
<*const T>::wrapping_add
and<*mut T>::wrapping_add
<*const T>::wrapping_sub
and<*mut T>::wrapping_sub
<[T]>::as_mut_ptr
<[T]>::as_ptr_range
<[T]>::as_mut_ptr_range
Cargo
No feature changes, but see compatibility notes.
Compatibility Notes
- Previously native static libraries were linked as
whole-archive
in some cases, but now rustc tries not to usewhole-archive
unless explicitly requested. This change may result in linking errors in some cases. To fix such errors, native libraries linked from the command line, build scripts, or#[link]
attributes need to- (more common) either be reordered to respect dependencies between them (if
a
depends onb
thena
should go first andb
second) - (less common) or be updated to use the
+whole-archive
modifier.
- (more common) either be reordered to respect dependencies between them (if
- Catching a second unwind from FFI code while cleaning up from a Rust panic now causes the process to abort
- Proc macros no longer see
ident
matchers wrapped in groups - The number of
#
inr#
raw string literals is now required to be less than 256 - When checking that a dyn type satisfies a trait bound, supertrait bounds are now enforced
cargo vendor
now only accepts one value for each--sync
flagcfg
predicates inall()
andany()
are always evaluated to detect errors, instead of short-circuiting. The compatibility considerations here arise in nightly-only code that used the short-circuiting behavior ofall
to write something likecfg(all(feature = "nightly", syntax-requiring-nightly))
, which will now fail to compile. Instead, use eithercfg_attr(feature = "nightly", ...)
or nested uses ofcfg
.- bootstrap: static-libstdcpp is now enabled by default, and can now be disabled when llvm-tools is enabled
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.
Version 1.60.0 (2022-04-07)
Language
- Stabilize
#[cfg(panic = "...")]
for either"unwind"
or"abort"
. - Stabilize
#[cfg(target_has_atomic = "...")]
for each integer size and"ptr"
.
Compiler
- Enable combining
+crt-static
andrelocation-model=pic
onx86_64-unknown-linux-gnu
- Fixes wrong
unreachable_pub
lints on nested and glob public reexport - Stabilize
-Z instrument-coverage
as-C instrument-coverage
- Stabilize
-Z print-link-args
as--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=full
by 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
/f64
accuracy by directly processing exponent and mantissa - Make
Instant::{duration_since, elapsed, sub}
saturating - Remove non-monotonic clocks workarounds in
Instant::now
- Make
BuildHasherDefault
,iter::Empty
andfuture::Pending
covariant
Stabilized APIs
Arc::new_cyclic
Rc::new_cyclic
slice::EscapeAscii
<[u8]>::escape_ascii
u8::escape_ascii
Vec::spare_capacity_mut
MaybeUninit::assume_init_drop
MaybeUninit::assume_init_read
i8::abs_diff
i16::abs_diff
i32::abs_diff
i64::abs_diff
i128::abs_diff
isize::abs_diff
u8::abs_diff
u16::abs_diff
u32::abs_diff
u64::abs_diff
u128::abs_diff
usize::abs_diff
Display for io::ErrorKind
From<u8> for ExitCode
Not for !
(the "never" type)- Op
Assign<$t> for Wrapping<$t>
arch::is_aarch64_feature_detected!
Cargo
- Port cargo from
toml-rs
totoml_edit
- Stabilize
-Ztimings
as--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 to0
instead. 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 results in0
rather 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.
Version 1.59.0 (2022-02-24)
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-incompat
as--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_parallelism
Result::copied
Result::cloned
arch::asm!
arch::global_asm!
ops::ControlFlow::is_break
ops::ControlFlow::is_continue
TryFrom<char> for u8
char::TryFromCharError
implementingClone
,Debug
,Display
,PartialEq
,Copy
,Eq
,Error
iter::zip
NonZeroU8::is_power_of_two
NonZeroU16::is_power_of_two
NonZeroU32::is_power_of_two
NonZeroU64::is_power_of_two
NonZeroU128::is_power_of_two
NonZeroUsize::is_power_of_two
DoubleEndedIterator for ToLowercase
DoubleEndedIterator for ToUppercase
TryFrom<&mut [T]> for [T; N]
UnwindSafe for Once
RefUnwindSafe for Once
- armv8 neon intrinsics for aarch64
Const-stable:
mem::MaybeUninit::as_ptr
mem::MaybeUninit::assume_init
mem::MaybeUninit::assume_init_ref
ffi::CStr::from_bytes_with_nul_unchecked
Cargo
- Stabilize the
strip
profile option - Stabilize future-incompat-report
- Support abbreviating
--release
as-r
- Support
term.quiet
configuration - Remove
--host
from 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.
Version 1.58.1 (2022-01-19)
- Fix race condition in
std::fs::remove_dir_all
(CVE-2022-21658) - Handle captured arguments in the
useless_format
Clippy lint - Move
non_send_fields_in_send_ty
Clippy lint to nursery - Fix wrong error message displayed when some imports are missing
- Fix rustfmt not formatting generated files from stdin
Version 1.58.0 (2022-01-13)
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 T
pointers can now be dereferenced in const contexts.- The rules for when a generic struct implements
Unsize
have 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
strip
option 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-none
at 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
copy
andcopy_nonoverlapping
- Implement
RefUnwindSafe
forRc<T>
- Make RSplit<T, P>: Clone not require T: Clone
- Implement
Termination
forResult<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 usesexec
to run another program).
Stabilized APIs
Metadata::is_symlink
Path::is_symlink
{integer}::saturating_div
Option::unwrap_unchecked
Result::unwrap_unchecked
Result::unwrap_err_unchecked
File::options
These APIs are now usable in const contexts:
Duration::new
Duration::checked_add
Duration::saturating_add
Duration::checked_sub
Duration::saturating_sub
Duration::checked_mul
Duration::saturating_mul
Duration::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::Command
will 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.
- Implement coherence checks for negative trait impls
- Add rustc lint, warning when iterating over hashmaps
- Optimize live point computation
- Enable verification for 1/32nd of queries loaded from disk
- Implement version of normalize_erasing_regions that allows for normalization failure
Version 1.57.0 (2021-12-02)
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
Clone
andDebug
implementations during dead code analysis.
Compiler
- Create more accurate debuginfo for vtables.
- Add
armv6k-nintendo-3ds
at Tier 3*. - Add
armv7-unknown-linux-uclibceabihf
at Tier 3*. - Add
m68k-unknown-linux-gnu
at 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_end
andread_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_slice
collections::TryReserveError
HashMap::try_reserve
HashSet::try_reserve
String::try_reserve
String::try_reserve_exact
Vec::try_reserve
Vec::try_reserve_exact
VecDeque::try_reserve
VecDeque::try_reserve_exact
Iterator::map_while
iter::MapWhile
proc_macro::is_available
Command::get_program
Command::get_args
Command::get_envs
Command::get_current_dir
CommandArgs
CommandEnvs
These APIs are now usable in const contexts:
Cargo
Compatibility notes
- Ignore derived
Clone
andDebug
implementations 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.
Version 1.56.1 (2021-11-01)
- New lints to detect the presence of bidirectional-override Unicode codepoints in the compiled source code (CVE-2021-42574)
Version 1.56.0 (2021-10-21)
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 non-existent.
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 non-existent 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.
Version 1.55.0 (2021-09-09)
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 envionment 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.
Version 1.54.0 (2021-07-29)
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
instrinsics 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
.
Version 1.53.0 (2021-06-17)
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.
- Rework the
std::sys::windows::alloc
implementation. - rustdoc: Don't enter an infer_ctxt in get_blanket_impls for impls that aren't blanket impls.
- rustdoc: Only look at blanket impls in
get_blanket_impls
- Rework rustdoc const type
Version 1.52.1 (2021-05-10)
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.
Version 1.52.0 (2021-05-06)
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
Version 1.51.0 (2021-03-25)
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
Version 1.50.0 (2021-02-11)
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.
Version 1.49.0 (2020-12-31)
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.
- rustc's internal crates are now compiled using the
initial-exec
Thread Local Storage model. - Calculate visibilities once in resolve.
- Added
system
to thellvm-libunwind
bootstrap config option. - Added
--color
for configuring terminal color support to bootstrap.
Version 1.48.0 (2020-11-19)
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
Version 1.47.0 (2020-10-08)
Language
Compiler
- Stabilized the
-C control-flow-guard
codegen 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-eabi
target. - 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
CStr
now implementsIndex<RangeFrom<usize>>
.- Traits in
std
/core
are now implemented for arrays of any length, not just those of length less than 33. ops::RangeFull
andops::Range
now implement Default.panic::Location
now implementsCopy
,Clone
,Eq
,Hash
,Ord
,PartialEq
, andPartialOrd
.
Stabilized APIs
Ident::new_raw
Range::is_empty
RangeInclusive::is_empty
Result::as_deref
Result::as_deref_mut
Vec::leak
pointer::offset_from
f32::TAU
f64::TAU
The following previously stable APIs have now been made const.
- The
new
method for allNonZero
integers. - The
checked_add
,checked_sub
,checked_mul
,checked_neg
,checked_shl
,checked_shr
,saturating_add
,saturating_sub
, andsaturating_mul
methods for all integers. - The
checked_abs
,saturating_abs
,saturating_neg
, andsignum
for 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_control
methods forchar
andu8
.
Cargo
build-dependencies
are 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-help
will now display man pages for commands rather just the--help
text.cargo-metadata
now emits atest
field indicating if a target has tests enabled.workspace.default-members
now respectsworkspace.exclude
.cargo-publish
will 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
{} && false
in 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 compiliation errors if your macro was unhygenic or didn't correctly handleDelimiter::None
. - Moved support for the CloudABI target to tier 3.
linux-gnu
targets now require minimum kernel 2.6.32 and glibc 2.11.- Added the
rustc-docs
component. 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.py
defaults" post on the Inside Rust blog.
Version 1.46.0 (2020-08-27)
Language
if
,match
, andloop
expressions 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.0
over(x.0).0
. mem::transmute
can now be used in statics and constants. Note You currently can't usemem::transmute
in constant functions.
Compiler
- You can now use the
cdylib
target on Apple iOS and tvOS platforms. - Enabled static "Position Independent Executables" by default
for
x86_64-unknown-linux-musl
.
Libraries
mem::forget
is now aconst fn
.String
now implementsFrom<char>
.- The
leading_ones
, andtrailing_ones
methods have been stabilised for all integer types. vec::IntoIter<T>
now implementsAsRef<[T]>
.- All non-zero integer types (
NonZeroU8
) now implementTryFrom
for 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_NAME
andCARGO_CRATE_NAME
Providing the name of the specific binary being compiled and the name of the crate.CARGO_PKG_LICENSE
The license from the manifest of the package.CARGO_PKG_LICENSE_FILE
The path to the license file.
Compatibility Notes
- The target configuration option
abi_blacklist
has 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 onenum
s. - 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}::asinh
now 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
rustc
would 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 forrustc
to 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.
Version 1.45.2 (2020-08-03)
Version 1.45.1 (2020-07-30)
- Fix const propagation with references.
- rustfmt accepts rustfmt_skip in cfg_attr again.
- Avoid spurious implicit region bound.
- Install clippy on x.py install
Version 1.45.0 (2020-07-16)
Language
- Out of range float to int conversions using
as
has been defined as a saturating conversion. This was previously undefined behaviour, but you can use the{f64, f32}::to_int_unchecked
methods to continue using the current behaviour, which may be desirable in rare performance sensitive situations. mem::Discriminant<T>
now usesT
's discriminant type instead of always usingu64
.- Function like procedural macros can now be used in expression, pattern, and statement
positions. This means you can now use a function-like procedural macro
anywhere you can use a declarative (
macro_rules!
) macro.
Compiler
- You can now override individual target features through the
target-feature
flag. E.g.-C target-feature=+avx2 -C target-feature=+fma
is now equivalent to-C target-feature=+avx2,+fma
. - Added the
force-unwind-tables
flag. This option allows rustc to always generate unwind tables regardless of panic strategy. - Added the
embed-bitcode
flag. This codegen flag allows rustc to include LLVM bitcode into generatedrlib
s (this is on by default). - Added the
tiny
value to thecode-model
codegen flag. - Added tier 3 support* for the
mipsel-sony-psp
target. - Added tier 3 support for the
thumbv7a-uwp-windows-msvc
target. - Upgraded to LLVM 10.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
net::{SocketAddr, SocketAddrV4, SocketAddrV6}
now implementsPartialOrd
andOrd
.proc_macro::TokenStream
now implementsDefault
.- You can now use
char
withops::{Range, RangeFrom, RangeFull, RangeInclusive, RangeTo}
to iterate over a range of codepoints. E.g. you can now write the following;for ch in 'a'..='z' { print!("{}", ch); } println!(); // Prints "abcdefghijklmnopqrstuvwxyz"
OsString
now implementsFromStr
.- The
saturating_neg
method has been added to all signed integer primitive types, and thesaturating_abs
method has been added for all integer primitive types. Arc<T>
,Rc<T>
now implementFrom<Cow<'_, T>>
, andBox
now implementsFrom<Cow>
whenT
is[T: Copy]
,str
,CStr
,OsStr
, orPath
.Box<[T]>
now implementsFrom<[T; N]>
.BitOr
andBitOrAssign
are implemented for allNonZero
integer types.- The
fetch_min
, andfetch_max
methods have been added to all atomic integer types. - The
fetch_update
method has been added to all atomic integer types.
Stabilized APIs
Arc::as_ptr
BTreeMap::remove_entry
Rc::as_ptr
rc::Weak::as_ptr
rc::Weak::from_raw
rc::Weak::into_raw
str::strip_prefix
str::strip_suffix
sync::Weak::as_ptr
sync::Weak::from_raw
sync::Weak::into_raw
char::UNICODE_VERSION
Span::resolved_at
Span::located_at
Span::mixed_site
unix::process::CommandExt::arg0
Cargo
Misc
- Rustdoc now supports strikethrough text in Markdown. E.g.
~~outdated information~~
becomes "outdated information". - Added an emoji to Rustdoc's deprecated API message.
Compatibility Notes
- Trying to self initialize a static value (that is creating a value using itself) is unsound and now causes a compile error.
{f32, f64}::powi
now returns a slightly different value on Windows. This is due to changes in LLVM's intrinsics which{f32, f64}::powi
uses.- Rustdoc's CLI's extra error exit codes have been removed. These were previously undocumented and not intended for public use. Rustdoc still provides a non-zero exit code on errors.
- Rustc's
lto
flag is incompatible with the newembed-bitcode=no
. This may cause issues if LTO is enabled throughRUSTFLAGS
orcargo rustc
flags while cargo is addingembed-bitcode
itself. The recommended way to control LTO is with Cargo profiles, either inCargo.toml
or.cargo/config
, or by settingCARGO_PROFILE_<name>_LTO
in the environment.
Internals Only
Version 1.44.1 (2020-06-18)
- rustfmt accepts rustfmt_skip in cfg_attr again.
- Don't hash executable filenames on apple platforms, fixing backtraces.
- Fix crashes when finding backtrace on macOS.
- Clippy applies lint levels into different files.
Version 1.44.0 (2020-06-04)
Language
Syntax-only changes
#[cfg(FALSE)]
mod foo {
mod bar {
mod baz; // `foo/bar/baz.rs` doesn't exist, but no error!
}
}
These are still rejected semantically, so you will likely receive an error but these changes can be seen and parsed by macros and conditional compilation.
Compiler
- Rustc now respects the
-C codegen-units
flag in incremental mode. Additionally when in incremental mode rustc defaults to 256 codegen units. - Refactored
catch_unwind
to have zero-cost, unless unwinding is enabled and a panic is thrown. - Added tier 3* support for the
aarch64-unknown-none
andaarch64-unknown-none-softfloat
targets. - Added tier 3 support for
arm64-apple-tvos
andx86_64-apple-tvos
targets.
Libraries
- Special cased
vec![]
to map directly toVec::new()
. This allowsvec![]
to be able to be used inconst
contexts. convert::Infallible
now implementsHash
.OsString
now implementsDerefMut
andIndexMut
returning a&mut OsStr
.- Unicode 13 is now supported.
String
now implementsFrom<&mut str>
.IoSlice
now implementsCopy
.Vec<T>
now implementsFrom<[T; N]>
. WhereN
is at most 32.proc_macro::LexError
now implementsfmt::Display
andError
.from_le_bytes
,to_le_bytes
,from_be_bytes
,to_be_bytes
,from_ne_bytes
, andto_ne_bytes
methods are nowconst
for all integer types.
Stabilized APIs
PathBuf::with_capacity
PathBuf::capacity
PathBuf::clear
PathBuf::reserve
PathBuf::reserve_exact
PathBuf::shrink_to_fit
f32::to_int_unchecked
f64::to_int_unchecked
Layout::align_to
Layout::pad_to_align
Layout::array
Layout::extend
Cargo
- Added the
cargo tree
command which will print a tree graph of your dependencies. E.g.You can also display dependencies on multiple versions of the same crate withmdbook v0.3.2 (/Users/src/rust/mdbook) ├── ammonia v3.0.0 │ ├── html5ever v0.24.0 │ │ ├── log v0.4.8 │ │ │ └── cfg-if v0.1.9 │ │ ├── mac v0.1.1 │ │ └── markup5ever v0.9.0 │ │ ├── log v0.4.8 (*) │ │ ├── phf v0.7.24 │ │ │ └── phf_shared v0.7.24 │ │ │ ├── siphasher v0.2.3 │ │ │ └── unicase v1.4.2 │ │ │ [build-dependencies] │ │ │ └── version_check v0.1.5 ...
cargo tree -d
(short forcargo tree --duplicates
).
Misc
Compatibility Notes
- Rustc now correctly generates static libraries on Windows GNU targets with
the
.a
extension, rather than the previous.lib
. - Removed the
-C no_integrated_as
flag from rustc. - The
file_name
property in JSON output of macro errors now points the actual source file rather than the previous format of<NAME macros>
. Note: this may not point to a file that actually exists on the user's system. - The minimum required external LLVM version has been bumped to LLVM 8.
mem::{zeroed, uninitialised}
will now panic when used with types that do not allow zero initialization such asNonZeroU8
. This was previously a warning.- In 1.45.0 (the next release) converting a
f64
tou32
using theas
operator has been defined as a saturating operation. This was previously undefined behaviour, but you can use the{f64, f32}::to_int_unchecked
methods to continue using the current behaviour, which may be desirable in rare performance sensitive situations.
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.
- dep_graph Avoid allocating a set on when the number reads are small.
- Replace big JS dict with JSON parsing.
Version 1.43.1 (2020-05-07)
- Updated openssl-src to 1.1.1g for CVE-2020-1967.
- Fixed the stabilization of AVX-512 features.
- Fixed
cargo package --list
not working with unpublished dependencies.
Version 1.43.0 (2020-04-23)
Language
- Fixed using binary operations with
&{number}
(e.g.&1.0
) not having the type inferred correctly. - Attributes such as
#[cfg()]
can now be used onif
expressions.
Syntax only changes
- Allow
type Foo: Ord
syntactically. - Fuse associated and extern items up to defaultness.
- Syntactically allow
self
in allfn
contexts. - Merge
fn
syntax + cleanup item parsing. item
macro fragments can be interpolated intotrait
s,impl
s, andextern
blocks. For example, you may now write:macro_rules! mac_trait { ($i:item) => { trait T { $i } } } mac_trait! { fn foo() {} }
These are still rejected semantically, so you will likely receive an error but these changes can be seen and parsed by macros and conditional compilation.
Compiler
- You can now pass multiple lint flags to rustc to override the previous
flags. For example;
rustc -D unused -A unused-variables
denies everything in theunused
lint group exceptunused-variables
which is explicitly allowed. However, passingrustc -A unused-variables -D unused
denies everything in theunused
lint group includingunused-variables
since the allow flag is specified before the deny flag (and therefore overridden). - rustc will now prefer your system MinGW libraries over its bundled libraries
if they are available on
windows-gnu
. - rustc now buffers errors/warnings printed in JSON.
Libraries
Arc<[T; N]>
,Box<[T; N]>
, andRc<[T; N]>
, now implementTryFrom<Arc<[T]>>
,TryFrom<Box<[T]>>
, andTryFrom<Rc<[T]>>
respectively. Note These conversions are only available whenN
is0..=32
.- You can now use associated constants on floats and integers directly, rather
than having to import the module. e.g. You can now write
u32::MAX
orf32::NAN
with no imports. u8::is_ascii
is nowconst
.String
now implementsAsMut<str>
.- Added the
primitive
module tostd
andcore
. This module reexports Rust's primitive types. This is mainly useful in macros where you want avoid these types being shadowed. - Relaxed some of the trait bounds on
HashMap
andHashSet
. string::FromUtf8Error
now implementsClone + Eq
.
Stabilized APIs
Cargo
- You can now set config
[profile]
s in your.cargo/config
, or through your environment. - Cargo will now set
CARGO_BIN_EXE_<name>
pointing to a binary's executable path when running integration tests or benchmarks.<name>
is the name of your binary as-is e.g. If you wanted the executable path for a binary namedmy-program
you would useenv!("CARGO_BIN_EXE_my-program")
.
Misc
- Certain checks in the
const_err
lint were deemed unrelated to const evaluation, and have been moved to theunconditional_panic
andarithmetic_overflow
lints.
Compatibility Notes
- Having trailing syntax in the
assert!
macro is now a hard error. This has been a warning since 1.36.0. - Fixed
Self
not having the correctly inferred type. This incorrectly led to some instances being accepted, and now correctly emits a hard error.
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.
- All components are now built with
opt-level=3
instead of2
. - Improved how rustc generates drop code.
- Improved performance from
#[inline]
-ing certain hot functions. - traits: preallocate 2 Vecs of known initial size
- Avoid exponential behaviour when relating types
- Skip
Drop
terminators for enum variants without drop glue - Improve performance of coherence checks
- Deduplicate types in the generator witness
- Invert control in struct_lint_level.
Version 1.42.0 (2020-03-12)
Language
-
You can now use the slice pattern syntax with subslices. e.g.
fn foo(words: &[&str]) { match words { ["Hello", "World", "!", ..] => println!("Hello World!"), ["Foo", "Bar", ..] => println!("Baz"), rest => println!("{:?}", rest), } }
-
You can now use
#[repr(transparent)]
on univariantenum
s. Meaning that you can create an enum that has the exact layout and ABI of the type it contains. -
You can now use outer attribute procedural macros on inline modules.
-
There are some syntax-only changes:
default
is syntactically allowed before items intrait
definitions.- Items in
impl
s (i.e.const
s,type
s, andfn
s) may syntactically leave out their bodies in favor of;
. - Bounds on associated types in
impl
s are now syntactically allowed (e.g.type Foo: Ord;
). ...
(the C-variadic type) may occur syntactically directly as the type of any function parameter.
These are still rejected semantically, so you will likely receive an error but these changes can be seen and parsed by procedural macros and conditional compilation.
Compiler
- Added tier 2* support for
armv7a-none-eabi
. - Added tier 2 support for
riscv64gc-unknown-linux-gnu
. Option::{expect,unwrap}
andResult::{expect, expect_err, unwrap, unwrap_err}
now produce panic messages pointing to the location where they were called, rather thancore
's internals.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
iter::Empty<T>
now implementsSend
andSync
for anyT
.Pin::{map_unchecked, map_unchecked_mut}
no longer require the return type to implementSized
.io::Cursor
now derivesPartialEq
andEq
.Layout::new
is nowconst
.- Added Standard Library support for
riscv64gc-unknown-linux-gnu
.
Stabilized APIs
CondVar::wait_while
CondVar::wait_timeout_while
DebugMap::key
DebugMap::value
ManuallyDrop::take
matches!
ptr::slice_from_raw_parts_mut
ptr::slice_from_raw_parts
Cargo
Compatibility Notes
Error::description
has been deprecated, and its use will now produce a warning. It's recommended to useDisplay
/to_string
instead.
Version 1.41.1 (2020-02-27)
- Always check types of static items
- Always check lifetime bounds of
Copy
impls - Fix miscompilation in callers of
Layout::repeat
Version 1.41.0 (2020-01-30)
Language
- You can now pass type parameters to foreign items when implementing
traits. E.g. You can now write
impl<T> From<Foo> for Vec<T> {}
. - You can now arbitrarily nest receiver types in the
self
position. E.g. you can now writefn foo(self: Box<Box<Self>>) {}
. Previously onlySelf
,&Self
,&mut Self
,Arc<Self>
,Rc<Self>
, andBox<Self>
were allowed. - You can now use any valid identifier in a
format_args
macro. Previously identifiers starting with an underscore were not allowed. - Visibility modifiers (e.g.
pub
) are now syntactically allowed on trait items and enum variants. These are still rejected semantically, but can be seen and parsed by procedural macros and conditional compilation. - You can now define a Rust
extern "C"
function withBox<T>
and useT*
as the corresponding type on the C side. Please see the documentation for more information, including the important caveat about preferring to avoidBox<T>
in Rust signatures for functions defined in C.
Compiler
- Rustc will now warn if you have unused loop
'label
s. - Removed support for the
i686-unknown-dragonfly
target. - Added tier 3 support* for the
riscv64gc-unknown-linux-gnu
target. - You can now pass an arguments file passing the
@path
syntax to rustc. Note that the format differs somewhat from what is found in other tooling; please see the documentation for more information. - You can now provide
--extern
flag without a path, indicating that it is available from the search path or specified with an-L
flag.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- The
core::panic
module is now stable. It was already stable throughstd
. NonZero*
numerics now implementFrom<NonZero*>
if it's a smaller integer width. E.g.NonZeroU16
now implementsFrom<NonZeroU8>
.MaybeUninit<T>
now implementsfmt::Debug
.
Stabilized APIs
Result::map_or
Result::map_or_else
std::rc::Weak::weak_count
std::rc::Weak::strong_count
std::sync::Weak::weak_count
std::sync::Weak::strong_count
Cargo
- Cargo will now document all the private items for binary crates by default.
cargo-install
will now reinstall the package if it detects that it is out of date.- Cargo.lock now uses a more git friendly format that should help to reduce merge conflicts.
- You can now override specific dependencies's build settings E.g.
[profile.dev.package.image] opt-level = 2
sets theimage
crate's optimisation level to2
for debug builds. You can also use[profile.<profile>.build-override]
to override build scripts and their dependencies.
Misc
- You can now specify
edition
in documentation code blocks to compile the block for that edition. E.g.edition2018
tells rustdoc that the code sample should be compiled the 2018 edition of Rust. - You can now provide custom themes to rustdoc with
--theme
, and check the current theme with--check-theme
. - You can use
#[cfg(doc)]
to compile an item when building documentation.
Compatibility Notes
- As previously announced 1.41.0 will be the last tier 1 release for 32-bit Apple targets. This means that the source code is still available to build, but the targets are no longer being tested and release binaries for those platforms will no longer be distributed by the Rust project. Please refer to the linked blog post for more information.
Version 1.40.0 (2019-12-19)
Language
-
You can now use tuple
struct
s and tupleenum
variant's constructors inconst
contexts. e.g.pub struct Point(i32, i32); const ORIGIN: Point = { let constructor = Point; constructor(0, 0) };
-
You can now mark
struct
s,enum
s, andenum
variants with the#[non_exhaustive]
attribute to indicate that there may be variants or fields added in the future. For example this requires adding a wild-card branch (_ => {}
) to any match statements on a non-exhaustiveenum
. (RFC 2008) -
You can now use function-like procedural macros in
extern
blocks and in type positions. e.g.type Generated = macro!();
-
The
meta
pattern matcher inmacro_rules!
now correctly matches the modern attribute syntax. For example(#[$m:meta])
now matches#[attr]
,#[attr{tokens}]
,#[attr[tokens]]
, and#[attr(tokens)]
.
Compiler
- Added tier 3 support* for the
thumbv7neon-unknown-linux-musleabihf
target. - Added tier 3 support for the
aarch64-unknown-none-softfloat
target. - Added tier 3 support for the
mips64-unknown-linux-muslabi64
, andmips64el-unknown-linux-muslabi64
targets.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
Stabilized APIs
BTreeMap::get_key_value
HashMap::get_key_value
Option::as_deref_mut
Option::as_deref
Option::flatten
UdpSocket::peer_addr
f32::to_be_bytes
f32::to_le_bytes
f32::to_ne_bytes
f64::to_be_bytes
f64::to_le_bytes
f64::to_ne_bytes
f32::from_be_bytes
f32::from_le_bytes
f32::from_ne_bytes
f64::from_be_bytes
f64::from_le_bytes
f64::from_ne_bytes
mem::take
slice::repeat
todo!
Cargo
- Cargo will now always display warnings, rather than only on fresh builds.
- Feature flags (except
--all-features
) passed to a virtual workspace will now produce an error. Previously these flags were ignored. - You can now publish
dev-dependencies
without including aversion
.
Misc
Compatibility Notes
- As previously announced, any previous NLL warnings in the 2015 edition are now hard errors.
- The
include!
macro will now warn if it failed to include the entire file. Theinclude!
macro unintentionally only includes the first expression in a file, and this can be unintuitive. This will become either a hard error in a future release, or the behavior may be fixed to include all expressions as expected. - Using
#[inline]
on function prototypes and consts now emits a warning underunused_attribute
lint. Using#[inline]
anywhere else inside traits orextern
blocks now correctly emits a hard error.
Version 1.39.0 (2019-11-07)
Language
- You can now create
async
functions and blocks withasync fn
,async move {}
, andasync {}
respectively, and you can now call.await
on async expressions. - You can now use certain attributes on function, closure, and function pointer
parameters. These attributes include
cfg
,cfg_attr
,allow
,warn
,deny
,forbid
as well as inert helper attributes used by procedural macro attributes applied to items. e.g.fn len( #[cfg(windows)] slice: &[u16], #[cfg(not(windows))] slice: &[u8], ) -> usize { slice.len() }
- You can now take shared references to bind-by-move patterns in the
if
guards ofmatch
arms. e.g.fn main() { let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]); match array { nums // ---- `nums` is bound by move. if nums.iter().sum::<u8>() == 10 // ^------ `.iter()` implicitly takes a reference to `nums`. => { drop(nums); // ----------- Legal as `nums` was bound by move and so we have ownership. } _ => unreachable!(), } }
Compiler
- Added tier 3* support for the
i686-unknown-uefi
target. - Added tier 3 support for the
sparc64-unknown-openbsd
target. - rustc will now trim code snippets in diagnostics to fit in your terminal. Note Cargo currently doesn't use this feature. Refer to cargo#7315 to track this feature's progress.
- You can now pass
--show-output
argument to test binaries to print the output of successful tests.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
Vec::new
andString::new
are nowconst
functions.LinkedList::new
is now aconst
function.str::len
,[T]::len
andstr::as_bytes
are nowconst
functions.- The
abs
,wrapping_abs
, andoverflowing_abs
numeric functions are nowconst
.
Stabilized APIs
Cargo
- You can now publish git dependencies if supplied with a
version
. - The
--all
flag has been renamed to--workspace
. Using--all
is now deprecated.
Misc
Compatibility Notes
- Code that was previously accepted by the old borrow checker, but rejected by the NLL borrow checker is now a hard error in Rust 2018. This was previously a warning, and will also become a hard error in the Rust 2015 edition in the 1.40.0 release.
rustdoc
now requiresrustc
to be installed and in the same directory to run tests. This should improve performance when running a large amount of doctests.- The
try!
macro will now issue a deprecation warning. It is recommended to use the?
operator instead. asinh(-0.0)
now correctly returns-0.0
. Previously this returned0.0
.
Version 1.38.0 (2019-09-26)
Language
- The
#[global_allocator]
attribute can now be used in submodules. - The
#[deprecated]
attribute can now be used on macros.
Compiler
- Added pipelined compilation support to
rustc
. This will improve compilation times in some cases. For further information please refer to the "Evaluating pipelined rustc compilation" thread. - Added tier 3* support for the
aarch64-uwp-windows-msvc
,i686-uwp-windows-gnu
,i686-uwp-windows-msvc
,x86_64-uwp-windows-gnu
, andx86_64-uwp-windows-msvc
targets. - Added tier 3 support for the
armv7-unknown-linux-gnueabi
andarmv7-unknown-linux-musleabi
targets. - Added tier 3 support for the
hexagon-unknown-linux-musl
target. - Added tier 3 support for the
riscv32i-unknown-none-elf
target. - Upgraded to LLVM 9.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
ascii::EscapeDefault
now implementsClone
andDisplay
.- Derive macros for prelude traits (e.g.
Clone
,Debug
,Hash
) are now available at the same path as the trait. (e.g. TheClone
derive macro is available atstd::clone::Clone
). This also makes all built-in macros available instd
/core
root. e.g.std::include_bytes!
. str::Chars
now implementsDebug
.slice::{concat, connect, join}
now accepts&[T]
in addition to&T
.*const T
and*mut T
now implementmarker::Unpin
.Arc<[T]>
andRc<[T]>
now implementFromIterator<T>
.- Added euclidean remainder and division operations (
div_euclid
,rem_euclid
) to all numeric primitives. Additionallychecked
,overflowing
, andwrapping
versions are available for all integer primitives. thread::AccessError
now implementsClone
,Copy
,Eq
,Error
, andPartialEq
.iter::{StepBy, Peekable, Take}
now implementDoubleEndedIterator
.
Stabilized APIs
<*const T>::cast
<*mut T>::cast
Duration::as_secs_f32
Duration::as_secs_f64
Duration::div_f32
Duration::div_f64
Duration::from_secs_f32
Duration::from_secs_f64
Duration::mul_f32
Duration::mul_f64
any::type_name
Cargo
- Added pipelined compilation support to
cargo
. - You can now pass the
--features
option multiple times to enable multiple features.
Rustdoc
Misc
Compatibility Notes
- The
x86_64-unknown-uefi
platform can not be built with rustc 1.38.0. - The
armv7-unknown-linux-gnueabihf
platform is known to have issues with certain crates such as libc.
Version 1.37.0 (2019-08-15)
Language
#[must_use]
will now warn if the type is contained in a tuple,Box
, or an array and unused.- You can now use the
cfg
andcfg_attr
attributes on generic parameters. - You can now use enum variants through type alias. e.g. You can
write the following:
type MyOption = Option<u8>; fn increment_or_zero(x: MyOption) -> u8 { match x { MyOption::Some(y) => y + 1, MyOption::None => 0, } }
- You can now use
_
as an identifier for consts. e.g. You can writeconst _: u32 = 5;
. - You can now use
#[repr(align(X)]
on enums. - The
?
Kleene macro operator is now available in the 2015 edition.
Compiler
- You can now enable Profile-Guided Optimization with the
-C profile-generate
and-C profile-use
flags. For more information on how to use profile guided optimization, please refer to the rustc book. - The
rust-lldb
wrapper script should now work again.
Libraries
Stabilized APIs
BufReader::buffer
BufWriter::buffer
Cell::from_mut
Cell<[T]>::as_slice_of_cells
DoubleEndedIterator::nth_back
Option::xor
Wrapping::reverse_bits
i128::reverse_bits
i16::reverse_bits
i32::reverse_bits
i64::reverse_bits
i8::reverse_bits
isize::reverse_bits
slice::copy_within
u128::reverse_bits
u16::reverse_bits
u32::reverse_bits
u64::reverse_bits
u8::reverse_bits
usize::reverse_bits
Cargo
Cargo.lock
files are now included by default when publishing executable crates with executables.- You can now specify
default-run="foo"
in[package]
to specify the default executable to use forcargo run
.
Misc
Compatibility Notes
- Using
...
for inclusive range patterns will now warn by default. Please transition your code to using the..=
syntax for inclusive ranges instead. - Using a trait object without the
dyn
will now warn by default. Please transition your code to usedyn Trait
for trait objects instead.
Version 1.36.0 (2019-07-04)
Language
- Non-Lexical Lifetimes are now enabled on the 2015 edition.
- The order of traits in trait objects no longer affects the semantics of that
object. e.g.
dyn Send + fmt::Debug
is now equivalent todyn fmt::Debug + Send
, where this was previously not the case.
Libraries
HashMap
's implementation has been replaced withhashbrown::HashMap
implementation.TryFromSliceError
now implementsFrom<Infallible>
.mem::needs_drop
is now available as a const fn.alloc::Layout::from_size_align_unchecked
is now available as a const fn.String
now implementsBorrowMut<str>
.io::Cursor
now implementsDefault
.- Both
NonNull::{dangling, cast}
are now const fns. - The
alloc
crate is now stable.alloc
allows you to use a subset ofstd
(e.g.Vec
,Box
,Arc
) in#![no_std]
environments if the environment has access to heap memory allocation. String
now implementsFrom<&String>
.- You can now pass multiple arguments to the
dbg!
macro.dbg!
will return a tuple of each argument when there is multiple arguments. Result::{is_err, is_ok}
are now#[must_use]
and will produce a warning if not used.
Stabilized APIs
VecDeque::rotate_left
VecDeque::rotate_right
Iterator::copied
io::IoSlice
io::IoSliceMut
Read::read_vectored
Write::write_vectored
str::as_mut_ptr
mem::MaybeUninit
pointer::align_offset
future::Future
task::Context
task::RawWaker
task::RawWakerVTable
task::Waker
task::Poll
Cargo
- Cargo will now produce an error if you attempt to use the name of a required dependency as a feature.
- You can now pass the
--offline
flag to run cargo without accessing the network.
You can find further change's in Cargo's 1.36.0 release notes.
Clippy
There have been numerous additions and fixes to clippy, see Clippy's 1.36.0 release notes for more details.
Misc
Compatibility Notes
- With the stabilisation of
mem::MaybeUninit
,mem::uninitialized
use is no longer recommended, and will be deprecated in 1.39.0.
Version 1.35.0 (2019-05-23)
Language
FnOnce
,FnMut
, and theFn
traits are now implemented forBox<FnOnce>
,Box<FnMut>
, andBox<Fn>
respectively.- You can now coerce closures into unsafe function pointers. e.g.
unsafe fn call_unsafe(func: unsafe fn()) { func() } pub fn main() { unsafe { call_unsafe(|| {}); } }
Compiler
- Added the
armv6-unknown-freebsd-gnueabihf
andarmv7-unknown-freebsd-gnueabihf
targets. - Added the
wasm32-unknown-wasi
target.
Libraries
Thread
will now show its ID inDebug
output.StdinLock
,StdoutLock
, andStderrLock
now implementAsRawFd
.alloc::System
now implementsDefault
.- Expanded
Debug
output ({:#?}
) for structs now has a trailing comma on the last field. char::{ToLowercase, ToUppercase}
now implementExactSizeIterator
.- All
NonZero
numeric types now implementFromStr
. - Removed the
Read
trait bounds on theBufReader::{get_ref, get_mut, into_inner}
methods. - You can now call the
dbg!
macro without any parameters to print the file and line where it is called. - In place ASCII case conversions are now up to 4× faster.
e.g.
str::make_ascii_lowercase
hash_map::{OccupiedEntry, VacantEntry}
now implementSync
andSend
.
Stabilized APIs
f32::copysign
f64::copysign
RefCell::replace_with
RefCell::map_split
ptr::hash
Range::contains
RangeFrom::contains
RangeTo::contains
RangeInclusive::contains
RangeToInclusive::contains
Option::copied
Cargo
- You can now set
cargo:rustc-cdylib-link-arg
at build time to pass custom linker arguments when building acdylib
. Its usage is highly platform specific.
Misc
Version 1.34.2 (2019-05-14)
Version 1.34.1 (2019-04-25)
- Fix false positives for the
redundant_closure
Clippy lint - Fix false positives for the
missing_const_for_fn
Clippy lint - Fix Clippy panic when checking some macros
Version 1.34.0 (2019-04-11)
Language
- You can now use
#[deprecated = "reason"]
as a shorthand for#[deprecated(note = "reason")]
. This was previously allowed by mistake but had no effect. - You can now accept token streams in
#[attr()]
,#[attr[]]
, and#[attr{}]
procedural macros. - You can now write
extern crate self as foo;
to import your crate's root into the extern prelude.
Compiler
- You can now target
riscv64imac-unknown-none-elf
andriscv64gc-unknown-none-elf
. - You can now enable linker plugin LTO optimisations with
-C linker-plugin-lto
. This allows rustc to compile your Rust code into LLVM bitcode allowing LLVM to perform LTO optimisations across C/C++ FFI boundaries. - You can now target
powerpc64-unknown-freebsd
.
Libraries
- The trait bounds have been removed on some of
HashMap<K, V, S>
's andHashSet<T, S>
's basic methods. Most notably you no longer require theHash
trait to create an iterator. - The
Ord
trait bounds have been removed on some ofBinaryHeap<T>
's basic methods. Most notably you no longer require theOrd
trait to create an iterator. - The methods
overflowing_neg
andwrapping_neg
are nowconst
functions for all numeric types. - Indexing a
str
is now generic over all types that implementSliceIndex<str>
. str::trim
,str::trim_matches
,str::trim_{start, end}
, andstr::trim_{start, end}_matches
are now#[must_use]
and will produce a warning if their returning type is unused.- The methods
checked_pow
,saturating_pow
,wrapping_pow
, andoverflowing_pow
are now available for all numeric types. These are equivalent to methods such aswrapping_add
for thepow
operation.
Stabilized APIs
std & core
Any::type_id
Error::type_id
atomic::AtomicI16
atomic::AtomicI32
atomic::AtomicI64
atomic::AtomicI8
atomic::AtomicU16
atomic::AtomicU32
atomic::AtomicU64
atomic::AtomicU8
convert::Infallible
convert::TryFrom
convert::TryInto
iter::from_fn
iter::successors
num::NonZeroI128
num::NonZeroI16
num::NonZeroI32
num::NonZeroI64
num::NonZeroI8
num::NonZeroIsize
slice::sort_by_cached_key
str::escape_debug
str::escape_default
str::escape_unicode
str::split_ascii_whitespace
std
Cargo
Misc
Compatibility Notes
Command::before_exec
is being replaced by the unsafe methodCommand::pre_exec
and will be deprecated with Rust 1.37.0.- Use of
ATOMIC_{BOOL, ISIZE, USIZE}_INIT
is now deprecated as you can now useconst
functions instatic
variables.
Version 1.33.0 (2019-02-28)
Language
- You can now use the
cfg(target_vendor)
attribute. E.g.#[cfg(target_vendor="apple")] fn main() { println!("Hello Apple!"); }
- Integer patterns such as in a match expression can now be exhaustive.
E.g. You can have match statement on a
u8
that covers0..=255
and you would no longer be required to have a_ => unreachable!()
case. - You can now have multiple patterns in
if let
andwhile let
expressions. You can do this with the same syntax as amatch
expression. E.g.enum Creature { Crab(String), Lobster(String), Person(String), } fn main() { let state = Creature::Crab("Ferris"); if let Creature::Crab(name) | Creature::Person(name) = state { println!("This creature's name is: {}", name); } }
- You can now have irrefutable
if let
andwhile let
patterns. Using this feature will by default produce a warning as this behaviour can be unintuitive. E.g.if let _ = 5 {}
- You can now use
let
bindings, assignments, expression statements, and irrefutable pattern destructuring in const functions. - You can now call unsafe const functions. E.g.
const unsafe fn foo() -> i32 { 5 } const fn bar() -> i32 { unsafe { foo() } }
- You can now specify multiple attributes in a
cfg_attr
attribute. E.g.#[cfg_attr(all(), must_use, optimize)]
- You can now specify a specific alignment with the
#[repr(packed)]
attribute. E.g.#[repr(packed(2))] struct Foo(i16, i32);
is a struct with an alignment of 2 bytes and a size of 6 bytes. - You can now import an item from a module as an
_
. This allows you to import a trait's impls, and not have the name in the namespace. E.g.use std::io::Read as _; // Allowed as there is only one `Read` in the module. pub trait Read {}
- You may now use
Rc
,Arc
, andPin
as method receivers.
Compiler
- You can now set a linker flavor for
rustc
with the-Clinker-flavor
command line argument. - The minimum required LLVM version has been bumped to 6.0.
- Added support for the PowerPC64 architecture on FreeBSD.
- The
x86_64-fortanix-unknown-sgx
target support has been upgraded to tier 2 support. Visit the platform support page for information on Rust's platform support. - Added support for the
thumbv7neon-linux-androideabi
andthumbv7neon-unknown-linux-gnueabihf
targets. - Added support for the
x86_64-unknown-uefi
target.
Libraries
- The methods
overflowing_{add, sub, mul, shl, shr}
are nowconst
functions for all numeric types. - The methods
rotate_left
,rotate_right
, andwrapping_{add, sub, mul, shl, shr}
are nowconst
functions for all numeric types. - The methods
is_positive
andis_negative
are nowconst
functions for all signed numeric types. - The
get
method for allNonZero
types is nowconst
. - The methods
count_ones
,count_zeros
,leading_zeros
,trailing_zeros
,swap_bytes
,from_be
,from_le
,to_be
,to_le
are nowconst
for all numeric types. Ipv4Addr::new
is now aconst
function
Stabilized APIs
unix::FileExt::read_exact_at
unix::FileExt::write_all_at
Option::transpose
Result::transpose
convert::identity
pin::Pin
marker::Unpin
marker::PhantomPinned
Vec::resize_with
VecDeque::resize_with
Duration::as_millis
Duration::as_micros
Duration::as_nanos
Cargo
- You can now publish crates that require a feature flag to compile with
cargo publish --features
orcargo publish --all-features
. - Cargo should now rebuild a crate if a file was modified during the initial build.
Compatibility Notes
- The methods
str::{trim_left, trim_right, trim_left_matches, trim_right_matches}
are now deprecated in the standard library, and their usage will now produce a warning. Please use thestr::{trim_start, trim_end, trim_start_matches, trim_end_matches}
methods instead. - The
Error::cause
method has been deprecated in favor ofError::source
which supports downcasting. - Libtest no longer creates a new thread for each test when
--test-threads=1
. It also runs the tests in deterministic order
Version 1.32.0 (2019-01-17)
Language
2018 edition
- You can now use the
?
operator in macro definitions. The?
operator allows you to specify zero or one repetitions similar to the*
and+
operators. - Module paths with no leading keyword like
super
,self
, orcrate
, will now always resolve to the item (enum
,struct
, etc.) available in the module if present, before resolving to a external crate or an item the prelude. E.g.enum Color { Red, Green, Blue } use Color::*;
All editions
- You can now match against
PhantomData<T>
types. - You can now match against literals in macros with the
literal
specifier. This will match against a literal of any type. E.g.1
,'A'
,"Hello World"
- Self can now be used as a constructor and pattern for unit and tuple structs. E.g.
struct Point(i32, i32); impl Point { pub fn new(x: i32, y: i32) -> Self { Self(x, y) } pub fn is_origin(&self) -> bool { match self { Self(0, 0) => true, _ => false, } } }
- Self can also now be used in type definitions. E.g.
enum List<T> where Self: PartialOrd<Self> // can write `Self` instead of `List<T>` { Nil, Cons(T, Box<Self>) // likewise here }
- You can now mark traits with
#[must_use]
. This provides a warning if aimpl Trait
ordyn Trait
is returned and unused in the program.
Compiler
- The default allocator has changed from jemalloc to the default allocator on your system. The compiler itself on Linux & macOS will still use jemalloc, but programs compiled with it will use the system allocator.
- Added the
aarch64-pc-windows-msvc
target.
Libraries
PathBuf
now implementsFromStr
.Box<[T]>
now implementsFromIterator<T>
.- The
dbg!
macro has been stabilized. This macro enables you to easily debug expressions in your rust program. E.g.let a = 2; let b = dbg!(a * 2) + 1; // ^-- prints: [src/main.rs:4] a * 2 = 4 assert_eq!(b, 5);
The following APIs are now const
functions and can be used in a
const
context.
Cell::as_ptr
UnsafeCell::get
char::is_ascii
iter::empty
ManuallyDrop::new
ManuallyDrop::into_inner
RangeInclusive::start
RangeInclusive::end
NonNull::as_ptr
slice::as_ptr
str::as_ptr
Duration::as_secs
Duration::subsec_millis
Duration::subsec_micros
Duration::subsec_nanos
CStr::as_ptr
Ipv4Addr::is_unspecified
Ipv6Addr::new
Ipv6Addr::octets
Stabilized APIs
i8::to_be_bytes
i8::to_le_bytes
i8::to_ne_bytes
i8::from_be_bytes
i8::from_le_bytes
i8::from_ne_bytes
i16::to_be_bytes
i16::to_le_bytes
i16::to_ne_bytes
i16::from_be_bytes
i16::from_le_bytes
i16::from_ne_bytes
i32::to_be_bytes
i32::to_le_bytes
i32::to_ne_bytes
i32::from_be_bytes
i32::from_le_bytes
i32::from_ne_bytes
i64::to_be_bytes
i64::to_le_bytes
i64::to_ne_bytes
i64::from_be_bytes
i64::from_le_bytes
i64::from_ne_bytes
i128::to_be_bytes
i128::to_le_bytes
i128::to_ne_bytes
i128::from_be_bytes
i128::from_le_bytes
i128::from_ne_bytes
isize::to_be_bytes
isize::to_le_bytes
isize::to_ne_bytes
isize::from_be_bytes
isize::from_le_bytes
isize::from_ne_bytes
u8::to_be_bytes
u8::to_le_bytes
u8::to_ne_bytes
u8::from_be_bytes
u8::from_le_bytes
u8::from_ne_bytes
u16::to_be_bytes
u16::to_le_bytes
u16::to_ne_bytes
u16::from_be_bytes
u16::from_le_bytes
u16::from_ne_bytes
u32::to_be_bytes
u32::to_le_bytes
u32::to_ne_bytes
u32::from_be_bytes
u32::from_le_bytes
u32::from_ne_bytes
u64::to_be_bytes
u64::to_le_bytes
u64::to_ne_bytes
u64::from_be_bytes
u64::from_le_bytes
u64::from_ne_bytes
u128::to_be_bytes
u128::to_le_bytes
u128::to_ne_bytes
u128::from_be_bytes
u128::from_le_bytes
u128::from_ne_bytes
usize::to_be_bytes
usize::to_le_bytes
usize::to_ne_bytes
usize::from_be_bytes
usize::from_le_bytes
usize::from_ne_bytes
Cargo
- You can now run
cargo c
as an alias forcargo check
. - Usernames are now allowed in alt registry URLs.
Misc
Compatibility Notes
- The argument types for AVX's
_mm256_stream_si256
,_mm256_stream_pd
,_mm256_stream_ps
have been changed from*const
to*mut
as the previous implementation was unsound.
Version 1.31.1 (2018-12-20)
- Fix Rust failing to build on
powerpc-unknown-netbsd
- Fix broken go-to-definition in RLS
- Fix infinite loop on hover in RLS
Version 1.31.0 (2018-12-06)
Language
🎉 This version marks the release of the 2018 edition of Rust.🎉 - New lifetime elision rules now allow for eliding lifetimes in functions and
impl headers. E.g.
impl<'a> Reader for BufReader<'a> {}
can now beimpl Reader for BufReader<'_> {}
. Lifetimes are still required to be defined in structs. - You can now define and use
const
functions. These are currently a strict minimal subset of the const fn RFC. Refer to the language reference for what exactly is available. - You can now use tool lints, which allow you to scope lints from external
tools using attributes. E.g.
#[allow(clippy::filter_map)]
. #[no_mangle]
and#[export_name]
attributes can now be located anywhere in a crate, not just in exported functions.- You can now use parentheses in pattern matches.
Compiler
Libraries
- You can now convert
num::NonZero*
types to their raw equivalents using theFrom
trait. E.g.u8
now implementsFrom<NonZeroU8>
. - You can now convert a
&Option<T>
intoOption<&T>
and&mut Option<T>
intoOption<&mut T>
using theFrom
trait. - You can now multiply (
*
) atime::Duration
by au32
.
Stabilized APIs
slice::align_to
slice::align_to_mut
slice::chunks_exact
slice::chunks_exact_mut
slice::rchunks
slice::rchunks_mut
slice::rchunks_exact
slice::rchunks_exact_mut
Option::replace
Cargo
- Cargo will now download crates in parallel using HTTP/2.
- You can now rename packages in your Cargo.toml We have a guide
on how to use the
package
key in your dependencies.
Version 1.30.1 (2018-11-08)
Version 1.30.0 (2018-10-25)
Language
- Procedural macros are now available. These kinds of macros allow for more powerful code generation. There is a new chapter available in the Rust Programming Language book that goes further in depth.
- You can now use keywords as identifiers using the raw identifiers
syntax (
r#
), e.g.let r#for = true;
- Using anonymous parameters in traits is now deprecated with a warning and will be a hard error in the 2018 edition.
- You can now use
crate
in paths. This allows you to refer to the crate root in the path, e.g.use crate::foo;
refers tofoo
insrc/lib.rs
. - Using a external crate no longer requires being prefixed with
::
. Previously, using a external crate in a module without a use statement requiredlet json = ::serde_json::from_str(foo);
but can now be written aslet json = serde_json::from_str(foo);
. - You can now apply the
#[used]
attribute to static items to prevent the compiler from optimising them away, even if they appear to be unused, e.g.#[used] static FOO: u32 = 1;
- You can now import and reexport macros from other crates with the
use
syntax. Macros exported with#[macro_export]
are now placed into the root module of the crate. If your macro relies on calling other local macros, it is recommended to export with the#[macro_export(local_inner_macros)]
attribute so users won't have to import those macros. - You can now catch visibility keywords (e.g.
pub
,pub(crate)
) in macros using thevis
specifier. - Non-macro attributes now allow all forms of literals, not just
strings. Previously, you would write
#[attr("true")]
, and you can now write#[attr(true)]
. - You can now specify a function to handle a panic in the Rust runtime with the
#[panic_handler]
attribute.
Compiler
- Added the
riscv32imc-unknown-none-elf
target. - Added the
aarch64-unknown-netbsd
target - Upgraded to LLVM 8.
Libraries
Stabilized APIs
-
The following methods are replacement methods for
trim_left
,trim_right
,trim_left_matches
, andtrim_right_matches
, which will be deprecated in 1.33.0:
Cargo
cargo run
doesn't require specifying a package in workspaces.cargo doc
now supports--message-format=json
. This is equivalent to callingrustdoc --error-format=json
.- Cargo will now provide a progress bar for builds.
Misc
rustdoc
allows you to specify what edition to treat your code as with the--edition
option.rustdoc
now has the--color
(specify whether to output color) and--error-format
(specify error format, e.g.json
) options.- We now distribute a
rust-gdbgui
script that invokesgdbgui
with Rust debug symbols. - Attributes from Rust tools such as
rustfmt
orclippy
are now available, e.g.#[rustfmt::skip]
will skip formatting the next item.
Version 1.29.2 (2018-10-11)
- Workaround for an aliasing-related LLVM bug, which caused miscompilation.
- The
rls-preview
component on the windows-gnu targets has been restored.
Version 1.29.1 (2018-09-25)
Security Notes
-
The standard library's
str::repeat
function contained an out of bounds write caused by an integer overflow. This has been fixed by deterministically panicking when an overflow happens.Thank you to Scott McMurray for responsibly disclosing this vulnerability to us.
Version 1.29.0 (2018-09-13)
Compiler
- Bumped minimum LLVM version to 5.0.
- Added
powerpc64le-unknown-linux-musl
target. - Added
aarch64-unknown-hermit
andx86_64-unknown-hermit
targets. - Upgraded to LLVM 7.
Libraries
Once::call_once
no longer requiresOnce
to be'static
.BuildHasherDefault
now implementsPartialEq
andEq
.Box<CStr>
,Box<OsStr>
, andBox<Path>
now implementClone
.- Implemented
PartialEq<&str>
forOsString
andPartialEq<OsString>
for&str
. Cell<T>
now allowsT
to be unsized.SocketAddr
is now stable on Redox.
Stabilized APIs
Cargo
- Cargo can silently fix some bad lockfiles. You can use
--locked
to disable this behavior. cargo-install
will now allow you to cross compile an install using--target
.- Added the
cargo-fix
subcommand to automatically move project code from 2015 edition to 2018. cargo doc
can now optionally document private types using the--document-private-items
flag.
Misc
rustdoc
now has the--cap-lints
option which demotes all lints above the specified level to that level. For example--cap-lints warn
will demotedeny
andforbid
lints towarn
.rustc
andrustdoc
will now have the exit code of1
if compilation fails and101
if there is a panic.- A preview of clippy has been made available through rustup.
You can install the preview with
rustup component add clippy-preview
.
Compatibility Notes
str::{slice_unchecked, slice_unchecked_mut}
are now deprecated. Usestr::get_unchecked(begin..end)
instead.std::env::home_dir
is now deprecated for its unintuitive behavior. Consider using thehome_dir
function from https://crates.io/crates/dirs instead.rustc
will no longer silently ignore invalid data in target spec.cfg
attributes and--cfg
command line flags are now more strictly validated.
Version 1.28.0 (2018-08-02)
Language
- The
#[repr(transparent)]
attribute is now stable. This attribute allows a Rust newtype wrapper (struct NewType<T>(T);
) to be represented as the inner type across Foreign Function Interface (FFI) boundaries. - The keywords
pure
,sizeof
,alignof
, andoffsetof
have been unreserved and can now be used as identifiers. - The
GlobalAlloc
trait and#[global_allocator]
attribute are now stable. This will allow users to specify a global allocator for their program. - Unit test functions marked with the
#[test]
attribute can now returnResult<(), E: Debug>
in addition to()
. - The
lifetime
specifier formacro_rules!
is now stable. This allows macros to easily target lifetimes.
Compiler
- The
s
andz
optimisation levels are now stable. These optimisations prioritise making smaller binary sizes.z
is the same ass
with the exception that it does not vectorise loops, which typically results in an even smaller binary. - The short error format is now stable. Specified with
--error-format=short
this option will provide a more compressed output of rust error messages. - Added a lint warning when you have duplicated
macro_export
s. - Reduced the number of allocations in the macro parser. This can improve compile times of macro heavy crates on average by 5%.
Libraries
- Implemented
Default
for&mut str
. - Implemented
From<bool>
for all integer and unsigned number types. - Implemented
Extend
for()
. - The
Debug
implementation oftime::Duration
should now be more easily human readable. Previously aDuration
of one second would printed asDuration { secs: 1, nanos: 0 }
and will now be printed as1s
. - Implemented
From<&String>
forCow<str>
,From<&Vec<T>>
forCow<[T]>
,From<Cow<CStr>>
forCString
,From<CString>, From<CStr>, From<&CString>
forCow<CStr>
,From<OsString>, From<OsStr>, From<&OsString>
forCow<OsStr>
,From<&PathBuf>
forCow<Path>
, andFrom<Cow<Path>>
forPathBuf
. - Implemented
Shl
andShr
forWrapping<u128>
andWrapping<i128>
. DirEntry::metadata
now usesfstatat
instead oflstat
when possible. This can provide up to a 40% speed increase.- Improved error messages when using
format!
.
Stabilized APIs
Iterator::step_by
Path::ancestors
SystemTime::UNIX_EPOCH
alloc::GlobalAlloc
alloc::Layout
alloc::LayoutErr
alloc::System
alloc::alloc
alloc::alloc_zeroed
alloc::dealloc
alloc::realloc
alloc::handle_alloc_error
btree_map::Entry::or_default
fmt::Alignment
hash_map::Entry::or_default
iter::repeat_with
num::NonZeroUsize
num::NonZeroU128
num::NonZeroU16
num::NonZeroU32
num::NonZeroU64
num::NonZeroU8
ops::RangeBounds
slice::SliceIndex
slice::from_mut
slice::from_ref
{Any + Send + Sync}::downcast_mut
{Any + Send + Sync}::downcast_ref
{Any + Send + Sync}::is