summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/ptr_arg.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/src/docs/ptr_arg.txt29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/ptr_arg.txt b/src/tools/clippy/src/docs/ptr_arg.txt
new file mode 100644
index 000000000..796b0a65b
--- /dev/null
+++ b/src/tools/clippy/src/docs/ptr_arg.txt
@@ -0,0 +1,29 @@
+### What it does
+This lint checks for function arguments of type `&String`, `&Vec`,
+`&PathBuf`, and `Cow<_>`. It will also suggest you replace `.clone()` calls
+with the appropriate `.to_owned()`/`to_string()` calls.
+
+### Why is this bad?
+Requiring the argument to be of the specific size
+makes the function less useful for no benefit; slices in the form of `&[T]`
+or `&str` usually suffice and can be obtained from other types, too.
+
+### Known problems
+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, of which you may not be aware. Carefully
+deprecate the function before applying the lint suggestions in this case.
+
+### Example
+```
+fn foo(&Vec<u32>) { .. }
+```
+
+Use instead:
+```
+fn foo(&[u32]) { .. }
+``` \ No newline at end of file