rust-lang / rust-lang/rust-clippy

Meta issue for Rust API Guidelines

Open
#1,798 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

L-guidelines
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Let's see what makes sense to get into Clippy or not from the Rust API Guidelines.

Check the box if a lint or issue already exist for an item. See also is:issue is:open label:A-guidelines.

  • Naming (crate aligns with Rust naming conventions)
    • Casing conforms to RFC 430 (C-CASE)
      • This is already covered by rustc's bad-style lint group.
    • Ad-hoc conversions follow as_, to_, into_ conventions (C-CONV)
    • Getter names follow Rust convention (C-GETTER)
    • Methods on collections that produce iterators follow iter, iter_mut, into_iter (C-ITER)
    • Iterator type names match the methods that produce them (C-ITER-TY)
      • Issue open: #1789
    • Feature names are free of placeholder words (C-FEATURE)
    • Names use a consistent word order (C-WORD-ORDER)
  • Interoperability (crate interacts nicely with other library functionality)
    • Types eagerly implement common traits (C-COMMON-TRAITS)
      • Copy (rustc's missing-copy-implementations)
      • Clone
      • Eq
      • PartialEq
      • Ord
      • PartialOrd
      • Hash
      • Debug (rustc's missing-debug-implementations)
      • Display
      • Default (we do have new_without_default)
      • We already have that in some cases, but it's hard to determine if there is a good reason not to implement those from Clippy.
    • Conversions use the standard traits From, AsRef, AsMut (C-CONV-TRAITS)
      • Already covered as much as we can by SHOULD_IMPLEMENT_TRAIT.
      • Check that Into and TryInto are never implemented manually (only automatically via From)
    • Collections implement FromIterator and Extend (C-COLLECT)
      • issue open: #1801
    • Data structures implement Serde's Serialize, Deserialize (C-SERDE)
      • Clippy cannot know whether a type is a data structure or not.
    • Types are Send and Sync where possible (C-SEND-SYNC)
      • This is default, if people remove that, they must have a reason.
    • Error types are meaningful and well-behaved (C-GOOD-ERR)
    • Binary number types provide Hex, Octal, Binary formatting (C-NUM-FMT)
      • Clippy cannot know if a type is a binary number type or not.
    • Generic reader/writer functions take R: Read and W: Write by value (C-RW-VALUE)
  • Macros (crate presents well-behaved macros)
    • Input syntax is evocative of the output (C-EVOCATIVE)
      • Too subjective.
    • Macros compose well with attributes (C-MACRO-ATTR)
      • Cannot lint on macros.
    • Item macros work anywhere that items are allowed (C-ANYWHERE)
      • Cannot lint on macros.
    • Item macros support visibility specifiers (C-MACRO-VIS)
      • Cannot lint on macros.
    • Type fragments are flexible (C-MACRO-TY)
      • Cannot lint on macros.
  • Documentation (crate is abundantly documented)
    • Crate level docs are thorough and include examples (C-CRATE-DOC)
    • All items have a rustdoc example (C-EXAMPLE)
    • Examples use ?, not try!, not unwrap (C-QUESTION-MARK)
    • Function docs include error, panic, and safety considerations (C-FAILURE)
      • Issue open: #1790
      • Issue open: #1791
      • Issue open: #2207
    • Prose contains hyperlinks to relevant things (C-LINK)
    • Cargo.toml includes all common metadata (C-METADATA, clippy::cargo_common_metadata)
      • authors, description, license, homepage, documentation, repository,
        readme, keywords, categories
    • Crate sets html_root_url attribute "https://docs.rs/CRATE/X.Y.Z" (C-HTML-ROOT)
      • Issue open: #1788
    • Release notes document all significant changes (C-RELNOTES)
    • Rustdoc does not show unhelpful implementation details (C-HIDDEN)
  • Predictability (crate enables legible code that acts how it looks)
    • Smart pointers do not add inherent methods (C-SMART-PTR)
    • Conversions live on the most specific type involved (C-CONV-SPECIFIC)
    • Functions with a clear receiver are methods (C-METHOD)
    • Functions do not take out-parameters (C-NO-OUT)
    • Operator overloads are unsurprising (C-OVERLOAD)
    • Only smart pointers implement Deref and DerefMut (C-DEREF)
    • Constructors are static, inherent methods (C-CTOR)
  • Flexibility (crate supports diverse real-world use cases)
    • Functions expose intermediate results to avoid duplicate work (C-INTERMEDIATE)
    • Caller decides where to copy and place data (C-CALLER-CONTROL)
    • Functions minimize assumptions about parameters by using generics (C-GENERIC)
      • Issue open: #1794
    • Traits are object-safe if they may be useful as a trait object (C-OBJECT)
  • Type safety (crate leverages the type system effectively)
    • Newtypes provide static distinctions (C-NEWTYPE)
    • Arguments convey meaning through types, not bool or Option (C-CUSTOM-TYPE)
    • Types for a set of flags are bitflags, not enums (C-BITFLAG)
      • Issue open: #1795
    • Builders enable construction of complex values (C-BUILDER)
  • Dependability (crate is unlikely to do the wrong thing)
  • Debuggability (crate is conducive to easy debugging)
    • All public types implement Debug (C-DEBUG)
      • Covered by rustc's missing-debug-implementations.
    • Debug representation is never empty (C-DEBUG-NONEMPTY)
      • Issue open: #1796
  • Future proofing (crate is free to improve without breaking users' code)
  • Necessities (to whom they matter, they really matter)
    • Public dependencies of a stable crate are stable (C-STABLE)
      • Issue open: #1797
    • Crate and its dependencies have a permissive license (C-PERMISSIVE)
      • Clippy is not a lawyer.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file, test, or implementation entry point is named. Review the unchecked Rust API Guidelines items and the referenced open issues, especially #1789, #1790, #1791, #2207, #1788, and #1794-#1797; the work is only complete once a specific guideline has a decided, scoped Clippy lint or issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.