Skip to content

Commit e87c324

Browse files
committed
Address/silence new clippy lints.
1 parent 50ebb52 commit e87c324

File tree

4 files changed

+41
-29
lines changed

4 files changed

+41
-29
lines changed

crates/rustc_codegen_spirv/src/builder_spirv.rs

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -619,35 +619,40 @@ impl<'tcx> BuilderSpirv<'tcx> {
619619
Ok(())
620620
}
621621

622-
SpirvConst::Composite(v) => v.iter().fold(Ok(()), |composite_legal, field| {
623-
let field_entry = &self.id_to_const.borrow()[field];
624-
let field_legal_in_composite = field_entry.legal.and(
625-
// `field` is itself some legal `SpirvConst`, but can we have
626-
// it as part of an `OpConstantComposite`?
627-
match field_entry.val {
628-
SpirvConst::PtrTo { .. } => Err(IllegalConst::Shallow(
629-
LeafIllegalConst::CompositeContainsPtrTo,
630-
)),
631-
_ => Ok(()),
632-
},
633-
);
634-
635-
match (composite_legal, field_legal_in_composite) {
636-
(Ok(()), Ok(())) => Ok(()),
637-
(Err(illegal), Ok(())) | (Ok(()), Err(illegal)) => Err(illegal),
638-
639-
// Combining two causes of an illegal `SpirvConst` has to
640-
// take into account which is "worse", i.e. which imposes
641-
// more restrictions on how the resulting value can be used.
642-
// `Indirect` is worse than `Shallow` because it cannot be
643-
// materialized at runtime in the same way `Shallow` can be.
644-
(Err(illegal @ IllegalConst::Indirect(_)), Err(_))
645-
| (Err(_), Err(illegal @ IllegalConst::Indirect(_)))
646-
| (Err(illegal @ IllegalConst::Shallow(_)), Err(IllegalConst::Shallow(_))) => {
647-
Err(illegal)
622+
SpirvConst::Composite(v) => v
623+
.iter()
624+
.map(|field| {
625+
let field_entry = &self.id_to_const.borrow()[field];
626+
field_entry.legal.and(
627+
// `field` is itself some legal `SpirvConst`, but can we have
628+
// it as part of an `OpConstantComposite`?
629+
match field_entry.val {
630+
SpirvConst::PtrTo { .. } => Err(IllegalConst::Shallow(
631+
LeafIllegalConst::CompositeContainsPtrTo,
632+
)),
633+
_ => Ok(()),
634+
},
635+
)
636+
})
637+
.reduce(|a, b| {
638+
match (a, b) {
639+
(Ok(()), Ok(())) => Ok(()),
640+
(Err(illegal), Ok(())) | (Ok(()), Err(illegal)) => Err(illegal),
641+
642+
// Combining two causes of an illegal `SpirvConst` has to
643+
// take into account which is "worse", i.e. which imposes
644+
// more restrictions on how the resulting value can be used.
645+
// `Indirect` is worse than `Shallow` because it cannot be
646+
// materialized at runtime in the same way `Shallow` can be.
647+
(Err(illegal @ IllegalConst::Indirect(_)), Err(_))
648+
| (Err(_), Err(illegal @ IllegalConst::Indirect(_)))
649+
| (
650+
Err(illegal @ IllegalConst::Shallow(_)),
651+
Err(IllegalConst::Shallow(_)),
652+
) => Err(illegal),
648653
}
649-
}
650-
}),
654+
})
655+
.unwrap_or(Ok(())),
651656

652657
SpirvConst::PtrTo { pointee } => match self.id_to_const.borrow()[&pointee].legal {
653658
Ok(()) => Ok(()),

crates/spirv-builder/src/watch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl SpirvBuilder {
105105
}
106106
}
107107
});
108-
std::mem::forget(thread);
108+
std::mem::drop(thread);
109109
Ok(first_result)
110110
}
111111
}

crates/spirv-std/src/memory.rs

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

crates/spirv-std/src/ray_tracing.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
//! Ray-tracing data types
2+
3+
// NOTE(eddyb) "&-masking with zero", likely due to `NONE = 0` in `bitflags!`.
4+
#![allow(clippy::bad_bit_mask)]
5+
26
use crate::vector::Vector;
37
#[cfg(target_arch = "spirv")]
48
use core::arch::asm;

0 commit comments

Comments
 (0)