about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Macleod <alex@macleod.io>2022-10-17 21:59:27 +0000
committerAlex Macleod <alex@macleod.io>2022-10-20 11:02:48 +0000
commitb6a860e0ed7a76b1834c9618842d299e4501d2ff (patch)
tree892632696f7909d2d973a0cf2cb63f7f026edb51 /src
parentd917590af6d4db6dcb8c4adda8f870a6950ff247 (diff)
downloadrust-b6a860e0ed7a76b1834c9618842d299e4501d2ff.tar.gz
rust-b6a860e0ed7a76b1834c9618842d299e4501d2ff.zip
Add `missing_trait_methods` lint
Diffstat (limited to 'src')
-rw-r--r--src/docs.rs1
-rw-r--r--src/docs/missing_trait_methods.txt40
2 files changed, 41 insertions, 0 deletions
diff --git a/src/docs.rs b/src/docs.rs
index b8b4286b488..8aaa61d2967 100644
--- a/src/docs.rs
+++ b/src/docs.rs
@@ -317,6 +317,7 @@ docs! {
     "missing_panics_doc",
     "missing_safety_doc",
     "missing_spin_loop",
+    "missing_trait_methods",
     "mistyped_literal_suffixes",
     "mixed_case_hex_literals",
     "mixed_read_write_in_expression",
diff --git a/src/docs/missing_trait_methods.txt b/src/docs/missing_trait_methods.txt
new file mode 100644
index 00000000000..788ad764f8c
--- /dev/null
+++ b/src/docs/missing_trait_methods.txt
@@ -0,0 +1,40 @@
+### What it does
+Checks if a provided method is used implicitly by a trait
+implementation. A usage example would be a wrapper where every method
+should perform some operation before delegating to the inner type's
+implemenation.
+
+This lint should typically be enabled on a specific trait `impl` item
+rather than globally.
+
+### Why is this bad?
+Indicates that a method is missing.
+
+### Example
+```
+trait Trait {
+    fn required();
+
+    fn provided() {}
+}
+
+#[warn(clippy::missing_trait_methods)]
+impl Trait for Type {
+    fn required() { /* ... */ }
+}
+```
+Use instead:
+```
+trait Trait {
+    fn required();
+
+    fn provided() {}
+}
+
+#[warn(clippy::missing_trait_methods)]
+impl Trait for Type {
+    fn required() { /* ... */ }
+
+    fn provided() { /* ... */ }
+}
+```
\ No newline at end of file