Skip to content

Commit 0c042cb

Browse files
chore(wgsl-in): remove unimplemented directive kinds
1 parent 8c13d8f commit 0c042cb

File tree

3 files changed

+3
-72
lines changed

3 files changed

+3
-72
lines changed

naga/src/front/wgsl/error.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::front::wgsl::parse::directive::enable_extension::{
55
use crate::front::wgsl::parse::directive::language_extension::{
66
LanguageExtension, UnimplementedLanguageExtension,
77
};
8-
use crate::front::wgsl::parse::directive::{DirectiveKind, UnimplementedDirectiveKind};
98
use crate::front::wgsl::parse::lexer::Token;
109
use crate::front::wgsl::Scalar;
1110
use crate::proc::{Alignment, ConstantEvaluatorError, ResolveError};
@@ -278,10 +277,6 @@ pub(crate) enum Error<'a> {
278277
PipelineConstantIDValue(Span),
279278
NotBool(Span),
280279
ConstAssertFailed(Span),
281-
DirectiveNotYetImplemented {
282-
kind: UnimplementedDirectiveKind,
283-
span: Span,
284-
},
285280
DirectiveAfterFirstGlobalDecl {
286281
directive_span: Span,
287282
},
@@ -932,24 +927,6 @@ impl<'a> Error<'a> {
932927
labels: vec![(span, "evaluates to false".into())],
933928
notes: vec![],
934929
},
935-
Error::DirectiveNotYetImplemented { kind, span } => ParseError {
936-
message: format!(
937-
"the `{}` directive is not yet implemented",
938-
DirectiveKind::Unimplemented(kind).to_ident()
939-
),
940-
labels: vec![(
941-
span,
942-
"this global directive is standard, but not yet implemented".into(),
943-
)],
944-
notes: vec![format!(
945-
concat!(
946-
"Let Naga maintainers know that you ran into this at ",
947-
"<https://github.com/gfx-rs/wgpu/issues/{}>, ",
948-
"so they can prioritize it!"
949-
),
950-
kind.tracking_issue_num()
951-
)],
952-
},
953930
Error::DirectiveAfterFirstGlobalDecl { directive_span } => ParseError {
954931
message: "expected global declaration, but found a global directive".into(),
955932
labels: vec![(

naga/src/front/wgsl/parse/directive.rs

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ pub(crate) mod language_extension;
77

88
/// A parsed sentinel word indicating the type of directive to be parsed next.
99
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
10+
#[cfg_attr(test, derive(strum::EnumIter))]
1011
pub(crate) enum DirectiveKind {
1112
/// A [`crate::diagnostic_filter`].
1213
Diagnostic,
1314
/// An [`enable_extension`].
1415
Enable,
1516
/// A [`language_extension`].
1617
Requires,
17-
Unimplemented(UnimplementedDirectiveKind),
1818
}
1919

2020
impl DirectiveKind {
@@ -31,36 +31,6 @@ impl DirectiveKind {
3131
_ => return None,
3232
})
3333
}
34-
35-
/// Maps this [`DirectiveKind`] into the sentinel word associated with it in WGSL.
36-
pub const fn to_ident(self) -> &'static str {
37-
match self {
38-
Self::Diagnostic => Self::DIAGNOSTIC,
39-
Self::Enable => Self::ENABLE,
40-
Self::Requires => Self::REQUIRES,
41-
Self::Unimplemented(kind) => match kind {},
42-
}
43-
}
44-
45-
#[cfg(test)]
46-
fn iter() -> impl Iterator<Item = Self> {
47-
use strum::IntoEnumIterator;
48-
49-
[Self::Diagnostic, Self::Enable, Self::Requires]
50-
.into_iter()
51-
.chain(UnimplementedDirectiveKind::iter().map(Self::Unimplemented))
52-
}
53-
}
54-
55-
/// A [`DirectiveKind`] that is not yet implemented. See [`DirectiveKind::Unimplemented`].
56-
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
57-
#[cfg_attr(test, derive(strum::EnumIter))]
58-
pub(crate) enum UnimplementedDirectiveKind {}
59-
60-
impl UnimplementedDirectiveKind {
61-
pub const fn tracking_issue_num(self) -> u16 {
62-
match self {}
63-
}
6434
}
6535

6636
impl crate::diagnostic_filter::Severity {
@@ -83,19 +53,7 @@ mod test {
8353

8454
use crate::front::wgsl::assert_parse_err;
8555

86-
use super::{DirectiveKind, UnimplementedDirectiveKind};
87-
88-
#[test]
89-
#[allow(clippy::never_loop, unreachable_code, unused_variables)]
90-
fn unimplemented_directives() {
91-
for unsupported_shader in UnimplementedDirectiveKind::iter() {
92-
let shader;
93-
let expected_msg;
94-
match unsupported_shader {};
95-
96-
assert_parse_err(shader, expected_msg);
97-
}
98-
}
56+
use super::DirectiveKind;
9957

10058
#[test]
10159
fn directive_after_global_decl() {
@@ -142,7 +100,6 @@ error: expected global declaration, but found a global directive
142100
143101
";
144102
}
145-
DirectiveKind::Unimplemented(kind) => match kind {},
146103
}
147104

148105
let shader = format!(

naga/src/front/wgsl/parse/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,7 @@ impl Parser {
25252525
let mut enable_extensions = EnableExtensions::empty();
25262526

25272527
// Parse directives.
2528-
while let Ok((ident, span)) = lexer.peek_ident_with_span() {
2528+
while let Ok((ident, _directive_ident_span)) = lexer.peek_ident_with_span() {
25292529
if let Some(kind) = DirectiveKind::from_ident(ident) {
25302530
self.push_rule_span(Rule::Directive, &mut lexer);
25312531
let _ = lexer.next_ident_with_span().unwrap();
@@ -2574,9 +2574,6 @@ impl Parser {
25742574
}
25752575
})?;
25762576
}
2577-
DirectiveKind::Unimplemented(kind) => {
2578-
return Err(Error::DirectiveNotYetImplemented { kind, span })
2579-
}
25802577
}
25812578
self.pop_rule_span(&lexer);
25822579
} else {

0 commit comments

Comments
 (0)