toolchain: Add rust-toolchain file

The rust-toolchain file defines a local toolchain override that is
respected by rustup when running Cargo commands. This override applies
to the directory containing the rust-toolchain file as well as its
subdirectories. It makes it so that running `cargo check` or `cargo fmt`
always uses the intended toolchain, unless overridden by e.g. `cargo
+nightly check`, regardless of what toolchain the user has selected as
global default. No more accidentally running a too new or old version of
rustfmt!

We will need to bump this version number when rolling to a newer
toolchain in ebuild. When that happens, local Cargo commands by other
crosvm developers will automatically download the new toolchain.

For details on rust-toolchain:

    https://github.com/rust-lang-nursery/rustup.rs#the-toolchain-file
    https://github.com/rust-lang-nursery/rustup.rs#override-precedence

This file is ignored during emerge. Verified by setting rust-toolchain
to a bogus version number and emerge succeeded anyway.

TEST=rustc --version
TEST=rustc +nightly --version
TEST=cargo check
TEST=cargo fmt --all
TEST=cargo +nightly check
TEST=build_packages

Change-Id: Ia4d74a0c8c632bcd7b171f6c039b068fb30b5502
Reviewed-on: https://chromium-review.googlesource.com/1340728
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
David Tolnay 2018-11-16 14:08:13 -08:00 committed by chrome-bot
parent e13b180f74
commit 298cf591ac

1
rust-toolchain Normal file
View file

@ -0,0 +1 @@
1.30.0