librustc_errors: Extract sugg/subst handling into method

An initial refactoring before working on #61809.

This moves the whole block into a method so that it can be reused in the
annotate-snippet output. It's already used in the new emitter, but
there's no UI tests with suggestions included in this PR.

A first look at some UI tests with suggestions showed that there's some
more work to do in [annotate-snippet-rs][annotate-snippet-rs] before the
new output is closer to the current one.
This commit is contained in:
Philipp Hansch 2019-09-01 12:15:33 +02:00
parent 2d851b3318
commit 84ccbe2076
No known key found for this signature in database
GPG key ID: 82AA61CAA11397E6
2 changed files with 32 additions and 12 deletions

View file

@ -30,10 +30,8 @@ pub struct AnnotateSnippetEmitterWriter {
impl Emitter for AnnotateSnippetEmitterWriter {
/// The entry point for the diagnostics generation
fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) {
let primary_span = db.span.clone();
let children = db.children.clone();
// FIXME(#59346): Collect suggestions (see emitter.rs)
let suggestions: &[_] = &[];
let (primary_span, suggestions) = self.primary_span_formatted(&db);
// FIXME(#59346): Add `fix_multispans_in_std_macros` function from emitter.rs