tamer: diagnose::report::VisualReporter::render: Avoid mspan collection

This used to be necessary when `Report` stored references to heap-allocated
strings, but `Report` now owns those values itself.

DEV-12151
main
Mike Gerwitz 2022-04-29 09:53:22 -04:00
parent b0a5265ad3
commit a533244473
1 changed files with 5 additions and 7 deletions

View File

@ -91,21 +91,19 @@ impl<R: SpanResolver> Reporter for VisualReporter<R> {
) -> Report<'d, D> {
// TODO: Avoid duplicate lookups of the same span,
// or at least adjacent ones.
let mspans = diagnostic
.describe()
.into_iter()
.map(|AnnotatedSpan(span, level, olabel)| {
let mspans = diagnostic.describe().into_iter().map(
|AnnotatedSpan(span, level, olabel)| {
let slabel = olabel.map(|label| SpanLabel(level, label));
match self.resolver.resolve(span) {
Ok(rspan) => MaybeResolvedSpan::Resolved(rspan, slabel),
Err(e) => MaybeResolvedSpan::Unresolved(span, slabel, e),
}
})
.collect::<Vec<_>>();
},
);
let mut report = Report::empty(Message(diagnostic));
report.extend(mspans.into_iter().map(Into::into));
report.extend(mspans.map(Into::into));
// Make each section's gutters the same size,
// which is more aesthetically pleasing.