Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta issue for Rust API Guidelines #1798

Open
mcarton opened this Issue May 27, 2017 · 8 comments

Comments

Projects
None yet
5 participants
@mcarton
Copy link
Collaborator

mcarton commented May 27, 2017

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)
    • 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.
    • Collections implement FromIterator and Extend (C-COLLECT)
    • 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)
  • 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)
    • 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)
    • 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)
  • 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)
    • Crate and its dependencies have a permissive license (C-PERMISSIVE)
      • Clippy is not a lawyer.
@kennytm

This comment has been minimized.

Copy link
Member

kennytm commented May 28, 2017

C-PANIC-DOC should point to #1791, C-DOCS-RS should point to #1788 or a new issue.

@killercup

This comment has been minimized.

Copy link
Member

killercup commented May 29, 2017

Nice work!

(You should use URLs with the commit hash in them (press y on github.com) so they continue to work in the future.)

@mcarton

This comment has been minimized.

Copy link
Collaborator Author

mcarton commented May 29, 2017

Thanks! I volontarily did not do that for this so that we point to the latest version of the guidelines. This might mean that we get broken links once in a while but that'll mean that the list here is outdated.

@clarfon

This comment has been minimized.

Copy link
Contributor

clarfon commented Jun 10, 2017

Note that C-EXAMPLE is covered by #1454.

@mcarton

This comment has been minimized.

Copy link
Collaborator Author

mcarton commented Jun 10, 2017

Not quite, C-EXAMPLE is about not having an example, #1454 is about having a non-relevant example.

@killercup

This comment has been minimized.

Copy link
Member

killercup commented Nov 5, 2017

As predicted, the links no longer work. Now, how using links like this one instead?

@Susurrus

This comment has been minimized.

Copy link

Susurrus commented Jan 23, 2019

Types eagerly implement common traits (C-COMMON-TRAITS)

rustc has missing-copy-implementations for Copy and missing-debug-implementations for Debug, but I don't see anything in rustc or clippy for any of the other traits:

  • Clone
  • Eq
  • Ord
  • PartialOrd
  • Hash
  • Display
  • Default

This was checked off in the original checklist, so I wanted to double-check I wasn't missing anything.

@mcarton

This comment has been minimized.

Copy link
Collaborator Author

mcarton commented Feb 4, 2019

@Susurrus I split the list into sub-lists and unchecked the main item.

@Susurrus Susurrus referenced this issue Feb 9, 2019

Open

WIP: Add missing trait implementation lints #3752

0 of 10 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.