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

Adding Drop impl to a type used in a public API type is a SemVer hazard #930

Open
obi1kenobi opened this issue Sep 15, 2024 · 0 comments
Open
Labels
A-lint Area: new or existing lint

Comments

@obi1kenobi
Copy link
Owner

If a type in the public API has no components that impl Drop, adding the first impl Drop on that type or any of its components appears to be a major breaking change: playground

struct Foo;

// Adding this block is a breaking change downstream on `Bar`.
impl Drop for Foo {
    fn drop(&mut self) {}
}

pub struct Bar(Foo);

// Witness of the breakage.
// We don't need to use the value, we're just dropping it.
const fn example(_value: Bar) -> i64 {
    0
}

I don't believe we have a reliable way of detecting this via rustdoc JSON right now. We can check for impl Drop on the public type itself, but I don't see a way to reliably check that for its components.

Perhaps either rustdoc JSON could be extended with a new field with this information, or a new marker auto-trait could be added to the language that we could track?

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
Projects
None yet
Development

No branches or pull requests

1 participant