about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-08-06 19:52:21 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-08-06 21:45:27 +0200
commit574fbbf92cd07006e2aa588ded23fc0ee5d04384 (patch)
tree9d51c3e4f37ac586a6c0313a28910a9d7a0c2f33 /src
parent9d8d47d894122b7c6a3538d141db22a533723bb8 (diff)
downloadrust-574fbbf92cd07006e2aa588ded23fc0ee5d04384.tar.gz
rust-574fbbf92cd07006e2aa588ded23fc0ee5d04384.zip
Add E0388 error explanation
Diffstat (limited to 'src')
-rw-r--r--src/librustc_borrowck/diagnostics.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/librustc_borrowck/diagnostics.rs b/src/librustc_borrowck/diagnostics.rs
index 400ae186010..f1792c7f6f5 100644
--- a/src/librustc_borrowck/diagnostics.rs
+++ b/src/librustc_borrowck/diagnostics.rs
@@ -286,6 +286,30 @@ You can read more about cell types in the API documentation:
 https://doc.rust-lang.org/std/cell/
 "##,
 
+E0388: r##"
+A mutable borrow was attempted in a static location.
+
+Erroneous code example:
+
+```compile_fail,E0388
+static X: i32 = 1;
+
+static STATIC_REF: &'static mut i32 = &mut X;
+// error: cannot borrow data mutably in a static location
+
+const CONST_REF: &'static mut i32 = &mut X;
+// error: cannot borrow data mutably in a static location
+```
+
+To fix this error, you have to use constant borrow:
+
+```
+static X: i32 = 1;
+
+static STATIC_REF: &'static i32 = &X;
+```
+"##,
+
 E0389: r##"
 An attempt was made to mutate data using a non-mutable reference. This
 commonly occurs when attempting to assign to a non-mutable reference of a
@@ -1113,6 +1137,5 @@ fn main() {
 
 register_diagnostics! {
     E0385, // {} in an aliasable location
-    E0388, // {} in a static location
     E0524, // two closures require unique access to `..` at the same time
 }