Richard interviews Predrag Gruevski, author of cargo-semver-checks, on the challenges of semantic versioning in Rust, trade-offs in enforcement, issues with changing function types, alternative versioning, minor and patch versions, and automation in versioning schemes. They also discuss the tools rock glue and Trustfall for embedding rocks and querying codebases.
Enforcing semantic versioning in Rust is complex due to non-obvious edge cases and requires tools like Cargo Semver Chex to detect accidental mistakes in Rust packages.
Checking semantic versioning in Rust is challenging due to continuously evolving data sets, especially the unstable format of Rust Doc JSON.
Handling version ranges that span major versions in Rust poses difficulties in ensuring compatibility, and avoiding such ranges can minimize potential issues and maintenance.
Deep dives
Enforcing Semantic Versioning in Rust
Enforcing semantic versioning in Cargo for Rust is a complex task. It requires determining when a change is a breaking change inside a package. The challenge arises because Rust's semver has non-obvious edge case situations, making it difficult to make semantic versioning easy. Several attempts have been made to solve this problem, but they often require continuous maintenance to keep working. One way to address this is through the use of a tool like Cargo Sember Chex, which checks for accidental semantic versioning mistakes in Rust packages. The goal is not to prevent breaking changes but to ensure that the changes are intentional and appropriately communicated to downstream users.
The Challenge of Handling Changing Data Sets in Rust Doc
Checking semantic versioning in Rust is complicated not only because of the rules but also due to the continuously changing data sets. The format of Rust Doc JSON, which is used by many tools for Semver checks, is unstable and evolves with the language. This unpredictability makes it difficult to maintain the tools and keep up with the changes. Rust Doc teams warn about relying on the JSON interface due to its volatility. Efforts are being made to integrate Cargo Semver checks into Cargo itself, making it a part of the development process, ensuring better compatibility and reducing the maintenance burden for Semver checks in the future.
Version Ranges and Compatibility Across Major Versions
Handling version ranges that span major version boundaries poses challenges for compatibility guarantees. In Rust, when multiple major versions of a package exist, they are treated as separate entities, making it hard to assert compatibility when depending on a package across multiple major versions. Dependencies may claim compatibility across major versions, but there's no direct way to enforce or test this. The Semver trick allows some compatibility by making older major versions depend on newer major versions and sharing the same type. However, this approach cannot resolve breaking changes related to specific functions or APIs. Maintainers should consider avoiding version ranges that span major versions to minimize potential issues and maintenance.
Trustfall: A Framework for Querying Datasets
Trustfall is a project that aims to provide an LLVM-like framework for datasets. It allows users to write queries in Trustfall's query language, which can run over various datasets like Rust Doc JSON or SQL databases. The project also offers adapters for different datasets, enabling easy querying and analysis. Trustfall has the potential to greatly improve productivity and automate tasks like semantic versioning checks and code linting. Additionally, it allows for a more consumer-centric view of versioning, making it easier to determine if an update will affect specific code paths or if it is safe to upgrade.
Benefits and Challenges of Automation in Versioning and Linting
The podcast episode explores the benefits and challenges of automation in versioning, linting, and codebase analysis. It discusses how automation tools like Trustfall and Rust Clippy can significantly simplify tasks like API compatibility checks and identifying breaking changes. These tools facilitate communication between crate publishers and users, helping to prevent surprises and minimize code breakage upon updates. However, there are cultural differences and varying opinions regarding version ranges, pinning versions, and version selection. The episode highlights the need for automation tools to consider different community norms and empower users to make informed decisions about versioning and dependency management.
Richard talks with Predrag Gruevski, author of the cargo-semver-checks tool for detecting accidental semantic versioning mistakes in Rust packages, as well as Trustfall, which is an incredibly flexible query engine. They talk about why semantic versioning is so especially tricky to get right in Rust, tradeoffs in different package managers' approaches to semver in general, and how his work on cargo-semver-checks motivated him to create a tool for querying data in just about any format.