about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-05-27 21:36:40 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-05-27 21:53:38 +0200
commitc848ca1f8df4ac550c83cbe22ff46c107dd86002 (patch)
tree73e8f3e322f11aa0c845db7f45b4a7baef019b1a /src
parentab7c35fa0fcd725cdc207487b760d85fd07ecdd7 (diff)
downloadrust-c848ca1f8df4ac550c83cbe22ff46c107dd86002.tar.gz
rust-c848ca1f8df4ac550c83cbe22ff46c107dd86002.zip
Improve E0133 error explanation
Diffstat (limited to 'src')
-rw-r--r--src/librustc/diagnostics.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index c64f0ddac50..2b2525b1045 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -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:
 
@@ -378,7 +390,7 @@ unsafe instructions with an `unsafe` block. For instance:
 unsafe fn f() { return; }
 
 fn main() {
-    unsafe { f(); }
+    unsafe { f(); } // ok!
 }
 ```