Skip to content

Commit 565db88

Browse files
committed
make vector and scalar traits also imply Copy
1 parent 9e874c3 commit 565db88

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

crates/spirv-std/src/scalar.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ use core::num::NonZeroUsize;
88
/// # Safety
99
/// Implementing this trait on non-scalar types breaks assumptions of other unsafe code, and should
1010
/// not be done.
11-
pub unsafe trait Scalar:
12-
VectorOrScalar<Scalar = Self> + Copy + Default + crate::sealed::Sealed
13-
{
14-
}
11+
pub unsafe trait Scalar: VectorOrScalar<Scalar = Self> + crate::sealed::Sealed {}
1512

1613
macro_rules! impl_scalar {
1714
($($ty:ty),+) => {

crates/spirv-std/src/vector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use glam::{Vec3Swizzles, Vec4Swizzles};
99
/// # Safety
1010
/// Implementing this trait on non-scalar or non-vector types may break assumptions about other
1111
/// unsafe code, and should not be done.
12-
pub unsafe trait VectorOrScalar: Default + Send + Sync + 'static {
12+
pub unsafe trait VectorOrScalar: Copy + Default + Send + Sync + 'static {
1313
/// Either the scalar component type of the vector or the scalar itself.
1414
type Scalar: Scalar;
1515

tests/ui/arch/all.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use spirv_std::{scalar::Scalar, vector::Vector, vector::VectorOrScalar};
1212
/// Fortunately, this requirement isn't checked on generic structs, so we have a way to work around
1313
/// it (for now at least)
1414
#[repr(simd)]
15+
#[derive(Copy, Clone, Debug)]
1516
struct Vec2<T>(T, T);
1617
unsafe impl<T: Scalar> VectorOrScalar for Vec2<T> {
1718
type Scalar = T;

tests/ui/arch/all.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
warning: [Rust-GPU] temporarily re-allowing old-style `#[repr(simd)]` (with fields)
2-
--> $DIR/all.rs:15:1
2+
--> $DIR/all.rs:16:1
33
|
4-
15 | struct Vec2<T>(T, T);
4+
16 | struct Vec2<T>(T, T);
55
| ^^^^^^^^^^^^^^
66
|
77
= note: removed upstream by https://github.com/rust-lang/rust/pull/129403

tests/ui/arch/any.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use spirv_std::{scalar::Scalar, vector::Vector, vector::VectorOrScalar};
1212
/// Fortunately, this requirement isn't checked on generic structs, so we have a way to work around
1313
/// it (for now at least)
1414
#[repr(simd)]
15+
#[derive(Copy, Clone, Debug)]
1516
struct Vec2<T>(T, T);
1617
unsafe impl<T: Scalar> VectorOrScalar for Vec2<T> {
1718
type Scalar = T;

tests/ui/arch/any.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
warning: [Rust-GPU] temporarily re-allowing old-style `#[repr(simd)]` (with fields)
2-
--> $DIR/any.rs:15:1
2+
--> $DIR/any.rs:16:1
33
|
4-
15 | struct Vec2<T>(T, T);
4+
16 | struct Vec2<T>(T, T);
55
| ^^^^^^^^^^^^^^
66
|
77
= note: removed upstream by https://github.com/rust-lang/rust/pull/129403

0 commit comments

Comments
 (0)