Skip to content

Commit baf8f5c

Browse files
committed
Add unit test to check which lifetime name is used in impls.
1 parent 3f0919f commit baf8f5c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

macro/src/tests.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,23 @@ fn test_struct_with_lifetime() {
137137
assert!(rs.contains("fn __f(arg0: ::cxx::UniquePtr<StructWithLifetime>) {"));
138138
assert!(rs.contains("impl<'a> self::Drop for super::StructWithLifetime<'a>"));
139139
}
140+
141+
#[test]
142+
fn test_original_lifetimes_used_in_impls() {
143+
let rs = bridge(quote! {
144+
mod ffi {
145+
struct Context<'sess> {
146+
session: &'sess str,
147+
}
148+
struct Server<'srv> {
149+
ctx: UniquePtr<Context<'srv>>,
150+
}
151+
struct Client<'clt> {
152+
ctx: UniquePtr<Context<'clt>>,
153+
}
154+
}
155+
});
156+
157+
// Verify if `'sess` vs `'clt` vs `'srv` lifetime name will be used in the generated code.
158+
assert!(rs.contains("impl<'sess> ::cxx::memory::UniquePtrTarget for Context<'sess> {"));
159+
}

0 commit comments

Comments
 (0)