Skip to content

Commit a1aa0d9

Browse files
committed
---
yaml --- r: 221820 b: refs/heads/auto c: 5d31dee h: refs/heads/master v: v3
1 parent 8720a08 commit a1aa0d9

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 688a09910a01800bfa031892540f29bb0c3b4095
11+
refs/heads/auto: 5d31deeae43e8f3803604f837649bbaeb625e726
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc/diagnostics.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,28 @@ const FOO: i32 = { const X : i32 = 0; X };
306306
```
307307
"##,
308308

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+
309331
E0018: r##"
310332
The value of static and const variables must be known at compile time. You
311333
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`).
12551277

12561278
register_diagnostics! {
12571279
// E0006 // merged with E0005
1258-
E0017,
12591280
E0022,
12601281
E0038,
12611282
// E0134,

0 commit comments

Comments
 (0)