File tree 1 file changed +23
-1
lines changed
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' addresses 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 which 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.
@@ -413,7 +436,6 @@ register_diagnostics! {
413
436
E0014 ,
414
437
E0016 ,
415
438
E0017 ,
416
- E0018 ,
417
439
E0019 ,
418
440
E0022 ,
419
441
E0079 , // enum variant: expected signed integer constant
You can’t perform that action at this time.
0 commit comments