diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2017-01-11 13:55:41 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2017-01-17 14:28:53 -0800 |
| commit | fc774e629fd805ef46566894da482ed8be680303 (patch) | |
| tree | 04e098b9d07adac374ea2cfe041c64df788d1430 /src/libsyntax | |
| parent | bd8e9b0c828bce489eb948853a6cf86b69b26799 (diff) | |
| download | rust-fc774e629fd805ef46566894da482ed8be680303.tar.gz rust-fc774e629fd805ef46566894da482ed8be680303.zip | |
Teach Diagnostics to highlight text
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 a1c273baeea..27ecd23eb42 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() |
