lints

`rustc` lints.
git clone https://git.philomathiclife.com/repos/lints
Log | Files | Refs | README

README.md (6655B)


      1 CLI app for `rustc` lints
      2 =========================
      3 
      4 [<img alt="git" src="https://git.philomathiclife.com/badges/lints.svg" height="20">](https://git.philomathiclife.com/lints/log.html)
      5 [<img alt="crates.io" src="https://img.shields.io/crates/v/lints.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/lints)
      6 
      7 `lints` is a CLI application that parses the output of [`rustc -Whelp`](https://doc.rust-lang.org/stable/rustc/)
      8 before writing the lints to `stdout` in a format that can be added to a TOML table, `lints.rust`, in `Cargo.toml`.
      9 
     10 ## Why is this useful?
     11 
     12 Unlike [Clippy](https://doc.rust-lang.org/stable/clippy/index.html), many `rustc` lints are not members of at
     13 least one lint group which makes it easy for one to not enjoy the benefit of a lint they didn't know about it.
     14 `rustc` lints and lint groups change rather frequently, so it can be "annoying" to maintain a list of up-to-date
     15 lints.
     16 
     17 ## Usage
     18 
     19 `lints [COMMAND] [OPTIONS]`
     20 
     21 ## Commands
     22 
     23 * `allow`: Allows all lints.
     24 * `deny`: Denies all lints.
     25 * `help`: This message.
     26 * `version`: Prints version info.
     27 
     28 ## Options
     29 
     30 * `--all`: Writes all individual lints even if they're already part of a lint group.
     31 * `--allow-undefined-lints`: Lint groups that contain undefined lints are allowed.
     32 * `-`: If the last argument, `stdin` is read instead of getting the output from `rustc`.
     33 
     34 When nothing or `deny` is passed, all lint groups and `allow`-by-default lints that are not part of a group
     35 are set to `deny`.
     36 When `allow` is passed, `"warnings"` and all `deny`-by-default lints are set to `allow`.
     37 `stdout` is written to in the format of the TOML table, `lints.rust`, which can be added to `Cargo.toml`.
     38 
     39 `--allow-undefined-lints` should rarely be necessary since the lints defined in a lint group per `rustc -Whelp`
     40 are almost always one of the lints listed. There have been exceptions though (e.g., `rustc 1.48.0` lists the
     41 lint group `"rustdoc"` containing the lint `"private-intra-doc-links"` despite that lint not being in the table
     42 of lints).
     43 
     44 ## `lints` in action
     45 
     46 ```bash
     47 [zack@laptop ~]$ rustc -V
     48 rustc 1.93.0 (254b59607 2026-01-19)
     49 [zack@laptop ~]$ lints version
     50 lints 0.3.0
     51 [zack@laptop ~]$ lints
     52 deprecated-safe = { level = "deny", priority = -1 }
     53 future-incompatible = { level = "deny", priority = -1 }
     54 keyword-idents = { level = "deny", priority = -1 }
     55 let-underscore = { level = "deny", priority = -1 }
     56 nonstandard-style = { level = "deny", priority = -1 }
     57 refining-impl-trait = { level = "deny", priority = -1 }
     58 rust-2018-compatibility = { level = "deny", priority = -1 }
     59 rust-2018-idioms = { level = "deny", priority = -1 }
     60 rust-2021-compatibility = { level = "deny", priority = -1 }
     61 rust-2024-compatibility = { level = "deny", priority = -1 }
     62 unknown-or-malformed-diagnostic-attributes = { level = "deny", priority = -1 }
     63 unused = { level = "deny", priority = -1 }
     64 warnings = { level = "deny", priority = -1 }
     65 ambiguous-negative-literals = { level = "deny", priority = -1 }
     66 closure-returning-async-block = { level = "deny", priority = -1 }
     67 deprecated-in-future = { level = "deny", priority = -1 }
     68 deref-into-dyn-supertrait = { level = "deny", priority = -1 }
     69 ffi-unwind-calls = { level = "deny", priority = -1 }
     70 fuzzy-provenance-casts = { level = "deny", priority = -1 }
     71 impl-trait-redundant-captures = { level = "deny", priority = -1 }
     72 linker-messages = { level = "deny", priority = -1 }
     73 lossy-provenance-casts = { level = "deny", priority = -1 }
     74 macro-use-extern-crate = { level = "deny", priority = -1 }
     75 meta-variable-misuse = { level = "deny", priority = -1 }
     76 missing-copy-implementations = { level = "deny", priority = -1 }
     77 missing-debug-implementations = { level = "deny", priority = -1 }
     78 missing-docs = { level = "deny", priority = -1 }
     79 multiple-supertrait-upcastable = { level = "deny", priority = -1 }
     80 must-not-suspend = { level = "deny", priority = -1 }
     81 non-ascii-idents = { level = "deny", priority = -1 }
     82 non-exhaustive-omitted-patterns = { level = "deny", priority = -1 }
     83 redundant-imports = { level = "deny", priority = -1 }
     84 redundant-lifetimes = { level = "deny", priority = -1 }
     85 resolving-to-items-shadowing-supertrait-items = { level = "deny", priority = -1 }
     86 shadowing-supertrait-items = { level = "deny", priority = -1 }
     87 single-use-lifetimes = { level = "deny", priority = -1 }
     88 trivial-casts = { level = "deny", priority = -1 }
     89 trivial-numeric-casts = { level = "deny", priority = -1 }
     90 unit-bindings = { level = "deny", priority = -1 }
     91 unnameable-types = { level = "deny", priority = -1 }
     92 unqualified-local-imports = { level = "deny", priority = -1 }
     93 unreachable-pub = { level = "deny", priority = -1 }
     94 unsafe-code = { level = "deny", priority = -1 }
     95 unstable-features = { level = "deny", priority = -1 }
     96 unused-crate-dependencies = { level = "deny", priority = -1 }
     97 unused-import-braces = { level = "deny", priority = -1 }
     98 unused-lifetimes = { level = "deny", priority = -1 }
     99 unused-qualifications = { level = "deny", priority = -1 }
    100 unused-results = { level = "deny", priority = -1 }
    101 variant-size-differences = { level = "deny", priority = -1 }
    102 ```
    103 
    104 ## Minimum Supported Rust Version (MSRV)
    105 
    106 This will frequently be updated to be the same as stable. Specifically, any time stable is updated and that
    107 update has "useful" features or compilation no longer succeeds (e.g., due to new compiler lints), then MSRV
    108 will be updated.
    109 
    110 MSRV changes will correspond to a SemVer patch version bump pre-`1.0.0`; otherwise a minor version bump.
    111 
    112 ## SemVer Policy
    113 
    114 * All on-by-default features of this library are covered by SemVer
    115 * MSRV is considered exempt from SemVer as noted above
    116 
    117 ## License
    118 
    119 Licensed under either of
    120 
    121 * Apache License, Version 2.0 ([LICENSE-APACHE](https://www.apache.org/licenses/LICENSE-2.0))
    122 * MIT license ([LICENSE-MIT](https://opensource.org/licenses/MIT))
    123 
    124 at your option.
    125 
    126 ## Contribution
    127 
    128 Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you,
    129 as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
    130 
    131 Before any PR is sent, `cargo clippy --all-targets` and `cargo test --all-targets` should be run using the stable
    132 and MSRV toolchains. One easy way to achieve this is by invoking [`ci-cargo`](https://crates.io/crates/ci-cargo)
    133 as `ci-cargo clippy --all-targets test --benches --bins --examples --tests` in the `lints` directory.
    134 
    135 Last, `cargo +nightly doc` should be run to ensure documentation can be built.
    136 
    137 ### Status
    138 
    139 The crate is only tested on the `x86_64-unknown-linux-gnu`, `x86_64-unknown-openbsd`, and `aarch64-apple-darwin`
    140 targets; but it should work on most platforms.