]> git.lizzy.rs Git - rust.git/blob - src/docs/must_use_candidate.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / must_use_candidate.txt
1 ### What it does
2 Checks for public functions that have no
3 `#[must_use]` attribute, but return something not already marked
4 must-use, have no mutable arg and mutate no statics.
5
6 ### Why is this bad?
7 Not bad at all, this lint just shows places where
8 you could add the attribute.
9
10 ### Known problems
11 The lint only checks the arguments for mutable
12 types without looking if they are actually changed. On the other hand,
13 it also ignores a broad range of potentially interesting side effects,
14 because we cannot decide whether the programmer intends the function to
15 be called for the side effect or the result. Expect many false
16 positives. At least we don't lint if the result type is unit or already
17 `#[must_use]`.
18
19 ### Examples
20 ```
21 // this could be annotated with `#[must_use]`.
22 fn id<T>(t: T) -> T { t }
23 ```