mirror of https://github.com/zkat/miette.git
`miette_diagnostic!` -> `diagnostic!`
This commit is contained in:
parent
e35a63a992
commit
4148552cf0
|
|
@ -209,7 +209,7 @@ macro_rules! miette {
|
||||||
(&error).miette_kind().new(error)
|
(&error).miette_kind().new(error)
|
||||||
});
|
});
|
||||||
($fmt:expr $(, $key:ident = $value:expr)* $(,)?) => {
|
($fmt:expr $(, $key:ident = $value:expr)* $(,)?) => {
|
||||||
$crate::Report::from($crate::miette_diagnostic!($fmt, $($key = $value,)*))
|
$crate::Report::from($crate::diagnostic!($fmt, $($key = $value,)*))
|
||||||
};
|
};
|
||||||
($fmt:expr, $($arg:tt)*) => {
|
($fmt:expr, $($arg:tt)*) => {
|
||||||
$crate::private::new_adhoc(format!($fmt, $($arg)*))
|
$crate::private::new_adhoc(format!($fmt, $($arg)*))
|
||||||
|
|
@ -220,10 +220,10 @@ macro_rules! miette {
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use miette::{miette_diagnostic, LabeledSpan, Severity};
|
/// use miette::{diagnostic, LabeledSpan, Severity};
|
||||||
///
|
///
|
||||||
/// let source = "(2 + 2".to_string();
|
/// let source = "(2 + 2".to_string();
|
||||||
/// let diag = miette_diagnostic!(
|
/// let diag = diagnostic!(
|
||||||
/// "expected closing ')'",
|
/// "expected closing ')'",
|
||||||
/// // Those fields are optional
|
/// // Those fields are optional
|
||||||
/// severity = Severity::Error,
|
/// severity = Severity::Error,
|
||||||
|
|
@ -234,7 +234,7 @@ macro_rules! miette {
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! miette_diagnostic {
|
macro_rules! diagnostic {
|
||||||
($fmt:expr $(, $key:ident = $value:expr)* $(,)?) => {{
|
($fmt:expr $(, $key:ident = $value:expr)* $(,)?) => {{
|
||||||
let mut diag = $crate::MietteDiagnostic::new(format!("{}", $fmt));
|
let mut diag = $crate::MietteDiagnostic::new(format!("{}", $fmt));
|
||||||
$(diag.$key = Some($value.into());)*
|
$(diag.$key = Some($value.into());)*
|
||||||
|
|
|
||||||
|
|
@ -596,7 +596,7 @@
|
||||||
//! If you...
|
//! If you...
|
||||||
//! - ...don't know all the possible errors upfront
|
//! - ...don't know all the possible errors upfront
|
||||||
//! - ...need to serialize/deserialize errors
|
//! - ...need to serialize/deserialize errors
|
||||||
//! then you may want to use [`miette!`], [`miette_diagnostic!`] macros or
|
//! then you may want to use [`miette!`], [`diagnostic!`] macros or
|
||||||
//! [`MietteDiagnostic`] directly to create diagnostic on the fly.
|
//! [`MietteDiagnostic`] directly to create diagnostic on the fly.
|
||||||
//!
|
//!
|
||||||
//! ```rs
|
//! ```rs
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue