use cyrs_hir::HirSpan;
use smol_str::SmolStr;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum PlanLowerError {
UnresolvedName {
name: SmolStr,
span: HirSpan,
},
UndesugaredExpr {
kind: &'static str,
span: HirSpan,
},
EmptyPatternPart {
span: HirSpan,
},
}
impl std::fmt::Display for PlanLowerError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::UnresolvedName { name, .. } => write!(
f,
"cyrs-plan: unresolved variable `{name}` in HIR → Plan lowering; \
run name resolution (cy-b4b) before calling lower_statement"
),
Self::UndesugaredExpr { kind, .. } => write!(
f,
"cyrs-plan: un-desugared `{kind}` expression in HIR → Plan lowering; \
run cyrs_hir::desugar::desugar_statement (cy-mla) first"
),
Self::EmptyPatternPart { .. } => write!(
f,
"cyrs-plan: empty or malformed pattern part in HIR → Plan lowering; \
parser error-recovery produced a pattern the lowerer cannot walk \
(e.g. bare `MATCH`)"
),
}
}
}
impl std::error::Error for PlanLowerError {}