Skip to content

Commit

Permalink
make AtomicRefProxy safe
Browse files Browse the repository at this point in the history
  • Loading branch information
shiinamiyuki committed Oct 20, 2023
1 parent 7718128 commit edbe1b9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions luisa_compute/src/lang/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub trait VarProxy: Copy + 'static + Deref<Target = Expr<Self::Value>> {
fn from_var(expr: Var<Self::Value>) -> Self;
}

pub unsafe trait AtomicRefProxy: Copy + 'static {
pub trait AtomicRefProxy: Copy + 'static {
type Value: Value<AtomicRef = Self>;

fn as_atomic_ref_from_proxy(&self) -> &AtomicRef<Self::Value>;
Expand Down Expand Up @@ -405,7 +405,7 @@ macro_rules! impl_simple_atomic_ref_proxy {
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct $name $(< $($bounds)* >)? ($crate::lang::types::AtomicRef<$t>) $(where $($where_bounds)+)?;
unsafe impl $(< $($bounds)* >)? $crate::lang::types::AtomicRefProxy for $name $(< $($qualifiers)* >)? $(where $($where_bounds)+)? {
impl $(< $($bounds)* >)? $crate::lang::types::AtomicRefProxy for $name $(< $($qualifiers)* >)? $(where $($where_bounds)+)? {
type Value = $t;
fn from_atomic_ref(var: $crate::lang::types::AtomicRef<$t>) -> Self {
Self(var)
Expand Down
2 changes: 1 addition & 1 deletion luisa_compute/src/lang/types/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ macro_rules! vector_proxies {
_deref_proxy(self)
}
}
unsafe impl<T: VectorAlign<$N, VectorAtomicRef = $AtomicName<T>>> AtomicRefProxy for $AtomicName<T> {
impl<T: VectorAlign<$N, VectorAtomicRef = $AtomicName<T>>> AtomicRefProxy for $AtomicName<T> {
type Value = Vector<T, $N>;
#[allow(unused_assignments)]
fn from_atomic_ref(e:AtomicRef<Self::Value>) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion luisa_compute_derive_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ impl Compiler {
}
}
#[allow(unused_parens)]
unsafe impl #impl_generics #lang_path::types::AtomicRefProxy for #atomic_ref_proxy_name #ty_generics #where_clause {
impl #impl_generics #lang_path::types::AtomicRefProxy for #atomic_ref_proxy_name #ty_generics #where_clause {
type Value = #name #ty_generics;
fn from_atomic_ref(var: #lang_path::types::AtomicRef<#name #ty_generics>) -> Self {
use #lang_path::ToNode;
Expand Down

0 comments on commit edbe1b9

Please sign in to comment.