diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-06 23:26:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-06 23:26:54 +0100 |
| commit | 2bd35c065cb097d1ea6480c372ab9b5eea358cee (patch) | |
| tree | a72085358f010d6572bf3010c36a4ab6fe28b077 /src/librustc_error_codes/error_codes | |
| parent | ae1b871cca56613b1af1a5121dd24ac810ff4b89 (diff) | |
| parent | e01ad6a01abce35f59543bf38a280a05eb7f6929 (diff) | |
| download | rust-2bd35c065cb097d1ea6480c372ab9b5eea358cee.tar.gz rust-2bd35c065cb097d1ea6480c372ab9b5eea358cee.zip | |
Rollup merge of #66606 - christianpoveda:mut-refs-in-const-fn, r=oli-obk
Add feature gate for mut refs in const fn r? @oli-obk
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0017.md | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/src/librustc_error_codes/error_codes/E0017.md b/src/librustc_error_codes/error_codes/E0017.md deleted file mode 100644 index d5e6857b4d6..00000000000 --- a/src/librustc_error_codes/error_codes/E0017.md +++ /dev/null @@ -1,20 +0,0 @@ -References in statics and constants may only refer to immutable values. - -Erroneous code example: - -```compile_fail,E0017 -static X: i32 = 1; -const C: i32 = 2; - -// these three are not allowed: -const CR: &mut i32 = &mut C; -static STATIC_REF: &'static mut i32 = &mut X; -static CONST_REF: &'static mut i32 = &mut C; -``` - -Statics are shared everywhere, and if they refer to mutable data one might -violate memory safety since holding multiple mutable references to shared data -is not allowed. - -If you really want global mutable state, try using `static mut` or a global -`UnsafeCell`. |
