annotate-snippets-rs icon indicating copy to clipboard operation
annotate-snippets-rs copied to clipboard

Support Sub-diagnostics with spans

Open Muscraft opened this issue 1 year ago • 1 comments

Currently, sub-diagnostics are handled by adding Annotation's to Snippet::footer. This system is fine, but it does not support sub-diagnostics with a span. This is needed for rust adoption as Subdiag can have spans.

One thing to note is that sub-diagnostics are rendered differently depending on if they have a span or they don't have any.

error[E0000]: main error message
  --> file.rs:LL:CC
   |
LL | <code>
   | -^^^^- secondary label
   |  |
   |  primary label
   |
   = note: note without a `Span`, created with `.note`
note: sub-diagnostic message for `.span_note`
  --> file.rs:LL:CC
   |
LL | more code
   |      ^^^^

Since spans need a source, sub-diagnostics should probably need to be moved under Slice or something similar. This does bring up the question of where we should show a sub-diagnostic, at the end of a Snippet, or at the end of source the span is associated with.

Muscraft avatar Mar 04 '24 18:03 Muscraft

#98 generalized footer but has not vetted the output to make sure it looks like what rustc needs

epage avatar Mar 13 '24 15:03 epage