rust-lang / rust-lang/rust-clippy
Meta issue for Rust API Guidelines
Open
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'sbad-stylelint group.
- This is already covered by
- 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)
- Casing conforms to RFC 430 (C-CASE)
- Interoperability (crate interacts nicely with other library functionality)
- Types eagerly implement common traits (C-COMMON-TRAITS)
-
Copy(rustc'smissing-copy-implementations) -
Clone -
Eq -
PartialEq -
Ord -
PartialOrd -
Hash -
Debug(rustc'smissing-debug-implementations) -
Display -
Default(we do havenew_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
IntoandTryIntoare never implemented manually (only automatically viaFrom)
- Already covered as much as we can by
- Collections implement
FromIteratorandExtend(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
SendandSyncwhere 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,Binaryformatting (C-NUM-FMT)- Clippy cannot know if a type is a binary number type or not.
- Generic reader/writer functions take
R: ReadandW: Writeby value (C-RW-VALUE)
- Types eagerly implement common traits (C-COMMON-TRAITS)
- 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.
- Input syntax is evocative of the output (C-EVOCATIVE)
- 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
?, nottry!, notunwrap(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
- authors, description, license, homepage, documentation, repository,
- 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
DerefandDerefMut(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
boolorOption(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)
- Functions validate their arguments (C-VALIDATE)
- Destructors never fail (C-DTOR-FAIL)
- Destructors that may block have alternatives (C-DTOR-BLOCK)
- Debuggability (crate is conducive to easy debugging)
- All public types implement
Debug(C-DEBUG)- Covered by
rustc'smissing-debug-implementations.
- Covered by
-
Debugrepresentation is never empty (C-DEBUG-NONEMPTY)- Issue open: #1796
- All public types implement
- Future proofing (crate is free to improve without breaking users' code)
- Sealed traits protect against downstream implementations (C-SEALED)
- Structs have private fields (C-STRUCT-PRIVATE)
- Newtypes encapsulate implementation details (C-NEWTYPE-HIDE)
- Data structures do not duplicate derived trait bounds (C-STRUCT-BOUNDS)
- 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.
- Public dependencies of a stable crate are stable (C-STABLE)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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