diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index 08c6dc2c5f..eeab34d47c 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -283,6 +283,10 @@ pub(crate) enum Error<'a> { kind: UnimplementedEnableExtension, span: Span, }, + EnableExtensionNotEnabled { + kind: EnableExtension, + span: Span, + }, } #[derive(Clone, Debug)] @@ -945,6 +949,33 @@ impl<'a> Error<'a> { kind.tracking_issue_num() )], }, + Error::EnableExtensionNotEnabled { kind, span } => ParseError { + message: format!("`{}` enable extension is not enabled", kind.to_ident()), + labels: vec![( + span, + format!( + concat!( + "the `{}` enable extension is needed for this functionality, ", + "but it is not currently enabled" + ), + kind.to_ident() + ) + .into(), + )], + notes: if let EnableExtension::Unimplemented(kind) = kind { + vec![format!( + concat!( + "This extension is not yet implemented. ", + "Let Naga maintainers know that you ran into this at ", + ", ", + "so they can prioritize it!" + ), + kind.tracking_issue_num() + )] + } else { + vec![] + }, + }, } } } diff --git a/naga/src/front/wgsl/parse/mod.rs b/naga/src/front/wgsl/parse/mod.rs index b1262dcc3a..ca35015943 100644 --- a/naga/src/front/wgsl/parse/mod.rs +++ b/naga/src/front/wgsl/parse/mod.rs @@ -1,5 +1,7 @@ use crate::front::wgsl::error::{Error, ExpectedToken}; -use crate::front::wgsl::parse::directive::enable_extension::{EnableExtension, EnableExtensions}; +use crate::front::wgsl::parse::directive::enable_extension::{ + EnableExtension, EnableExtensions, UnimplementedEnableExtension, +}; use crate::front::wgsl::parse::directive::DirectiveKind; use crate::front::wgsl::parse::lexer::{Lexer, Token}; use crate::front::wgsl::parse::number::Number; @@ -667,7 +669,15 @@ impl Parser { } (Token::Number(res), span) => { let _ = lexer.next(); - let num = res.map_err(|err| Error::BadNumber(span, err))?; + let num = res.map_err(|err| match err { + super::error::NumberError::UnimplementedF16 => { + Error::EnableExtensionNotEnabled { + kind: EnableExtension::Unimplemented(UnimplementedEnableExtension::F16), + span, + } + } + err => Error::BadNumber(span, err), + })?; ast::Expression::Literal(ast::Literal::Number(num)) } (Token::Word("RAY_FLAG_NONE"), _) => {