mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 14:23:32 +00:00
chore(wgsl-in): remove unimplemented directive kinds
This commit is contained in:
parent
8c13d8ff56
commit
82f9ca6da8
@ -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 ",
|
||||
"<https://github.com/gfx-rs/wgpu/issues/{}>, ",
|
||||
"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![(
|
||||
|
@ -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<Item = Self> {
|
||||
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!(
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user