diff --git a/src/diag.rs b/src/diag.rs index e0cae9ac..e9fdd6a8 100644 --- a/src/diag.rs +++ b/src/diag.rs @@ -261,9 +261,10 @@ struct NodePrint { #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum DiagnosticCode { Advisory(crate::advisories::Code), - //Bans(crate::bans::Code), + Bans(crate::bans::Code), License(crate::licenses::Code), Source(crate::sources::Code), + General(general::Code), } impl DiagnosticCode { @@ -271,18 +272,20 @@ impl DiagnosticCode { use strum::IntoEnumIterator; crate::advisories::Code::iter() .map(Self::Advisory) - //.chain(crate::bans::Code::iter().map(Self::Bans)) + .chain(crate::bans::Code::iter().map(Self::Bans)) .chain(crate::licenses::Code::iter().map(Self::License)) .chain(crate::sources::Code::iter().map(Self::Source)) + .chain(general::Code::iter().map(Self::General)) } #[inline] pub fn as_str(self) -> &'static str { match self { Self::Advisory(code) => code.into(), - //Self::Bans(code) => code.into(), + Self::Bans(code) => code.into(), Self::License(code) => code.into(), Self::Source(code) => code.into(), + Self::General(code) => code.into(), } } } @@ -301,9 +304,10 @@ impl std::str::FromStr for DiagnosticCode { fn from_str(s: &str) -> Result { s.parse::() .map(Self::Advisory) - //.or_else(|_err| s.parse::().map(Self::Bans)) + .or_else(|_err| s.parse::().map(Self::Bans)) .or_else(|_err| s.parse::().map(Self::License)) .or_else(|_err| s.parse::().map(Self::Source)) + .or_else(|_err| s.parse::().map(Self::General)) } } @@ -319,5 +323,7 @@ mod test { panic!("existing code '{code}'"); } } + + insta::assert_debug_snapshot!(unique); } } diff --git a/src/snapshots/cargo_deny__diag__test__codes_unique.snap b/src/snapshots/cargo_deny__diag__test__codes_unique.snap new file mode 100644 index 00000000..54be5a0f --- /dev/null +++ b/src/snapshots/cargo_deny__diag__test__codes_unique.snap @@ -0,0 +1,62 @@ +--- +source: src/diag.rs +expression: unique +--- +{ + "accepted", + "advisory-ignored", + "advisory-not-detected", + "allowed", + "allowed-by-organization", + "allowed-by-wrapper", + "allowed-source", + "banned", + "build-script-not-allowed", + "checksum-match", + "checksum-mismatch", + "default-feature-enabled", + "denied-by-extension", + "deprecated", + "detected-executable", + "detected-executable-script", + "duplicate", + "exact-features-mismatch", + "feature-banned", + "feature-not-explicitly-allowed", + "features-enabled", + "git-source-underspecified", + "index-cache-load-failure", + "index-failure", + "license-exception-not-encountered", + "license-not-encountered", + "missing-clarification-file", + "not-allowed", + "notice", + "path-bypassed", + "path-bypassed-by-glob", + "rejected", + "skipped", + "skipped-by-root", + "skipped-private-workspace-crate", + "source-not-allowed", + "unable-to-check-path", + "unknown-advisory", + "unknown-feature", + "unlicensed", + "unmaintained", + "unmatched-bypass", + "unmatched-glob", + "unmatched-organization", + "unmatched-path-bypass", + "unmatched-skip", + "unmatched-skip-root", + "unmatched-source", + "unmatched-wrapper", + "unsound", + "unused-wrapper", + "vulnerability", + "wildcard", + "yanked", + "yanked-ignored", + "yanked-not-detected", +}