File tree 1 file changed +22
-4
lines changed
1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -188,12 +188,30 @@ avoid mutation if possible.
188
188
"## ,
189
189
190
190
E0394 : r##"
191
- From [RFC 246]:
191
+ A static was referred to by value by another static.
192
192
193
- > It is invalid for a static to reference another static by value. It is
194
- > required that all references be borrowed.
193
+ Erroneous code examples:
195
194
196
- [RFC 246]: https://github.com/rust-lang/rfcs/pull/246
195
+ ```compile_fail,E0394
196
+ static A: u32 = 0;
197
+ static B: u32 = A; // error: cannot refer to other statics by value, use the
198
+ // address-of operator or a constant instead
199
+ ```
200
+
201
+ A static cannot be referred by value. To fix this issue, either use a
202
+ constant:
203
+
204
+ ```
205
+ const A: u32 = 0; // `A` is now a constant
206
+ static B: u32 = A; // ok!
207
+ ```
208
+
209
+ Or refer to `A` by reference:
210
+
211
+ ```
212
+ static A: u32 = 0;
213
+ static B: &'static u32 = &A; // ok!
214
+ ```
197
215
"## ,
198
216
199
217
You can’t perform that action at this time.
0 commit comments