Skip to content

"compat" lint category and related lints? #6324

Open
@kentfredric

Description

@kentfredric

What it does

In general, most of the lints presently in clippy seem to promote "latest features" and "modern practices", which is fine for people who are developing end-of-the-dep chain apps.

However, there are those of us who would rather strive towards the broader goal of maximising source compatibility with a broad range of Rust's, or have a water mark MSRV they target.

My proposal is really a more "meta" proposal, that:

  • Lint categories for compat exist
  • Lints for various compat syntax problems exist
  • That general lint categories can be used to "group" a collection of related lints based on your designated target, such as:
   clippy::compat::msrv::1_0_0

(Or something like that)

Why?

Presently the only safeguards against MSRV regression is multi-testing crates before publish, either by the maintainer, a CI, or both.

This means people who submit changes are unlikely to know they've made a change that breaks the MSRV goals, because they're less likely to test older rusts themselves.

Having clippy lints that targeted the most obvious cases of these that are achievable, would at least, mean an end user could run cargo clippy and get told they've added code changes that break rust compat, turned on by configured policy in the repo.

Caveats

Obviously, this is not a guarantee of any kind, because not all classes of compat issues can be stuffed into clippy.

My favourite example of a really silly one, that I don't think clippy can handle, is crates declaring edition = ["2018"] in Cargo.toml, but otherwise not doing anything that requires Edition 2018.

This is silly, because as a dependency, these crates compile and your dependent project compiles just fine, on every rust, except the 3 versions of rust that knew edition was a thing, and that it was also still unstable.

https://kentfredric.github.io/rust-vmatrix/crates-t/tt/tt/
snapshot_20201112_190703

And I also think its probably out-of-scope to verify your dependencies are all, also, meeting your MSRV goals.

But fortunately, there are other ways of managing that

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions