Skip to content

Commit 8fddd16

Browse files
committed
Allow multiple source lifetimes for BoxedRef
1 parent a5f313d commit 8fddd16

File tree

8 files changed

+102
-90
lines changed

8 files changed

+102
-90
lines changed

binding-generator/src/func.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,16 +466,16 @@ impl<'tu, 'ge> Func<'tu, 'ge> {
466466
if let Some(return_hint) = gen_env.settings.return_override.get(&mut self.matcher()) {
467467
out.set_type_hint(return_hint.clone());
468468
// if we're returning a BoxedRef then assign its mutability to the mutability of the borrowed argument
469-
if let Some((_, borrow_arg_name, _)) = return_hint.as_boxed_as_ref() {
470-
let borrow_arg_constness = if borrow_arg_name == ARG_OVERRIDE_SELF {
469+
if let Some((_, borrow_arg_names, _)) = return_hint.as_boxed_as_ref() {
470+
let borrow_arg_constness = if borrow_arg_names.contains(&ARG_OVERRIDE_SELF) {
471471
self.constness()
472472
} else {
473473
self
474474
.arguments()
475475
.iter()
476-
.find(|arg| arg.cpp_name(CppNameStyle::Declaration) == *borrow_arg_name)
476+
.find(|arg| borrow_arg_names.contains(&arg.cpp_name(CppNameStyle::Declaration).as_ref()))
477477
.map(|arg| arg.type_ref().constness())
478-
.unwrap_or_else(|| panic!("BoxedAsRef refers to the non-existent argument name: {borrow_arg_name}"))
478+
.unwrap_or_else(|| panic!("BoxedAsRef refers to the non-existent argument names: {borrow_arg_names:?}"))
479479
};
480480
out.set_inherent_constness(borrow_arg_constness);
481481
}

binding-generator/src/func/func_matcher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ mod test {
236236
],
237237
TypeRefDesc::cv_input_array()
238238
.with_inherent_constness(Constness::Const)
239-
.with_type_hint(TypeRefTypeHint::BoxedAsRef(Constness::Const, "vec", Lifetime::Elided)),
239+
.with_type_hint(TypeRefTypeHint::BoxedAsRef(Constness::Const, &["vec"], Lifetime::Elided)),
240240
)
241241
.rust_custom_leafname("from_byte_slice"),
242242
);
@@ -314,7 +314,7 @@ mod test {
314314
],
315315
TypeRefDesc::cv_input_array()
316316
.with_inherent_constness(Constness::Const)
317-
.with_type_hint(TypeRefTypeHint::BoxedAsRef(Constness::Const, "vec", Lifetime::Elided)),
317+
.with_type_hint(TypeRefTypeHint::BoxedAsRef(Constness::Const, &["vec"], Lifetime::Elided)),
318318
)
319319
.rust_custom_leafname("from_byte_slice"),
320320
);

0 commit comments

Comments
 (0)