Add E0327 error code. Thanks @nagisa for his help!

This commit is contained in:
Guillaume Gomez 2015-06-24 22:32:12 +02:00
parent b7e41d9aea
commit 7b4eb1aa90
2 changed files with 37 additions and 3 deletions

View file

@ -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.

View 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 @@ 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