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.