Skip to content

False negative: major bumping of dependency with exposed API is not detected #447

Open
@dodomorandi

Description

Steps to reproduce the bug with the above code

  • Create a new crate with cargo new inner --lib and chdir inside.
  • Add a dependency for which we are going to expose a member and later perform a dep bump. This examples uses time:
    cargo add time@0.2
  • Edit src/lib.rs so it contains the following:
    pub struct Wrapper {
      pub date: time::Date
    }
  • Create a new commit:
    git add . && git commit -m "Initial commit"
  • Bump time to 0.3:
    cargo add time@0.3
  • Add another commit (useful for further checks):
    git commit -a -m "bump time"
  • Run cargo-semver-checks:
    cargo semver-checks check-release --baseline-rev HEAD^

Further check to ensure it is a breaking change

  • Checkout to previous commit:

    git checkout HEAD^
  • Create a worktree with the latest commit in a different path:

    git worktree add ../inner-new main

    Note that if you are using an old version of git, you could need to use master instead of main

  • Change back to the parent folder and run cargo new --lib outer, then chdir inside outer.

  • Add the first version of inner as dependency:

    cargo add inner --path ../inner
  • Also add time@0.2 as dependency: cargo add time@0.2

  • Edit the src/lib.rs so it contains the following:

    use inner::Wrapper;
    use time::Date;
    
    pub fn get_wrapped(wrapped: Wrapper) -> Date {
        wrapped.date
    }
  • Run cargo check, assess that everything is fine.

  • Use the new version of inner:

    cargo add inner --path ../inner-new
  • Run cargo check again. Now you should expect a mismatching time::Date type.

Actual Behaviour

No breaking changes are reported

Expected Behaviour

A breaking change should be detected: bumping the major version of a dependency when the crate exposes something from its API is breaking.

Generated System Information

Software version

cargo-semver-checks 0.20.0 (cf03e7f)

Operating system

Linux 6.2.13-arch1-1

Command-line

/home/edoardo/.cargo/bin/cargo-semver-checks semver-checks --bugreport

cargo version

> cargo -V
cargo 1.69.0 (6e9a83356 2023-04-12)

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-linux-gnu
  • Family: unix
  • OS: linux
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2
  • Host: x86_64-unknown-linux-gnu

Build Configuration

Should not be relevant, but here the ~/.cargo/config.toml:

[registries.crates-io]
protocol = "sparse"

[target.x86_64-unknown-linux-gnu]
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Clink-arg=-Wl,--no-rosegment"]

[target.x86_64-unknown-linux-musl]
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Clink-arg=-Wl,--no-rosegment"]

[target.arm-unknown-linux-musleabihf]
linker = "arm-linux-musleabihf-gcc"

Additional Context

The issue has been discovered while bumping the wot-td dependency of the crate wot-serve.

CC @lu-zero

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: new or existing lintC-enhancementCategory: raise the bar on expectations

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions