Skip to content

Commit

Permalink
Address/silence new clippy lints.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Aug 1, 2023
1 parent 50ebb52 commit e87c324
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 29 deletions.
61 changes: 33 additions & 28 deletions crates/rustc_codegen_spirv/src/builder_spirv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,35 +619,40 @@ impl<'tcx> BuilderSpirv<'tcx> {
Ok(())
}

SpirvConst::Composite(v) => v.iter().fold(Ok(()), |composite_legal, field| {
let field_entry = &self.id_to_const.borrow()[field];
let field_legal_in_composite = field_entry.legal.and(
// `field` is itself some legal `SpirvConst`, but can we have
// it as part of an `OpConstantComposite`?
match field_entry.val {
SpirvConst::PtrTo { .. } => Err(IllegalConst::Shallow(
LeafIllegalConst::CompositeContainsPtrTo,
)),
_ => Ok(()),
},
);

match (composite_legal, field_legal_in_composite) {
(Ok(()), Ok(())) => Ok(()),
(Err(illegal), Ok(())) | (Ok(()), Err(illegal)) => Err(illegal),

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

// Combining two causes of an illegal `SpirvConst` has to
// take into account which is "worse", i.e. which imposes
// more restrictions on how the resulting value can be used.
// `Indirect` is worse than `Shallow` because it cannot be
// materialized at runtime in the same way `Shallow` can be.
(Err(illegal @ IllegalConst::Indirect(_)), Err(_))
| (Err(_), Err(illegal @ IllegalConst::Indirect(_)))
| (
Err(illegal @ IllegalConst::Shallow(_)),
Err(IllegalConst::Shallow(_)),
) => Err(illegal),
}
}
}),
})
.unwrap_or(Ok(())),

SpirvConst::PtrTo { pointee } => match self.id_to_const.borrow()[&pointee].legal {
Ok(()) => Ok(()),
Expand Down
2 changes: 1 addition & 1 deletion crates/spirv-builder/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl SpirvBuilder {
}
}
});
std::mem::forget(thread);
std::mem::drop(thread);
Ok(first_result)
}
}
3 changes: 3 additions & 0 deletions crates/spirv-std/src/memory.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! 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
/// functions that take a configurable scope.
#[derive(Debug, PartialEq, Eq)]
Expand Down
4 changes: 4 additions & 0 deletions crates/spirv-std/src/ray_tracing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
//! 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;
#[cfg(target_arch = "spirv")]
use core::arch::asm;
Expand Down

0 comments on commit e87c324

Please sign in to comment.