mirror of
https://github.com/typst/typst
synced 2025-05-15 17:45:27 +08:00
improve identifier naming, remove error id
not gonna need error ids for now
This commit is contained in:
parent
1b5c6e8eb8
commit
afaa45e0e0
@ -122,7 +122,7 @@ macro_rules! __warning {
|
|||||||
) => {
|
) => {
|
||||||
$crate::diag::SourceDiagnostic::warning(
|
$crate::diag::SourceDiagnostic::warning(
|
||||||
$span,
|
$span,
|
||||||
std::option::Option::Some($crate::diag::WarnIdentifier::$id),
|
std::option::Option::Some($crate::diag::CompilerWarning::$id),
|
||||||
$crate::diag::eco_format!($fmt, $($arg),*),
|
$crate::diag::eco_format!($fmt, $($arg),*),
|
||||||
) $(.with_hint($crate::diag::eco_format!($hint, $($hint_arg),*)))*
|
) $(.with_hint($crate::diag::eco_format!($hint, $($hint_arg),*)))*
|
||||||
};
|
};
|
||||||
@ -195,7 +195,7 @@ impl SourceDiagnostic {
|
|||||||
/// Create a new, bare warning.
|
/// Create a new, bare warning.
|
||||||
pub fn warning(
|
pub fn warning(
|
||||||
span: Span,
|
span: Span,
|
||||||
identifier: Option<WarnIdentifier>,
|
identifier: Option<CompilerWarning>,
|
||||||
message: impl Into<EcoString>,
|
message: impl Into<EcoString>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -242,19 +242,14 @@ impl From<SyntaxError> for SourceDiagnostic {
|
|||||||
/// Any possible identifier for a diagnostic.
|
/// Any possible identifier for a diagnostic.
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
||||||
pub enum Identifier {
|
pub enum Identifier {
|
||||||
/// Identifier for a built-in compiler error.
|
|
||||||
Error(ErrorIdentifier),
|
|
||||||
/// Identifier for a built-in compiler warning.
|
/// Identifier for a built-in compiler warning.
|
||||||
Warn(WarnIdentifier),
|
Warn(CompilerWarning),
|
||||||
/// Identifier for a warning raised by a package.
|
/// Identifier for a warning raised by a package.
|
||||||
User(EcoString),
|
User(EcoString),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
||||||
pub enum ErrorIdentifier {}
|
pub enum CompilerWarning {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
|
||||||
pub enum WarnIdentifier {
|
|
||||||
UnnecessaryImportRenaming,
|
UnnecessaryImportRenaming,
|
||||||
UnnecessaryStars,
|
UnnecessaryStars,
|
||||||
UnnecessaryUnderscores,
|
UnnecessaryUnderscores,
|
||||||
@ -262,24 +257,24 @@ pub enum WarnIdentifier {
|
|||||||
UnknownFontFamilies,
|
UnknownFontFamilies,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WarnIdentifier {
|
impl CompilerWarning {
|
||||||
pub const fn name(&self) -> &'static str {
|
pub const fn name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
WarnIdentifier::UnnecessaryImportRenaming => "unnecessary-import-renaming",
|
CompilerWarning::UnnecessaryImportRenaming => "unnecessary-import-renaming",
|
||||||
WarnIdentifier::UnnecessaryStars => "unnecessary-stars",
|
CompilerWarning::UnnecessaryStars => "unnecessary-stars",
|
||||||
WarnIdentifier::UnnecessaryUnderscores => "unnecessary-underscores",
|
CompilerWarning::UnnecessaryUnderscores => "unnecessary-underscores",
|
||||||
WarnIdentifier::NonConvergingLayout => "non-converging-layout",
|
CompilerWarning::NonConvergingLayout => "non-converging-layout",
|
||||||
WarnIdentifier::UnknownFontFamilies => "unknown-font-families",
|
CompilerWarning::UnknownFontFamilies => "unknown-font-families",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn categories(&self) -> &'_ [&'static str] {
|
pub const fn categories(&self) -> &'_ [&'static str] {
|
||||||
match self {
|
match self {
|
||||||
WarnIdentifier::UnnecessaryImportRenaming => &["unnecessary", "syntax"],
|
CompilerWarning::UnnecessaryImportRenaming => &["unnecessary", "syntax"],
|
||||||
WarnIdentifier::UnnecessaryStars => &["unnecessary", "markup"],
|
CompilerWarning::UnnecessaryStars => &["unnecessary", "markup"],
|
||||||
WarnIdentifier::UnnecessaryUnderscores => &["unnecessary", "markup"],
|
CompilerWarning::UnnecessaryUnderscores => &["unnecessary", "markup"],
|
||||||
WarnIdentifier::NonConvergingLayout => &["layout"],
|
CompilerWarning::NonConvergingLayout => &["layout"],
|
||||||
WarnIdentifier::UnknownFontFamilies => &["fonts"],
|
CompilerWarning::UnknownFontFamilies => &["fonts"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,7 +285,6 @@ impl Identifier {
|
|||||||
match self {
|
match self {
|
||||||
Self::Warn(warning_identifier) => warning_identifier.name(),
|
Self::Warn(warning_identifier) => warning_identifier.name(),
|
||||||
Self::User(user_identifier) => user_identifier,
|
Self::User(user_identifier) => user_identifier,
|
||||||
Self::Error(_) => unreachable!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user