diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2017-08-30 11:11:12 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-30 11:11:12 -0500 |
| commit | fd4f362b304b0e93e7842830b1d3a0fee7d7c1bc (patch) | |
| tree | ca188916d8267f8a5728f0d8bc05f90c6bef38a9 /src/rustllvm/RustWrapper.cpp | |
| parent | bc6981ba55bc20fdd7513b0e1e89af5c7d547d34 (diff) | |
| parent | 8be132e9d76232feb2376de9edcbb34fe3ac99ac (diff) | |
| download | rust-fd4f362b304b0e93e7842830b1d3a0fee7d7c1bc.tar.gz rust-fd4f362b304b0e93e7842830b1d3a0fee7d7c1bc.zip | |
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
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
