#![allow(unused_assignments)]
use crate::Span;
use miette::Diagnostic;
use std::hash::Hash;
use thiserror::Error;
use crate::{ConfigWarning, ReportMode, Reportable};
#[derive(Clone, Debug, Error, Diagnostic)]
#[diagnostic(severity(Warning))]
pub enum ShellWarning {
#[error("{dep_type} deprecated.")]
#[diagnostic(code(nu::shell::deprecated))]
Deprecated {
dep_type: String,
label: String,
#[label("{label}")]
span: Span,
#[help]
help: Option<String>,
report_mode: ReportMode,
},
#[error("Encountered {} warnings(s) when updating config", warnings.len())]
#[diagnostic(code(nu::shell::invalid_config))]
InvalidConfig {
#[related]
warnings: Vec<ConfigWarning>,
},
}
impl Reportable for ShellWarning {
fn report_mode(&self) -> ReportMode {
match self {
ShellWarning::Deprecated { report_mode, .. } => *report_mode,
ShellWarning::InvalidConfig { .. } => ReportMode::FirstUse,
}
}
}
impl Hash for ShellWarning {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
match self {
ShellWarning::Deprecated {
dep_type, label, ..
} => {
dep_type.hash(state);
label.hash(state);
}
ShellWarning::InvalidConfig { .. } => (),
}
}
}