Skip to content

Commit c848ca1

Browse files
Improve E0133 error explanation
1 parent ab7c35f commit c848ca1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/librustc/diagnostics.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,18 @@ type X = u32; // ok!
364364
"##,
365365

366366
E0133: r##"
367+
Unsafe code was used outside of an unsafe function or block.
368+
369+
Erroneous code example:
370+
371+
```compile_fail
372+
unsafe fn f() { return; } // This is the unsafe code
373+
374+
fn main() {
375+
f(); // error: call to unsafe function requires unsafe function or block
376+
}
377+
```
378+
367379
Using unsafe functionality is potentially dangerous and disallowed by safety
368380
checks. Examples:
369381
@@ -378,7 +390,7 @@ unsafe instructions with an `unsafe` block. For instance:
378390
unsafe fn f() { return; }
379391
380392
fn main() {
381-
unsafe { f(); }
393+
unsafe { f(); } // ok!
382394
}
383395
```
384396

0 commit comments

Comments
 (0)