Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[doc(hidden)] pub type with non hidden aliases not flagged when breaking semver #895

Open
jalil-salame opened this issue Aug 31, 2024 · 1 comment
Labels
A-lint Area: new or existing lint C-enhancement Category: raise the bar on expectations

Comments

@jalil-salame
Copy link

jalil-salame commented Aug 31, 2024

Is this about an existing lint, or proposing a new one?

I guess this is from an existing lint? But I don't know which one...

Steps to reproduce the bug with the above code

Original code:

//! src/lib.rs
#[doc(hidden)]
pub struct IdType<T>(pub T);

pub type Id = IdType<String>;

Updated code (patch or minor release)):

//! src/lib.rs
#[doc(hidden)]
pub struct IdType<T>(T); // change visibility

pub type Id = IdType<String>; // Observable through the type alias

Actual Behaviour

cargo semver-checks (v0.34.0) output:

$ cargo semver-checks --baseline-rev '...'
     Cloning dddfce3f349b
     Parsing repro v0.1.1 (current)
      Parsed [   0.217s] (current)
     Parsing repro v0.1.0 (baseline)
      Parsed [   0.234s] (baseline)
    Checking repro v0.1.0 -> v0.1.1 (minor change)
     Checked [   0.002s] 72 checks: 72 pass, 7 skip
     Summary no semver update required
    Finished [   0.456s] repro

Expected Behaviour

cargo semver-checks should flag the visibility change in IdType.0 as a semver violation.

Generated System Information

Software version

cargo-semver-checks 0.34.0

Operating system

Linux 6.6.47

Command-line

/nix/store/4j0iyaxn6img53nhhpbx165irrl3r0ry-cargo-semver-checks-0.34.0/bin/cargo-semver-checks semver-checks --bugreport 

cargo version

> cargo -V 
cargo 1.80.1 (376290515 2024-07-16)

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

$ printenv | rg ^CARGO_
CARGO_HOME=/home/jalil/.local/share/cargo

Repository is a cargo new --lib blank repo

Additional Context

This came up while discussing changes to rustdoc-types c:

@jalil-salame jalil-salame added A-lint Area: new or existing lint C-enhancement Category: raise the bar on expectations labels Aug 31, 2024
@obi1kenobi
Copy link
Owner

Nice, thank you.

I think the best way to handle this would probably be designing some schema to express pub type aliases, and flag it that way. It would let us scan for it together with any other changes to what users of the pub type can do, instead of special-casing it for "is this struct used as part of any pub type aliases" etc.

I'm not yet sure what the schema for this should look like. Figuring that out is the first action item here.

@obi1kenobi obi1kenobi changed the title #[doc(hidden)] pub Type with non hidden aliases not flagegd when breaking semver #[doc(hidden)] pub type with non hidden aliases not flagged when breaking semver Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: new or existing lint C-enhancement Category: raise the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants