diff options
| author | bors <bors@rust-lang.org> | 2017-01-20 09:33:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-20 09:33:10 +0000 |
| commit | b7ca2b9e143248c8fc33353636c0051f91d7f77f (patch) | |
| tree | 48e1846658c05461fe489f9037286e2b823116ee /src/libsyntax | |
| parent | b53d37479079d820290e21c424f0a6f9af112afe (diff) | |
| parent | fc774e629fd805ef46566894da482ed8be680303 (diff) | |
| download | rust-b7ca2b9e143248c8fc33353636c0051f91d7f77f.tar.gz rust-b7ca2b9e143248c8fc33353636c0051f91d7f77f.zip | |
Auto merge of #38955 - estebank:highlighted-diags, r=nikomatsakis
Teach Diagnostics to highlight text Support styled `Diagnostic` output: <img width="469" alt="mismatched types error with colorized types in the note" src="https://cloud.githubusercontent.com/assets/1606434/21871227/93a84198-d815-11e6-88b1-0ede3c7e28ef.png"> Closes #37532 and #38901. r? @nikomatsakis CC @jonathandturner @nagisa @nrc
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/json.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index adab76309fe..fd762552248 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -74,15 +74,15 @@ impl Emitter for JsonEmitter { // The following data types are provided just for serialisation. #[derive(RustcEncodable)] -struct Diagnostic<'a> { +struct Diagnostic { /// The primary error message. - message: &'a str, + message: String, code: Option<DiagnosticCode>, /// "error: internal compiler error", "error", "warning", "note", "help". level: &'static str, spans: Vec<DiagnosticSpan>, /// Associated diagnostic messages. - children: Vec<Diagnostic<'a>>, + children: Vec<Diagnostic>, /// The message as rustc would render it. Currently this is only /// `Some` for "suggestions", but eventually it will include all /// snippets. @@ -148,12 +148,12 @@ struct DiagnosticCode { explanation: Option<&'static str>, } -impl<'a> Diagnostic<'a> { - fn from_diagnostic_builder<'c>(db: &'c DiagnosticBuilder, - je: &JsonEmitter) - -> Diagnostic<'c> { +impl Diagnostic { + fn from_diagnostic_builder(db: &DiagnosticBuilder, + je: &JsonEmitter) + -> Diagnostic { Diagnostic { - message: &db.message, + message: db.message(), code: DiagnosticCode::map_opt_string(db.code.clone(), je), level: db.level.to_str(), spans: DiagnosticSpan::from_multispan(&db.span, je), @@ -164,9 +164,9 @@ impl<'a> Diagnostic<'a> { } } - fn from_sub_diagnostic<'c>(db: &'c SubDiagnostic, je: &JsonEmitter) -> Diagnostic<'c> { + fn from_sub_diagnostic(db: &SubDiagnostic, je: &JsonEmitter) -> Diagnostic { Diagnostic { - message: &db.message, + message: db.message(), code: None, level: db.level.to_str(), spans: db.render_span.as_ref() |
