reflect: replace let_chains with Option::filter

This commit is contained in:
chyyran 2024-09-14 01:51:00 -04:00 committed by Ronny Chan
parent 3d9139b4e0
commit 8b2ff57ee8
3 changed files with 24 additions and 13 deletions

View file

@ -44,7 +44,6 @@
//! a pure-Rust shader compiler, as well as SPIRV-Cross via [SpirvCompilation](crate::front::SpirvCompilation) //! a pure-Rust shader compiler, as well as SPIRV-Cross via [SpirvCompilation](crate::front::SpirvCompilation)
//! is supported. //! is supported.
#![feature(impl_trait_in_assoc_type)] #![feature(impl_trait_in_assoc_type)]
#![feature(let_chains)]
#![allow(stable_features)] #![allow(stable_features)]
#![feature(c_str_literals)] #![feature(c_str_literals)]
/// Shader codegen backends. /// Shader codegen backends.

View file

@ -383,8 +383,10 @@ where
UniqueSemantics::FloatParameter => { UniqueSemantics::FloatParameter => {
let offset = range.offset; let offset = range.offset;
if let Some(meta) = meta.parameter_meta.get_mut::<str>(&name.as_ref()) { if let Some(meta) = meta.parameter_meta.get_mut::<str>(&name.as_ref()) {
if let Some(expected) = meta.offset.offset(offset_type) if let Some(expected) = meta
&& expected != offset .offset
.offset(offset_type)
.filter(|expected| *expected != offset)
{ {
return Err(ShaderReflectError::MismatchedOffset { return Err(ShaderReflectError::MismatchedOffset {
semantic: name.to_string(), semantic: name.to_string(),
@ -419,8 +421,10 @@ where
semantics => { semantics => {
let offset = range.offset; let offset = range.offset;
if let Some(meta) = meta.unique_meta.get_mut(semantics) { if let Some(meta) = meta.unique_meta.get_mut(semantics) {
if let Some(expected) = meta.offset.offset(offset_type) if let Some(expected) = meta
&& expected != offset .offset
.offset(offset_type)
.filter(|expected| *expected != offset)
{ {
return Err(ShaderReflectError::MismatchedOffset { return Err(ShaderReflectError::MismatchedOffset {
semantic: name.to_string(), semantic: name.to_string(),
@ -470,8 +474,10 @@ where
let offset = range.offset; let offset = range.offset;
if let Some(meta) = meta.texture_size_meta.get_mut(&texture) { if let Some(meta) = meta.texture_size_meta.get_mut(&texture) {
if let Some(expected) = meta.offset.offset(offset_type) if let Some(expected) = meta
&& expected != offset .offset
.offset(offset_type)
.filter(|expected| *expected != offset)
{ {
return Err(ShaderReflectError::MismatchedOffset { return Err(ShaderReflectError::MismatchedOffset {
semantic: name.to_string(), semantic: name.to_string(),

View file

@ -679,8 +679,10 @@ impl NagaReflect {
UniqueSemantics::FloatParameter => { UniqueSemantics::FloatParameter => {
let offset = member.offset; let offset = member.offset;
if let Some(meta) = meta.parameter_meta.get_mut::<str>(name.as_ref()) { if let Some(meta) = meta.parameter_meta.get_mut::<str>(name.as_ref()) {
if let Some(expected) = meta.offset.offset(offset_type) if let Some(expected) = meta
&& expected != offset as usize .offset
.offset(offset_type)
.filter(|expected| *expected != offset as usize)
{ {
return Err(ShaderReflectError::MismatchedOffset { return Err(ShaderReflectError::MismatchedOffset {
semantic: name, semantic: name,
@ -715,8 +717,10 @@ impl NagaReflect {
semantics => { semantics => {
let offset = member.offset; let offset = member.offset;
if let Some(meta) = meta.unique_meta.get_mut(semantics) { if let Some(meta) = meta.unique_meta.get_mut(semantics) {
if let Some(expected) = meta.offset.offset(offset_type) if let Some(expected) = meta
&& expected != offset as usize .offset
.offset(offset_type)
.filter(|expected| *expected != offset as usize)
{ {
return Err(ShaderReflectError::MismatchedOffset { return Err(ShaderReflectError::MismatchedOffset {
semantic: name, semantic: name,
@ -764,8 +768,10 @@ impl NagaReflect {
let offset = member.offset; let offset = member.offset;
if let Some(meta) = meta.texture_size_meta.get_mut(&texture) { if let Some(meta) = meta.texture_size_meta.get_mut(&texture) {
if let Some(expected) = meta.offset.offset(offset_type) if let Some(expected) = meta
&& expected != offset as usize .offset
.offset(offset_type)
.filter(|expected| *expected != offset as usize)
{ {
return Err(ShaderReflectError::MismatchedOffset { return Err(ShaderReflectError::MismatchedOffset {
semantic: name, semantic: name,