rust-lang/rust — pull request #16619 by steveklabnik (2014-08-19 23:11:11+00:00)
Title: Better errors

This is the start of my attempt to address #2092.

## What this is

Right now, when you compile with an error, you get this:

```
steve@computer:~/tmp$ cat hello.rs
fn foo(x: int) {
match x {
1 .. 10 => (),
7 => (),
_ => (),
}
}

fn main() {

}
steve@computer:~/tmp$ rustc hello.rs
hello.rs:4:9: 4:10 error: unreachable pattern [E0001] (pass `--explain E0001` to see a detailed explanation)
hello.rs:4 7 => (),
^
error: aborting due to previous error
```

Note the `[E0001]` error code and the ability to get an explanation.

```
steve@computer:~/tmp$ rustc --explain E0001

This error suggests that the expression arm corresponding to the noted pattern
will never be reached as for all possible values of the expression being matched,
one of the preceeding patterns will match.

This means that perhaps some of the preceeding patterns are too general, this
one is too specific or the ordering is incorrect.
```

This is sweet! But we can do better.

## What this adds

With this PR applied, you get this instead:

```
steve@computer:~/tmp$ rustc hello.rs
hello.rs:4:9: 4:10 error: unreachable pattern [E0001] (pass `--explain E0001` to see more detail or visit http://doc.rust-lang.org/errors/E0001.html for extensive help with this error)
hello.rs:4 7 => (),
^
error: aborting due to previous error
```

Along with the doc machinery to generate that page. This should give us a place to provide even more help around errors, and guide people through problems. If they don't have an internet connection, they can see the pages locally as well.

This PR isn't really 'ready' yet, but I wanted to get some feedback. The error pages don't display CSS correctly, and I think I screwed up my git-fu to fix that error message, but I'm about to jump on a plane. Please let me know what you think, and I'll keep working on this if it's a path we want to go down.