Skip to content

Commit 9f3c861

Browse files
committed
feat: add attributes from annotations for fn items
1 parent eb3f139 commit 9f3c861

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

bindgen/codegen/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,7 +3024,7 @@ impl Method {
30243024
let function = function_item.expect_function();
30253025
let times_seen = function.codegen(ctx, result, function_item);
30263026
let Some(times_seen) = times_seen else { return };
3027-
let signature_item = ctx.resolve_item(function.signature());
3027+
let signature_item: &Item = ctx.resolve_item(function.signature());
30283028
let mut name = match self.kind() {
30293029
MethodKind::Constructor => "new".into(),
30303030
MethodKind::Destructor => "destruct".into(),
@@ -3146,7 +3146,13 @@ impl Method {
31463146

31473147
let block = ctx.wrap_unsafe_ops(quote! ( #( #stmts );*));
31483148

3149-
let mut attrs = vec![attributes::inline()];
3149+
let mut attrs: Vec<proc_macro2::TokenStream> = vec![attributes::inline()];
3150+
attrs.extend(
3151+
function_item.annotations()
3152+
.attributes()
3153+
.iter()
3154+
.map(|s| s.parse().unwrap()),
3155+
);
31503156

31513157
let custom_attributes = ctx.options().all_callbacks(|cb| {
31523158
cb.add_attributes(&AttributeInfo {
@@ -4602,6 +4608,12 @@ impl CodeGenerator for Function {
46024608
}
46034609

46044610
let mut attributes = vec![];
4611+
attributes.extend(
4612+
item.annotations()
4613+
.attributes()
4614+
.iter()
4615+
.map(|s| s.parse().unwrap()),
4616+
);
46054617

46064618
let custom_attributes = ctx.options().all_callbacks(|cb| {
46074619
cb.add_attributes(&AttributeInfo {

0 commit comments

Comments
 (0)