Skip to content

Improve E0133 error explanation #33913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,18 @@ type X = u32; // ok!
"##,

E0133: r##"
Unsafe code was used outside of an unsafe function or block.

Erroneous code example:

```compile_fail
unsafe fn f() { return; } // This is the unsafe code

fn main() {
f(); // error: call to unsafe function requires unsafe function or block
}
```

Using unsafe functionality is potentially dangerous and disallowed by safety
checks. Examples:

Expand All @@ -378,7 +390,7 @@ unsafe instructions with an `unsafe` block. For instance:
unsafe fn f() { return; }

fn main() {
unsafe { f(); }
unsafe { f(); } // ok!
}
```

Expand Down