0e80dbe59e
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`. |
||
---|---|---|
.. | ||
borrowck | ||
cfg | ||
save | ||
trans | ||
typeck | ||
astencode.rs | ||
check_const.rs | ||
check_loop.rs | ||
check_match.rs | ||
check_static.rs | ||
const_eval.rs | ||
dataflow.rs | ||
dead.rs | ||
def.rs | ||
dependency_format.rs | ||
effect.rs | ||
entry.rs | ||
expr_use_visitor.rs | ||
freevars.rs | ||
graph.rs | ||
intrinsicck.rs | ||
kind.rs | ||
lang_items.rs | ||
liveness.rs | ||
mem_categorization.rs | ||
pat_util.rs | ||
privacy.rs | ||
reachable.rs | ||
region.rs | ||
resolve_lifetime.rs | ||
resolve.rs | ||
stability.rs | ||
subst.rs | ||
ty_fold.rs | ||
ty.rs | ||
weak_lang_items.rs |