From eec6a3a0d1475941064447ab0aee42658b068462 Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Wed, 26 Jun 2024 12:37:53 -0300 Subject: [PATCH] diag ids: remove categories, improve docs --- crates/typst/src/diag.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/crates/typst/src/diag.rs b/crates/typst/src/diag.rs index 6277b9912..7baedae1d 100644 --- a/crates/typst/src/diag.rs +++ b/crates/typst/src/diag.rs @@ -239,7 +239,7 @@ impl From for SourceDiagnostic { } } -/// Any possible identifier for a diagnostic. +/// The identifier of a [`SourceDiagnostic`]. #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum Identifier { /// Identifier for a built-in compiler warning. @@ -248,6 +248,7 @@ pub enum Identifier { User(EcoString), } +/// Built-in compiler warnings. #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum CompilerWarning { UnnecessaryImportRenaming, @@ -258,6 +259,8 @@ pub enum CompilerWarning { } impl CompilerWarning { + /// The name of the warning as a string, following the format of diagnostic + /// identifiers. pub const fn name(&self) -> &'static str { match self { CompilerWarning::UnnecessaryImportRenaming => "unnecessary-import-renaming", @@ -267,16 +270,6 @@ impl CompilerWarning { CompilerWarning::UnknownFontFamilies => "unknown-font-families", } } - - pub const fn categories(&self) -> &'_ [&'static str] { - match self { - CompilerWarning::UnnecessaryImportRenaming => &["unnecessary", "syntax"], - CompilerWarning::UnnecessaryStars => &["unnecessary", "markup"], - CompilerWarning::UnnecessaryUnderscores => &["unnecessary", "markup"], - CompilerWarning::NonConvergingLayout => &["layout"], - CompilerWarning::UnknownFontFamilies => &["fonts"], - } - } } impl Identifier {