New lints: Opt-in minor lints for added functionality #949
Labels
A-lint
Area: new or existing lint
E-help-wanted
Call for participation: Help is requested to fix this issue.
E-mentor
Call for participation: Mentorship is available for this issue.
By default, Rust isn't particularly prescriptive about the difference between a minor and a patch version bump. But many libraries and maintainers may choose to offer stronger guarantees about which kinds of changes should go patches vs minor versions. For example, they may prefer to publish new functionality (new public APIs) in minor versions while keeping patches reserved for bugfixes or other small changes that aren't noticeable at the API level.
Just like detecting removals of public APIs,
cargo-semver-checks
lints can also be used to detect additions to public APIs. This issue is about writing such lints.These lints should be opt-in rather than opt-out. They should have defaults of
required_update: Minor
andlint_level: Allow
in their definition files, and users can opt into them by increasing the lint level (e.g. to "warn") as per their preference.Keep in mind that some API additions are major breaking changes and we already have lints for them, such as adding a variant to an exhaustive enum. New lints added here should take care to not overlap with such major lints — we never want to simultaneously flag the same change as both major and minor, since that would be very confusing to our users!
Lints in this category:
#[non_exhaustive]
and has no non-public fields: Implement new_struct_added lint #495#[non_exhaustive]
to the struct, since adding new fields or#[non_exhaustive]
itself later on is a major breaking change.#[non_exhaustive]
public API struct (one of two complements of the above lint)#[non_exhaustive]
(the remaining complement of the top lint)#[non_exhaustive]
#[non_exhaustive]
to the enum, since adding new variants or#[non_exhaustive]
itself later on is a major breaking change.#[non_exhaustive]
public API enum (the complement of the above lint)ImplOwner
in our schema#[non_exhaustive]
public API struct#[non_exhaustive]
public API enum — multiple lints here:#[non_exhaustive]
then this would be a major breaking change instead.#[non_exhaustive]
, or not. Adding that#[non_exhaustive]
later, or adding new fields to the variant, are both major breaking changes, so having a lint users can use to recommend newly-added variants be#[non_exhaustive]
could be useful.#[non_exhaustive]
variant#[non_exhaustive]
#[non_exhaustive]
#[non_exhaustive]
#[non_exhaustive]
tuple variant of a public API enum#[non_exhaustive]
, then this would be a major breaking change instead.#[non_exhaustive]
struct variant of a public API enum#[non_exhaustive]
, then this would be a major breaking change instead.#[non_exhaustive]
from a public API struct that has no non-public fieldsMyStruct { field: 0 }
#[non_exhaustive]
from a public API enum#[non_exhaustive]
from a variant of a public API enumimpl
block (a so-called "inherent method")const
impl
block has newly becomeconst
unsafe
impl
block has stopped beingunsafe
static
itemconst
itemconst
itemrepr(C)
added on a public API type that previously did not have anyrepr
repr(transparent)
added on a public API type that previously did not have anyrepr
repr(i8)
) newly added to a public API enum that previously did not have anyrepr
export_name
property, populated by e.g.#[no_mangle]
)Taking a look at the existing major lints for each area is recommended, since the corresponding minor lints will likely be quite similar in implementation. For example, the "enum added" lint here will be similar to the enum missing lint, albeit with some logic flipped.
Make sure to check out our contributing guide, and take a look at what prior lints' merged PRs looked like so you know what to expect. It's easier than you think!
If you start working on one of the lint checkboxes, please post a message here to temporarily claim it (for ~a week or two, I'll follow up with you) so we don't have multiple people working on the same lint. I'll associate your name and PR with the appropriate checkbox.
The text was updated successfully, but these errors were encountered: