From ab1723b6704f31390a55a160955240aef817c8b3 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Tue, 14 Apr 2015 19:31:42 +0200 Subject: [PATCH] rustc: Add long diagnostics for E0301 --- src/librustc/diagnostics.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 63d10a83751..3495f8eb160 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -139,6 +139,20 @@ for item in xs { } "##, +E0301: r##" +Mutable borrows are not allowed in pattern guards, because matching cannot have +side effects. Side effects could alter the matched object or the environment +on which the match depends in such a way, that the match would not be +exhaustive. For instance, the following would not match any arm if mutable +borrows were allowed: + +match Some(()) { + None => { }, + option if option.take().is_none() => { /* impossible, option is `Some` */ }, + Some(_) => { } // When the previous match failed, the option became `None`. +} +"##, + E0303: r##" In certain cases it is possible for sub-bindings to violate memory safety. Updates to the borrow checker in a future version of Rust may remove this @@ -224,7 +238,6 @@ register_diagnostics! { E0298, // mismatched types between arms E0299, // mismatched types between arms E0300, // unexpanded macro - E0301, // cannot mutable borrow in a pattern guard E0302, // cannot assign in a pattern guard E0304, // expected signed integer constant E0305, // expected constant