mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 14:23:32 +00:00
refactor(naga)!: diagnostic_filter
: s/{from,to}_ident/{from,to}_wgsl_ident
This commit is contained in:
parent
a2044aefe7
commit
66d2ac6f5d
@ -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,
|
||||
}
|
||||
|
@ -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()),
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user