about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/diagnostics.rs2
-rw-r--r--src/librustc_typeck/diagnostics.rs38
2 files changed, 37 insertions, 3 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index c6b465b47f0..034d3ee1604 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -1018,7 +1018,7 @@ const foo: i32 = 42;
 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.
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index d32e194dbd4..2154aee320f 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -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 @@ For more information see the [opt-in builtin traits RFC](https://github.com/rust
 
 }
 
-
 register_diagnostics! {
     E0068,
     E0074,
@@ -1640,7 +1675,6 @@ register_diagnostics! {
     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