about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-20 15:05:06 +0000
committerbors <bors@rust-lang.org>2022-10-20 15:05:06 +0000
commit4612fdfa7b183c778e6985c96c06f9bdebe36e2e (patch)
tree6f996c239fd4c200914d0d15aacf6c880dabd9d1 /src
parenta4e872602be3feb5f2392827d1900225ff0a9ed4 (diff)
parentb6a860e0ed7a76b1834c9618842d299e4501d2ff (diff)
downloadrust-4612fdfa7b183c778e6985c96c06f9bdebe36e2e.tar.gz
rust-4612fdfa7b183c778e6985c96c06f9bdebe36e2e.zip
Auto merge of #9670 - Alexendoo:missing-trait-methods, r=Jarcho
Add `missing_trait_methods` lint

Closes #9661

changelog: new lint: [`missing_trait_methods`]
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 0a9fb1ecd84..c033ad294a3 100644
--- a/src/docs.rs
+++ b/src/docs.rs
@@ -316,6 +316,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