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
|
||||
let context = &snippet.snippet;
|
||||
let context = quote! {
|
||||
context: &self.#context,
|
||||
context: self.#context.clone(),
|
||||
};
|
||||
|
||||
// Highlights
|
||||
let highlights = snippet.highlights.iter().map(|highlight| {
|
||||
let Highlight { highlight } = highlight;
|
||||
quote! {
|
||||
&self.#highlight
|
||||
self.#highlight.clone()
|
||||
}
|
||||
});
|
||||
let highlights = quote! {
|
||||
|
|
@ -288,7 +288,7 @@ impl Snippets {
|
|||
}
|
||||
};
|
||||
let context = quote! {
|
||||
context: #context,
|
||||
context: #context.clone(),
|
||||
};
|
||||
|
||||
// Highlights
|
||||
|
|
@ -301,7 +301,7 @@ impl Snippets {
|
|||
}
|
||||
};
|
||||
quote! {
|
||||
#m
|
||||
#m.clone()
|
||||
}
|
||||
});
|
||||
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.
|
||||
pub source: &'a (dyn Source),
|
||||
/// 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
|
||||
/// example, to underline specific text within the larger span. They're
|
||||
/// 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)?;
|
||||
let context_data = snippet
|
||||
.source
|
||||
.read_span(snippet.context)
|
||||
.read_span(&snippet.context)
|
||||
.map_err(|_| fmt::Error)?;
|
||||
let context = std::str::from_utf8(context_data.data()).expect("Bad utf8 detected");
|
||||
let mut line = context_data.line();
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ impl Diagnostic for MyBad {
|
|||
vec![DiagnosticSnippet {
|
||||
message: Some(self.message.as_ref()),
|
||||
source: &self.src,
|
||||
context: &self.ctx,
|
||||
highlights: Some(vec![&self.highlight]),
|
||||
context: self.ctx.clone(),
|
||||
highlights: Some(vec![self.highlight.clone()]),
|
||||
}]
|
||||
.into_iter(),
|
||||
))
|
||||
|
|
|
|||
Loading…
Reference in New Issue