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

False negative: Removing an empty module should be a breaking change #482

Closed
Tracked by #5
nmathewson opened this issue Jul 2, 2023 · 1 comment · Fixed by #534
Closed
Tracked by #5

False negative: Removing an empty module should be a breaking change #482

nmathewson opened this issue Jul 2, 2023 · 1 comment · Fixed by #534
Labels
A-lint Area: new or existing lint C-enhancement Category: raise the bar on expectations E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue.

Comments

@nmathewson
Copy link
Contributor

Steps to reproduce the bug with the above code

Check out the demo repository at https://github.com/nmathewson/cargo-semver-checks-demo-1 .

Note that in main, lib.rs is empty.

Note that in v0.1.0, lib.rs contains an empty public module.

Run cargo semver-checks --baseline-rev v0.1.0.

Actual Behaviour

The output is:

[1115]$ cargo semver-checks --baseline-rev v0.1.0
     Cloning v0.1.0
     Parsing csc-demo-1 v0.1.1 (current)
     Parsing csc-demo-1 v0.1.0 (baseline)
    Checking csc-demo-1 v0.1.0 -> v0.1.1 (minor change)
   Completed [   0.004s] 39 checks; 39 passed, 6 unnecessary

Expected Behaviour

There should be an error, since any code that tried to import the empty module from an external crate will be broken by a removal of the empty module.

I think this is plausible in realistic scenarios. For example, you could make a crate with an (empty) prelude, and tell people that they are expected to say use mycrate::prelude::*, even if you don't yet have anything in the prelude.

Generated System Information


cargo-semver-checks 0.22.1

#### Operating system

Linux 6.3.8-200.fc38.x86_64

#### Command-line

```bash
/home/nickm/.cargo/bin/cargo-semver-checks semver-checks --bugreport 

cargo version

> cargo -V 
cargo 1.70.0 (ec8a8a0ca 2023-04-25)

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

_No response_

### Additional Context

I'm happy to work on this if you can give me some pointers of what to look at and where to start.
@nmathewson nmathewson added the C-bug Category: doesn't meet expectations label Jul 2, 2023
@obi1kenobi
Copy link
Owner

Thanks for offering to help! Adding a lint for this is not difficult but it does require a bit of context on a few different moving parts, since it requires changes in both schema and lints.

To be honest, the schema change here isn't the easiest to pull off — it isn't difficult but it does require a bunch of related changes in different places, and I don't trust our onboarding docs enough to feel like I'd be setting you up for success rather than frustration. If you'd rather just add the lint, I'm happy to take care of the schema editing (though I'm also happy to guide you through it, if you feel up for a challenge!) I'm also happy to find you an easier case where you can make a schema extension and write some new lints with it where there wouldn't be as many moving pieces to learn about on day 1.

Make sure to read the CONTRIBUTING guide, especially the section on adding new lints: https://github.com/obi1kenobi/cargo-semver-checks/blob/main/CONTRIBUTING.md

It would also be helpful to read through this prior issue, where another new contributor exposed traits' supertraits to the linter by similarly adding new schema and then using it in a new lint: #232

Here's what needs to be done:

Again, I'm happy to do the first two points here so you can focus on the last three, and once you've gotten a chance to "warm up" here I can suggest another issue where you can try out making edits to the schema and writing more lints.

We also have a playground where you can write queries against rustdoc. It uses the same underlying code as cargo-semver-checks and you can use it to get a sense of the query syntax and what everything does: https://play.predr.ag/rustdoc

@obi1kenobi obi1kenobi added A-lint Area: new or existing lint C-enhancement Category: raise the bar on expectations E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue. and removed C-bug Category: doesn't meet expectations labels Jul 3, 2023
nmathewson added a commit to nmathewson/trustfall-rustdoc-adapter that referenced this issue Sep 8, 2023
nmathewson added a commit to nmathewson/trustfall-rustdoc-adapter that referenced this issue Sep 8, 2023
obi1kenobi added a commit to obi1kenobi/trustfall-rustdoc-adapter that referenced this issue Sep 9, 2023
* Add adapter support for a Module item type.

This is prerequisite for solving
obi1kenobi/cargo-semver-checks#482

* fixup! Add adapter support for a Module item type.

Remove extraneous empty lines from test_crates/modules.

* fixup! Add adapter support for a Module item type.

In resolve_module_edge, tolerate item re-exports.

* fixup! Add adapter support for a Module item type.

In test, use @fold to combine all module members.

* fixup! Add adapter support for a Module item type.

Modules:items: only return supported items.

* fixup! Add adapter support for a Module item type.

In modules test, check item types.

* Implement a root_module edge from Crate.

* Update src/rustdoc_schema.graphql

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>

* fixup! Add adapter support for a Module item type.

Remove "is_crate" property.

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
obi1kenobi added a commit to obi1kenobi/trustfall-rustdoc-adapter that referenced this issue Sep 9, 2023
* Add adapter support for a Module item type.

This is prerequisite for solving
obi1kenobi/cargo-semver-checks#482

* fixup! Add adapter support for a Module item type.

Remove extraneous empty lines from test_crates/modules.

* fixup! Add adapter support for a Module item type.

In resolve_module_edge, tolerate item re-exports.

* fixup! Add adapter support for a Module item type.

In test, use @fold to combine all module members.

* fixup! Add adapter support for a Module item type.

Modules:items: only return supported items.

* fixup! Add adapter support for a Module item type.

In modules test, check item types.

* Implement a root_module edge from Crate.

* Update src/rustdoc_schema.graphql

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>

* fixup! Add adapter support for a Module item type.

Remove "is_crate" property.

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
obi1kenobi added a commit to obi1kenobi/trustfall-rustdoc-adapter that referenced this issue Sep 9, 2023
* Add adapter support for a Module item type.

This is prerequisite for solving
obi1kenobi/cargo-semver-checks#482

* fixup! Add adapter support for a Module item type.

Remove extraneous empty lines from test_crates/modules.

* fixup! Add adapter support for a Module item type.

In resolve_module_edge, tolerate item re-exports.

* fixup! Add adapter support for a Module item type.

In test, use @fold to combine all module members.

* fixup! Add adapter support for a Module item type.

Modules:items: only return supported items.

* fixup! Add adapter support for a Module item type.

In modules test, check item types.

* Implement a root_module edge from Crate.

* Update src/rustdoc_schema.graphql

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>

* fixup! Add adapter support for a Module item type.

Remove "is_crate" property.

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
obi1kenobi added a commit to obi1kenobi/trustfall-rustdoc-adapter that referenced this issue Sep 9, 2023
* Add adapter support for a Module item type.

This is prerequisite for solving
obi1kenobi/cargo-semver-checks#482

* fixup! Add adapter support for a Module item type.

Remove extraneous empty lines from test_crates/modules.

* fixup! Add adapter support for a Module item type.

In resolve_module_edge, tolerate item re-exports.

* fixup! Add adapter support for a Module item type.

In test, use @fold to combine all module members.

* fixup! Add adapter support for a Module item type.

Modules:items: only return supported items.

* fixup! Add adapter support for a Module item type.

In modules test, check item types.

* Implement a root_module edge from Crate.

* Update src/rustdoc_schema.graphql

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>

* fixup! Add adapter support for a Module item type.

Remove "is_crate" property.

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
obi1kenobi added a commit to obi1kenobi/trustfall-rustdoc-adapter that referenced this issue Sep 9, 2023
* Add adapter support for a Module item type.

This is prerequisite for solving
obi1kenobi/cargo-semver-checks#482

* fixup! Add adapter support for a Module item type.

Remove extraneous empty lines from test_crates/modules.

* fixup! Add adapter support for a Module item type.

In resolve_module_edge, tolerate item re-exports.

* fixup! Add adapter support for a Module item type.

In test, use @fold to combine all module members.

* fixup! Add adapter support for a Module item type.

Modules:items: only return supported items.

* fixup! Add adapter support for a Module item type.

In modules test, check item types.

* Implement a root_module edge from Crate.

* Update src/rustdoc_schema.graphql



* fixup! Add adapter support for a Module item type.

Remove "is_crate" property.

---------

Co-authored-by: Nick Mathewson <nickm@freehaven.net>
obi1kenobi added a commit to obi1kenobi/trustfall-rustdoc-adapter that referenced this issue Sep 9, 2023
* Add adapter support for a Module item type.

This is prerequisite for solving
obi1kenobi/cargo-semver-checks#482

* fixup! Add adapter support for a Module item type.

Remove extraneous empty lines from test_crates/modules.

* fixup! Add adapter support for a Module item type.

In resolve_module_edge, tolerate item re-exports.

* fixup! Add adapter support for a Module item type.

In test, use @fold to combine all module members.

* fixup! Add adapter support for a Module item type.

Modules:items: only return supported items.

* fixup! Add adapter support for a Module item type.

In modules test, check item types.

* Implement a root_module edge from Crate.

* Update src/rustdoc_schema.graphql



* fixup! Add adapter support for a Module item type.

Remove "is_crate" property.

---------

Co-authored-by: Nick Mathewson <nickm@freehaven.net>
obi1kenobi added a commit to obi1kenobi/trustfall-rustdoc-adapter that referenced this issue Sep 9, 2023
* Add adapter support for a Module item type.

This is prerequisite for solving
obi1kenobi/cargo-semver-checks#482

* fixup! Add adapter support for a Module item type.

Remove extraneous empty lines from test_crates/modules.

* fixup! Add adapter support for a Module item type.

In resolve_module_edge, tolerate item re-exports.

* fixup! Add adapter support for a Module item type.

In test, use @fold to combine all module members.

* fixup! Add adapter support for a Module item type.

Modules:items: only return supported items.

* fixup! Add adapter support for a Module item type.

In modules test, check item types.

* Implement a root_module edge from Crate.

* Update src/rustdoc_schema.graphql



* fixup! Add adapter support for a Module item type.

Remove "is_crate" property.

---------

Co-authored-by: Nick Mathewson <nickm@freehaven.net>
nmathewson added a commit to nmathewson/cargo-semver-checks that referenced this issue Sep 10, 2023
obi1kenobi added a commit that referenced this issue Sep 10, 2023
…modules (#534)

* Update lockfile to latest trustfall-rustdoc-adapter(s)

* Add a new "module_missing" lint

Resolves #482.

* module_missing: Add expected positives for trait_missing*

* fixup! Add a new "module_missing" lint

Tweak error message.

* fixup! Add a new "module_missing" lint

Adjust formatting on test_crates/module_missing

* Update test_crates/module_missing/new/src/lib.rs

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
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 E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: Mentorship is available for this issue.
Projects
None yet
2 participants