]> git.lizzy.rs Git - rust.git/commitdiff
Add E0327 error code. Thanks @nagisa for his help!
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Wed, 24 Jun 2015 20:32:12 +0000 (22:32 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Thu, 25 Jun 2015 16:20:29 +0000 (18:20 +0200)
src/librustc/diagnostics.rs
src/librustc_typeck/diagnostics.rs

index c6b465b47f025aed2733cab72630f7e75448a7a1..034d3ee1604a041f954f75edadb798a9cd2d38f7 100644 (file)
@@ -1018,7 +1018,7 @@ fn bar(&self) -> i32 { self.0 }
 const baz: *const i32 = (&foo as *const i32);
 
 const deref: i32 = *baz;
-// error: raw pointers cannot be dereferenced in constants!
+// error: raw pointers cannot be dereferenced in constants
 ```
 
 To fix this error, please do not assign this value to a constant expression.
index d32e194dbd439c061efac02a3d16517dbd7f0216..2154aee320f796bed304d7880945025eb3a0ae70 100644 (file)
@@ -1457,6 +1457,42 @@ impl Foo for Bar {
 ```
 "##,
 
+E0327: r##"
+You cannot use associated items other than constant items as patterns. This
+includes method items. Example of erroneous code:
+
+```
+enum B {}
+
+impl B {
+    fn bb() -> i32 { 0 }
+}
+
+fn main() {
+    match 0 {
+        B::bb => {} // error: associated items in match patterns must
+                    // be constants
+    }
+}
+```
+
+Please check that you're not using a method as a pattern. Example:
+
+```
+enum B {
+    ba,
+    bb
+}
+
+fn main() {
+    match B::ba {
+        B::bb => {} // ok!
+        _ => {}
+    }
+}
+```
+"##,
+
 E0368: r##"
 This error indicates that a binary assignment operator like `+=` or `^=` was
 applied to the wrong types. For example:
@@ -1540,7 +1576,6 @@ impl Baz for Bar { } // Note: This is OK
 
 }
 
-
 register_diagnostics! {
     E0068,
     E0074,
@@ -1640,7 +1675,6 @@ impl Baz for Bar { } // Note: This is OK
     E0323, // implemented an associated const when another trait item expected
     E0324, // implemented a method when another trait item expected
     E0325, // implemented an associated type when another trait item expected
-    E0327, // referred to method instead of constant in match pattern
     E0328, // cannot implement Unsize explicitly
     E0329, // associated const depends on type parameter or Self.
     E0366, // dropck forbid specialization to concrete type or region