mirror of https://github.com/zkat/miette.git
parent
ea5fdaf562
commit
1d111e87ba
|
|
@ -69,7 +69,10 @@ impl Related {
|
|||
let rel = &self.0;
|
||||
Some(quote! {
|
||||
fn related<'a>(&'a self) -> std::option::Option<std::boxed::Box<dyn std::iter::Iterator<Item = &'a dyn miette::Diagnostic> + 'a>> {
|
||||
std::option::Option::Some(std::boxed::Box::new(self.#rel.iter().map(|x| -> &(dyn miette::Diagnostic) { &*x })))
|
||||
use ::core::borrow::Borrow;
|
||||
std::option::Option::Some(std::boxed::Box::new(
|
||||
self.#rel.iter().map(|x| -> &(dyn miette::Diagnostic) { &*x.borrow() })
|
||||
))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -727,3 +727,9 @@ impl AsRef<dyn Diagnostic> for Report {
|
|||
&**self
|
||||
}
|
||||
}
|
||||
|
||||
impl std::borrow::Borrow<dyn Diagnostic> for Report {
|
||||
fn borrow(&self) -> &(dyn Diagnostic + 'static) {
|
||||
self.as_ref()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use miette::{Diagnostic, Severity, SourceSpan};
|
||||
use miette::{Diagnostic, Report, Severity, SourceSpan};
|
||||
use thiserror::Error;
|
||||
|
||||
#[test]
|
||||
|
|
@ -32,6 +32,17 @@ fn related() {
|
|||
struct Baz;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn related_report() {
|
||||
#[derive(Error, Debug, Diagnostic)]
|
||||
#[error("welp")]
|
||||
#[diagnostic(code(foo::bar::baz))]
|
||||
struct Foo {
|
||||
#[related]
|
||||
related: Vec<Report>,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic_struct() {
|
||||
#[derive(Debug, Diagnostic, Error)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue