Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions crates/spirv-std/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use core::num::NonZeroUsize;
/// # Safety
/// Implementing this trait on non-scalar types breaks assumptions of other unsafe code, and should
/// not be done.
pub unsafe trait Scalar:
VectorOrScalar<Scalar = Self> + Copy + Default + crate::sealed::Sealed
{
}
pub unsafe trait Scalar: VectorOrScalar<Scalar = Self> + crate::sealed::Sealed {}

macro_rules! impl_scalar {
($($ty:ty),+) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/spirv-std/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use glam::{Vec3Swizzles, Vec4Swizzles};
/// # Safety
/// Implementing this trait on non-scalar or non-vector types may break assumptions about other
/// unsafe code, and should not be done.
pub unsafe trait VectorOrScalar: Default {
pub unsafe trait VectorOrScalar: Copy + Default + Send + Sync + 'static {
/// Either the scalar component type of the vector or the scalar itself.
type Scalar: Scalar;

Expand Down
1 change: 1 addition & 0 deletions tests/ui/arch/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use spirv_std::{scalar::Scalar, vector::Vector, vector::VectorOrScalar};
/// Fortunately, this requirement isn't checked on generic structs, so we have a way to work around
/// it (for now at least)
#[repr(simd)]
#[derive(Copy, Clone, Debug)]
struct Vec2<T>(T, T);
unsafe impl<T: Scalar> VectorOrScalar for Vec2<T> {
type Scalar = T;
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/arch/all.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
warning: [Rust-GPU] temporarily re-allowing old-style `#[repr(simd)]` (with fields)
--> $DIR/all.rs:15:1
--> $DIR/all.rs:16:1
|
15 | struct Vec2<T>(T, T);
16 | struct Vec2<T>(T, T);
| ^^^^^^^^^^^^^^
|
= note: removed upstream by https://github.com/rust-lang/rust/pull/129403
Expand Down
1 change: 1 addition & 0 deletions tests/ui/arch/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use spirv_std::{scalar::Scalar, vector::Vector, vector::VectorOrScalar};
/// Fortunately, this requirement isn't checked on generic structs, so we have a way to work around
/// it (for now at least)
#[repr(simd)]
#[derive(Copy, Clone, Debug)]
struct Vec2<T>(T, T);
unsafe impl<T: Scalar> VectorOrScalar for Vec2<T> {
type Scalar = T;
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/arch/any.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
warning: [Rust-GPU] temporarily re-allowing old-style `#[repr(simd)]` (with fields)
--> $DIR/any.rs:15:1
--> $DIR/any.rs:16:1
|
15 | struct Vec2<T>(T, T);
16 | struct Vec2<T>(T, T);
| ^^^^^^^^^^^^^^
|
= note: removed upstream by https://github.com/rust-lang/rust/pull/129403
Expand Down