Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

cargo-semver-checks

> 编程语言
Open source

Scan your Rust crate for semver violations.

1.7K stars0 likes2 views
WebsiteGitHub

About

Scan your Rust crate for semver violations.

cargo-semver-checks

Lint your crate API changes for semver violations.

  • Quick Start
  • FAQ
  • Configuration
  • Exit status
  • Troubleshooting
  • Contributing

Quick Start

bash
# If you already use `cargo-binstall` for faster tool installations:
$ cargo binstall cargo-semver-checks

# Otherwise:
$ cargo install cargo-semver-checks --locked

# Lint a new release for SemVer breakage before `cargo publish`:
$ cargo semver-checks

Or use as a GitHub Action (used in .github/workflows/ci.yml in this repo):

yaml
- name: Check semver
  uses: obi1kenobi/cargo-semver-checks-action@v2

Each failing check references specific items in the Cargo SemVer reference or other reference pages, as appropriate. It also includes the item name and file location that are the cause of the problem, as well as a link to the implementation of that query in the current version of the tool.

FAQ

  • What Rust versions does cargo-semver-checks support?
  • Can I use cargo-semver-checks with nightly Rust?
  • What if my project needs stronger guarantees around supported Rust versions?
  • Does the crate I'm checking have to be published on crates.io?
    • Git repository detection and configuration
    • Use with jujutsu
  • What features does cargo-semver-checks enable in the tested crates?
  • My crate uses --cfg conditional compilation. Can cargo-semver-checks scan it?
  • Should I run cargo-semver-checks for multiple target triples?
  • Does cargo-semver-checks have false positives?
  • What are witness checks, and when are they useful?
  • Will cargo-semver-checks catch every semver violation?
  • Can I configure individual lints?
  • If I really want a new feature to be implemented, can I sponsor its development?
  • How is cargo-semver-checks similar to and different from other tools?
  • Why is it sometimes cargo-semver-check and cargo-semver-checks?
  • What is the MSRV policy with respect to semver?

What Rust versions does cargo-semver-checks support?

cargo-semver-checks uses the rustdoc tool to analyze the crate's API. Rustdoc's JSON output format isn't stable, and can have breaking changes in new Rust versions.

When each cargo-semver-checks version is released, it will at minimum include support for the then-current stable and beta Rust versions. It may, but is not guaranteed to, additionally support some nightly Rust versions.

The GitHub Action by default uses the most recent versions of both cargo-semver-checks and stable Rust, so it should be unaffected. Users using cargo-semver-checks in other ways are encouraged to update cargo-semver-checks when updating Rust versions to ensure continued compatibility.

Can I use cargo-semver-checks with nightly Rust?

Support for nightly Rust versions is on a best-effort basis. It will work often, but not always. If you must use nightly, it's strongly recommended to pin to a specific nightly version to avoid broken workflows.

cargo-semver-checks relies on the rustdoc JSON format, which is unstable and changes often. After a new rustdoc JSON format version gets shipped in nightly, it usually takes several days to several weeks for it to be supported in a new cargo-semver-checks, during which time it is not possible to use cargo-semver-checks with those nightly versions.

It's also possible that support for some nightly versions may be dropped even while older stable versions are still supported. This usually happens when a rustdoc format gets superseded by a newer version before becoming part of any stable Rust. In that case, we may drop support for that format to conserve maintenance bandwidth and speed up compile times. For example, cargo-semver-checks v0.24 supported rustdoc formats v24, v26, and v27, but did not support the nightly-only v25 format.

What if my project needs stronger guarantees around supported Rust versions?

If you'd like extended support for older Rust versions, or an SLA on supporting new nightly releases, we're happy to offer those on a commercial basis. It could be in the form of a formal support contract, or something as simple as discussing expectations over email and setting up a recurring GitHub sponsorship for an agreed-upon amount.

Please reach out at the email in the Cargo.toml and let us know about what projects this is for and what their needs are.

