News for hackers. Stuff that matters.
Re:Cargo-semver-checks: Scan your Rust crate for semver viol... by bloopernova on Sunday July 09, 2023 @09:07AM (#36654164)
I'm not familiar with rust+semver problems.

Can someone please explain what the issue is?

Re:Cargo-semver-checks: Scan your Rust crate for semver viol... by mjw1007 on Sunday July 09, 2023 @09:22AM (#36654256)
Unlike 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.

Re:Cargo-semver-checks: Scan your Rust crate for semver viol... by obi1kenobi on Sunday July 09, 2023 @09:26AM (#36654279)
Nice 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/

Re:Cargo-semver-checks: Scan your Rust crate for semver viol... by transportheap on Sunday July 09, 2023 @09:35AM (#36654348)
rust 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.
Re:Cargo-semver-checks: Scan your Rust crate for semver viol... by obi1kenobi on Sunday July 09, 2023 @09:19AM (#36654238)
Tool 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/

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.

Re:Cargo-semver-checks: Scan your Rust crate for semver viol... by bloopernova on Sunday July 09, 2023 @09:29AM (#36654300)
oh 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?"

Re:Cargo-semver-checks: Scan your Rust crate for semver viol... by obi1kenobi on Sunday July 09, 2023 @09:47AM (#36654422)
cargo-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.