use std::fmt;
use std::sync::Arc;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum ProtoArtifactStage {
Dataflow,
Structure,
Hir,
}
impl fmt::Display for ProtoArtifactStage {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(match self {
Self::Dataflow => "dataflow",
Self::Structure => "structure",
Self::Hir => "hir",
})
}
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ProtoFailure {
pub proto: usize,
pub failed_stage: ProtoArtifactStage,
pub last_completed_stage: ProtoArtifactStage,
pub error: Arc<str>,
pub last_completed_dump: Arc<str>,
}
impl ProtoFailure {
pub(crate) fn diagnostic(&self) -> String {
format!(
"proto#{} failed during {}: {}\nlast completed stage: {}\n{}",
self.proto,
self.failed_stage,
self.error,
self.last_completed_stage,
self.last_completed_dump.trim_end(),
)
}
}