byteor_pipeline_lower/
error.rs1#[cfg(feature = "alloc")]
2use alloc::vec::Vec;
3
4#[cfg(feature = "alloc")]
5use crate::diagnostics::LowerDiagnosticV2;
6
7pub type Result<T> = core::result::Result<T, LowerError>;
9
10#[derive(Debug, Clone, PartialEq, Eq)]
12#[non_exhaustive]
13pub enum LowerError {
14 Invalid(&'static str),
16 Unsupported(&'static str),
18 #[cfg(feature = "alloc")]
20 DiagnosticsV2(Vec<LowerDiagnosticV2>),
21}
22
23impl core::fmt::Display for LowerError {
24 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
25 match self {
26 LowerError::Invalid(msg) => write!(f, "invalid lowering input: {msg}"),
27 LowerError::Unsupported(msg) => write!(f, "unsupported lowering input: {msg}"),
28 #[cfg(feature = "alloc")]
29 LowerError::DiagnosticsV2(diagnostics) => {
30 if let Some(LowerDiagnosticV2::Rejected { message, .. }) = diagnostics.first() {
31 write!(f, "invalid lowering input: {message}")
32 } else {
33 write!(f, "invalid lowering input: structured diagnostics available")
34 }
35 }
36 }
37 }
38}
39
40#[cfg(feature = "std")]
41impl std::error::Error for LowerError {}