Update Sep 10, 2020 tracked by Updatify
Rust 1.45.0
Language
-
Out of range float to int conversions using
ashas been defined as a saturating conversion. 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. -
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-featureflag. E.g.-C target-feature=+avx2 -C target-feature=+fmais now equivalent to-C target-feature=+avx2,+fma. -
Added the
force-unwind-tablesflag. This option allows rustc to always generate unwind tables regardless of panic strategy. -
Added the
embed-bitcodeflag. This codegen flag allows rustc to include LLVM bitcode into generatedrlibs (this is on by default). -
Added the
tinyvalue to thecode-modelcodegen flag. -
Added tier 3 support* for the
mipsel-sony-psptarget. -
Added tier 3 support for the
thumbv7a-uwp-windows-msvctarget. - 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 implementsPartialOrdandOrd. -
proc_macro::TokenStreamnow implementsDefault. -
You can now use
charwithops::{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" -
OsStringnow implementsFromStr. -
The
saturating_negmethod has been added to all signed integer primitive types, and thesaturating_absmethod has been added for all integer primitive types. -
Arc<T>,Rc<T>now implementFrom<Cow<'_, T>>, andBoxnow implementsFrom<Cow>whenTis[T: Copy],str,CStr,OsStr, orPath. -
Box<[T]>now implementsFrom<[T; N]>. -
BitOrandBitOrAssignare implemented for allNonZerointeger types. -
The
fetch_min, andfetch_maxmethods have been added to all atomic integer types. -
The
fetch_updatemethod 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}::powinow returns a slightly different value on Windows. This is due to changes in LLVM’s intrinsics which{f32, f64}::powiuses. - 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
ltoflag is incompatible with the newembed-bitcode=no. 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.