rune/diagnostics/
runtime_warning.rsuse core::fmt;
use crate::Hash;
#[derive(Debug)]
pub struct RuntimeWarningDiagnostic {
pub(crate) ip: usize,
pub(crate) kind: RuntimeWarningDiagnosticKind,
}
impl RuntimeWarningDiagnostic {
pub fn ip(&self) -> usize {
self.ip
}
#[cfg(feature = "emit")]
#[allow(unused)]
pub(crate) fn kind(&self) -> &RuntimeWarningDiagnosticKind {
&self.kind
}
#[cfg(test)]
#[allow(unused)]
pub(crate) fn into_kind(self) -> RuntimeWarningDiagnosticKind {
self.kind
}
}
impl fmt::Display for RuntimeWarningDiagnostic {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.kind, f)
}
}
impl core::error::Error for RuntimeWarningDiagnostic {
#[inline]
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
None
}
}
#[derive(Debug)]
#[allow(missing_docs)]
#[non_exhaustive]
pub(crate) enum RuntimeWarningDiagnosticKind {
UsedDeprecated {
#[cfg_attr(not(feature = "emit"), allow(dead_code))]
hash: Hash,
},
}
impl fmt::Display for RuntimeWarningDiagnosticKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
RuntimeWarningDiagnosticKind::UsedDeprecated { .. } => {
write!(f, "Used deprecated function")
}
}
}
}