mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Add details about unsafe_op_in_unsafe_fn
to E0133
This commit is contained in:
parent
a525c7ddba
commit
8f94253254
@ -1,4 +1,4 @@
|
||||
Unsafe code was used outside of an unsafe function or block.
|
||||
Unsafe code was used outside of an unsafe block.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
@ -30,4 +30,21 @@ fn main() {
|
||||
|
||||
See the [unsafe section][unsafe-section] of the Book for more details.
|
||||
|
||||
#### Unsafe code in functions
|
||||
|
||||
Unsafe code is currently accepted in unsafe functions, but that is being phased
|
||||
out in favor of requiring unsafe blocks here too.
|
||||
|
||||
```
|
||||
unsafe fn f() { return; }
|
||||
|
||||
unsafe fn g() {
|
||||
f(); // Is accepted, but no longer recommended
|
||||
unsafe { f(); } // Recommended way to write this
|
||||
}
|
||||
```
|
||||
|
||||
Linting against this is controlled via the `unsafe_op_in_unsafe_fn` lint, which
|
||||
is `allow` by default but will be upgraded to `warn` in a future edition.
|
||||
|
||||
[unsafe-section]: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
|
||||
|
Loading…
Reference in New Issue
Block a user