New keywords Minimum Rust version: 1.27 Summary • dyn is a strict keyword, in 2015 it is a weak keyword. • async and await are strict keywords. • try is a reserved keyword. Motivation dyn Trait for trait objects The dyn Trait feature is the...
Method dispatch for raw pointers to inference variables Summary • The tyvar_behind_raw_pointer lint is now a hard error. Details See Rust issue #46906 for details.
Cargo changes Summary • If there is a target definition in a Cargo.toml manifest, it no longer automatically disables automatic discovery of other targets. • Target paths of the form src/{target_name}.rs are no longer inferred for targets w...
Rust 2021 | Info | | | --- | --- | | RFC | #3085 | | Release version | 1.56.0 | The Rust 2021 Edition contains several changes that bring new capabilities and more consistency to the language, and opens up room for expansion in the future....
Additions to the prelude Summary • The TryInto, TryFrom and FromIterator traits are now part of the prelude. • This might make calls to trait methods ambiguous which could make some code fail to compile. Details The prelude of the standard...
Default Cargo feature resolver Summary • edition = "2021" implies resolver = "2" in Cargo.toml. Details Since Rust 1.51.0, Cargo has opt-in support for a new feature resolver which can be activated with resolver = "2" in Cargo.toml. Startin...
IntoIterator for arrays Summary • Arrays implement IntoIterator in all editions. • Calls to IntoIterator::into_iter are hidden in Rust 2015 and Rust 2018 when using method call syntax (i.e., array.into_iter()). So, array.into_iter() still r...
Disjoint capture in closures Summary • || a.x + 1 now captures only a.x instead of a. • This can cause things to be dropped at different times or affect whether closures implement traits like Send or Clone. • If possible changes are detecte...
Panic macro consistency Summary • panic!(..) now always uses format_args!(..), just like println!(). • panic!("{") is no longer accepted, without escaping the { as {{. • panic!(x) is no longer accepted if x is not a string literal. • Use st...
Reserved syntax Summary • any_identifier#, any_identifier"...", any_identifier'...', and 'any_identifier# are now reserved syntax, and no longer tokenize. • This is mostly relevant to macros. E.g. quote!{ #a#b } is no longer accepted. • It...
Raw lifetimes Summary • 'r#ident_or_keyword is now allowed as a lifetime, which allows using keywords such as 'r#fn. Details Raw lifetimes are introduced in the 2021 edition to support the ability to migrate to newer editions that introduce...
Warnings promoted to errors Summary • Code that triggered the bare_trait_objects and ellipsis_inclusive_range_patterns lints will error in Rust 2021. Details Two existing lints are becoming hard errors in Rust 2021, but these lints will rem...
Or patterns in macro-rules Summary • How patterns work in macro_rules macros changes slightly: • $_:pat in macro_rules now matches usage of | too: e.g. A | B. • The new $_:pat_param behaves like $_:pat did before; it does not match (top lev...
C-string literals Summary • Literals of the form c"foo" or cr"foo" represent a string of type &core::ffi::CStr. Details Starting with Rust 1.77, C-strings can be written using C-string literal syntax with the c or cr prefix. Previously, it...
Rust 2024 | Info | | | --- | --- | | RFC | #3501 | | Release version | 1.85.0 |
Language The following chapters detail changes to the language in the 2024 Edition.
RPIT lifetime capture rules This chapter describes changes related to the Lifetime Capture Rules 2024 introduced in RFC 3498, including how to use opaque type precise capturing (introduced in RFC 3617) to migrate your code. Summary • In Rus...
if let temporary scope Summary • In an if let $pat = $expr { .. } else { .. } expression, the temporary values generated from evaluating $expr will be dropped before the program enters the else branch instead of after. Details The 2024 Edit...
let chains in if and while Summary • Allow chaining of let expressions in the condition operand of if and while. Details Starting with the 2024 Edition, it is now allowed to have chaining of let expressions inside if and while condition ope...
Tail expression temporary scope Summary • Temporary values generated in evaluation of the tail expression of a function or closure body, or a block may now be dropped before local variables, and are sometimes not extended to the next larger...