@@ -8,17 +8,30 @@ keyword are kept small then reviews won't trigger too often. However, it may als
8
8
when unsafe code relies on properties outside files with the unsafe keyword (like robust
9
9
implementations).
10
10
11
+ ## Sound triggering
12
+
11
13
If the robust keyword existed, unsafe reviews could trigger on files containing any of those 2
12
14
keywords. By making sure during unsafe review that proofs only rely on documented robust properties
13
15
(parameter of unsafe function or result of robust function), this would make sure that unsafe review
14
16
will trigger each time it is needed.
15
17
18
+ Here are some examples of proofs that depended on undocumented or incorrect robustness:
19
+ - < https://github.com/rust-lang/regex/pull/1154 >
20
+ - < https://github.com/rust-lang/rust/issues/80335 >
21
+ - < https://rustsec.org/advisories/RUSTSEC-2024-0019.html >
22
+
23
+ ## Burden of proof
24
+
16
25
To avoid increasing the burden of unsafe reviews, it is important that items are not documented as
17
26
robust unless it is known that a proof relies on them. To ensure this, robust items should also
18
27
document in their robustness section which crates rely on their robustness. This could alternatively
19
28
be tracked in a separate global tool like [ ` cargo-vet ` ] [ cargo-vet ] .
20
29
21
- ## Lints
30
+ For example, one should not implement [ ` TrustedLen ` ] [ TrustedLen ] unless it is relied upon somewhere.
31
+ This is deliberately a borderline example to show that it is actually a trade-off between increasing
32
+ the burden of proof and implementing possibly useful functionalities.
33
+
34
+ ## Recommended lints
22
35
23
36
It is almost obligatory to enable [ unsafe-op-in-unsafe-fn] which is allowed-by-default up to edition
24
37
2021 and warn-by-default starting from edition 2024. Not using this lint will:
@@ -42,6 +55,7 @@ multiple-unsafe-ops-per-block. Both together ensure that there is a one-to-one c
42
55
between the usage of unsafe superpower and the safety comment proving its soundness, thus
43
56
simplifying unsafe reviews.
44
57
58
+ [ TrustedLen ] : https://doc.rust-lang.org/std/iter/trait.TrustedLen.html
45
59
[ cargo-vet ] : https://github.com/mozilla/cargo-vet
46
60
[ multiple-unsafe-ops-per-block ] : https://rust-lang.github.io/rust-clippy/master/index.html#/multiple_unsafe_ops_per_block
47
61
[ undocumented-unsafe-blocks ] : https://rust-lang.github.io/rust-clippy/master/index.html#/undocumented_unsafe_blocks
0 commit comments