Releases: pietroalbini/rust
Rust 1.46.0
Language
if,match, andloopexpressions 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.0over(x.0).0. mem::transmutecan now be used in statics and constants. Note You currently can't usemem::transmutein constant functions.
Compiler
- You can now use the
cdylibtarget on Apple iOS and tvOS platforms. - Enabled static "Position Independent Executables" by default for
x86_64-unknown-linux-musl.
Libraries
mem::forgetis now aconst fn.Stringnow implementsFrom<char>.- The
leading_ones, andtrailing_onesmethods have been stabilised for all integer types. vec::IntoIter<T>now implementsAsRef<[T]>.- All non-zero integer types (
NonZeroU8) now implementTryFromfor 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_NAMEandCARGO_CRATE_NAMEProviding the name of the specific binary being compiled and the name of the crate.CARGO_PKG_LICENSEThe license from the manifest of the package.CARGO_PKG_LICENSE_FILEThe path to the license file.
Compatibility Notes
- The target configuration option
abi_blacklisthas 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 onenums. - 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}::asinhnow 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
rustcwould 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 forrustcto 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
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.
* 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. -
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.