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
124
124
125
125
Many `unsafe fn ` are actually rather short (no more than 3 lines ) and will
126
126
likely 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
+ ```
128
134
129
135
# Rationale and alternatives
130
136
[ rationale-and-alternatives ] : #rationale-and-alternatives
@@ -137,6 +143,14 @@ We could introduce named proof obligations (proposed by @Centril) such that the
137
143
compiler can be be told (to some extend) if the assumptions made by the `unsafe
138
144
fn` are sufficient to discharge the requirements of the unsafe operations.
139
145
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
+
140
154
# Prior art
141
155
[ prior-art ] : #prior-art
142
156
You can’t perform that action at this time.
0 commit comments