]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/await_holding_invalid_type.txt
:arrow_up: rust-analyzer
[rust.git] / src / tools / clippy / src / docs / await_holding_invalid_type.txt
1 ### What it does
2 Allows users to configure types which should not be held across `await`
3 suspension points.
4
5 ### Why is this bad?
6 There are some types which are perfectly "safe" to be used concurrently
7 from a memory access perspective but will cause bugs at runtime if they
8 are held in such a way.
9
10 ### Example
11
12 ```
13 await-holding-invalid-types = [
14   # You can specify a type name
15   "CustomLockType",
16   # You can (optionally) specify a reason
17   { path = "OtherCustomLockType", reason = "Relies on a thread local" }
18 ]
19 ```
20
21 ```
22 struct CustomLockType;
23 struct OtherCustomLockType;
24 async fn foo() {
25   let _x = CustomLockType;
26   let _y = OtherCustomLockType;
27   baz().await; // Lint violation
28 }
29 ```