How to help test the 2018 edition

How to help test the 2018 edition

An edition brings together the features that have landed into a clear package, with fully updated documentation and tooling. By the end of the year we are planning to release the 2018 edition, our first since the Rust 1.0 release. You can currently opt-in to a preview of the 2018 edition to try it out and help test it.

In fact, we really need help testing it out! Once you’ve turned it on and seen its wonderful new features, what then? Here we’ve got some specific things we’d like you to test.

How to use the 2018 edition

  • You’ll first need a nightly toolchain (compiler, etc). If you’re not using nightly, install it with rustup install nightly
  • Add #![feature(rust_2018_preview)] to your crate (at the top of any lib.rs or main.rs files, or any other root files)
  • Add cargo-features = ["edition"] to the top of your Cargo.toml
  • Add edition = '2018``' to the [package] section of your Cargo.toml

How to report issues

  • File an issue, adding the ‘A-rust-2018-preview’ label (if you can, and if you can’t, note in the issue that it should be labeled as such). Please search the existing issues first to avoid duplication (start with the A-rust-2018-preview and A-2018-edition-lints labels). If you find a duplicate, leave a comment explaining how this also applied to your situation.
  • Tell someone in the rust-edition channel on irc, or on Discord, they might ask you to file an issue instead 🙂

What to test

Here are some suggestions for things you can do that would be extra-helpful to test. It’s also great if you can just use Rust like you normally would, but using the new language features and idioms of the 2018 edition. In either case, please report any crashes, bugs, or any rough edges.

Make sure you make a backup or commit your code before experimenting - some of these tools are at the ‘might eat your laundry’ stage.

Transition an existing crate

Use Rustfix, report any mistakes it makes, anything it can’t transition, bugs when compiling the transitioned code, anything surprising that happens. If you have a good time and things worked well, please also tell us!

To install Rustfix, use

cargo install --force cargo-fix

To use Rustfix before transitioning to the 2018 edition, you can run

cargo +nightly fix --prepare-for 2018

If you want to use it after you’ve transitioned, use

cargo +nightly fix

The latter may give you more warnings to fix up.

You don’t need +nightly if nightly is your default toolchain. You can use --all-targets to run Rustfix on all configurations (e.g., this includes tests).

Test the tools

Once you’ve transitioned the crate to the 2018 edition, try running rustdoc, Clippy, Rustfmt, or your favorite IDE on the crate and see if it works. Report any bugs that occur (either as issues in the Rust repo (or the specific tool’s repo if you know where to go) or on irc or Discord).

Use some new language features

Are there any bugs in the compiler or tools? Did the feature feel good? Did you hit any surprising edge cases? The new features are listed in the guide.

There’s a few features we’d like feedback on: the new module system and in-band lifetimes.

The module system changes include no longer requiring extern crate statements, absolute paths always starting with a crate name or crate for the current crate, using crate instead of pub(crate), and permitting foo.rs and foo/ subdirectories to coexist. We’re interested in how these changes make the module system feel as a whole, especially once you’ve adjusted to the new mental model.

In-band lifetimes allow the programmer to write lifetimes in function signatures without declaring them, e.g., fn two_args(foo: &Foo, bar: &'b Bar) -> &'b Baz instead of fn two_args<'b>(foo: &Foo, bar: &'b Bar) -> &'b Baz.

Resources

Some resources if you’re looking for more information about the 2018 edition:

Thanks to centril, marksimulacrum, and steveklabnik for feedback on this post.