Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use rustup to install/use a specific history version of the component like: rustfmt, clippy

How to use rustup to install/use a specific history version of the component like: rustfmt, clippy?

My intention is that i would like to lint my code base always on a specific version of the components like rustfmt, clippy, then only upgrade the versions after i purposely did the evaluation, instead of randomly moving to the latest version.

like image 566
lnshi Avatar asked Oct 25 '25 03:10

lnshi


1 Answers

When installed through rustup, the version of rustfmt, cargo, clippy and other components is tied to the version of Rust you are currently using, not the latest version.

For example, on my system I get different versions of clippy if I specify +stable (1.56.1) or +nightly (1.58.0-nightly):

$ cargo +stable clippy --version
clippy 0.1.56 (59eed8a 2021-11-01)

$ cargo +nightly clippy --version
clippy 0.1.58 (d914f17 2021-11-16)

When using rustup, you can pin your project to use a specific Rust version (as well as corresponding versions for other components) by using a rust-toolchain.toml file, like this:

[toolchain]
channel = "1.56.1"
like image 160
Frxstrem Avatar answered Oct 26 '25 22:10

Frxstrem