From 82f9ca6da864de1478a8a06732a4b3841d869dcd Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Thu, 24 Oct 2024 15:33:44 -0400 Subject: [PATCH] chore(wgsl-in): remove unimplemented directive kinds --- naga/src/front/wgsl/error.rs | 23 ------------- naga/src/front/wgsl/parse/directive.rs | 47 ++------------------------ naga/src/front/wgsl/parse/mod.rs | 5 +-- 3 files changed, 3 insertions(+), 72 deletions(-) diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index c51f4c12f..f5e633208 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -5,7 +5,6 @@ use crate::front::wgsl::parse::directive::enable_extension::{ use crate::front::wgsl::parse::directive::language_extension::{ LanguageExtension, UnimplementedLanguageExtension, }; -use crate::front::wgsl::parse::directive::{DirectiveKind, UnimplementedDirectiveKind}; use crate::front::wgsl::parse::lexer::Token; use crate::front::wgsl::Scalar; use crate::proc::{Alignment, ConstantEvaluatorError, ResolveError}; @@ -278,10 +277,6 @@ pub(crate) enum Error<'a> { PipelineConstantIDValue(Span), NotBool(Span), ConstAssertFailed(Span), - DirectiveNotYetImplemented { - kind: UnimplementedDirectiveKind, - span: Span, - }, DirectiveAfterFirstGlobalDecl { directive_span: Span, }, @@ -932,24 +927,6 @@ impl<'a> Error<'a> { labels: vec![(span, "evaluates to false".into())], notes: vec![], }, - Error::DirectiveNotYetImplemented { kind, span } => ParseError { - message: format!( - "the `{}` directive is not yet implemented", - DirectiveKind::Unimplemented(kind).to_ident() - ), - labels: vec![( - span, - "this global directive is standard, but not yet implemented".into(), - )], - notes: vec![format!( - concat!( - "Let Naga maintainers know that you ran into this at ", - ", ", - "so they can prioritize it!" - ), - kind.tracking_issue_num() - )], - }, Error::DirectiveAfterFirstGlobalDecl { directive_span } => ParseError { message: "expected global declaration, but found a global directive".into(), labels: vec![( diff --git a/naga/src/front/wgsl/parse/directive.rs b/naga/src/front/wgsl/parse/directive.rs index 96069ca23..5302fff13 100644 --- a/naga/src/front/wgsl/parse/directive.rs +++ b/naga/src/front/wgsl/parse/directive.rs @@ -7,6 +7,7 @@ pub(crate) mod language_extension; /// A parsed sentinel word indicating the type of directive to be parsed next. #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] +#[cfg_attr(test, derive(strum::EnumIter))] pub(crate) enum DirectiveKind { /// A [`crate::diagnostic_filter`]. Diagnostic, @@ -14,7 +15,6 @@ pub(crate) enum DirectiveKind { Enable, /// A [`language_extension`]. Requires, - Unimplemented(UnimplementedDirectiveKind), } impl DirectiveKind { @@ -31,36 +31,6 @@ impl DirectiveKind { _ => return None, }) } - - /// Maps this [`DirectiveKind`] into the sentinel word associated with it in WGSL. - pub const fn to_ident(self) -> &'static str { - match self { - Self::Diagnostic => Self::DIAGNOSTIC, - Self::Enable => Self::ENABLE, - Self::Requires => Self::REQUIRES, - Self::Unimplemented(kind) => match kind {}, - } - } - - #[cfg(test)] - fn iter() -> impl Iterator { - use strum::IntoEnumIterator; - - [Self::Diagnostic, Self::Enable, Self::Requires] - .into_iter() - .chain(UnimplementedDirectiveKind::iter().map(Self::Unimplemented)) - } -} - -/// A [`DirectiveKind`] that is not yet implemented. See [`DirectiveKind::Unimplemented`]. -#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] -#[cfg_attr(test, derive(strum::EnumIter))] -pub(crate) enum UnimplementedDirectiveKind {} - -impl UnimplementedDirectiveKind { - pub const fn tracking_issue_num(self) -> u16 { - match self {} - } } impl crate::diagnostic_filter::Severity { @@ -83,19 +53,7 @@ mod test { use crate::front::wgsl::assert_parse_err; - use super::{DirectiveKind, UnimplementedDirectiveKind}; - - #[test] - #[allow(clippy::never_loop, unreachable_code, unused_variables)] - fn unimplemented_directives() { - for unsupported_shader in UnimplementedDirectiveKind::iter() { - let shader; - let expected_msg; - match unsupported_shader {}; - - assert_parse_err(shader, expected_msg); - } - } + use super::DirectiveKind; #[test] fn directive_after_global_decl() { @@ -142,7 +100,6 @@ error: expected global declaration, but found a global directive "; } - DirectiveKind::Unimplemented(kind) => match kind {}, } let shader = format!( diff --git a/naga/src/front/wgsl/parse/mod.rs b/naga/src/front/wgsl/parse/mod.rs index 379a8f2b8..4e674062b 100644 --- a/naga/src/front/wgsl/parse/mod.rs +++ b/naga/src/front/wgsl/parse/mod.rs @@ -2525,7 +2525,7 @@ impl Parser { let mut enable_extensions = EnableExtensions::empty(); // Parse directives. - while let Ok((ident, span)) = lexer.peek_ident_with_span() { + while let Ok((ident, _directive_ident_span)) = lexer.peek_ident_with_span() { if let Some(kind) = DirectiveKind::from_ident(ident) { self.push_rule_span(Rule::Directive, &mut lexer); let _ = lexer.next_ident_with_span().unwrap(); @@ -2574,9 +2574,6 @@ impl Parser { } })?; } - DirectiveKind::Unimplemented(kind) => { - return Err(Error::DirectiveNotYetImplemented { kind, span }) - } } self.pop_rule_span(&lexer); } else {