No way to specify rust version in Cargo.toml?


It seems that there is no way to specify which version of rust a crate depends on. As a result, crate authors implement build scripts that check that the version of rust the user is building with is compatible. For example, in Rocket This seems like something that Cargo could check while it’s resolving dependencies.

But I’m new to Rust so maybe I’m just missing something (docs or the history for how we got to where we are). Any illumination would be much appreciated.


I know there will be support for specifying an epoch a couple years down the track when the next epoch comes along, but I haven’t heard of any way of saying “This only works for rustc 1.21 and after”.

I think Rocket is just a special case because it currently relies on unstable features and they’ve added that check to make it easier on end users who may not have the latest version of nightly installed. Rust itself is really stable and very committed to backwards compatibility, so if you are using the stable channel then things usually Just Work.

Another thing to keep in mind is that, unlike a lot of other languages and tools, it’s almost trivial to install the latest version of the compiler or switch between stable, beta, and nightly (rustup update). Combine that with the fact that the community is still very young means it’s probably never been necessary to specify a minimum compiler version so it isn’t implemented (yet).


There have been a few RFCs along these lines:


Thanks for the thorough response. These are exactly the kind of answers I was hoping for.