Skip to content

Commit 7475236

Browse files
Rollup merge of #33913 - GuillaumeGomez:improve_e0133, r=GuillaumeGomez
Improve E0133 error explanation r? @steveklabnik
2 parents 075ea13 + c848ca1 commit 7475236

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
@@ -366,6 +366,18 @@ type X = u32; // ok!
366366
"##,
367367

368368
E0133: r##"
369+
Unsafe code was used outside of an unsafe function or block.
370+
371+
Erroneous code example:
372+
373+
```compile_fail
374+
unsafe fn f() { return; } // This is the unsafe code
375+
376+
fn main() {
377+
f(); // error: call to unsafe function requires unsafe function or block
378+
}
379+
```
380+
369381
Using unsafe functionality is potentially dangerous and disallowed by safety
370382
checks. Examples:
371383
@@ -380,7 +392,7 @@ unsafe instructions with an `unsafe` block. For instance:
380392
unsafe fn f() { return; }
381393
382394
fn main() {
383-
unsafe { f(); }
395+
unsafe { f(); } // ok!
384396
}
385397
```
386398

0 commit comments

Comments
 (0)