miden_utils_diagnostics/
lib.rs

1#![no_std]
2
3#[macro_use]
4extern crate alloc;
5
6#[cfg(feature = "std")]
7extern crate std;
8
9mod label;
10mod related;
11pub mod reporting;
12
13pub use miette::{
14    self, Diagnostic, IntoDiagnostic, LabeledSpan, NamedSource, Report, Result, Severity,
15    SourceCode, WrapErr,
16};
17pub use tracing;
18
19pub use self::{
20    label::Label,
21    related::{RelatedError, RelatedLabel},
22};
23
24#[macro_export]
25macro_rules! report {
26    ($($key:ident = $value:expr,)* $fmt:literal $($arg:tt)*) => {
27        $crate::Report::from(
28            $crate::diagnostic!($($key = $value,)* $fmt $($arg)*)
29        )
30    };
31}
32
33#[macro_export]
34macro_rules! diagnostic {
35    ($fmt:literal $($arg:tt)*) => {{
36        $crate::miette::MietteDiagnostic::new(format!($fmt $($arg)*))
37    }};
38    ($($key:ident = $value:expr,)+ $fmt:literal $($arg:tt)*) => {{
39        let mut diag = $crate::miette::MietteDiagnostic::new(format!($fmt $($arg)*));
40        $(diag.$key = Some($value.into());)*
41        diag
42    }};
43}