Skip to content

Commit

Permalink
if let syn::parse::<ItemFn>
Browse files Browse the repository at this point in the history
  • Loading branch information
zanciks committed Nov 28, 2024
1 parent 6dc4bc7 commit a4304a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions crates/spirv-std/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,8 @@ pub fn spirv(attr: TokenStream, item: TokenStream) -> TokenStream {
let attr: proc_macro2::TokenStream = attr.into();
tokens.extend(quote! { #[cfg_attr(target_arch="spirv", rust_gpu::spirv(#attr))] });

if attr.to_string().trim() == "fragment" {
let item_clone = item.clone();
let input = syn::parse_macro_input!(item_clone as ItemFn);
if !matches!(input.vis, Visibility::Public(_)) {
if let Ok(item_fn) = syn::parse::<ItemFn>(item.clone()) {
if !matches!(item_fn.vis, Visibility::Public(_)) {
panic!("The `spirv` macro can only be applied to public functions.");
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/spirv-std/src/byte_addressable_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::mem;
// HACK(eddyb) try to prevent MIR inlining from breaking our intrinsics.
#[inline(never)]
#[spirv_std_macros::gpu_only]
unsafe fn buffer_load_intrinsic<T>(
pub unsafe fn buffer_load_intrinsic<T>(
buffer: &[u32],
// FIXME(eddyb) should be `usize`.
offset: u32,
Expand All @@ -26,7 +26,7 @@ unsafe fn buffer_load_intrinsic<T>(
// HACK(eddyb) try to prevent MIR inlining from breaking our intrinsics.
#[inline(never)]
#[spirv_std_macros::gpu_only]
unsafe fn buffer_store_intrinsic<T>(
pub unsafe fn buffer_store_intrinsic<T>(
buffer: &mut [u32],
// FIXME(eddyb) should be `usize`.
offset: u32,
Expand Down

0 comments on commit a4304a6

Please sign in to comment.