Cargo and rustc versions

Do rustc and cargo versions need to match up? I mean, can I use the latest cargo binary with a very old version of rustc?

I'm thinking in terms of packaging the two. Will mismatched versions cause issues for users?

In general you want to keep all the tooling together. Rust's release channels do this for you. If you want to package the rust tooling in some other fashion, I'd suggest starting from the mechanisms we already have for producing the channels.

We do not guarantee that cargo will work correctly with any version of rustc other than the one it is paired with. For example, cargo may use command line flags that don't exist in previous versions of rustc.

1 Like

There is a tool, cargo-bisect-rustc that does by default use a current cargo with an old rustc (it also has a flag to make it also download the corresponding old cargo versions). From my experience this (i.e. using new cargo with older rustc) tends to work for all rustc versions that are new enough to support the flag for outputting the error messages in JSON format. With versions of rustc that don’t have that flag, current cargo does not work (at all), so that is, with – IIRC – rustc that is (at least) 2 or 3 years old or so. Hence, depending on your definition of “very old version of rustc” the answer may be that it does cause issues.

1 Like