rust/src/librustc_errors
Alex Crichton fd4f362b30 Rollup merge of #44125 - SergioBenitez:master, r=nrc
Initial diagnostic API for proc-macros.

This commit introduces the ability to create and emit `Diagnostic` structures from proc-macros, allowing for proc-macro authors to emit warning, error, note, and help messages just like the compiler does.

The API is somewhat based on the diagnostic API already present in `rustc` with several changes that improve usability. The entry point into the diagnostic API is a new `Diagnostic` type which is primarily created through new `error`, `warning`, `help`, and `note` methods on `Span`. The `Diagnostic` type records the diagnostic level, message, and optional `Span` for the top-level diagnostic and contains a `Vec` of all of the child diagnostics. Child diagnostics can be added through builder methods on `Diagnostic`.

A typical use of the API may look like:

```rust
let token = parse_token();
let val = parse_val();

val.span
    .error(format!("expected A but found {}", val))
    .span_note(token.span, "because of this token")
    .help("consider using a different token")
    .emit();
```

cc @jseyfried @nrc @dtolnay @alexcrichton
2017-08-30 11:11:12 -05:00
..
Cargo.toml store typeck lints in the `TypeckTables` 2017-02-02 20:38:16 -05:00
diagnostic.rs Initial diagnostic API for proc-macros. 2017-08-28 02:58:22 -07:00
diagnostic_builder.rs Initial diagnostic API for proc-macros. 2017-08-28 02:58:22 -07:00
emitter.rs Make fields of `Span` private 2017-08-30 01:38:54 +03:00
lib.rs Auto merge of #43968 - petrochenkov:span2, r=michaelwoerister 2017-08-30 11:08:26 +00:00
lock.rs run rustfmt on librustc_errors folder 2016-10-18 23:13:02 +05:30
registry.rs run rustfmt on librustc_errors folder 2016-10-18 23:13:02 +05:30
snippet.rs Fix typos & us spellings 2017-08-15 21:56:30 +02:00
styled_buffer.rs Remove unused code from librustc_errors 2017-07-06 18:49:32 -07:00