diff options
| author | bors <bors@rust-lang.org> | 2014-07-10 23:26:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-10 23:26:39 +0000 |
| commit | 0e80dbe59ea986ea53cc3caabffd40b2eaee4dc6 (patch) | |
| tree | 3044cbdb7fe356d52a07c9048bc431aac3de5c4a /src/libsyntax/lib.rs | |
| parent | a672456c40d28f051ecbdb2caf5bf6733371d494 (diff) | |
| parent | 9b9cce2316119a2ffdc9556d410e464b7542d64d (diff) | |
| download | rust-0e80dbe59ea986ea53cc3caabffd40b2eaee4dc6.tar.gz rust-0e80dbe59ea986ea53cc3caabffd40b2eaee4dc6.zip | |
auto merge of #15336 : jakub-/rust/diagnostics, r=brson
This is a continuation of @brson's work from https://github.com/rust-lang/rust/pull/12144.
This implements the minimal scaffolding that allows mapping diagnostic messages to alpha-numeric codes, which could improve the searchability of errors. In addition, there's a new compiler option, `--explain {code}` which takes an error code and prints out a somewhat detailed explanation of the error. Example:
```rust
fn f(x: Option<bool>) {
match x {
Some(true) | Some(false) => (),
None => (),
Some(true) => ()
}
}
```
```shell
[~/rust]$ ./build/x86_64-apple-darwin/stage2/bin/rustc ./diagnostics.rs --crate-type dylib
diagnostics.rs:5:3: 5:13 error: unreachable pattern [E0001] (pass `--explain E0001` to see a detailed explanation)
diagnostics.rs:5 Some(true) => ()
^~~~~~~~~~
error: aborting due to previous error
[~/rust]$ ./build/x86_64-apple-darwin/stage2/bin/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.
```
I've refrained from migrating many errors to actually use the new macros as it can be done in an incremental fashion but if we're happy with the approach, it'd be good to do all of them sooner rather than later.
Originally, I was going to make libdiagnostics a separate crate but that's posing some interesting challenges with semi-circular dependencies. In particular, librustc would have a plugin-phase dependency on libdiagnostics, which itself depends on librustc. Per my conversation with @alexcrichton, it seems like the snapshotting process would also have to change. So for now the relevant modules from libdiagnostics are included using `#[path = ...] mod`.
Diffstat (limited to 'src/libsyntax/lib.rs')
| -rw-r--r-- | src/libsyntax/lib.rs | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 1ef376c6615..184ce39aaf2 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -27,12 +27,11 @@ #![feature(quote, unsafe_destructor)] #![allow(deprecated)] -extern crate serialize; -extern crate term; -#[phase(plugin, link)] extern crate log; - extern crate fmt_macros; extern crate debug; +#[phase(plugin, link)] extern crate log; +extern crate serialize; +extern crate term; pub mod util { pub mod interner; @@ -41,26 +40,30 @@ pub mod util { pub mod small_vector; } +pub mod diagnostics { + pub mod macros; + pub mod plugin; + pub mod registry; +} + pub mod syntax { pub use ext; pub use parse; pub use ast; } -pub mod owned_slice; -pub mod attr; -pub mod diagnostic; -pub mod codemap; pub mod abi; pub mod ast; -pub mod ast_util; pub mod ast_map; -pub mod visit; +pub mod ast_util; +pub mod attr; +pub mod codemap; +pub mod crateid; +pub mod diagnostic; pub mod fold; - - +pub mod owned_slice; pub mod parse; -pub mod crateid; +pub mod visit; pub mod print { pub mod pp; @@ -70,31 +73,25 @@ pub mod print { pub mod ext { pub mod asm; pub mod base; + pub mod build; + pub mod bytes; + pub mod cfg; + pub mod concat; + pub mod concat_idents; + pub mod deriving; + pub mod env; pub mod expand; - + pub mod fmt; + pub mod format; + pub mod log_syntax; + pub mod mtwt; pub mod quote; - - pub mod deriving; - - pub mod build; + pub mod source_util; + pub mod trace_macros; pub mod tt { pub mod transcribe; pub mod macro_parser; pub mod macro_rules; } - - pub mod mtwt; - - pub mod cfg; - pub mod fmt; - pub mod format; - pub mod env; - pub mod bytes; - pub mod concat; - pub mod concat_idents; - pub mod log_syntax; - pub mod source_util; - - pub mod trace_macros; } |
