Skip to content

Commit 2f4de2f

Browse files
committed
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.
2 parents 3ed0a4c + 7d2e42d commit 2f4de2f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

clippy_lints/src/ptr.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,27 @@ declare_clippy_lint! {
3636
/// argument may also fail to compile if you change the argument. Applying
3737
/// this lint on them will fix the problem, but they may be in other crates.
3838
///
39+
/// One notable example of a function that may cause issues, and which cannot
40+
/// easily be changed due to being in the standard library is `Vec::contains`.
41+
/// when called on a `Vec<Vec<T>>`. If a `&Vec` is passed to that method then
42+
/// it will compile, but if a `&[T]` is passed then it will not compile.
43+
///
44+
/// ```ignore
45+
/// fn cannot_take_a_slice(v: &Vec<u8>) -> bool {
46+
/// let vec_of_vecs: Vec<Vec<u8>> = some_other_fn();
47+
///
48+
/// vec_of_vecs.contains(v)
49+
/// }
50+
/// ```
51+
///
3952
/// Also there may be `fn(&Vec)`-typed references pointing to your function.
4053
/// If you have them, you will get a compiler error after applying this lint's
4154
/// suggestions. You then have the choice to undo your changes or change the
4255
/// type of the reference.
4356
///
4457
/// Note that if the function is part of your public interface, there may be
45-
/// other crates referencing it you may not be aware. Carefully deprecate the
46-
/// function before applying the lint suggestions in this case.
58+
/// other crates referencing it, of which you may not be aware. Carefully
59+
/// deprecate the function before applying the lint suggestions in this case.
4760
///
4861
/// **Example:**
4962
/// ```ignore

0 commit comments

Comments
 (0)