]> git.proxmox.com Git - rustc.git/blame - src/librustc_error_codes/error_codes/E0133.md
New upstream version 1.47.0+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0133.md
CommitLineData
60c5eb7d
XL
1Unsafe code was used outside of an unsafe function or block.
2
3Erroneous code example:
4
5```compile_fail,E0133
6unsafe fn f() { return; } // This is the unsafe code
7
8fn main() {
9 f(); // error: call to unsafe function requires unsafe function or block
10}
11```
12
13Using unsafe functionality is potentially dangerous and disallowed by safety
14checks. Examples:
15
16* Dereferencing raw pointers
17* Calling functions via FFI
18* Calling functions marked unsafe
19
20These safety checks can be relaxed for a section of the code by wrapping the
21unsafe instructions with an `unsafe` block. For instance:
22
23```
24unsafe fn f() { return; }
25
26fn main() {
27 unsafe { f(); } // ok!
28}
29```
30
74b04a01
XL
31See the [unsafe section][unsafe-section] of the Book for more details.
32
33[unsafe-section]: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html