about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2015-04-17 19:20:47 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2015-04-20 00:49:53 +0200
commit8a6980c55349cd3ce0ab9a873caa24eb41dab1bd (patch)
tree8f91e897859ea53b878f150f85a3b6de0de05b3f /src
parent49a94f29bbe49bd26d14cbf87b0955bd4befb8c1 (diff)
downloadrust-8a6980c55349cd3ce0ab9a873caa24eb41dab1bd.tar.gz
rust-8a6980c55349cd3ce0ab9a873caa24eb41dab1bd.zip
Add long explanation for E0018
Diffstat (limited to 'src')
-rw-r--r--src/librustc/diagnostics.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 306d2cd102f..15e62d2adc2 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -168,6 +168,29 @@ variant constructors or struct constructors (for unit or tuple structs). This
 is because Rust currently does not support compile-time function execution.
 "##,
 
+E0018: r##"
+The value of static and const variables must be known at compile time. You
+can't cast a pointer as an integer because we can't know what value the
+address will take.
+
+However, pointers to other constants' address are allowed in constants,
+example:
+
+```
+const X: u32 = 50;
+const Y: *const u32 = &X;
+```
+
+Therefore, casting one of these non-constant pointers to an integer results
+in a non-constant integer whichs lead to this error. Example:
+
+```
+const X: u32 = 50;
+const Y: *const u32 = &X;
+println!("{:?}", Y);
+```
+"##,
+
 E0020: r##"
 This error indicates that an attempt was made to divide by zero (or take the
 remainder of a zero divisor) in a static or constant expression.
@@ -398,7 +421,6 @@ register_diagnostics! {
     E0014,
     E0016,
     E0017,
-    E0018,
     E0019,
     E0022,
     E0079, // enum variant: expected signed integer constant