1
Fork 0

refactor constant evaluation error reporting

Refactor constant evaluation to use a single error reporting function
that reports a type-error-like message.

Also, unify all error codes with the "constant evaluation error" message
to just E0080, and similarly for a few other duplicate codes. The old
situation was a total mess, and now that we have *something* we can
further iterate on the UX.
This commit is contained in:
Ariel Ben-Yehuda 2016-07-20 00:02:56 +03:00
parent fa4eda8935
commit 37c569627c
55 changed files with 506 additions and 376 deletions

View file

@ -17,22 +17,26 @@ enum Cake {
use Cake::*;
const BOO: (Cake, Cake) = (Marmor, BlackForest);
//~^ ERROR: constant evaluation error: unimplemented constant expression: enum variants [E0471]
//~^ ERROR: constant evaluation error [E0080]
//~| unimplemented constant expression: enum variants
const FOO: Cake = BOO.1;
const fn foo() -> Cake {
Marmor //~ ERROR: constant evaluation error: unimplemented constant expression: enum variants
//~^ ERROR: unimplemented constant expression: enum variants
Marmor
//~^ ERROR: constant evaluation error [E0080]
//~| unimplemented constant expression: enum variants
//~^^^ ERROR: constant evaluation error [E0080]
//~| unimplemented constant expression: enum variants
}
const WORKS: Cake = Marmor;
const GOO: Cake = foo();
const GOO: Cake = foo(); //~ NOTE for expression here
fn main() {
match BlackForest {
FOO => println!("hi"), //~ NOTE: in pattern here
GOO => println!("meh"), //~ NOTE: in pattern here
FOO => println!("hi"), //~ NOTE: for pattern here
GOO => println!("meh"), //~ NOTE: for pattern here
WORKS => println!("möp"),
_ => println!("bye"),
}