refactor(naga)!: diagnostic_filter: s/{from,to}_ident/{from,to}_wgsl_ident

This commit is contained in:
Erich Gubler 2024-11-05 09:18:21 -05:00
parent a2044aefe7
commit 66d2ac6f5d
3 changed files with 8 additions and 9 deletions

View File

@ -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<Self> {
pub fn from_wgsl_ident(s: &str) -> Option<Self> {
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<Self> {
pub fn from_wgsl_ident(s: &str) -> Option<Self> {
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,
}

View File

@ -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()),

View File

@ -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