Does the crate I'm checking have to be published on crates.io?

No, it does not have to be published anywhere. You'll just need to use a flag to help cargo-semver-checks locate the version to use as a baseline for semver-checking.

By default, cargo-semver-checks uses crates.io to look up the previous version of the crate, which is used as the baseline for semver-checking the current version of the crate. The following flags can be used to explicitly specify a baseline instead:

--baseline-version <X.Y.Z>
    Version from registry to lookup for a baseline

--baseline-rev <REV>
    Git revision to lookup for a baseline

--baseline-root <MANIFEST_ROOT>
    Directory containing baseline crate source

--baseline-rustdoc <JSON_PATH>
    The rustdoc json file to use as a semver baseline

Custom registries are not currently supported (#160), so crates published on registries other than crates.io should use one of the other approaches of generating the baseline.

Git repository detection and configuration

When looking up a git revision with --baseline-rev, cargo-semver-checks will walk up the current directory until it finds a .git/ directory to resolve the revision and extract the corresponding worktree. You can use the following environment variables to influence git repository detection:

  • GIT_DIR: explicitly set the location of the .git/ directory. If the value is a relative path, it is resolved from the current working directory. If this is not set, cargo-semver-checks will search the current working directory and any of its parents for the .git/ directory.
  • GIT_CEILING_DIRECTORIES: a colon (:) separated list of absolute paths which cargo-semver-checks should not search for the .git/ directory. This can be used to prevent cargo-semver-checks from searching slow network mounted directories. This environment variable cannot be used to prevent searching the current working directory, or a directory explicitly set with GIT_DIR. If this is not set, cargo-semver-checks will search the current working directory and any of its parents (up to the root directory).
  • GIT_DISCOVERY_ACROSS_FILESYSTEM: enable git repository detection across filesystems. By default, cargo-semver-checks will not cross filesystem boundaries when searching for the .git/ directory. Set this environment variable to true to enable cross-filesystem detection. This environment variable has no effect when setting GIT_DIR explicitly.

Use with jujutsu

Setting the GIT_DIR environment variable allows using cargo-semver-checks with a non-colocated jujutsu repository.

bash
GIT_DIR="$(jj root)/.jj/repo/store/git" cargo semver-checks --package "foo" --baseline-rev "foo/v0.1.0"

What features does cargo-semver-checks enable in the tested crates?

By default, checking is done on all features except features named unstable, nightly, bench, no_std, or ones with prefix _, unstable-, or unstable_, as such names are commonly used for private or unstable features.

This behavior can be overridden. Checked feature set can be changed to:

  • all the features, selected with --all-features,
  • only the crate's default features, selected with --default-features,
  • empty set, selected with --only-explicit-features.

Additionally, features can be enabled one-by-one, using flags --features, --baseline-features and --current-features.

For example, consider crate serde, with the following features (per v1.0.163):

  • std - the crate's only default feature,
  • alloc, derive, rc - optional features,
  • unstable - a feature that possibly breaks semver.
used flags selected feature set explanation
none std, alloc, derive, rc Feature unstable is excluded by the default heuristic.
--features unstable std, alloc, derive, rc, unstable The flag explicitly adds unstable to the heuristic's selections.
--all-features std, alloc, derive, rc, unstable All the features are used, disabling the default heuristic.
--default-features std The crate has only one default feature.
--default-features --features derive std, derive Feature derive is used along with crate's default features.
--only-explicit-features none No explicit features are passed.
--only-explicit-features --features unstable unstable All features can be added explicitly, regardless of their name.

My crate uses --cfg conditional compilation. Can cargo-semver-checks scan it?

Yes! You can configure the --cfg options that cargo-semver-checks will use when scanning your crate by setting them in the RUSTDOCFLAGS environment variable.

For example, you can ask cargo-semver-checks to enable the some-option config by invoking it as:

RUSTDOCFLAGS="--cfg some-optio

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言