mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +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";
|
const OFF: &'static str = "off";
|
||||||
|
|
||||||
/// Convert from a sentinel word in WGSL into its associated [`Severity`], if possible.
|
/// 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 {
|
Some(match s {
|
||||||
Self::ERROR => Self::Error,
|
Self::ERROR => Self::Error,
|
||||||
Self::WARNING => Self::Warning,
|
Self::WARNING => Self::Warning,
|
||||||
@ -82,7 +82,7 @@ impl FilterableTriggeringRule {
|
|||||||
const DERIVATIVE_UNIFORMITY: &'static str = "derivative_uniformity";
|
const DERIVATIVE_UNIFORMITY: &'static str = "derivative_uniformity";
|
||||||
|
|
||||||
/// Convert from a sentinel word in WGSL into its associated [`FilterableTriggeringRule`], if possible.
|
/// 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 {
|
Some(match s {
|
||||||
Self::DERIVATIVE_UNIFORMITY => Self::DerivativeUniformity,
|
Self::DERIVATIVE_UNIFORMITY => Self::DerivativeUniformity,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
@ -90,7 +90,7 @@ impl FilterableTriggeringRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Maps this [`FilterableTriggeringRule`] into the sentinel word associated with it in WGSL.
|
/// 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 {
|
match self {
|
||||||
Self::DerivativeUniformity => Self::DERIVATIVE_UNIFORMITY,
|
Self::DerivativeUniformity => Self::DERIVATIVE_UNIFORMITY,
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +1028,7 @@ impl<'a> Error<'a> {
|
|||||||
ParseError {
|
ParseError {
|
||||||
message: format!(
|
message: format!(
|
||||||
"found conflicting `diagnostic(…)` rule(s) for `{}`",
|
"found conflicting `diagnostic(…)` rule(s) for `{}`",
|
||||||
triggering_rule.to_ident()
|
triggering_rule.to_wgsl_ident()
|
||||||
),
|
),
|
||||||
labels: vec![
|
labels: vec![
|
||||||
(first_span, "first rule".into()),
|
(first_span, "first rule".into()),
|
||||||
|
@ -2631,11 +2631,10 @@ impl Parser {
|
|||||||
lexer.expect(Token::Paren('('))?;
|
lexer.expect(Token::Paren('('))?;
|
||||||
|
|
||||||
let (severity_control_name, severity_control_name_span) = lexer.next_ident_with_span()?;
|
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(
|
let new_severity = diagnostic_filter::Severity::from_wgsl_ident(severity_control_name)
|
||||||
Error::DiagnosticInvalidSeverity {
|
.ok_or(Error::DiagnosticInvalidSeverity {
|
||||||
severity_control_name_span,
|
severity_control_name_span,
|
||||||
},
|
})?;
|
||||||
)?;
|
|
||||||
|
|
||||||
lexer.expect(Token::Separator(','))?;
|
lexer.expect(Token::Separator(','))?;
|
||||||
|
|
||||||
@ -2652,7 +2651,7 @@ impl Parser {
|
|||||||
|
|
||||||
let filter = diagnostic_rule_name
|
let filter = diagnostic_rule_name
|
||||||
.and_then(|name| {
|
.and_then(|name| {
|
||||||
FilterableTriggeringRule::from_ident(name)
|
FilterableTriggeringRule::from_wgsl_ident(name)
|
||||||
.map(Ok)
|
.map(Ok)
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
diagnostic_filter::Severity::Warning
|
diagnostic_filter::Severity::Warning
|
||||||
|
Loading…
Reference in New Issue
Block a user