File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,29 @@ variant constructors or struct constructors (for unit or tuple structs). This
168
168
is because Rust currently does not support compile-time function execution.
169
169
"## ,
170
170
171
+ E0018 : r##"
172
+ The value of static and const variables must be known at compile time. You
173
+ can't cast a pointer as an integer because we can't know what value the
174
+ address will take.
175
+
176
+ However, pointers to other constants' address are allowed in constants,
177
+ example:
178
+
179
+ ```
180
+ const X: u32 = 50;
181
+ const Y: *const u32 = &X;
182
+ ```
183
+
184
+ Therefore, casting one of these non-constant pointers to an integer results
185
+ in a non-constant integer whichs lead to this error. Example:
186
+
187
+ ```
188
+ const X: u32 = 50;
189
+ const Y: *const u32 = &X;
190
+ println!("{:?}", Y);
191
+ ```
192
+ "## ,
193
+
171
194
E0020 : r##"
172
195
This error indicates that an attempt was made to divide by zero (or take the
173
196
remainder of a zero divisor) in a static or constant expression.
@@ -398,7 +421,6 @@ register_diagnostics! {
398
421
E0014 ,
399
422
E0016 ,
400
423
E0017 ,
401
- E0018 ,
402
424
E0019 ,
403
425
E0022 ,
404
426
E0079 , // enum variant: expected signed integer constant
You can’t perform that action at this time.
0 commit comments