Preserve function abi in gpu_only macro (#617)

* Preserve function abi in gpu_only macro
This commit is contained in:
Markus Siglreithmaier 2021-05-17 12:21:52 +02:00 committed by GitHub
parent 943f09fef7
commit fc268da041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -160,16 +160,22 @@ pub fn gpu_only(_attr: TokenStream, item: TokenStream) -> TokenStream {
let fn_name = sig.ident.clone();
let sig = syn::Signature { abi: None, ..sig };
let sig_cpu = syn::Signature {
abi: None,
..sig.clone()
};
let output = quote::quote! {
// Don't warn on unused arguments on the CPU side.
#[cfg_attr(not(target_arch = "spirv"), allow(unused_variables))]
#[cfg(not(target_arch="spirv"))]
#[allow(unused_variables)]
#(#attrs)* #vis #sig_cpu {
unimplemented!(concat!("`", stringify!(#fn_name), "` is only available on SPIR-V platforms."))
}
#[cfg(target_arch="spirv")]
#(#attrs)* #vis #sig {
#[cfg(target_arch="spirv")] { #block }
#[cfg(not(target_arch="spirv"))] {
unimplemented!(concat!("`", stringify!(#fn_name), "` is only available on SPIR-V platforms."))
}
#block
}
};