From 574fbbf92cd07006e2aa588ded23fc0ee5d04384 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 6 Aug 2016 19:52:21 +0200 Subject: [PATCH] Add E0388 error explanation --- src/librustc_borrowck/diagnostics.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/librustc_borrowck/diagnostics.rs b/src/librustc_borrowck/diagnostics.rs index 400ae186010e3..f1792c7f6f5a9 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 }