summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/must_use_candidate.txt
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
commit17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch)
tree3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /src/tools/clippy/src/docs/must_use_candidate.txt
parentAdding upstream version 1.64.0+dfsg1. (diff)
downloadrustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.tar.xz
rustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.zip
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/src/docs/must_use_candidate.txt')
-rw-r--r--src/tools/clippy/src/docs/must_use_candidate.txt23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/must_use_candidate.txt b/src/tools/clippy/src/docs/must_use_candidate.txt
new file mode 100644
index 000000000..70890346f
--- /dev/null
+++ b/src/tools/clippy/src/docs/must_use_candidate.txt
@@ -0,0 +1,23 @@
+### What it does
+Checks for public functions that have no
+`#[must_use]` attribute, but return something not already marked
+must-use, have no mutable arg and mutate no statics.
+
+### Why is this bad?
+Not bad at all, this lint just shows places where
+you could add the attribute.
+
+### Known problems
+The lint only checks the arguments for mutable
+types without looking if they are actually changed. On the other hand,
+it also ignores a broad range of potentially interesting side effects,
+because we cannot decide whether the programmer intends the function to
+be called for the side effect or the result. Expect many false
+positives. At least we don't lint if the result type is unit or already
+`#[must_use]`.
+
+### Examples
+```
+// this could be annotated with `#[must_use]`.
+fn id<T>(t: T) -> T { t }
+``` \ No newline at end of file