summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/must_use_candidate.txt
blob: 70890346fe6b8172e299238db33f394d8092d83b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 }
```