Rust 1.40.0
Language
-
You can now use tuple
structs and tupleenumvariant's constructors inconstcontexts. e.g.pub struct Point(i32, i32); const ORIGIN: Point = { let constructor = Point; constructor(0, 0) };
-
You can now mark
structs,enums, andenumvariants 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
externblocks and in type positions. e.g.type Generated = macro!(); -
The
metapattern 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-musleabihftarget. - Added tier 3 support for the
aarch64-unknown-none-softfloattarget. - Added tier 3 support for the
mips64-unknown-linux-muslabi64, andmips64el-unknown-linux-muslabi64targets.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
Stabilized APIs
BTreeMap::get_key_valueHashMap::get_key_valueOption::as_deref_mutOption::as_derefOption::flattenUdpSocket::peer_addrf32::to_be_bytesf32::to_le_bytesf32::to_ne_bytesf64::to_be_bytesf64::to_le_bytesf64::to_ne_bytesf32::from_be_bytesf32::from_le_bytesf32::from_ne_bytesf64::from_be_bytesf64::from_le_bytesf64::from_ne_bytesmem::takeslice::repeattodo!
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-dependencieswithout 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_attributelint. Using#[inline]anywhere else inside traits orexternblocks now correctly emits a hard error.