Description
Describe the problem you are trying to solve
Today, the version
field is required. However, in many (most?) cases it doesn't make sense:
- when doing some casual rust hacking for fun or learning
- inside "live at HEAD" company monorepo
- when working on a large Rust projects not distributed via
cargo install
This creates specific issues:
- additional confusion -- there is a line in Cargo.toml which is there "just because", and not due to some specific reason
- diluted meaning of versions: semver compatibility is a lot to promise, by having versions everywhere it's harder to notice where they matter and where you need to care about API compatibility
- For projects which mix published and non-published crates in the same source tree, it becomes harder to know at a glance if a particular crate is published.
Describe the solution you'd like
Make the version
field in Cargo.toml optional. Do populate it by default, as it is today. Prevent publishing the crates which (transitively) depend on non-versioned crates.
Notes
There is publish = false
, to my mind that serves a different purpose -- preventing accidental publishing of the crates. It doesn't help with solving confusion problem -- the version is still there, and it still doesn't have a meaning. Although, if we were to re-design Cargo from scratch, I would argue that we shouldn't have publish
field at all, and insead define it as publish = version.is_some()
.
Implementation wise, it seems like we can desugar absence of version as version = "0.0.0" publish = false
. I personally use version = "0.0.0"
as a way to explicitly signal that there's no meaningful version.