1.45.0
版本发布时间: 2020-09-10 16:08:43
rust-lang/rust最新发布版本:1.82.0(2024-10-18 00:44:34)
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.