Version 1.40.0 (2019-12-19)
Language
-
You can now use tuple
struct
s and tupleenum
variant's constructors inconst
contexts. e.g.#![allow(unused)] fn main() { pub struct Point(i32, i32); const ORIGIN: Point = { let constructor = Point; constructor(0, 0) }; }
-
You can now mark
struct
s,enum
s, andenum
variants with the#[non_exhaustive]
attribute to indicate that there may be variants or fields added in the future. For example this requires adding a wild-card branch (_ => {}
) to any match statements on a non-exhaustiveenum
. (RFC 2008) -
You can now use function-like procedural macros in
extern
blocks and in type positions. e.g.type Generated = macro!();
-
The
meta
pattern matcher inmacro_rules!
now correctly matches the modern attribute syntax. For example(#[$m:meta])
now matches#[attr]
,#[attr{tokens}]
,#[attr[tokens]]
, and#[attr(tokens)]
.
Compiler
- Added tier 3 support* for the
thumbv7neon-unknown-linux-musleabihf
target. - Added tier 3 support for the
aarch64-unknown-none-softfloat
target. - Added tier 3 support for the
mips64-unknown-linux-muslabi64
, andmips64el-unknown-linux-muslabi64
targets.
* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
Libraries
Stabilized APIs
BTreeMap::get_key_value
HashMap::get_key_value
Option::as_deref_mut
Option::as_deref
Option::flatten
UdpSocket::peer_addr
f32::to_be_bytes
f32::to_le_bytes
f32::to_ne_bytes
f64::to_be_bytes
f64::to_le_bytes
f64::to_ne_bytes
f32::from_be_bytes
f32::from_le_bytes
f32::from_ne_bytes
f64::from_be_bytes
f64::from_le_bytes
f64::from_ne_bytes
mem::take
slice::repeat
todo!
Cargo
- Cargo will now always display warnings, rather than only on fresh builds.
- Feature flags (except
--all-features
) passed to a virtual workspace will now produce an error. Previously these flags were ignored. - You can now publish
dev-dependencies
without including aversion
.
Misc
Compatibility Notes
- As previously announced, any previous NLL warnings in the 2015 edition are now hard errors.
- The
include!
macro will now warn if it failed to include the entire file. Theinclude!
macro unintentionally only includes the first expression in a file, and this can be unintuitive. This will become either a hard error in a future release, or the behavior may be fixed to include all expressions as expected. - Using
#[inline]
on function prototypes and consts now emits a warning underunused_attribute
lint. Using#[inline]
anywhere else inside traits orextern
blocks now correctly emits a hard error.