Rust versions / 1.45
Rust release · Jul 16, 2020
Rust 1.45: what's new, what was stabilized
Short answerRust 1.45 was released on Jul 16, 2020: 16 newly stable APIs (Arc::as_ptr, BTreeMap::remove_entry, Rc::as_ptr, rc::Weak::as_ptr, ...); 4 compatibility notes that can affect existing code. Point releases: 1.45.1 (Jul 30, 2020), 1.45.2 (Aug 3, 2020).
← Rust 1.44All versionsRust 1.46 →
16 APIs stabilized
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
Can it break my build?
The release lists these compatibility notes. Most only affect rare code, but read them before you raise your toolchain in CI:
- [Trying to self initialize a static value (that is creating a value using
- [
{f32, f64}::powinow returns a slightly different value on Windows.][73420] - [Rustdoc's CLI's extra error exit codes have been removed.][71900] These were
- [Rustc's
ltoflag is incompatible with the newembed-bitcode=no.][71848]
Use it
rustup update stable # get the newest release
rustup install 1.45 # or exactly this one
rustup override set 1.45 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.45" under [package] in Cargo.toml. Cargo then refuses to build it on older compilers with a clear message, and with resolver 3 (the default on the 2024 edition, Rust 1.85+) it also prefers dependency versions that support it.
Full release notes
Language
- [Out of range float to int conversions using
ashas been defined as a saturating conversion.][71269] This was previously undefined behaviour, but you can use the{f64, f32}::to_int_uncheckedmethods 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.][70705] - [Function like procedural macros can now be used in expression, pattern, and statement positions.][68717] 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-featureflag.][72094] E.g.-C target-feature=+avx2 -C target-feature=+fmais now equivalent to-C target-feature=+avx2,+fma. - [Added the
force-unwind-tablesflag.][69984] This option allows rustc to always generate unwind tables regardless of panic strategy. - [Added the
embed-bitcodeflag.][71716] This codegen flag allows rustc to include LLVM bitcode into generatedrlibs (this is on by default). - [Added the
tinyvalue to thecode-modelcodegen flag.][72397] - [Added tier 3 support\* for the
mipsel-sony-psptarget.][72062] - [Added tier 3 support for the
thumbv7a-uwp-windows-msvctarget.][72133] - [Upgraded to LLVM 10.][67759]
\* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
Libraries
- [
net::{SocketAddr, SocketAddrV4, SocketAddrV6}now implementsPartialOrdandOrd.][72239] - [
proc_macro::TokenStreamnow implementsDefault.][72234] - [You can now use
charwithops::{Range, RangeFrom, RangeFull, RangeInclusive, RangeTo}to iterate over a range of codepoints.][72413] E.g. you can now write the following; ``rust for ch in 'a'..='z' { print!("{}", ch); } println!(); // Prints "abcdefghijklmnopqrstuvwxyz"`` - [
OsStringnow implementsFromStr.][71662] - [The
saturating_negmethod has been added to all signed integer primitive types, and thesaturating_absmethod has been added for all integer primitive types.][71886] - [
Arc<T>,Rc<T>now implementFrom<Cow<'_, T>>, andBoxnow implementsFrom<Cow>whenTis[T: Copy],str,CStr,OsStr, orPath.][71447] - [
Box<[T]>now implementsFrom<[T; N]>.][71095] - [
BitOrandBitOrAssignare implemented for allNonZerointeger types.][69813] - [The
fetch_min, andfetch_maxmethods have been added to all atomic integer types.][72324] - [The
fetch_updatemethod has been added to all atomic integer types.][71843]
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
- [Cargo uses the
embed-bitcodeflag to optimize disk usage and build time.][cargo/8066]
Misc
- [Rustdoc now supports strikethrough text in Markdown.][71928] E.g.
~~outdated information~~becomes "~~outdated information~~". - [Added an emoji to Rustdoc's deprecated API message.][72014]
Compatibility Notes
- [Trying to self initialize a static value (that is creating a value using itself) is unsound and now causes a compile error.][71140]
- [
{f32, f64}::powinow returns a slightly different value on Windows.][73420] This is due to changes in LLVM's intrinsics which{f32, f64}::powiuses. - [Rustdoc's CLI's extra error exit codes have been removed.][71900] These were previously undocumented and not intended for public use. Rustdoc still provides a non-zero exit code on errors.
- [Rustc's
ltoflag is incompatible with the newembed-bitcode=no.][71848] This may cause issues if LTO is enabled throughRUSTFLAGSorcargo rustcflags while cargo is addingembed-bitcodeitself. The recommended way to control LTO is with Cargo profiles, either inCargo.tomlor.cargo/config, or by settingCARGO_PROFILE_<name>_LTOin the environment.
Internals Only
1.45.1 (Jul 30, 2020)
- Fix const propagation with references.
- rustfmt accepts rustfmt_skip in cfg_attr again.
- Avoid spurious implicit region bound.
- Install clippy on x.py install
1.45.2 (Aug 3, 2020)
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.46Released Aug 27, 2020.Read it next →Also worth your time
Did this answer your question?