doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~9 min read
doc.rust-lang.org
Language The following chapters detail changes to the language in the 2024 Edition.
The Rust Edition Guide
Book
2024-01-01
~1 min read
doc.rust-lang.org
Rust 2024 | Info | | | --- | --- | | RFC | #3501 | | Release version | 1.85.0 |
The Rust Edition Guide
Book
2024-01-01
~1 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~1 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~2 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~1 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~1 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~2 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~2 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~5 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~2 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~5 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~5 min read
doc.rust-lang.org
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....
The Rust Edition Guide
Book
2024-01-01
~1 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~1 min read
doc.rust-lang.org
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.
The Rust Edition Guide
Book
2024-01-01
~1 min read
doc.rust-lang.org
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...
The Rust Edition Guide
Book
2024-01-01
~1 min read
doc.rust-lang.org
Anonymous trait function parameters deprecated Minimum Rust version: 1.31 Summary • Trait function parameters may use any irrefutable pattern when the function has a body. Details In accordance with RFC #1685, parameters in trait method dec...
The Rust Edition Guide
Book
2024-01-01
~1 min read
doc.rust-lang.org
Path and module system changes Minimum Rust version: 1.31 Summary • Paths in use declarations now work the same as other paths. • Paths starting with :: must now be followed with an external crate. • Paths in pub(in path) visibility modifie...
The Rust Edition Guide
Book
2024-01-01
~7 min read
doc.rust-lang.org
Rust 2018 | Info | | | --- | --- | | RFC | #2052, which also proposed the Edition system | | Release version | 1.31.0 | The edition system was created for the release of Rust 2018. The release of the Rust 2018 edition coincided with a numbe...
The Rust Edition Guide
Book
2024-01-01
~1 min read