mirror of https://github.com/zkat/miette.git
parent
ea5fdaf562
commit
75d4505e7d
|
|
@ -69,7 +69,10 @@ impl Related {
|
||||||
let rel = &self.0;
|
let rel = &self.0;
|
||||||
Some(quote! {
|
Some(quote! {
|
||||||
fn related<'a>(&'a self) -> std::option::Option<std::boxed::Box<dyn std::iter::Iterator<Item = &'a dyn miette::Diagnostic> + 'a>> {
|
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
|
&**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;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -32,6 +32,17 @@ fn related() {
|
||||||
struct Baz;
|
struct Baz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn related_report() {
|
||||||
|
#[derive(Error, Debug, Diagnostic)]
|
||||||
|
#[error("welp")]
|
||||||
|
#[diagnostic(code(foo::bar::baz))]
|
||||||
|
struct Foo {
|
||||||
|
#[related]
|
||||||
|
related: Vec<Report>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_struct() {
|
fn basic_struct() {
|
||||||
#[derive(Debug, Diagnostic, Error)]
|
#[derive(Debug, Diagnostic, Error)]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue