File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,13 @@ This new warning will likely fire for the vast majority of `unsafe fn` out there
124124
125125Many `unsafe fn ` are actually rather short (no more than 3 lines ) and will
126126likely end up just being one large `unsafe ` block . This change would make such
127- functions less ergonomic to write .
127+ functions less ergonomic to write , they would likely become
128+
129+ ```rust
130+ unsafe fn foo (... ) -> ... { unsafe {
131+ // Code goes here
132+ } }
133+ ```
128134
129135# Rationale and alternatives
130136[ rationale-and-alternatives ] : #rationale-and-alternatives
@@ -137,6 +143,14 @@ We could introduce named proof obligations (proposed by @Centril) such that the
137143compiler can be be told (to some extend) if the assumptions made by the `unsafe
138144fn` are sufficient to discharge the requirements of the unsafe operations.
139145
146+ We could restrict this requirement to use ` unsafe ` blocks in ` unsafe fn ` to
147+ those ` unsafe fn ` that contain at least one ` unsafe ` block, meaning short
148+ ` unsafe fn ` would keep compiling like they do now.
149+
150+ We could have separate marker for ` unsafe fn ` with and without an implicitly
151+ unsafe body, e.g. ` unsafe unsafe fn ` has an unsafe body, or `unsafe fn foo(...)
152+ -> ... unsafe { }` has an unsafe body, or ` unsafe_to_call fn` has a safe body.
153+
140154# Prior art
141155[ prior-art ] : #prior-art
142156
You can’t perform that action at this time.
0 commit comments