Releases: rust-lang/rust
Rust 1.50.0
Language
- You can now use
const
values forx
in[x; N]
array expressions. This has been technically possible since 1.38.0, as it was unintentionally stabilized. - Assignments to
ManuallyDrop<T>
union fields are now considered safe.
Compiler
- Added tier 3* support for the
armv5te-unknown-linux-uclibceabi
target. - Added tier 3 support for the
aarch64-apple-ios-macabi
target. - The
x86_64-unknown-freebsd
is now built with the full toolset. - Dropped support for all cloudabi targets.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
proc_macro::Punct
now implementsPartialEq<char>
.ops::{Index, IndexMut}
are now implemented for fixed sized arrays of any length.- On Unix platforms, the
std::fs::File
type now has a "niche" of-1
. This value cannot be a valid file descriptor, and now meansOption<File>
takes up the same amount of space asFile
.
Stabilized APIs
bool::then
btree_map::Entry::or_insert_with_key
f32::clamp
f64::clamp
hash_map::Entry::or_insert_with_key
Ord::clamp
RefCell::take
slice::fill
UnsafeCell::get_mut
The following previously stable methods are now const
.
IpAddr::is_ipv4
IpAddr::is_ipv6
IpAddr::is_unspecified
IpAddr::is_loopback
IpAddr::is_multicast
Ipv4Addr::octets
Ipv4Addr::is_loopback
Ipv4Addr::is_private
Ipv4Addr::is_link_local
Ipv4Addr::is_multicast
Ipv4Addr::is_broadcast
Ipv4Addr::is_documentation
Ipv4Addr::to_ipv6_compatible
Ipv4Addr::to_ipv6_mapped
Ipv6Addr::segments
Ipv6Addr::is_unspecified
Ipv6Addr::is_loopback
Ipv6Addr::is_multicast
Ipv6Addr::to_ipv4
Layout::size
Layout::align
Layout::from_size_align
pow
for all integer types.checked_pow
for all integer types.saturating_pow
for all integer types.wrapping_pow
for all integer types.next_power_of_two
for all unsigned integer types.checked_next_power_of_two
for all unsigned integer types.
Cargo
- Added the
[build.rustc-workspace-wrapper]
option. This option sets a wrapper to execute instead ofrustc
, for workspace members only. cargo:rerun-if-changed
will now, if provided a directory, scan the entire contents of that directory for changes.- Added the
--workspace
flag to thecargo update
command.
Misc
- The search results tab and the help button are focusable with keyboard in rustdoc.
- Running tests will now print the total time taken to execute.
Compatibility Notes
- The
compare_and_swap
method on atomics has been deprecated. It's recommended to use thecompare_exchange
andcompare_exchange_weak
methods instead. - Changes in how
TokenStream
s are checked have fixed some cases where you could write unhygenicmacro_rules!
macros. #![test]
as an inner attribute is now considered unstable like other inner macro attributes, and reports an error by default through thesoft_unstable
lint.- Overriding a
forbid
lint at the same level that it was set is now a hard error. - You can no longer intercept
panic!
calls by supplying your own macro. It's recommended to use the#[panic_handler]
attribute to provide your own implementation. - Semi-colons after item statements (e.g.
struct Foo {};
) now produce a warning.
Rust 1.49.0
Language
- Unions can now implement
Drop
, and you can now have a field in a union withManuallyDrop<T>
. - You can now cast uninhabited enums to integers.
- You can now bind by reference and by move in patterns. This allows you to selectively borrow individual components of a type. E.g.
#[derive(Debug)] struct Person { name: String, age: u8, } let person = Person { name: String::from("Alice"), age: 20, }; // `name` is moved out of person, but `age` is referenced. let Person { name, ref age } = person; println!("{} {}", name, age);
Compiler
- Added tier 1* support for
aarch64-unknown-linux-gnu
. - Added tier 2 support for
aarch64-apple-darwin
. - Added tier 2 support for
aarch64-pc-windows-msvc
. - Added tier 3 support for
mipsel-unknown-none
. - Raised the minimum supported LLVM version to LLVM 9.
- Output from threads spawned in tests is now captured.
- Change os and vendor values to "none" and "unknown" for some targets
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
RangeInclusive
now checks for exhaustion when callingcontains
and indexing.ToString::to_string
now no longer shrinks the internal buffer in the default implementation.
Stabilized APIs
The following previously stable methods are now const
.
Cargo
- Building a crate with
cargo-package
should now be independently reproducible. cargo-tree
now marks proc-macro crates.- Added
CARGO_PRIMARY_PACKAGE
build-time environment variable. This variable will be set if the crate being built is one the user selected to build, either with-p
or through defaults. - You can now use glob patterns when specifying packages & targets.
Compatibility Notes
- Demoted
i686-unknown-freebsd
from host tier 2 to target tier 2 support. - Macros that end with a semi-colon are now treated as statements even if they expand to nothing.
- Rustc will now check for the validity of some built-in attributes on enum variants. Previously such invalid or unused attributes could be ignored.
- Leading whitespace is stripped more uniformly in documentation comments, which may change behavior. You read this post about the changes for more details.
- Trait bounds are no longer inferred for associated types.
Internal Only
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.
Rust 1.48.0
Language
- The
unsafe
keyword is now syntactically permitted on modules. This is still rejected semantically, but can now be parsed by procedural macros.
Compiler
- Stabilised the
-C link-self-contained=<yes|no>
compiler flag. This tellsrustc
whether to link its own C runtime and libraries or to rely on a external linker to find them. (Supported only onwindows-gnu
,linux-musl
, andwasi
platforms.) - You can now use
-C target-feature=+crt-static
onlinux-gnu
targets. Note: If you're using cargo you must explicitly pass the--target
flag. - Added tier 2* support for
aarch64-unknown-linux-musl
.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
io::Write
is now implemented for&ChildStdin
&Sink
,&Stdout
, and&Stderr
.- All arrays of any length now implement
TryFrom<Vec<T>>
. - The
matches!
macro now supports having a trailing comma. Vec<A>
now implementsPartialEq<[B]>
whereA: PartialEq<B>
.- The
RefCell::{replace, replace_with, clone}
methods now all use#[track_caller]
.
Stabilized APIs
The following previously stable methods are now const fn
's:
Option::is_some
Option::is_none
Option::as_ref
Result::is_ok
Result::is_err
Result::as_ref
Ordering::reverse
Ordering::then
Cargo
Rustdoc
- You can now link to items in
rustdoc
using the intra-doc link syntax. E.g./// Uses [`std::future`]
will automatically generate a link tostd::future
's documentation. See "Linking to items by name" for more information. - You can now specify
#[doc(alias = "<alias>")]
on items to add search aliases when searching throughrustdoc
's UI.
Compatibility Notes
- Promotion of references to
'static
lifetime insideconst fn
now follows the same rules as inside afn
body. In particular,&foo()
will not be promoted to'static
lifetime any more insideconst fn
s. - Associated type bindings on trait objects are now verified to meet the bounds declared on the trait when checking that they implement the trait.
- When trait bounds on associated types or opaque types are ambiguous, the compiler no longer makes an arbitrary choice on which bound to use.
- Fixed recursive nonterminals not being expanded in macros during pretty-print/reparse check. This may cause errors if your macro wasn't correctly handling recursive nonterminal tokens.
&mut
references to non zero-sized types are no longer promoted.rustc
will now warn if you use attributes like#[link_name]
or#[cold]
in places where they have no effect.- Updated
_mm256_extract_epi8
and_mm256_extract_epi16
signatures inarch::{x86, x86_64}
to returni32
to match the vendor signatures. mem::uninitialized
will now panic if any inner types inside a struct or enum disallow zero-initialization.#[target_feature]
will now error if used in a place where it has no effect.- Foreign exceptions are now caught by
catch_unwind
and will cause an abort. Note: This behaviour is not guaranteed and is still considered undefined behaviour, see thecatch_unwind
documentation for further information.
Internal Only
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.
- Building
rustc
from source now usesninja
by default overmake
. You can continue building withmake
by settingninja=false
in yourconfig.toml
. - cg_llvm:
fewer_names
inuncached_llvm_type
- Made
ensure_sufficient_stack()
non-generic
Rust 1.47.0
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 compilation 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.
Rust 1.46.0
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.
Rust 1.45.2
Rust 1.45.1
Rust 1.45.0
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
Rust 1.44.1
Rust 1.44.0
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.