Address/silence new clippy lints.

This commit is contained in:
Eduard-Mihai Burtescu 2023-07-25 23:40:10 +03:00 committed by Eduard-Mihai Burtescu
parent 50ebb52619
commit e87c324bfd
4 changed files with 40 additions and 28 deletions

View File

@ -619,35 +619,40 @@ impl<'tcx> BuilderSpirv<'tcx> {
Ok(()) Ok(())
} }
SpirvConst::Composite(v) => v.iter().fold(Ok(()), |composite_legal, field| { SpirvConst::Composite(v) => v
let field_entry = &self.id_to_const.borrow()[field]; .iter()
let field_legal_in_composite = field_entry.legal.and( .map(|field| {
// `field` is itself some legal `SpirvConst`, but can we have let field_entry = &self.id_to_const.borrow()[field];
// it as part of an `OpConstantComposite`? field_entry.legal.and(
match field_entry.val { // `field` is itself some legal `SpirvConst`, but can we have
SpirvConst::PtrTo { .. } => Err(IllegalConst::Shallow( // it as part of an `OpConstantComposite`?
LeafIllegalConst::CompositeContainsPtrTo, match field_entry.val {
)), SpirvConst::PtrTo { .. } => Err(IllegalConst::Shallow(
_ => Ok(()), LeafIllegalConst::CompositeContainsPtrTo,
}, )),
); _ => Ok(()),
},
)
})
.reduce(|a, b| {
match (a, b) {
(Ok(()), Ok(())) => Ok(()),
(Err(illegal), Ok(())) | (Ok(()), Err(illegal)) => Err(illegal),
match (composite_legal, field_legal_in_composite) { // Combining two causes of an illegal `SpirvConst` has to
(Ok(()), Ok(())) => Ok(()), // take into account which is "worse", i.e. which imposes
(Err(illegal), Ok(())) | (Ok(()), Err(illegal)) => Err(illegal), // more restrictions on how the resulting value can be used.
// `Indirect` is worse than `Shallow` because it cannot be
// Combining two causes of an illegal `SpirvConst` has to // materialized at runtime in the same way `Shallow` can be.
// take into account which is "worse", i.e. which imposes (Err(illegal @ IllegalConst::Indirect(_)), Err(_))
// more restrictions on how the resulting value can be used. | (Err(_), Err(illegal @ IllegalConst::Indirect(_)))
// `Indirect` is worse than `Shallow` because it cannot be | (
// materialized at runtime in the same way `Shallow` can be. Err(illegal @ IllegalConst::Shallow(_)),
(Err(illegal @ IllegalConst::Indirect(_)), Err(_)) Err(IllegalConst::Shallow(_)),
| (Err(_), Err(illegal @ IllegalConst::Indirect(_))) ) => Err(illegal),
| (Err(illegal @ IllegalConst::Shallow(_)), Err(IllegalConst::Shallow(_))) => {
Err(illegal)
} }
} })
}), .unwrap_or(Ok(())),
SpirvConst::PtrTo { pointee } => match self.id_to_const.borrow()[&pointee].legal { SpirvConst::PtrTo { pointee } => match self.id_to_const.borrow()[&pointee].legal {
Ok(()) => Ok(()), Ok(()) => Ok(()),

View File

@ -105,7 +105,7 @@ impl SpirvBuilder {
} }
} }
}); });
std::mem::forget(thread); std::mem::drop(thread);
Ok(first_result) Ok(first_result)
} }
} }

View File

@ -1,5 +1,8 @@
//! Types for handling memory ordering constraints for concurrent memory access. //! Types for handling memory ordering constraints for concurrent memory access.
// NOTE(eddyb) "&-masking with zero", likely due to `NONE = 0` in `bitflags!`.
#![allow(clippy::bad_bit_mask)]
/// Specification for how large of a scope some instructions should operate on - used when calling /// Specification for how large of a scope some instructions should operate on - used when calling
/// functions that take a configurable scope. /// functions that take a configurable scope.
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]

View File

@ -1,4 +1,8 @@
//! Ray-tracing data types //! Ray-tracing data types
// NOTE(eddyb) "&-masking with zero", likely due to `NONE = 0` in `bitflags!`.
#![allow(clippy::bad_bit_mask)]
use crate::vector::Vector; use crate::vector::Vector;
#[cfg(target_arch = "spirv")] #[cfg(target_arch = "spirv")]
use core::arch::asm; use core::arch::asm;