Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1a2fa7e

Browse files
authored
Merge pull request rust-lang#274 from Muscraft/add-report
feat: Add top-level Report type
2 parents e526c18 + dbef156 commit 1a2fa7e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

‎src/renderer/mod.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ use crate::renderer::source_map::{
4848
};
4949
use crate::renderer::styled_buffer::StyledBuffer;
5050
use crate::snippet::Id;
51-
use crate::{Annotation, AnnotationKind, Element, Group, Message, Origin, Patch, Snippet, Title};
51+
use crate::{
52+
Annotation, AnnotationKind, Element, Group, Message, Origin, Patch, Report, Snippet, Title,
53+
};
5254
pub use anstyle::*;
5355
use margin::Margin;
5456
use std::borrow::Cow;
@@ -225,7 +227,7 @@ impl Renderer {
225227

226228
impl Renderer {
227229
/// Render a diagnostic, a series of [`Group`]s
228-
pub fn render(&self, groups: &[Group<'_>]) -> String {
230+
pub fn render(&self, groups: Report<'_>) -> String {
229231
if self.short_message {
230232
self.render_short_message(groups).unwrap()
231233
} else {

‎src/snippet.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ pub(crate) const INFO_TXT: &str = "info";
1111
pub(crate) const NOTE_TXT: &str = "note";
1212
pub(crate) const WARNING_TXT: &str = "warning";
1313

14+
/// A [diagnostic message][Title] and any associated context to help users
15+
/// understand it
16+
///
17+
/// The first [`Group`] is the "primary" group, ie it contains the diagnostic
18+
/// message. All subsequent [`Group`]s are for distinct pieces of context.
19+
pub type Report<'a> = &'a [Group<'a>];
20+
1421
#[derive(Clone, Debug, Default)]
1522
pub(crate) struct Id<'a> {
1623
pub(crate) id: Option<Cow<'a, str>>,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /