Skip to content

Commit 3c678e2

Browse files
committed
Add failing test for lifetime problem.
1 parent 0dd3f63 commit 3c678e2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

integration-tests/tests/cpprefs_test.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,25 @@ fn test_method_call_const() {
107107
&[],
108108
)
109109
}
110+
111+
#[test]
112+
fn test_return_reference_cpprefs() {
113+
let cxx = indoc! {"
114+
const Bob& give_bob(const Bob& input_bob) {
115+
return input_bob;
116+
}
117+
"};
118+
let hdr = indoc! {"
119+
#include <cstdint>
120+
struct Bob {
121+
uint32_t a;
122+
uint32_t b;
123+
};
124+
const Bob& give_bob(const Bob& input_bob);
125+
"};
126+
let rs = quote! {
127+
let b = ffi::Bob { a: 3, b: 4 };
128+
assert_eq!(ffi::give_bob(&b).b, 4);
129+
};
130+
run_cpprefs_test(cxx, hdr, rs, &["give_bob"], &["Bob"]);
131+
}

0 commit comments

Comments
 (0)