1
Fork 0

Minimize single span suggestions into a note

This commit is contained in:
Oliver Schneider 2017-03-24 17:31:41 +01:00
parent 0777c757a6
commit 0e920fde4f
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9
6 changed files with 47 additions and 28 deletions

View file

@ -22,8 +22,9 @@
use codemap::CodeMap;
use syntax_pos::{self, MacroBacktrace, Span, SpanLabel, MultiSpan};
use errors::registry::Registry;
use errors::{DiagnosticBuilder, SubDiagnostic, RenderSpan, CodeSuggestion, CodeMapper};
use errors::{Level, DiagnosticBuilder, SubDiagnostic, RenderSpan, CodeSuggestion, CodeMapper};
use errors::emitter::Emitter;
use errors::snippet::Style;
use std::rc::Rc;
use std::io::{self, Write};
@ -152,12 +153,21 @@ impl Diagnostic {
fn from_diagnostic_builder(db: &DiagnosticBuilder,
je: &JsonEmitter)
-> Diagnostic {
let sugg = db.suggestion.as_ref().map(|sugg| {
SubDiagnostic {
level: Level::Help,
message: vec![(sugg.msg.clone(), Style::NoStyle)],
span: MultiSpan::new(),
render_span: Some(RenderSpan::Suggestion(sugg.clone())),
}
});
let sugg = sugg.as_ref();
Diagnostic {
message: db.message(),
code: DiagnosticCode::map_opt_string(db.code.clone(), je),
level: db.level.to_str(),
spans: DiagnosticSpan::from_multispan(&db.span, je),
children: db.children.iter().map(|c| {
children: db.children.iter().chain(sugg).map(|c| {
Diagnostic::from_sub_diagnostic(c, je)
}).collect(),
rendered: None,