3 ms·
I'm not familiar with rust+semver problems. Can someone please explain what the issue is?
by bloopernova 3y ago
I'm not familiar with rust+semver problems.
Can someone please explain what the issue is?
- obi1kenobi 3y agoTool author here! I wrote a blog post that explains the motivation for building cargo-semver-checks here: https://predr.ag/blog/toward-fearless-cargo-update/ https://predr.ag/blog/toward-fearless-cargo-update/ TL;DR: Semver is particularly tricky in Rust and can be broken in many far-from-obvious ways. When a library breaks semver it can cause compile errors in every downstream bit of code that uses it. This sucks for everyone on all sides.
- bloopernova 3y agooh interesting, thank you! So semver is something that Rust always uses and enforces as opposed to stuff I've seen where it's a manual number added by a human. Cool, I can definitely see how that would cause issues, and your examples+blog were helpful. Much appreciated! Could there be a workflow in Rust compilation or packaging that uses your tool and says "oops, looks like the semver needs to be updated, can I do that for you?"
- obi1kenobi 3y agocargo-semver-checks is in the process of being merged into cargo itself, which would make the default publishing process into essentially exactly what you describe! Running `cargo publish` would check for semver issues and alert if it finds anything. Users would be able to override it, of course, but most often they'd probably accept the version change or revert the semver break if it wasn't intended.
- mjw1007 3y agoUnlike the way some languages' package systems work, Rust crates don't cleanly separate the public interface from the private implementation. In practice a crate's public interface is effectively scattered throughout a number of modules. There's no separate textual interface definition that you could diff to see what you changed without also seeing changes to the implementation. Clients importing your library compile against the whole source. So in practice if you want to check whether you changed your public interface unintentionally, your best bet is to compare the old and new output of Rust's automated documentation system, which by default is describing only the public interface. Cargo-semver-checks attempts to automate that.
- obi1kenobi 3y agoNice summary! I'd also add that part of the public interface you're on the hook for is never explicitly written down in the source code, and is instead derived automatically by the compiler based on a set of rules. There are excellent reasons why this is the case, but as you could imagine this doesn't make semver any easier. For Rust folks, I'm talking about auto traits like Send and Sync. More info and examples here: https://predr.ag/blog/toward-fearless-cargo-update/ https://predr.ag/blog/toward-fearless-cargo-update/
- transportheap 3y agorust lang shifts the digits right by 1 so minor (second spot) == major in their eyes meaning always breaking and nobody hit 1.0+ because they are scared of not changing thing or misunderstand semver.