File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -169,8 +169,26 @@ is because Rust currently does not support compile-time function execution.
169
169
"## ,
170
170
171
171
E0018 : r##"
172
- The value of static and const variables must be known at compile time, which is
173
- not possible with a pointer or with a value pointed by a pointer.
172
+ The value of static and const variables must be known at compile time. You
173
+ can't cast an integer as a pointer because we can't know what value will be
174
+ at the address.
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
+ ```
174
192
"## ,
175
193
176
194
E0020 : r##"
You can’t perform that action at this time.
0 commit comments