2018-Specific Changes
The following is a summary of changes that only apply to code compiled with the 2018 edition compared to the 2015 edition.
Rust
- Non-lexical lifetimes (future inclusion planned for 2015 edition)
- At most once
?macro repetition operator. - Path changes:
usedeclarations must begin with:crate– refers to the current crate.self– refers to the current module.super– refers to the parent module.- An external crate name.
::– must be followed by an external crate name. This is required if an external crate has the same name as an in-scope item, to catch possible ambiguities with uniform paths (which is planned for inclusion soon #55618).
- Paths in
pub(in path)visibility modifiers must start withcrate,self, orsuper.
- Anonymous trait function parameters are not allowed.
- Trait function parameters may use any irrefutable pattern when the function has a body.
dynis a strict keyword, in 2015 it is a weak keyword.async,await, andtryare reserved keywords.- The following lints are now deny by default:
Cargo
- If there is a target definition in a
Cargo.tomlmanifest, it no longer automatically disables automatic discovery of other targets. - Target paths of the form
src/{target_name}.rsare no longer inferred for targets where thepathfield is not set. cargo installfor the current directory is no longer allowed, you must specifycargo install --path .to install the current package.