Update Nov 19, 2020 tracked by Updatify
Rust 1.48.0
Language
-
The
unsafekeyword is now syntactically permitted on modules. This is still rejected semantically, but can now be parsed by procedural macros.
Compiler
-
Stabilised the
-C link-self-contained=<yes|no>compiler flag. This tellsrustcwhether to link its own C runtime and libraries or to rely on a external linker to find them. (Supported only onwindows-gnu,linux-musl, andwasiplatforms.) -
You can now use
-C target-feature=+crt-staticonlinux-gnutargets. Note: If you’re using cargo you must explicitly pass the--targetflag. -
Added tier 2* support for
aarch64-unknown-linux-musl.
* Refer to Rust’s platform support page for more information on Rust’s tiered platform support.
Libraries
-
io::Writeis now implemented for&ChildStdin&Sink,&Stdout, and&Stderr. -
All arrays of any length now implement
TryFrom<Vec<T>>. -
The
matches!macro now supports having a trailing comma. -
Vec<A>now implementsPartialEq<[B]>whereA: PartialEq<B>. -
The
RefCell::{replace, replace_with, clone}methods now all use#[track_caller].
Stabilized APIs
The following previously stable methods are now const fn‘s:
-
Option::is_some -
Option::is_none -
Option::as_ref -
Result::is_ok -
Result::is_err -
Result::as_ref -
Ordering::reverse -
Ordering::then
Cargo
Rustdoc
-
You can now link to items in
rustdocusing the intra-doc link syntax. E.g./// Uses [`std::future`]will automatically generate a link tostd::future‘s documentation. See “Linking to items by name” for more information. -
You can now specify
#[doc(alias = "<alias>")]on items to add search aliases when searching throughrustdoc‘s UI.
Compatibility Notes
-
Promotion of references to
'staticlifetime insideconst fnnow follows the same rules as inside afnbody. In particular,&foo()will not be promoted to'staticlifetime any more insideconst fns. - Associated type bindings on trait objects are now verified to meet the bounds declared on the trait when checking that they implement the trait.
- When trait bounds on associated types or opaque types are ambiguous, the compiler no longer makes an arbitrary choice on which bound to use.
- Fixed recursive nonterminals not being expanded in macros during pretty-print/reparse check. This may cause errors if your macro wasn’t correctly handling recursive nonterminal tokens.
-
&mutreferences to non zero-sized types are no longer promoted. -
rustcwill now warn if you use attributes like#[link_name]or#[cold]in places where they have no effect. -
Updated
_mm256_extract_epi8and_mm256_extract_epi16signatures inarch::{x86, x86_64}to returni32to match the vendor signatures. -
mem::uninitializedwill now panic if any inner types inside a struct or enum disallow zero-initialization. -
#[target_feature]will now error if used in a place where it has no effect. -
Foreign exceptions are now caught by
catch_unwindand will cause an abort. Note: This behaviour is not guaranteed and is still considered undefined behaviour, see thecatch_unwinddocumentation for further information.
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.
-
Building
rustcfrom source now usesninjaby default overmake. You can continue building withmakeby settingninja=falsein yourbootstrap.toml. -
cg_llvm:
fewer_namesinuncached_llvm_type -
Made
ensure_sufficient_stack()non-generic