mirror of https://github.com/zkat/miette.git
fix(protocol): keep the owned spans
This commit is contained in:
parent
f390520b45
commit
49151bb095
|
|
@ -200,14 +200,14 @@ impl Snippets {
|
||||||
// Context
|
// Context
|
||||||
let context = &snippet.snippet;
|
let context = &snippet.snippet;
|
||||||
let context = quote! {
|
let context = quote! {
|
||||||
context: &self.#context,
|
context: self.#context.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Highlights
|
// Highlights
|
||||||
let highlights = snippet.highlights.iter().map(|highlight| {
|
let highlights = snippet.highlights.iter().map(|highlight| {
|
||||||
let Highlight { highlight } = highlight;
|
let Highlight { highlight } = highlight;
|
||||||
quote! {
|
quote! {
|
||||||
&self.#highlight
|
self.#highlight.clone()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let highlights = quote! {
|
let highlights = quote! {
|
||||||
|
|
@ -288,7 +288,7 @@ impl Snippets {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let context = quote! {
|
let context = quote! {
|
||||||
context: #context,
|
context: #context.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Highlights
|
// Highlights
|
||||||
|
|
@ -301,7 +301,7 @@ impl Snippets {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
quote! {
|
quote! {
|
||||||
#m
|
#m.clone()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let highlights = quote! {
|
let highlights = quote! {
|
||||||
|
|
|
||||||
|
|
@ -177,11 +177,11 @@ pub struct DiagnosticSnippet<'a> {
|
||||||
/// A [Source] that can be used to read the actual text of a source.
|
/// A [Source] that can be used to read the actual text of a source.
|
||||||
pub source: &'a (dyn Source),
|
pub source: &'a (dyn Source),
|
||||||
/// The primary [SourceSpan] where this diagnostic is located.
|
/// The primary [SourceSpan] where this diagnostic is located.
|
||||||
pub context: &'a SourceSpan,
|
pub context: SourceSpan,
|
||||||
/// Additional [SourceSpan]s that mark specific sections of the span, for
|
/// Additional [SourceSpan]s that mark specific sections of the span, for
|
||||||
/// example, to underline specific text within the larger span. They're
|
/// example, to underline specific text within the larger span. They're
|
||||||
/// paired with labels that should be applied to those sections.
|
/// paired with labels that should be applied to those sections.
|
||||||
pub highlights: Option<Vec<&'a SourceSpan>>,
|
pub highlights: Option<Vec<SourceSpan>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ impl MietteReporter {
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
let context_data = snippet
|
let context_data = snippet
|
||||||
.source
|
.source
|
||||||
.read_span(snippet.context)
|
.read_span(&snippet.context)
|
||||||
.map_err(|_| fmt::Error)?;
|
.map_err(|_| fmt::Error)?;
|
||||||
let context = std::str::from_utf8(context_data.data()).expect("Bad utf8 detected");
|
let context = std::str::from_utf8(context_data.data()).expect("Bad utf8 detected");
|
||||||
let mut line = context_data.line();
|
let mut line = context_data.line();
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ impl Diagnostic for MyBad {
|
||||||
vec![DiagnosticSnippet {
|
vec![DiagnosticSnippet {
|
||||||
message: Some(self.message.as_ref()),
|
message: Some(self.message.as_ref()),
|
||||||
source: &self.src,
|
source: &self.src,
|
||||||
context: &self.ctx,
|
context: self.ctx.clone(),
|
||||||
highlights: Some(vec![&self.highlight]),
|
highlights: Some(vec![self.highlight.clone()]),
|
||||||
}]
|
}]
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
))
|
))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue