diff --git a/naga/src/diagnostic_filter.rs b/naga/src/diagnostic_filter.rs index 602953ca4..80d841214 100644 --- a/naga/src/diagnostic_filter.rs +++ b/naga/src/diagnostic_filter.rs @@ -33,7 +33,7 @@ impl Severity { const OFF: &'static str = "off"; /// Convert from a sentinel word in WGSL into its associated [`Severity`], if possible. - pub fn from_ident(s: &str) -> Option { + pub fn from_wgsl_ident(s: &str) -> Option { Some(match s { Self::ERROR => Self::Error, Self::WARNING => Self::Warning, @@ -82,7 +82,7 @@ impl FilterableTriggeringRule { const DERIVATIVE_UNIFORMITY: &'static str = "derivative_uniformity"; /// Convert from a sentinel word in WGSL into its associated [`FilterableTriggeringRule`], if possible. - pub fn from_ident(s: &str) -> Option { + pub fn from_wgsl_ident(s: &str) -> Option { Some(match s { Self::DERIVATIVE_UNIFORMITY => Self::DerivativeUniformity, _ => return None, @@ -90,7 +90,7 @@ impl FilterableTriggeringRule { } /// Maps this [`FilterableTriggeringRule`] into the sentinel word associated with it in WGSL. - pub const fn to_ident(self) -> &'static str { + pub const fn to_wgsl_ident(self) -> &'static str { match self { Self::DerivativeUniformity => Self::DERIVATIVE_UNIFORMITY, } diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index c3f104b2b..5b8303ac9 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -1028,7 +1028,7 @@ impl<'a> Error<'a> { ParseError { message: format!( "found conflicting `diagnostic(…)` rule(s) for `{}`", - triggering_rule.to_ident() + triggering_rule.to_wgsl_ident() ), labels: vec![ (first_span, "first rule".into()), diff --git a/naga/src/front/wgsl/parse/mod.rs b/naga/src/front/wgsl/parse/mod.rs index 06c501495..eb69c5fe4 100644 --- a/naga/src/front/wgsl/parse/mod.rs +++ b/naga/src/front/wgsl/parse/mod.rs @@ -2631,11 +2631,10 @@ impl Parser { lexer.expect(Token::Paren('('))?; let (severity_control_name, severity_control_name_span) = lexer.next_ident_with_span()?; - let new_severity = diagnostic_filter::Severity::from_ident(severity_control_name).ok_or( - Error::DiagnosticInvalidSeverity { + let new_severity = diagnostic_filter::Severity::from_wgsl_ident(severity_control_name) + .ok_or(Error::DiagnosticInvalidSeverity { severity_control_name_span, - }, - )?; + })?; lexer.expect(Token::Separator(','))?; @@ -2652,7 +2651,7 @@ impl Parser { let filter = diagnostic_rule_name .and_then(|name| { - FilterableTriggeringRule::from_ident(name) + FilterableTriggeringRule::from_wgsl_ident(name) .map(Ok) .or_else(|| { diagnostic_filter::Severity::Warning