about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-08-12 15:51:39 +0000
committerbors <bors@rust-lang.org>2020-08-12 15:51:39 +0000
commit2f4de2fc7579b53f80f9946d5ab77708f9870301 (patch)
treefc59e5f569f224448da1983fa9c449339c8b4092
parent3ed0a4ce5dd199c2abb1241fd59a5bdfb3bc5ee8 (diff)
parent7d2e42daec1a56ad8f70a2b146bd842e98e0430d (diff)
downloadrust-2f4de2fc7579b53f80f9946d5ab77708f9870301.tar.gz
rust-2f4de2fc7579b53f80f9946d5ab77708f9870301.zip
Auto merge of #5885 - Ryan1729:patch-2, r=flip1995
Add example of false positive to PTR_ARG docs.

Addresses #214

changelog: Add example of false positive to `ptr_arg` docs.
-rw-r--r--clippy_lints/src/ptr.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs
index 460d631fab0..7dafb1555dc 100644
--- a/clippy_lints/src/ptr.rs
+++ b/clippy_lints/src/ptr.rs
@@ -36,14 +36,27 @@ declare_clippy_lint! {
     /// argument may also fail to compile if you change the argument. Applying
     /// this lint on them will fix the problem, but they may be in other crates.
     ///
+    /// One notable example of a function that may cause issues, and which cannot
+    /// easily be changed due to being in the standard library is `Vec::contains`.
+    /// when called on a `Vec<Vec<T>>`. If a `&Vec` is passed to that method then
+    /// it will compile, but if a `&[T]` is passed then it will not compile.
+    ///
+    /// ```ignore
+    /// fn cannot_take_a_slice(v: &Vec<u8>) -> bool {
+    ///     let vec_of_vecs: Vec<Vec<u8>> = some_other_fn();
+    ///
+    ///     vec_of_vecs.contains(v)
+    /// }
+    /// ```
+    ///
     /// Also there may be `fn(&Vec)`-typed references pointing to your function.
     /// If you have them, you will get a compiler error after applying this lint's
     /// suggestions. You then have the choice to undo your changes or change the
     /// type of the reference.
     ///
     /// Note that if the function is part of your public interface, there may be
-    /// other crates referencing it you may not be aware. Carefully deprecate the
-    /// function before applying the lint suggestions in this case.
+    /// other crates referencing it, of which you may not be aware. Carefully
+    /// deprecate the function before applying the lint suggestions in this case.
     ///
     /// **Example:**
     /// ```ignore