about summary refs log tree commit diff
diff options
context:
space:
mode:
authorggomez <guillaume1.gomez@gmail.com>2016-05-12 14:38:07 +0200
committerggomez <guillaume1.gomez@gmail.com>2016-05-12 16:42:43 +0200
commit5f2099d4af1a88c616fc2fae74c6429461de49fc (patch)
tree824ae5c1b8abb5ba05c862ea98b18d235214087b
parent992bb1332ffc68093a6aa555807b9129a1e94977 (diff)
downloadrust-5f2099d4af1a88c616fc2fae74c6429461de49fc.tar.gz
rust-5f2099d4af1a88c616fc2fae74c6429461de49fc.zip
Add more details and examples in error code
-rw-r--r--src/librustc_const_eval/diagnostics.rs13
-rw-r--r--src/librustc_typeck/diagnostics.rs8
2 files changed, 13 insertions, 8 deletions
diff --git a/src/librustc_const_eval/diagnostics.rs b/src/librustc_const_eval/diagnostics.rs
index c86c22b1e0f..457d25923c6 100644
--- a/src/librustc_const_eval/diagnostics.rs
+++ b/src/librustc_const_eval/diagnostics.rs
@@ -62,8 +62,6 @@ fn foo(x: Empty) {
 However, this won't:
 
 ```compile_fail
-enum Empty {}
-
 fn foo(x: Option<String>) {
     match x {
         // empty
@@ -191,7 +189,7 @@ inner `String` to be moved into a variable called `s`.
 let x = Some("s".to_string());
 
 match x {
-    op_string @ Some(s) => {},
+    op_string @ Some(s) => {}, // error: cannot bind by-move with sub-bindings
     None => {},
 }
 ```
@@ -288,7 +286,8 @@ struct X { x: (), }
 
 let x = Some((X { x: () }, X { x: () }));
 match x {
-    Some((y, ref z)) => {},
+    Some((y, ref z)) => {}, // error: cannot bind by-move and by-ref in the
+                            //        same pattern
     None => panic!()
 }
 ```
@@ -574,6 +573,12 @@ be a compile-time constant. Erroneous code example:
     let x = [0i32; len]; // error: expected constant integer for repeat count,
                          //        found variable
 ```
+
+Working example:
+
+```
+let x = [0i32; 10];
+```
 "##,
 
 }
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index 05e4c79a7e8..ac23d6f57ea 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -45,8 +45,8 @@ Matching with the wrong number of fields has no sensible interpretation:
 
 ```compile_fail
 enum Fruit {
-    Apple(String, String),
-    Pear(u32),
+    Fruit::Apple(String, String),
+    Fruit::Pear(u32),
 }
 
 let x = Fruit::Apple(String::new(), String::new());
@@ -77,8 +77,8 @@ enum Number {
 
 // Assuming x is a Number we can pattern match on its contents.
 match x {
-    Zero(inside) => {},
-    One(inside) => {},
+    Number::Zero(inside) => {},
+    Number::One(inside) => {},
 }
 ```