Chapter 5. Changes in Rust Toolset in Red Hat Developer Tools 2019.1
This chapter lists some notable changes in Rust Toolset since its previous release.
Rust has been updated from version 1.29.0 to 1.31.1. Notable changes include:
New capabilities with defining procedural macros
Attribute macros let you define custom
Function macros work like those defined by
macro_rules!, but have more flexibility being implemented in Rust.
Macros can now be imported in
usestatements, removing the need for the
proc_macrocrate is now stable, to help write these new macros.
- Attribute macros let you define custom
- External crates are now in the prelude, which allows a crate name to serve as the root of a path from anywhere.
cratekeyword now serves as the root of your own crate in paths and
The new 2018 edition marks a collective milestone of the last 3 years of Rust development, while also making a few opt-in breaking changes. Existing code will default to 2015 edition, with no breaking changes, and crates from different editions are fully interoperable.
cargo newwill specify
edition = "2018"in
Cargo.tomlfor new projects.
tryare reserved keywords in 2018, and
dynis now a strict keyword.
- Non-lexical lifetimes are a refinement of the previous block-based lifetime system, allowing borrowed values to be released sooner in many cases to be reused elsewhere. This is initially exclusive to the 2018 edition, but planned for 2015 as well.
Module changes: Explicit
extern cratedeclarations are unnecessary in most cases in 2018.
usepaths can now be relative from the current scope, rather than always starting from the root scope as in 2015.
- The new 2018 edition marks a collective milestone of the last 3 years of Rust development, while also making a few opt-in breaking changes. Existing code will default to 2015 edition, with no breaking changes, and crates from different editions are fully interoperable.
Lifetimes can now be left implicit in more cases, especially using the new
const fn— Functions can be declared constant, which allows them to be used in restricted contexts, like the initialization of a
rustfmt. We have been shipping these tools as preview already, but now they are officially supported.
clippyadds extra lints for code/style issues.
rlsimplements the Language Server protocol for IDE integration.
rustfmtformats your code, also integrated with the
Tool lints allow you to add warning annotations for custom lints, especially for those added by
clippy. For example,
#[allow(clippy::bool_comparison)]will silence that warning on an item for which you deem it acceptable.
cargo tool has been updated from version 1.29.0 to 1.31.0. Notable changes include:
- Cargo now shows a progress bar as it builds your crates and dependencies.
Cargo now allows renaming dependencies in
Cargo.toml, affecting how they are referenced in your sources. Previously, you could only rename in source like
extern crate published_name as new_name;.