cargo-semver-checks icon indicating copy to clipboard operation
cargo-semver-checks copied to clipboard

Check lints related to trait implementations for false-positives if the trait impl is `#[doc(hidden)]`

Open obi1kenobi opened this issue 10 months ago • 0 comments

For example:

pub struct SecretlyIter;

#[doc(hidden)]
impl Iterator for SecretlyIter {
    type Item = i64;

    fn next(&mut self) -> Option<Self::Item> {
        None
    }
}

The fact that SecretlyIter is impl Iterator is not public API. But there is still a hazard, since users may rely on SecretlyIter being impl Iterator indirectly, e.g. by using it in a for loop. Discussion on that here: https://hachyderm.io/@[email protected]/112292583897196920

This situation will require some nuance. Tentative plan:

  • [ ] Add test cases for various edge cases, to pin down the current behavior of our lints.
  • [ ] Make the "trait no longer implemented" lint check that the original impl was public API.
  • [ ] Add a new lint for "trait impl stopped being public API".
  • [ ] After #58, add a new warning-level lint that checks for "trait no longer implemented" ignoring the public API property, narrowed specifically for special traits in the Rust prelude like Iterator.
  • [ ] Eliminate any other false-positives, and consider adding more lints if needed, analogously to the above.

obi1kenobi avatar Apr 18 '24 20:04 obi1kenobi