diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 671ca25f..c82907ca 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -48,7 +48,9 @@ use crate::renderer::source_map::{ }; use crate::renderer::styled_buffer::StyledBuffer; use crate::snippet::Id; -use crate::{Annotation, AnnotationKind, Element, Group, Message, Origin, Patch, Snippet, Title}; +use crate::{ + Annotation, AnnotationKind, Element, Group, Message, Origin, Patch, Report, Snippet, Title, +}; pub use anstyle::*; use margin::Margin; use std::borrow::Cow; @@ -225,7 +227,7 @@ impl Renderer { impl Renderer { /// Render a diagnostic, a series of [`Group`]s - pub fn render(&self, groups: &[Group<'_>]) -> String { + pub fn render(&self, groups: Report<'_>) -> String { if self.short_message { self.render_short_message(groups).unwrap() } else { diff --git a/src/snippet.rs b/src/snippet.rs index 8ce857f7..9bb44020 100644 --- a/src/snippet.rs +++ b/src/snippet.rs @@ -11,6 +11,13 @@ pub(crate) const INFO_TXT: &str = "info"; pub(crate) const NOTE_TXT: &str = "note"; pub(crate) const WARNING_TXT: &str = "warning"; +/// A [diagnostic message][Title] and any associated context to help users +/// understand it +/// +/// The first [`Group`] is the "primary" group, ie it contains the diagnostic +/// message. All subsequent [`Group`]s are for distinct pieces of context. +pub type Report<'a> = &'a [Group<'a>]; + #[derive(Clone, Debug, Default)] pub(crate) struct Id<'a> { pub(crate) id: Option>,