From 66ba9a0a666bb9cc3181c1bcf08a52729d7a0084 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 4 Jul 2022 09:20:52 -0700 Subject: [PATCH] Preserve clippy attrs on extern "Rust" fn #[cxx::bridge] mod ffi { extern "Rust" { #[allow(clippy::too_many_arguments)] fn repro(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) -> bool; } } Before: warning: this function has too many arguments (8/7) --> src/main.rs:5:12 | 5 | fn repro(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) -> bool; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(clippy::too_many_arguments)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments After: no lint. --- macro/src/expand.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/macro/src/expand.rs b/macro/src/expand.rs index 8ca2c4af..7e93368b 100644 --- a/macro/src/expand.rs +++ b/macro/src/expand.rs @@ -787,6 +787,7 @@ fn expand_function_pointer_trampoline( prevent_unwind_label, None, Some(&efn.generics), + &efn.attrs, body_span, ); let var = &var.rust; @@ -937,6 +938,7 @@ fn expand_rust_function_shim(efn: &ExternFn, types: &Types) -> TokenStream { prevent_unwind_label, invoke, None, + &efn.attrs, body_span, ) } @@ -949,6 +951,7 @@ fn expand_rust_function_shim_impl( prevent_unwind_label: String, invoke: Option<&Ident>, outer_generics: Option<&Generics>, + attrs: &OtherAttrs, body_span: Span, ) -> TokenStream { let generics = outer_generics.unwrap_or(&sig.generics); @@ -1123,6 +1126,7 @@ fn expand_rust_function_shim_impl( }; quote_spanned! {span=> + #attrs #[doc(hidden)] #[export_name = #link_name] unsafe extern "C" fn #local_name #generics(#(#all_args,)* #outparam #pointer) #ret {