Skip to content

Commit f6cab80

Browse files
committed
Support for parsing modules with inner attributes
1 parent a7898a2 commit f6cab80

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

gen/src/file.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ fn parse(input: ParseStream, modules: &mut Vec<Module>) -> Result<()> {
2121
while !input.is_empty() {
2222
let mut cxx_bridge = false;
2323
let mut namespace = Namespace::ROOT;
24+
let inner_attrs = input.call(Attribute::parse_inner)?;
2425
let mut attrs = input.call(Attribute::parse_outer)?;
26+
attrs.extend(inner_attrs);
2527
for attr in &attrs {
2628
let path = &attr.path().segments;
2729
if path.len() == 2 && path[0].ident == "cxx" && path[1].ident == "bridge" {

tests/ffi/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ mod other {
394394
}
395395
}
396396

397+
pub mod test_for_inner_attrs {
398+
#![allow(dead_code)]
399+
pub fn may_not_be_called() {}
400+
}
401+
397402
#[derive(PartialEq, Debug)]
398403
pub struct R(pub usize);
399404

tests/test.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use cxx::{SharedPtr, UniquePtr};
1515
use cxx_test_suite::module::ffi2;
16-
use cxx_test_suite::{cast, ffi, R};
16+
use cxx_test_suite::{cast, ffi, test_for_inner_attrs, R};
1717
use std::cell::Cell;
1818
use std::ffi::CStr;
1919
use std::panic::{self, RefUnwindSafe, UnwindSafe};
@@ -395,3 +395,8 @@ fn test_unwind_safe() {
395395
fn require_ref_unwind_safe<T: RefUnwindSafe>() {}
396396
require_ref_unwind_safe::<ffi::C>();
397397
}
398+
399+
#[test]
400+
fn test_inner_attrs() {
401+
test_for_inner_attrs::may_not_be_called();
402+
}

0 commit comments

Comments
 (0)