Releases: rust-lang/rust
Rust 1.45.2
Rust 1.45.1
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_ptrBTreeMap::remove_entryRc::as_ptrrc::Weak::as_ptrrc::Weak::from_rawrc::Weak::into_rawstr::strip_prefixstr::strip_suffixsync::Weak::as_ptrsync::Weak::from_rawsync::Weak::into_rawchar::UNICODE_VERSIONSpan::resolved_atSpan::located_atSpan::mixed_siteunix::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.
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-unitsflag in incremental mode. Additionally when in incremental mode rustc defaults to 256 codegen units. - Refactored
catch_unwindto have zero-cost, unless unwinding is enabled and a panic is thrown. - Added tier 3* support for the
aarch64-unknown-noneandaarch64-unknown-none-softfloattargets. - Added tier 3 support for
arm64-apple-tvosandx86_64-apple-tvostargets.
Libraries
- Special cased
vec![]to map directly toVec::new(). This allowsvec![]to be able to be used inconstcontexts. convert::Infalliblenow implementsHash.OsStringnow implementsDerefMutandIndexMutreturning a&mut OsStr.- Unicode 13 is now supported.
Stringnow implementsFrom<&mut str>.IoSlicenow implementsCopy.Vec<T>now implementsFrom<[T; N]>. WhereNis at most 32.proc_macro::LexErrornow implementsfmt::DisplayandError.from_le_bytes,to_le_bytes,from_be_bytes,to_be_bytes,from_ne_bytes, andto_ne_bytesmethods are nowconstfor all integer types.
Stabilized APIs
PathBuf::with_capacityPathBuf::capacityPathBuf::clearPathBuf::reservePathBuf::reserve_exactPathBuf::shrink_to_fitf32::to_int_uncheckedf64::to_int_uncheckedLayout::align_toLayout::pad_to_alignLayout::arrayLayout::extend
Cargo
- Added the
cargo treecommand 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
.aextension, rather than the previous.lib. - Removed the
-C no_integrated_asflag from rustc. - The
file_nameproperty 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
f64tou32using theasoperator has been defined as a saturating operation. 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.
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.43.1
Rust 1.43.0
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 onifexpressions.
Syntax only changes
- Allow
type Foo: Ordsyntactically. - Fuse associated and extern items up to defaultness.
- Syntactically allow
selfin allfncontexts. - Merge
fnsyntax + cleanup item parsing. itemmacro fragments can be interpolated intotraits,impls, andexternblocks. 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-variablesdenies everything in theunusedlint group exceptunused-variableswhich is explicitly allowed. However, passingrustc -A unused-variables -D unuseddenies everything in theunusedlint group includingunused-variablessince 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 whenNis0..=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::MAXorf32::NANwith no imports. u8::is_asciiis nowconst.Stringnow implementsAsMut<str>.- Added the
primitivemodule tostdandcore. 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
HashMapandHashSet. string::FromUtf8Errornow 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-programyou would useenv!("CARGO_BIN_EXE_my-program").
Misc
- Certain checks in the
const_errlint were deemed unrelated to const evaluation, and have been moved to theunconditional_panicandarithmetic_overflowlints.
Compatibility Notes
- Having trailing syntax in the
assert!macro is now a hard error. This has been a warning since 1.36.0. - Fixed
Selfnot 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=3instead 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
Dropterminators for enum variants without drop glue - Improve performance of coherence checks
- Deduplicate types in the generator witness
- Invert control in struct_lint_level.
Rust 1.42.0
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 univariantenums. 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:
defaultis syntactically allowed before items intraitdefinitions.- Items in
impls (i.e.consts,types, andfns) may syntactically leave out their bodies in favor of;. - Bounds on associated types in
impls 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 implementsSendandSyncfor anyT.Pin::{map_unchecked, map_unchecked_mut}no longer require the return type to implementSized.io::Cursornow derivesPartialEqandEq.Layout::newis nowconst.- Added Standard Library support for
riscv64gc-unknown-linux-gnu.
Stabilized APIs
CondVar::wait_whileCondVar::wait_timeout_whileDebugMap::keyDebugMap::valueManuallyDrop::takematches!ptr::slice_from_raw_parts_mutptr::slice_from_raw_parts
Cargo
Compatibility Notes
Error::descriptionhas been deprecated, and its use will now produce a warning. It's recommended to useDisplay/to_stringinstead.
Rust 1.41.1
- Always check types of static items
- Always check lifetime bounds of
Copyimpls - Fix miscompilation in callers of
Layout::repeat - Rust 1.41.0 was announced as the last Rust release with tier 1 or tier 2 support for 32-bit Apple targets. That announcement did not expect a patch release. 1.41.1 also includes release binaries for these targets.
Rust 1.41.0
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
selfposition. 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_argsmacro. 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
'labels. - Removed support for the
i686-unknown-dragonflytarget. - Added tier 3 support* for the
riscv64gc-unknown-linux-gnutarget. - You can now pass an arguments file passing the
@pathsyntax 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
--externflag without a path, indicating that it is available from the search path or specified with an-Lflag.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- The
core::panicmodule is now stable. It was already stable throughstd. NonZero*numerics now implementFrom<NonZero*>if it's a smaller integer width. E.g.NonZeroU16now implementsFrom<NonZeroU8>.MaybeUninit<T>now implementsfmt::Debug.
Stabilized APIs
Result::map_orResult::map_or_elsestd::rc::Weak::weak_countstd::rc::Weak::strong_countstd::sync::Weak::weak_countstd::sync::Weak::strong_count
Cargo
- Cargo will now document all the private items for binary crates by default.
cargo-installwill 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 = 2sets theimagecrate's optimisation level to2for debug builds. You can also use[profile.<profile>.build-override]to override build scripts and their dependencies.
Misc
- You can now specify
editionin documentation code blocks to compile the block for that edition. E.g.edition2018tells 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 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.