Releases: pietroalbini/rust
Rust 1.46.0
Language
if
,match
, andloop
expressions 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.0
over(x.0).0
. mem::transmute
can now be used in statics and constants. Note You currently can't usemem::transmute
in constant functions.
Compiler
- You can now use the
cdylib
target on Apple iOS and tvOS platforms. - Enabled static "Position Independent Executables" by default for
x86_64-unknown-linux-musl
.
Libraries
mem::forget
is now aconst fn
.String
now implementsFrom<char>
.- The
leading_ones
, andtrailing_ones
methods have been stabilised for all integer types. vec::IntoIter<T>
now implementsAsRef<[T]>
.- All non-zero integer types (
NonZeroU8
) now implementTryFrom
for 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_NAME
andCARGO_CRATE_NAME
Providing the name of the specific binary being compiled and the name of the crate.CARGO_PKG_LICENSE
The license from the manifest of the package.CARGO_PKG_LICENSE_FILE
The path to the license file.
Compatibility Notes
- The target configuration option
abi_blacklist
has 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 onenum
s. - 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}::asinh
now 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
rustc
would 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 forrustc
to 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
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.
* 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.
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-units
flag in incremental mode. Additionally when in incremental mode rustc defaults to 256 codegen units. - Refactored
catch_unwind
to have zero-cost, unless unwinding is enabled and a panic is thrown. - Added tier 3* support for the
aarch64-unknown-none
andaarch64-unknown-none-softfloat
targets. - Added tier 3 support for
arm64-apple-tvos
andx86_64-apple-tvos
targets.
Libraries
- Special cased
vec![]
to map directly toVec::new()
. This allowsvec![]
to be able to be used inconst
contexts. convert::Infallible
now implementsHash
.OsString
now implementsDerefMut
andIndexMut
returning a&mut OsStr
.- Unicode 13 is now supported.
String
now implementsFrom<&mut str>
.IoSlice
now implementsCopy
.Vec<T>
now implementsFrom<[T; N]>
. WhereN
is at most 32.proc_macro::LexError
now implementsfmt::Display
andError
.from_le_bytes
,to_le_bytes
,from_be_bytes
,to_be_bytes
,from_ne_bytes
, andto_ne_bytes
methods are nowconst
for all integer types.
Stabilized APIs
PathBuf::with_capacity
PathBuf::capacity
PathBuf::clear
PathBuf::reserve
PathBuf::reserve_exact
PathBuf::shrink_to_fit
f32::to_int_unchecked
f64::to_int_unchecked
Layout::align_to
Layout::pad_to_align
Layout::array
Layout::extend
Cargo
- Added the
cargo tree
command 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
.a
extension, rather than the previous.lib
. - Removed the
-C no_integrated_as
flag from rustc. - The
file_name
property 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
f64
tou32
using theas
operator has been defined as a saturating operation. 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.
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 onif
expressions.
Syntax only changes
- Allow
type Foo: Ord
syntactically. - Fuse associated and extern items up to defaultness.
- Syntactically allow
self
in allfn
contexts. - Merge
fn
syntax + cleanup item parsing. item
macro fragments can be interpolated intotrait
s,impl
s, andextern
blocks. 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-variables
denies everything in theunused
lint group exceptunused-variables
which is explicitly allowed. However, passingrustc -A unused-variables -D unused
denies everything in theunused
lint group includingunused-variables
since 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 whenN
is0..=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::MAX
orf32::NAN
with no imports. u8::is_ascii
is nowconst
.String
now implementsAsMut<str>
.- Added the
primitive
module tostd
andcore
. 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
HashMap
andHashSet
. string::FromUtf8Error
now 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-program
you would useenv!("CARGO_BIN_EXE_my-program")
.
Misc
- Certain checks in the
const_err
lint were deemed unrelated to const evaluation, and have been moved to theunconditional_panic
andarithmetic_overflow
lints.
Compatibility Notes
- Having trailing syntax in the
assert!
macro is now a hard error. This has been a warning since 1.36.0. - Fixed
Self
not 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=3
instead 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
Drop
terminators 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 univariantenum
s. 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:
default
is syntactically allowed before items intrait
definitions.- Items in
impl
s (i.e.const
s,type
s, andfn
s) may syntactically leave out their bodies in favor of;
. - Bounds on associated types in
impl
s 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 implementsSend
andSync
for anyT
.Pin::{map_unchecked, map_unchecked_mut}
no longer require the return type to implementSized
.io::Cursor
now derivesPartialEq
andEq
.Layout::new
is nowconst
.- Added Standard Library support for
riscv64gc-unknown-linux-gnu
.
Stabilized APIs
CondVar::wait_while
CondVar::wait_timeout_while
DebugMap::key
DebugMap::value
ManuallyDrop::take
matches!
ptr::slice_from_raw_parts_mut
ptr::slice_from_raw_parts
Cargo
Compatibility Notes
Error::description
has been deprecated, and its use will now produce a warning. It's recommended to useDisplay
/to_string
instead.