File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
branches/stable/src/librustc Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
29
29
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
30
30
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
31
31
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32
- refs/heads/stable: 688a09910a01800bfa031892540f29bb0c3b4095
32
+ refs/heads/stable: 5d31deeae43e8f3803604f837649bbaeb625e726
33
33
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
34
34
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
35
35
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e
Original file line number Diff line number Diff line change @@ -306,6 +306,28 @@ const FOO: i32 = { const X : i32 = 0; X };
306
306
```
307
307
"## ,
308
308
309
+ E0017 : r##"
310
+ References in statics and constants may only refer to immutable values. Example:
311
+
312
+ ```
313
+ static X: i32 = 1;
314
+ const C: i32 = 2;
315
+
316
+ // these three are not allowed:
317
+ const CR: &'static mut i32 = &mut C;
318
+ static STATIC_REF: &'static mut i32 = &mut X;
319
+ static CONST_REF: &'static mut i32 = &mut C;
320
+ ```
321
+
322
+ Statics are shared everywhere, and if they refer to mutable data one might
323
+ violate memory safety since holding multiple mutable references to shared data
324
+ is not allowed.
325
+
326
+ If you really want global mutable state, try using a global `UnsafeCell` or
327
+ `static mut`.
328
+
329
+ "## ,
330
+
309
331
E0018 : r##"
310
332
The value of static and const variables must be known at compile time. You
311
333
can't cast a pointer as an integer because we can't know what value the
@@ -1255,7 +1277,6 @@ contain references (with a maximum lifetime of `'a`).
1255
1277
1256
1278
register_diagnostics ! {
1257
1279
// E0006 // merged with E0005
1258
- E0017 ,
1259
1280
E0022 ,
1260
1281
E0038 ,
1261
1282
// E0134,
You can’t perform that action at this time.
0 commit comments