Search

Chapter 5. Changes in Rust Toolset in Red Hat Developer Tools 2019.1

download PDF

This chapter lists some notable changes in Rust Toolset since its previous release.

5.1. Rust

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 #[name] annotations.
    • Function macros work like those defined by macro_rules!, but have more flexibility being implemented in Rust.
    • Macros can now be imported in use statements, removing the need for the #[macro_use] crate attribute.
    • The proc_macro crate is now stable, to help write these new macros.
  • Module improvements

    • External crates are now in the prelude, which allows a crate name to serve as the root of a path from anywhere.
    • The crate keyword now serves as the root of your own crate in paths and use statements.
  • 2018 edition

    • 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 new will specify edition = "2018" in Cargo.toml for new projects.
    • async, await, and try are reserved keywords in 2018, and dyn is 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 crate declarations are unnecessary in most cases in 2018. use paths can now be relative from the current scope, rather than always starting from the root scope as in 2015.
  • Lifetimes can now be left implicit in more cases, especially using the new '_ placeholder.
  • const fn — Functions can be declared constant, which allows them to be used in restricted contexts, like the initialization of a const or static value.
  • Stable tools: clippy, rls, and rustfmt. We have been shipping these tools as preview already, but now they are officially supported.

    • clippy adds extra lints for code/style issues.
    • rls implements the Language Server protocol for IDE integration.
    • rustfmt formats your code, also integrated with the cargo fmt subcommand.
  • 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.

5.2. cargo

The 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;.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.