Implement `!Unpin` move constructors.
This very nearly is as simple as just adding && to the IR. The other necessary change was to
use `std::forward` to propagate rvalue references in thunks. (Thanks sbenza@ for giving me the exact form that
would also work for non-reference types! I was about to write my own forward function...)
(The remaining changes are just goldens/tests.)
However, a followup CL is needed to make move constructors actually usable for `Unpin` types -- they can't just call `From<RvalueReference>` because they can't create an `RvalueReference`.
Similarly, while this creates bindings for functions that take or return rvalue reference parameters, they aren't as useful as they could be.
PiperOrigin-RevId: 437970361
diff --git a/rs_bindings_from_cc/importer.cc b/rs_bindings_from_cc/importer.cc
index 7933fa7..89ec891 100644
--- a/rs_bindings_from_cc/importer.cc
+++ b/rs_bindings_from_cc/importer.cc
@@ -916,7 +916,8 @@
if (auto maybe_mapped_type = MapKnownCcTypeToRsType(type_string);
maybe_mapped_type.has_value()) {
return MappedType::Simple(std::string(*maybe_mapped_type), type_string);
- } else if (type->isPointerType() || type->isLValueReferenceType()) {
+ } else if (type->isPointerType() || type->isLValueReferenceType() ||
+ type->isRValueReferenceType()) {
clang::QualType pointee_type = type->getPointeeType();
std::optional<LifetimeId> lifetime;
if (lifetimes.has_value()) {
@@ -967,10 +968,17 @@
if (type->isPointerType()) {
return MappedType::PointerTo(std::move(mapped_pointee_type), lifetime,
nullable);
- } else {
- CRUBIT_CHECK(type->isLValueReferenceType());
+ } else if (type->isLValueReferenceType()) {
return MappedType::LValueReferenceTo(std::move(mapped_pointee_type),
lifetime);
+ } else {
+ CRUBIT_CHECK(type->isRValueReferenceType());
+ if (!lifetime.has_value()) {
+ return absl::UnimplementedError(
+ "Unsupported type: && without lifetime");
+ }
+ return MappedType::RValueReferenceTo(std::move(mapped_pointee_type),
+ *lifetime);
}
} else if (const auto* builtin_type =
// Use getAsAdjusted instead of getAs so we don't desugar
diff --git a/rs_bindings_from_cc/ir.cc b/rs_bindings_from_cc/ir.cc
index 8b22e49..ee3ea5a 100644
--- a/rs_bindings_from_cc/ir.cc
+++ b/rs_bindings_from_cc/ir.cc
@@ -69,18 +69,28 @@
};
}
-static MappedType PointerOrReferenceTo(MappedType pointee_type,
- absl::string_view cc_ptr_name,
- std::optional<LifetimeId> lifetime,
- bool nullable) {
+namespace {
+enum class ValueCategory { kLvalue, kRvalue };
+
+MappedType PointerOrReferenceTo(MappedType pointee_type,
+ absl::string_view cc_ptr_name,
+ ValueCategory value_category,
+ std::optional<LifetimeId> lifetime,
+ bool nullable) {
bool has_lifetime = lifetime.has_value();
absl::string_view rs_name;
- if (has_lifetime) {
- rs_name = pointee_type.cc_type.is_const ? internal::kRustRefConst
- : internal::kRustRefMut;
+ if (value_category == ValueCategory::kLvalue) {
+ if (has_lifetime) {
+ rs_name = pointee_type.cc_type.is_const ? internal::kRustRefConst
+ : internal::kRustRefMut;
+ } else {
+ rs_name = pointee_type.cc_type.is_const ? internal::kRustPtrConst
+ : internal::kRustPtrMut;
+ }
} else {
- rs_name = pointee_type.cc_type.is_const ? internal::kRustPtrConst
- : internal::kRustPtrMut;
+ CRUBIT_CHECK(has_lifetime);
+ rs_name = pointee_type.cc_type.is_const ? internal::kRustRvalueRefConst
+ : internal::kRustRvalueRefMut;
}
auto pointer_type =
MappedType::Simple(std::string(rs_name), std::string(cc_ptr_name));
@@ -95,18 +105,27 @@
pointer_type.cc_type.type_args.push_back(std::move(pointee_type.cc_type));
return pointer_type;
}
+} // namespace
MappedType MappedType::PointerTo(MappedType pointee_type,
std::optional<LifetimeId> lifetime,
bool nullable) {
return PointerOrReferenceTo(std::move(pointee_type), internal::kCcPtr,
- lifetime, nullable);
+ ValueCategory::kLvalue, lifetime, nullable);
}
MappedType MappedType::LValueReferenceTo(MappedType pointee_type,
std::optional<LifetimeId> lifetime) {
return PointerOrReferenceTo(std::move(pointee_type), internal::kCcLValueRef,
- lifetime, /*nullable=*/false);
+ ValueCategory::kLvalue, lifetime,
+ /*nullable=*/false);
+}
+
+MappedType MappedType::RValueReferenceTo(MappedType pointee_type,
+ LifetimeId lifetime) {
+ return PointerOrReferenceTo(std::move(pointee_type), internal::kCcRValueRef,
+ ValueCategory::kRvalue, lifetime,
+ /*nullable=*/false);
}
MappedType MappedType::FuncPtr(absl::string_view cc_call_conv,
diff --git a/rs_bindings_from_cc/ir.h b/rs_bindings_from_cc/ir.h
index 7029caa..d95bfc4 100644
--- a/rs_bindings_from_cc/ir.h
+++ b/rs_bindings_from_cc/ir.h
@@ -33,14 +33,26 @@
namespace rs_bindings_from_cc {
namespace internal {
+// Pointers and LValue references.
inline constexpr absl::string_view kRustPtrMut = "*mut";
inline constexpr absl::string_view kRustPtrConst = "*const";
inline constexpr absl::string_view kRustRefMut = "&mut";
inline constexpr absl::string_view kRustRefConst = "&";
+
+// RValue References
+inline constexpr absl::string_view kRustRvalueRefMut = "#RvalueReference mut";
+inline constexpr absl::string_view kRustRvalueRefConst =
+ "#RvalueReference const";
+
+// Function pointers.
inline constexpr absl::string_view kRustFuncPtr = "#funcPtr";
+
+// C++ types therein.
inline constexpr absl::string_view kCcPtr = "*";
inline constexpr absl::string_view kCcLValueRef = "&";
+inline constexpr absl::string_view kCcRValueRef = "&&";
inline constexpr absl::string_view kCcFuncValue = "#funcValue";
+
inline constexpr int kJsonIndent = 2;
} // namespace internal
@@ -206,6 +218,15 @@
static MappedType LValueReferenceTo(MappedType pointee_type,
std::optional<LifetimeId> lifetime);
+ // Creates an Rvalue Reference mapped type.
+ //
+ // Note: we don't currently support rvalue references that do not have a
+ // lifetime. (Such a thing would require an "Rvalue Pointer" type -- probably
+ // spelled `Move<*mut T>` in Rust, although that doesn't work today due to
+ // the `P: DerefMut` bound in `Move<P>`.)
+ static MappedType RValueReferenceTo(MappedType pointee_type,
+ LifetimeId lifetime);
+
static MappedType FuncPtr(absl::string_view cc_call_conv,
absl::string_view rs_abi,
std::optional<LifetimeId> lifetime,
diff --git a/rs_bindings_from_cc/src_code_gen.rs b/rs_bindings_from_cc/src_code_gen.rs
index 4fdbad1..48ee478 100644
--- a/rs_bindings_from_cc/src_code_gen.rs
+++ b/rs_bindings_from_cc/src_code_gen.rs
@@ -460,7 +460,6 @@
format_first_param_as_self = false;
}
2 => {
- // TODO(lukasza): Do something smart with move constructor.
if param_type_kinds[1].is_shared_ref_to(record) {
// Copy constructor
if should_derive_clone(record) {
@@ -576,6 +575,7 @@
// here.
let func_body = match &impl_kind {
ImplKind::Trait { trait_name: TraitName::CtorNew(..), .. } => {
+ // TODO(b/226447239): check for copy here and instead use copies in that case?
quote! {
ctor::FnCtor::new(move |dest: std::pin::Pin<&mut std::mem::MaybeUninit<Self>>| {
unsafe {
@@ -1339,13 +1339,35 @@
// references (e.g. &'ir Record`) instead of ItemIds.
#[derive(Debug)]
enum RsTypeKind<'ir> {
- Pointer { pointee: Box<RsTypeKind<'ir>>, mutability: Mutability },
- Reference { referent: Box<RsTypeKind<'ir>>, mutability: Mutability, lifetime_id: LifetimeId },
- FuncPtr { abi: &'ir str, return_type: Box<RsTypeKind<'ir>>, param_types: Vec<RsTypeKind<'ir>> },
+ Pointer {
+ pointee: Box<RsTypeKind<'ir>>,
+ mutability: Mutability,
+ },
+ Reference {
+ referent: Box<RsTypeKind<'ir>>,
+ mutability: Mutability,
+ lifetime_id: LifetimeId,
+ },
+ RvalueReference {
+ referent: Box<RsTypeKind<'ir>>,
+ mutability: Mutability,
+ lifetime_id: LifetimeId,
+ },
+ FuncPtr {
+ abi: &'ir str,
+ return_type: Box<RsTypeKind<'ir>>,
+ param_types: Vec<RsTypeKind<'ir>>,
+ },
Record(&'ir Record),
- TypeAlias { type_alias: &'ir TypeAlias, underlying_type: Box<RsTypeKind<'ir>> },
+ TypeAlias {
+ type_alias: &'ir TypeAlias,
+ underlying_type: Box<RsTypeKind<'ir>>,
+ },
Unit,
- Other { name: &'ir str, type_args: Vec<RsTypeKind<'ir>> },
+ Other {
+ name: &'ir str,
+ type_args: Vec<RsTypeKind<'ir>>,
+ },
}
impl<'ir> RsTypeKind<'ir> {
@@ -1409,6 +1431,16 @@
mutability: Mutability::Const,
lifetime_id: get_lifetime()?,
},
+ "#RvalueReference mut" => RsTypeKind::RvalueReference {
+ referent: get_pointee()?,
+ mutability: Mutability::Mut,
+ lifetime_id: get_lifetime()?,
+ },
+ "#RvalueReference const" => RsTypeKind::RvalueReference {
+ referent: get_pointee()?,
+ mutability: Mutability::Const,
+ lifetime_id: get_lifetime()?,
+ },
name => {
let mut type_args = get_type_args()?;
match name.strip_prefix("#funcPtr ") {
@@ -1463,6 +1495,16 @@
reference
}
}
+ RsTypeKind::RvalueReference { referent, mutability, lifetime_id } => {
+ let lifetime = Self::format_lifetime(lifetime_id, lifetime_to_name)?;
+ let nested_type = referent.format(ir, lifetime_to_name)?;
+ // TODO(b/200067242): Add a `use ctor::RvalueReference` (etc.) to the crate.
+ if mutability == &Mutability::Mut {
+ quote! {ctor::RvalueReference<#lifetime, #nested_type>}
+ } else {
+ quote! {ctor::ConstRvalueReference<#lifetime, #nested_type>}
+ }
+ }
RsTypeKind::FuncPtr { abi, return_type, param_types } => {
let return_frag =
return_type.format_as_return_type_fragment(ir, lifetime_to_name)?;
@@ -1607,6 +1649,7 @@
RsTypeKind::FuncPtr { .. } => true,
RsTypeKind::Reference { mutability: Mutability::Const, .. } => true,
RsTypeKind::Reference { mutability: Mutability::Mut, .. } => false,
+ RsTypeKind::RvalueReference { .. } => false,
RsTypeKind::Record(record) => should_derive_copy(record),
RsTypeKind::TypeAlias { underlying_type, .. } => underlying_type.implements_copy(),
RsTypeKind::Other { type_args, .. } => {
@@ -1689,6 +1732,7 @@
RsTypeKind::Unit | RsTypeKind::Record(_) => (),
RsTypeKind::Pointer { pointee, .. } => self.todo.push(pointee),
RsTypeKind::Reference { referent, .. } => self.todo.push(referent),
+ RsTypeKind::RvalueReference { referent, .. } => self.todo.push(referent),
RsTypeKind::TypeAlias { underlying_type: t, .. } => self.todo.push(t),
RsTypeKind::FuncPtr { return_type, param_types, .. } => {
self.todo.push(return_type);
@@ -1770,6 +1814,13 @@
let nested_type = format_cc_type(&ty.type_args[0], ir)?;
Ok(quote! {#nested_type &})
}
+ "&&" => {
+ if ty.type_args.len() != 1 {
+ bail!("Invalid rvalue reference type (need exactly 1 type argument): {:?}", ty);
+ }
+ let nested_type = format_cc_type(&ty.type_args[0], ir)?;
+ Ok(quote! {#nested_type &&})
+ }
cc_type_name => match cc_type_name.strip_prefix("#funcValue ") {
None => {
if !ty.type_args.is_empty() {
@@ -1977,8 +2028,17 @@
}
},
};
+
+ let arg_expressions: Vec<_> = param_idents
+ .iter()
+ .map(
+ // Forward references along. (If the parameter is a value, not a reference, this
+ // will create an lvalue reference, and still do the right thing.)
+ |ident| quote! {std::forward<decltype(#ident)>(#ident)},
+ )
+ .collect();
let (implementation_function, arg_expressions) = if !needs_this_deref {
- (implementation_function, param_idents.clone())
+ (implementation_function, arg_expressions.clone())
} else {
let this_param = func
.params
@@ -1987,7 +2047,7 @@
let this_arg = format_cc_ident(&this_param.identifier.identifier);
(
quote! { #this_arg -> #implementation_function},
- param_idents.iter().skip(1).cloned().collect_vec(),
+ arg_expressions.iter().skip(1).cloned().collect_vec(),
)
};
@@ -2138,7 +2198,7 @@
generate_rs_api_impl(&ir)?,
quote! {
extern "C" int __rust_thunk___Z3Addii(int a, int b) {
- return Add(a, b);
+ return Add(std::forward<decltype(a)>(a), std::forward<decltype(b)>(b));
}
}
);
@@ -2180,7 +2240,7 @@
generate_rs_api_impl(&ir)?,
quote! {
extern "C" class ReturnStruct __rust_thunk___Z11DoSomething11ParamStruct(class ParamStruct param) {
- return DoSomething(param);
+ return DoSomething(std::forward<decltype(param)>(param));
}
}
);
@@ -2231,7 +2291,7 @@
rs_api_impl,
quote! {
extern "C" void __rust_thunk___ZN10SomeStructD1Ev(class SomeStruct * __this) {
- std :: destroy_at (__this) ;
+ std :: destroy_at (std::forward<decltype(__this)>(__this)) ;
}
}
);
@@ -2254,7 +2314,7 @@
rs_api_impl,
quote! {
extern "C" void __rust_thunk___Z3fooR1S(class S& s) {
- foo(s);
+ foo(std::forward<decltype(s)>(s));
}
}
);
@@ -2269,7 +2329,7 @@
rs_api_impl,
quote! {
extern "C" void __rust_thunk___Z3fooRK1S(const class S& s) {
- foo(s);
+ foo(std::forward<decltype(s)>(s));
}
}
);
@@ -2284,7 +2344,7 @@
rs_api_impl,
quote! {
extern "C" void __rust_thunk___Z3fooj(unsigned int i) {
- foo(i);
+ foo(std::forward<decltype(i)>(i));
}
}
);
@@ -2323,7 +2383,7 @@
quote! {
extern "C" int __rust_thunk___ZNK10SomeStruct9some_funcEi(
const class SomeStruct* __this, int arg) {
- return __this->some_func(arg);
+ return __this->some_func(std::forward<decltype(arg)>(arg));
}
}
);
@@ -2427,7 +2487,7 @@
generate_rs_api_impl(&ir)?,
quote! {
extern "C" int* __rust_thunk___Z5DerefPKPi(int* const * p) {
- return Deref(p);
+ return Deref(std::forward<decltype(p)>(p));
}
}
);
@@ -2467,7 +2527,7 @@
assert_cc_matches!(
generate_rs_api_impl(&ir)?,
quote! {
- extern "C" void __rust_thunk___Z1fPKc(char const * str){ f(str) ; }
+ extern "C" void __rust_thunk___Z1fPKc(char const * str){ f(std::forward<decltype(str)>(str)) ; }
}
);
Ok(())
@@ -3385,7 +3445,7 @@
quote! {
extern "C" float __rust_thunk___Z31f_vectorcall_calling_conventionff(
float p1, float p2) {
- return f_vectorcall_calling_convention (p1 , p2);
+ return f_vectorcall_calling_convention (std::forward<decltype(p1)>(p1), std::forward<decltype(p2)>(p2));
}
}
);
@@ -3542,7 +3602,7 @@
quote! {
extern "C" void __rust_thunk___ZN20DefaultedConstructorC1Ev(
class DefaultedConstructor* __this) {
- rs_api_impl_support::construct_at (__this) ;
+ rs_api_impl_support::construct_at (std::forward<decltype(__this)>(__this)) ;
}
}
);
@@ -3717,7 +3777,7 @@
quote! {
extern "C" bool __rust_thunk___ZNK10SomeStructeqERKS_(
const class SomeStruct* __this, const class SomeStruct& other) {
- return __this->operator==(other);
+ return __this->operator==(std::forward<decltype(other)>(other));
}
}
);
@@ -3938,7 +3998,7 @@
assert_cc_matches!(
generate_rs_api_impl(&ir)?,
quote! {
- extern "C" void __rust_thunk___Z1fi(MyTypedefDecl t){ f (t) ; }
+ extern "C" void __rust_thunk___Z1fi(MyTypedefDecl t){ f (std::forward<decltype(t)>(t)) ; }
}
);
Ok(())
diff --git a/rs_bindings_from_cc/support/ctor.rs b/rs_bindings_from_cc/support/ctor.rs
index f54262c..350e52c 100644
--- a/rs_bindings_from_cc/support/ctor.rs
+++ b/rs_bindings_from_cc/support/ctor.rs
@@ -213,6 +213,7 @@
// DerefMut based move construction
// ================================
+#[repr(transparent)]
pub struct RvalueReference<'a, T>(Pin<&'a mut T>);
impl<T> RvalueReference<'_, T> {
@@ -263,6 +264,7 @@
/// !Unpin to override the blanket Ctor impl.
impl<P> !Unpin for Move<P> {}
+#[repr(transparent)]
pub struct ConstRvalueReference<'a, T>(&'a T);
impl<'a, T> ConstRvalueReference<'a, T> {
diff --git a/rs_bindings_from_cc/test/golden/clang_attrs_rs_api.rs b/rs_bindings_from_cc/test/golden/clang_attrs_rs_api.rs
index 51a49b3..4c02d8c 100644
--- a/rs_bindings_from_cc/test/golden/clang_attrs_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/clang_attrs_rs_api.rs
@@ -36,7 +36,7 @@
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=8
// Error while generating bindings for item 'HasCustomAlignment::HasCustomAlignment':
-// Parameter #0 is not supported: Unsupported type 'struct HasCustomAlignment &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct HasCustomAlignment &&': Unsupported type: && without lifetime
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=8
// Error while generating bindings for item 'HasCustomAlignment::operator=':
@@ -44,7 +44,7 @@
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=8
// Error while generating bindings for item 'HasCustomAlignment::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct HasCustomAlignment &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct HasCustomAlignment &&': Unsupported type: && without lifetime
#[repr(C)]
pub struct HasFieldWithCustomAlignment {
@@ -63,7 +63,7 @@
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=10
// Error while generating bindings for item 'HasFieldWithCustomAlignment::HasFieldWithCustomAlignment':
-// Parameter #0 is not supported: Unsupported type 'struct HasFieldWithCustomAlignment &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct HasFieldWithCustomAlignment &&': Unsupported type: && without lifetime
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=10
// Error while generating bindings for item 'HasFieldWithCustomAlignment::operator=':
@@ -71,7 +71,7 @@
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=10
// Error while generating bindings for item 'HasFieldWithCustomAlignment::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct HasFieldWithCustomAlignment &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct HasFieldWithCustomAlignment &&': Unsupported type: && without lifetime
#[repr(C, align(64))]
pub struct InheritsFromBaseWithCustomAlignment {
@@ -97,7 +97,7 @@
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=14
// Error while generating bindings for item 'InheritsFromBaseWithCustomAlignment::InheritsFromBaseWithCustomAlignment':
-// Parameter #0 is not supported: Unsupported type 'struct InheritsFromBaseWithCustomAlignment &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct InheritsFromBaseWithCustomAlignment &&': Unsupported type: && without lifetime
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=14
// Error while generating bindings for item 'InheritsFromBaseWithCustomAlignment::operator=':
@@ -105,7 +105,7 @@
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=14
// Error while generating bindings for item 'InheritsFromBaseWithCustomAlignment::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct InheritsFromBaseWithCustomAlignment &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct InheritsFromBaseWithCustomAlignment &&': Unsupported type: && without lifetime
#[repr(C, align(64))]
pub struct HasCustomAlignmentWithGnuAttr {
@@ -125,7 +125,7 @@
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=16
// Error while generating bindings for item 'HasCustomAlignmentWithGnuAttr::HasCustomAlignmentWithGnuAttr':
-// Parameter #0 is not supported: Unsupported type 'struct HasCustomAlignmentWithGnuAttr &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct HasCustomAlignmentWithGnuAttr &&': Unsupported type: && without lifetime
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=16
// Error while generating bindings for item 'HasCustomAlignmentWithGnuAttr::operator=':
@@ -133,7 +133,7 @@
// rs_bindings_from_cc/test/golden/clang_attrs.h;l=16
// Error while generating bindings for item 'HasCustomAlignmentWithGnuAttr::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct HasCustomAlignmentWithGnuAttr &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct HasCustomAlignmentWithGnuAttr &&': Unsupported type: && without lifetime
// CRUBIT_RS_BINDINGS_FROM_CC_TEST_GOLDEN_CLANG_ATTRS_H_
diff --git a/rs_bindings_from_cc/test/golden/clang_attrs_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/clang_attrs_rs_api_impl.cc
index 7dc6f36..dbb00ca 100644
--- a/rs_bindings_from_cc/test/golden/clang_attrs_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/clang_attrs_rs_api_impl.cc
@@ -12,79 +12,87 @@
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN18HasCustomAlignmentC1Ev(
class HasCustomAlignment* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN18HasCustomAlignmentC1ERKS_(
class HasCustomAlignment* __this,
const class HasCustomAlignment& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN18HasCustomAlignmentD1Ev(
class HasCustomAlignment* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class HasCustomAlignment&
__rust_thunk___ZN18HasCustomAlignmentaSERKS_(
class HasCustomAlignment* __this,
const class HasCustomAlignment& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN27HasFieldWithCustomAlignmentC1Ev(
class HasFieldWithCustomAlignment* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN27HasFieldWithCustomAlignmentC1ERKS_(
class HasFieldWithCustomAlignment* __this,
const class HasFieldWithCustomAlignment& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN27HasFieldWithCustomAlignmentD1Ev(
class HasFieldWithCustomAlignment* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class HasFieldWithCustomAlignment&
__rust_thunk___ZN27HasFieldWithCustomAlignmentaSERKS_(
class HasFieldWithCustomAlignment* __this,
const class HasFieldWithCustomAlignment& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN35InheritsFromBaseWithCustomAlignmentC1Ev(
class InheritsFromBaseWithCustomAlignment* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN35InheritsFromBaseWithCustomAlignmentC1ERKS_(
class InheritsFromBaseWithCustomAlignment* __this,
const class InheritsFromBaseWithCustomAlignment& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN35InheritsFromBaseWithCustomAlignmentD1Ev(
class InheritsFromBaseWithCustomAlignment* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class InheritsFromBaseWithCustomAlignment&
__rust_thunk___ZN35InheritsFromBaseWithCustomAlignmentaSERKS_(
class InheritsFromBaseWithCustomAlignment* __this,
const class InheritsFromBaseWithCustomAlignment& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN29HasCustomAlignmentWithGnuAttrC1Ev(
class HasCustomAlignmentWithGnuAttr* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN29HasCustomAlignmentWithGnuAttrC1ERKS_(
class HasCustomAlignmentWithGnuAttr* __this,
const class HasCustomAlignmentWithGnuAttr& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN29HasCustomAlignmentWithGnuAttrD1Ev(
class HasCustomAlignmentWithGnuAttr* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class HasCustomAlignmentWithGnuAttr&
__rust_thunk___ZN29HasCustomAlignmentWithGnuAttraSERKS_(
class HasCustomAlignmentWithGnuAttr* __this,
const class HasCustomAlignmentWithGnuAttr& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class HasCustomAlignment) == 64);
diff --git a/rs_bindings_from_cc/test/golden/comment_rs_api.rs b/rs_bindings_from_cc/test/golden/comment_rs_api.rs
index e7be93e..b494dcb 100644
--- a/rs_bindings_from_cc/test/golden/comment_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/comment_rs_api.rs
@@ -45,9 +45,16 @@
}
}
-// rs_bindings_from_cc/test/golden/comment.h;l=17
-// Error while generating bindings for item 'Foo::Foo':
-// Parameter #0 is not supported: Unsupported type 'struct Foo &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, Foo>> for Foo {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, Foo>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN3FooC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/comment.h;l=17
// Error while generating bindings for item 'Foo::operator=':
@@ -55,7 +62,7 @@
// rs_bindings_from_cc/test/golden/comment.h;l=17
// Error while generating bindings for item 'Foo::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct Foo &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
// b
@@ -87,9 +94,16 @@
}
}
-// rs_bindings_from_cc/test/golden/comment.h;l=43
-// Error while generating bindings for item 'Bar::Bar':
-// Parameter #0 is not supported: Unsupported type 'struct Bar &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, Bar>> for Bar {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, Bar>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN3BarC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/comment.h;l=43
// Error while generating bindings for item 'Bar::operator=':
@@ -97,7 +111,7 @@
// rs_bindings_from_cc/test/golden/comment.h;l=43
// Error while generating bindings for item 'Bar::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct Bar &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
/// d
#[derive(Clone, Copy)]
@@ -117,9 +131,16 @@
}
}
-// rs_bindings_from_cc/test/golden/comment.h;l=49
-// Error while generating bindings for item 'HasNoComments::HasNoComments':
-// Parameter #0 is not supported: Unsupported type 'struct HasNoComments &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, HasNoComments>> for HasNoComments {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, HasNoComments>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN13HasNoCommentsC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/comment.h;l=49
// Error while generating bindings for item 'HasNoComments::operator=':
@@ -127,7 +148,7 @@
// rs_bindings_from_cc/test/golden/comment.h;l=49
// Error while generating bindings for item 'HasNoComments::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct HasNoComments &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
// e
@@ -138,11 +159,23 @@
use super::*;
extern "C" {
pub(crate) fn __rust_thunk___ZN3FooC1Ev<'a>(__this: &'a mut std::mem::MaybeUninit<Foo>);
+ pub(crate) fn __rust_thunk___ZN3FooC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<Foo>,
+ __param_0: ctor::RvalueReference<'b, Foo>,
+ );
pub(crate) fn __rust_thunk___Z3foov();
pub(crate) fn __rust_thunk___ZN3BarC1Ev<'a>(__this: &'a mut std::mem::MaybeUninit<Bar>);
+ pub(crate) fn __rust_thunk___ZN3BarC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<Bar>,
+ __param_0: ctor::RvalueReference<'b, Bar>,
+ );
pub(crate) fn __rust_thunk___ZN13HasNoCommentsC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<HasNoComments>,
);
+ pub(crate) fn __rust_thunk___ZN13HasNoCommentsC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<HasNoComments>,
+ __param_0: ctor::RvalueReference<'b, HasNoComments>,
+ );
}
}
diff --git a/rs_bindings_from_cc/test/golden/comment_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/comment_rs_api_impl.cc
index 49aff99..4425baf 100644
--- a/rs_bindings_from_cc/test/golden/comment_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/comment_rs_api_impl.cc
@@ -11,49 +11,85 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN3FooC1Ev(class Foo* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN3FooC1ERKS_(class Foo* __this,
const class Foo& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN3FooC1EOS_(class Foo* __this,
+ class Foo&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN3FooD1Ev(class Foo* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class Foo& __rust_thunk___ZN3FooaSERKS_(class Foo* __this,
const class Foo& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class Foo& __rust_thunk___ZN3FooaSEOS_(class Foo* __this,
+ class Foo&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___Z3foov() { foo(); }
extern "C" void __rust_thunk___ZN3BarC1Ev(class Bar* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN3BarC1ERKS_(class Bar* __this,
const class Bar& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN3BarC1EOS_(class Bar* __this,
+ class Bar&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN3BarD1Ev(class Bar* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class Bar& __rust_thunk___ZN3BaraSERKS_(class Bar* __this,
const class Bar& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class Bar& __rust_thunk___ZN3BaraSEOS_(class Bar* __this,
+ class Bar&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN13HasNoCommentsC1Ev(
class HasNoComments* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN13HasNoCommentsC1ERKS_(
class HasNoComments* __this, const class HasNoComments& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN13HasNoCommentsC1EOS_(
+ class HasNoComments* __this, class HasNoComments&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN13HasNoCommentsD1Ev(
class HasNoComments* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class HasNoComments& __rust_thunk___ZN13HasNoCommentsaSERKS_(
class HasNoComments* __this, const class HasNoComments& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class HasNoComments& __rust_thunk___ZN13HasNoCommentsaSEOS_(
+ class HasNoComments* __this, class HasNoComments&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class Foo) == 8);
diff --git a/rs_bindings_from_cc/test/golden/doc_comment_rs_api.rs b/rs_bindings_from_cc/test/golden/doc_comment_rs_api.rs
index e673bc4..e999998 100644
--- a/rs_bindings_from_cc/test/golden/doc_comment_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/doc_comment_rs_api.rs
@@ -28,9 +28,16 @@
pub i: i32,
}
-// rs_bindings_from_cc/test/golden/doc_comment.h;l=13
-// Error while generating bindings for item 'DocCommentSlashes::DocCommentSlashes':
-// Parameter #0 is not supported: Unsupported type 'struct DocCommentSlashes &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, DocCommentSlashes>> for DocCommentSlashes {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, DocCommentSlashes>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN17DocCommentSlashesC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/doc_comment.h;l=13
// Error while generating bindings for item 'DocCommentSlashes::operator=':
@@ -38,7 +45,7 @@
// rs_bindings_from_cc/test/golden/doc_comment.h;l=13
// Error while generating bindings for item 'DocCommentSlashes::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct DocCommentSlashes &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
/// The default constructor which will get translated into
/// `impl Default for DocCommentSlashes`.
@@ -113,9 +120,16 @@
}
}
-// rs_bindings_from_cc/test/golden/doc_comment.h;l=39
-// Error while generating bindings for item 'DocCommentBang::DocCommentBang':
-// Parameter #0 is not supported: Unsupported type 'struct DocCommentBang &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, DocCommentBang>> for DocCommentBang {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, DocCommentBang>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN14DocCommentBangC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/doc_comment.h;l=39
// Error while generating bindings for item 'DocCommentBang::operator=':
@@ -123,7 +137,7 @@
// rs_bindings_from_cc/test/golden/doc_comment.h;l=39
// Error while generating bindings for item 'DocCommentBang::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct DocCommentBang &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
/// Multiline comment
///
@@ -146,9 +160,16 @@
}
}
-// rs_bindings_from_cc/test/golden/doc_comment.h;l=47
-// Error while generating bindings for item 'MultilineCommentTwoStars::MultilineCommentTwoStars':
-// Parameter #0 is not supported: Unsupported type 'struct MultilineCommentTwoStars &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, MultilineCommentTwoStars>> for MultilineCommentTwoStars {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, MultilineCommentTwoStars>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN24MultilineCommentTwoStarsC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/doc_comment.h;l=47
// Error while generating bindings for item 'MultilineCommentTwoStars::operator=':
@@ -156,7 +177,7 @@
// rs_bindings_from_cc/test/golden/doc_comment.h;l=47
// Error while generating bindings for item 'MultilineCommentTwoStars::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct MultilineCommentTwoStars &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
/// Line comment
///
@@ -179,9 +200,16 @@
}
}
-// rs_bindings_from_cc/test/golden/doc_comment.h;l=55
-// Error while generating bindings for item 'LineComment::LineComment':
-// Parameter #0 is not supported: Unsupported type 'struct LineComment &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, LineComment>> for LineComment {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, LineComment>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN11LineCommentC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/doc_comment.h;l=55
// Error while generating bindings for item 'LineComment::operator=':
@@ -189,7 +217,7 @@
// rs_bindings_from_cc/test/golden/doc_comment.h;l=55
// Error while generating bindings for item 'LineComment::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct LineComment &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
/// Multiline comment
///
@@ -212,9 +240,16 @@
}
}
-// rs_bindings_from_cc/test/golden/doc_comment.h;l=63
-// Error while generating bindings for item 'MultilineOneStar::MultilineOneStar':
-// Parameter #0 is not supported: Unsupported type 'struct MultilineOneStar &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, MultilineOneStar>> for MultilineOneStar {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, MultilineOneStar>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN16MultilineOneStarC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/doc_comment.h;l=63
// Error while generating bindings for item 'MultilineOneStar::operator=':
@@ -222,7 +257,7 @@
// rs_bindings_from_cc/test/golden/doc_comment.h;l=63
// Error while generating bindings for item 'MultilineOneStar::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct MultilineOneStar &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
/// A function
#[inline(always)]
@@ -239,6 +274,10 @@
#[allow(unused_imports)]
use super::*;
extern "C" {
+ pub(crate) fn __rust_thunk___ZN17DocCommentSlashesC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<DocCommentSlashes>,
+ __param_0: ctor::RvalueReference<'b, DocCommentSlashes>,
+ );
#[link_name = "_ZN17DocCommentSlashesC1Ev"]
pub(crate) fn __rust_thunk___ZN17DocCommentSlashesC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<DocCommentSlashes>,
@@ -262,15 +301,31 @@
pub(crate) fn __rust_thunk___ZN14DocCommentBangC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<DocCommentBang>,
);
+ pub(crate) fn __rust_thunk___ZN14DocCommentBangC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<DocCommentBang>,
+ __param_0: ctor::RvalueReference<'b, DocCommentBang>,
+ );
pub(crate) fn __rust_thunk___ZN24MultilineCommentTwoStarsC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<MultilineCommentTwoStars>,
);
+ pub(crate) fn __rust_thunk___ZN24MultilineCommentTwoStarsC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<MultilineCommentTwoStars>,
+ __param_0: ctor::RvalueReference<'b, MultilineCommentTwoStars>,
+ );
pub(crate) fn __rust_thunk___ZN11LineCommentC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<LineComment>,
);
+ pub(crate) fn __rust_thunk___ZN11LineCommentC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<LineComment>,
+ __param_0: ctor::RvalueReference<'b, LineComment>,
+ );
pub(crate) fn __rust_thunk___ZN16MultilineOneStarC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<MultilineOneStar>,
);
+ pub(crate) fn __rust_thunk___ZN16MultilineOneStarC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<MultilineOneStar>,
+ __param_0: ctor::RvalueReference<'b, MultilineOneStar>,
+ );
pub(crate) fn __rust_thunk___Z3foov() -> i32;
}
}
diff --git a/rs_bindings_from_cc/test/golden/doc_comment_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/doc_comment_rs_api_impl.cc
index 59275cd..7303fd0 100644
--- a/rs_bindings_from_cc/test/golden/doc_comment_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/doc_comment_rs_api_impl.cc
@@ -12,80 +12,143 @@
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN17DocCommentSlashesC1ERKS_(
class DocCommentSlashes* __this, const class DocCommentSlashes& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN17DocCommentSlashesC1EOS_(
+ class DocCommentSlashes* __this, class DocCommentSlashes&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN17DocCommentSlashesD1Ev(
class DocCommentSlashes* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class DocCommentSlashes& __rust_thunk___ZN17DocCommentSlashesaSERKS_(
class DocCommentSlashes* __this, const class DocCommentSlashes& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class DocCommentSlashes& __rust_thunk___ZN17DocCommentSlashesaSEOS_(
+ class DocCommentSlashes* __this, class DocCommentSlashes&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN14DocCommentBangC1Ev(
class DocCommentBang* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN14DocCommentBangC1ERKS_(
class DocCommentBang* __this, const class DocCommentBang& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN14DocCommentBangC1EOS_(
+ class DocCommentBang* __this, class DocCommentBang&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN14DocCommentBangD1Ev(
class DocCommentBang* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class DocCommentBang& __rust_thunk___ZN14DocCommentBangaSERKS_(
class DocCommentBang* __this, const class DocCommentBang& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class DocCommentBang& __rust_thunk___ZN14DocCommentBangaSEOS_(
+ class DocCommentBang* __this, class DocCommentBang&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN24MultilineCommentTwoStarsC1Ev(
class MultilineCommentTwoStars* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN24MultilineCommentTwoStarsC1ERKS_(
class MultilineCommentTwoStars* __this,
const class MultilineCommentTwoStars& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN24MultilineCommentTwoStarsC1EOS_(
+ class MultilineCommentTwoStars* __this,
+ class MultilineCommentTwoStars&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN24MultilineCommentTwoStarsD1Ev(
class MultilineCommentTwoStars* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class MultilineCommentTwoStars&
__rust_thunk___ZN24MultilineCommentTwoStarsaSERKS_(
class MultilineCommentTwoStars* __this,
const class MultilineCommentTwoStars& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class MultilineCommentTwoStars&
+__rust_thunk___ZN24MultilineCommentTwoStarsaSEOS_(
+ class MultilineCommentTwoStars* __this,
+ class MultilineCommentTwoStars&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN11LineCommentC1Ev(class LineComment* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN11LineCommentC1ERKS_(
class LineComment* __this, const class LineComment& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN11LineCommentC1EOS_(
+ class LineComment* __this, class LineComment&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN11LineCommentD1Ev(class LineComment* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class LineComment& __rust_thunk___ZN11LineCommentaSERKS_(
class LineComment* __this, const class LineComment& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class LineComment& __rust_thunk___ZN11LineCommentaSEOS_(
+ class LineComment* __this, class LineComment&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN16MultilineOneStarC1Ev(
class MultilineOneStar* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN16MultilineOneStarC1ERKS_(
class MultilineOneStar* __this, const class MultilineOneStar& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN16MultilineOneStarC1EOS_(
+ class MultilineOneStar* __this, class MultilineOneStar&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN16MultilineOneStarD1Ev(
class MultilineOneStar* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class MultilineOneStar& __rust_thunk___ZN16MultilineOneStaraSERKS_(
class MultilineOneStar* __this, const class MultilineOneStar& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class MultilineOneStar& __rust_thunk___ZN16MultilineOneStaraSEOS_(
+ class MultilineOneStar* __this, class MultilineOneStar&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" int __rust_thunk___Z3foov() { return foo(); }
diff --git a/rs_bindings_from_cc/test/golden/escaping_keywords_rs_api.rs b/rs_bindings_from_cc/test/golden/escaping_keywords_rs_api.rs
index 3441e7b..e4a4f42 100644
--- a/rs_bindings_from_cc/test/golden/escaping_keywords_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/escaping_keywords_rs_api.rs
@@ -35,9 +35,16 @@
}
}
-// rs_bindings_from_cc/test/golden/escaping_keywords.h;l=10
-// Error while generating bindings for item 'type::type':
-// Parameter #0 is not supported: Unsupported type 'struct type &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, r#type>> for r#type {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, r#type>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN4typeC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/escaping_keywords.h;l=10
// Error while generating bindings for item 'type::operator=':
@@ -45,7 +52,7 @@
// rs_bindings_from_cc/test/golden/escaping_keywords.h;l=10
// Error while generating bindings for item 'type::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct type &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
#[inline(always)]
pub fn r#impl(r#match: i32) {
@@ -67,6 +74,10 @@
use super::*;
extern "C" {
pub(crate) fn __rust_thunk___ZN4typeC1Ev<'a>(__this: &'a mut std::mem::MaybeUninit<r#type>);
+ pub(crate) fn __rust_thunk___ZN4typeC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<r#type>,
+ __param_0: ctor::RvalueReference<'b, r#type>,
+ );
#[link_name = "_Z4impli"]
pub(crate) fn __rust_thunk___Z4impli(r#match: i32);
}
diff --git a/rs_bindings_from_cc/test/golden/escaping_keywords_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/escaping_keywords_rs_api_impl.cc
index ec59dcf..3675dc8 100644
--- a/rs_bindings_from_cc/test/golden/escaping_keywords_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/escaping_keywords_rs_api_impl.cc
@@ -11,18 +11,30 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN4typeC1Ev(class type* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN4typeC1ERKS_(class type* __this,
const class type& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN4typeC1EOS_(class type* __this,
+ class type&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN4typeD1Ev(class type* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class type& __rust_thunk___ZN4typeaSERKS_(
class type* __this, const class type& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class type& __rust_thunk___ZN4typeaSEOS_(class type* __this,
+ class type&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class type) == 4);
diff --git a/rs_bindings_from_cc/test/golden/inheritance_rs_api.rs b/rs_bindings_from_cc/test/golden/inheritance_rs_api.rs
index bec520c..a9dec12 100644
--- a/rs_bindings_from_cc/test/golden/inheritance_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/inheritance_rs_api.rs
@@ -39,7 +39,7 @@
// rs_bindings_from_cc/test/golden/inheritance.h;l=13
// Error while generating bindings for item 'Base0::Base0':
-// Parameter #0 is not supported: Unsupported type 'class Base0 &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'class Base0 &&': Unsupported type: && without lifetime
// rs_bindings_from_cc/test/golden/inheritance.h;l=13
// Error while generating bindings for item 'Base0::operator=':
@@ -47,7 +47,7 @@
// rs_bindings_from_cc/test/golden/inheritance.h;l=13
// Error while generating bindings for item 'Base0::operator=':
-// Parameter #0 is not supported: Unsupported type 'class Base0 &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'class Base0 &&': Unsupported type: && without lifetime
#[repr(C)]
pub struct Base1 {
@@ -67,7 +67,7 @@
// rs_bindings_from_cc/test/golden/inheritance.h;l=14
// Error while generating bindings for item 'Base1::Base1':
-// Parameter #0 is not supported: Unsupported type 'class Base1 &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'class Base1 &&': Unsupported type: && without lifetime
// rs_bindings_from_cc/test/golden/inheritance.h;l=14
// Error while generating bindings for item 'Base1::operator=':
@@ -75,7 +75,7 @@
// rs_bindings_from_cc/test/golden/inheritance.h;l=14
// Error while generating bindings for item 'Base1::operator=':
-// Parameter #0 is not supported: Unsupported type 'class Base1 &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'class Base1 &&': Unsupported type: && without lifetime
#[repr(C)]
pub struct Base2 {
@@ -94,7 +94,7 @@
// rs_bindings_from_cc/test/golden/inheritance.h;l=19
// Error while generating bindings for item 'Base2::Base2':
-// Parameter #0 is not supported: Unsupported type 'class Base2 &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'class Base2 &&': Unsupported type: && without lifetime
// rs_bindings_from_cc/test/golden/inheritance.h;l=19
// Error while generating bindings for item 'Base2::operator=':
@@ -102,7 +102,7 @@
// rs_bindings_from_cc/test/golden/inheritance.h;l=19
// Error while generating bindings for item 'Base2::operator=':
-// Parameter #0 is not supported: Unsupported type 'class Base2 &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'class Base2 &&': Unsupported type: && without lifetime
#[derive(Clone, Copy)]
#[repr(C, align(8))]
@@ -136,7 +136,7 @@
// rs_bindings_from_cc/test/golden/inheritance.h;l=23
// Error while generating bindings for item 'Derived::Derived':
-// Parameter #0 is not supported: Unsupported type 'struct Derived &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct Derived &&': Unsupported type: && without lifetime
// rs_bindings_from_cc/test/golden/inheritance.h;l=23
// Error while generating bindings for item 'Derived::operator=':
@@ -144,7 +144,7 @@
// rs_bindings_from_cc/test/golden/inheritance.h;l=23
// Error while generating bindings for item 'Derived::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct Derived &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct Derived &&': Unsupported type: && without lifetime
// CRUBIT_RS_BINDINGS_FROM_CC_TEST_GOLDEN_INHERITANCE_H_
diff --git a/rs_bindings_from_cc/test/golden/inheritance_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/inheritance_rs_api_impl.cc
index c34e00f..5cfff93 100644
--- a/rs_bindings_from_cc/test/golden/inheritance_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/inheritance_rs_api_impl.cc
@@ -11,60 +11,68 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN5Base0C1Ev(class Base0* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN5Base0C1ERKS_(class Base0* __this,
const class Base0& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN5Base0D1Ev(class Base0* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class Base0& __rust_thunk___ZN5Base0aSERKS_(
class Base0* __this, const class Base0& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN5Base1C1Ev(class Base1* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN5Base1C1ERKS_(class Base1* __this,
const class Base1& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN5Base1D1Ev(class Base1* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class Base1& __rust_thunk___ZN5Base1aSERKS_(
class Base1* __this, const class Base1& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN5Base2C1Ev(class Base2* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN5Base2C1ERKS_(class Base2* __this,
const class Base2& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN5Base2D1Ev(class Base2* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class Base2& __rust_thunk___ZN5Base2aSERKS_(
class Base2* __this, const class Base2& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN7DerivedC1Ev(class Derived* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN7DerivedC1ERKS_(
class Derived* __this, const class Derived& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN7DerivedD1Ev(class Derived* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class Derived& __rust_thunk___ZN7DerivedaSERKS_(
class Derived* __this, const class Derived& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class Base0) == 1);
diff --git a/rs_bindings_from_cc/test/golden/item_order_rs_api.rs b/rs_bindings_from_cc/test/golden/item_order_rs_api.rs
index d087401..684b785 100644
--- a/rs_bindings_from_cc/test/golden/item_order_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/item_order_rs_api.rs
@@ -35,9 +35,16 @@
}
}
-// rs_bindings_from_cc/test/golden/item_order.h;l=10
-// Error while generating bindings for item 'FirstStruct::FirstStruct':
-// Parameter #0 is not supported: Unsupported type 'struct FirstStruct &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, FirstStruct>> for FirstStruct {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, FirstStruct>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN11FirstStructC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/item_order.h;l=10
// Error while generating bindings for item 'FirstStruct::operator=':
@@ -45,7 +52,7 @@
// rs_bindings_from_cc/test/golden/item_order.h;l=10
// Error while generating bindings for item 'FirstStruct::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct FirstStruct &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
#[inline(always)]
pub fn first_func() -> i32 {
@@ -69,9 +76,16 @@
}
}
-// rs_bindings_from_cc/test/golden/item_order.h;l=16
-// Error while generating bindings for item 'SecondStruct::SecondStruct':
-// Parameter #0 is not supported: Unsupported type 'struct SecondStruct &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, SecondStruct>> for SecondStruct {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, SecondStruct>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN12SecondStructC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/item_order.h;l=16
// Error while generating bindings for item 'SecondStruct::operator=':
@@ -79,7 +93,7 @@
// rs_bindings_from_cc/test/golden/item_order.h;l=16
// Error while generating bindings for item 'SecondStruct::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct SecondStruct &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
#[inline(always)]
pub fn second_func() -> i32 {
@@ -95,10 +109,18 @@
pub(crate) fn __rust_thunk___ZN11FirstStructC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<FirstStruct>,
);
+ pub(crate) fn __rust_thunk___ZN11FirstStructC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<FirstStruct>,
+ __param_0: ctor::RvalueReference<'b, FirstStruct>,
+ );
pub(crate) fn __rust_thunk___Z10first_funcv() -> i32;
pub(crate) fn __rust_thunk___ZN12SecondStructC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<SecondStruct>,
);
+ pub(crate) fn __rust_thunk___ZN12SecondStructC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<SecondStruct>,
+ __param_0: ctor::RvalueReference<'b, SecondStruct>,
+ );
pub(crate) fn __rust_thunk___Z11second_funcv() -> i32;
}
}
diff --git a/rs_bindings_from_cc/test/golden/item_order_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/item_order_rs_api_impl.cc
index e190a75..e1d387e 100644
--- a/rs_bindings_from_cc/test/golden/item_order_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/item_order_rs_api_impl.cc
@@ -11,35 +11,59 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN11FirstStructC1Ev(class FirstStruct* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN11FirstStructC1ERKS_(
class FirstStruct* __this, const class FirstStruct& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN11FirstStructC1EOS_(
+ class FirstStruct* __this, class FirstStruct&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN11FirstStructD1Ev(class FirstStruct* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class FirstStruct& __rust_thunk___ZN11FirstStructaSERKS_(
class FirstStruct* __this, const class FirstStruct& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class FirstStruct& __rust_thunk___ZN11FirstStructaSEOS_(
+ class FirstStruct* __this, class FirstStruct&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" int __rust_thunk___Z10first_funcv() { return first_func(); }
extern "C" void __rust_thunk___ZN12SecondStructC1Ev(
class SecondStruct* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN12SecondStructC1ERKS_(
class SecondStruct* __this, const class SecondStruct& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN12SecondStructC1EOS_(
+ class SecondStruct* __this, class SecondStruct&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN12SecondStructD1Ev(
class SecondStruct* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class SecondStruct& __rust_thunk___ZN12SecondStructaSERKS_(
class SecondStruct* __this, const class SecondStruct& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class SecondStruct& __rust_thunk___ZN12SecondStructaSEOS_(
+ class SecondStruct* __this, class SecondStruct&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" int __rust_thunk___Z11second_funcv() { return second_func(); }
diff --git a/rs_bindings_from_cc/test/golden/no_elided_lifetimes_rs_api.rs b/rs_bindings_from_cc/test/golden/no_elided_lifetimes_rs_api.rs
index df4d9d2..b056519 100644
--- a/rs_bindings_from_cc/test/golden/no_elided_lifetimes_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/no_elided_lifetimes_rs_api.rs
@@ -40,7 +40,7 @@
// rs_bindings_from_cc/test/golden/no_elided_lifetimes.h;l=10
// Error while generating bindings for item 'S::S':
-// Parameter #0 is not supported: Unsupported type 'struct S &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct S &&': Unsupported type: && without lifetime
// rs_bindings_from_cc/test/golden/no_elided_lifetimes.h;l=10
// Error while generating bindings for item 'S::operator=':
@@ -48,7 +48,7 @@
// rs_bindings_from_cc/test/golden/no_elided_lifetimes.h;l=10
// Error while generating bindings for item 'S::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct S &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct S &&': Unsupported type: && without lifetime
impl S {
#[inline(always)]
diff --git a/rs_bindings_from_cc/test/golden/no_elided_lifetimes_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/no_elided_lifetimes_rs_api_impl.cc
index 1a6248e..aae75e0 100644
--- a/rs_bindings_from_cc/test/golden/no_elided_lifetimes_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/no_elided_lifetimes_rs_api_impl.cc
@@ -11,18 +11,20 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN1SC1Ev(class S* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN1SC1ERKS_(class S* __this,
const class S& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN1SD1Ev(class S* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class S& __rust_thunk___ZN1SaSERKS_(class S* __this,
const class S& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class S) == 1);
diff --git a/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api.rs b/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api.rs
index adc1110..fd6250d 100644
--- a/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api.rs
@@ -43,9 +43,18 @@
}
}
-// rs_bindings_from_cc/test/golden/nontrivial_type.h;l=17
-// Error while generating bindings for item 'Nontrivial::Nontrivial':
-// Parameter #0 is not supported: Unsupported type 'struct Nontrivial &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> ctor::CtorNew<ctor::RvalueReference<'b, Nontrivial>> for Nontrivial {
+ type CtorType = impl ctor::Ctor<Output = Self>;
+ #[inline(always)]
+ fn ctor_new(__param_0: ctor::RvalueReference<'b, Nontrivial>) -> Self::CtorType {
+ ctor::FnCtor::new(move |dest: std::pin::Pin<&mut std::mem::MaybeUninit<Self>>| unsafe {
+ crate::detail::__rust_thunk___ZN10NontrivialC1EOS_(
+ std::pin::Pin::into_inner_unchecked(dest),
+ __param_0,
+ );
+ })
+ }
+}
impl Drop for Nontrivial {
#[inline(always)]
@@ -85,9 +94,18 @@
}
}
-// rs_bindings_from_cc/test/golden/nontrivial_type.h;l=31
-// Error while generating bindings for item 'NontrivialInline::NontrivialInline':
-// Parameter #0 is not supported: Unsupported type 'struct NontrivialInline &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> ctor::CtorNew<ctor::RvalueReference<'b, NontrivialInline>> for NontrivialInline {
+ type CtorType = impl ctor::Ctor<Output = Self>;
+ #[inline(always)]
+ fn ctor_new(__param_0: ctor::RvalueReference<'b, NontrivialInline>) -> Self::CtorType {
+ ctor::FnCtor::new(move |dest: std::pin::Pin<&mut std::mem::MaybeUninit<Self>>| unsafe {
+ crate::detail::__rust_thunk___ZN16NontrivialInlineC1EOS_(
+ std::pin::Pin::into_inner_unchecked(dest),
+ __param_0,
+ );
+ })
+ }
+}
impl Drop for NontrivialInline {
#[inline(always)]
@@ -115,9 +133,18 @@
impl !Unpin for NontrivialMembers {}
-// rs_bindings_from_cc/test/golden/nontrivial_type.h;l=44
-// Error while generating bindings for item 'NontrivialMembers::NontrivialMembers':
-// Parameter #0 is not supported: Unsupported type 'struct NontrivialMembers &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> ctor::CtorNew<ctor::RvalueReference<'b, NontrivialMembers>> for NontrivialMembers {
+ type CtorType = impl ctor::Ctor<Output = Self>;
+ #[inline(always)]
+ fn ctor_new(__param_0: ctor::RvalueReference<'b, NontrivialMembers>) -> Self::CtorType {
+ ctor::FnCtor::new(move |dest: std::pin::Pin<&mut std::mem::MaybeUninit<Self>>| unsafe {
+ crate::detail::__rust_thunk___ZN17NontrivialMembersC1EOS_(
+ std::pin::Pin::into_inner_unchecked(dest),
+ __param_0,
+ );
+ })
+ }
+}
impl Drop for NontrivialMembers {
#[inline(always)]
@@ -161,6 +188,11 @@
__this: &'a mut std::mem::MaybeUninit<Nontrivial>,
field: i32,
);
+ #[link_name = "_ZN10NontrivialC1EOS_"]
+ pub(crate) fn __rust_thunk___ZN10NontrivialC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<Nontrivial>,
+ __param_0: ctor::RvalueReference<'b, Nontrivial>,
+ );
#[link_name = "_ZN10NontrivialD1Ev"]
pub(crate) fn __rust_thunk___ZN10NontrivialD1Ev<'a>(__this: *mut Nontrivial);
#[link_name = "_ZN10Nontrivial14MemberFunctionEv"]
@@ -171,10 +203,18 @@
__this: &'a mut std::mem::MaybeUninit<NontrivialInline>,
field: i32,
);
+ pub(crate) fn __rust_thunk___ZN16NontrivialInlineC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<NontrivialInline>,
+ __param_0: ctor::RvalueReference<'b, NontrivialInline>,
+ );
pub(crate) fn __rust_thunk___ZN16NontrivialInlineD1Ev<'a>(__this: *mut NontrivialInline);
pub(crate) fn __rust_thunk___ZN16NontrivialInline14MemberFunctionEv<'a>(
__this: std::pin::Pin<&'a mut NontrivialInline>,
);
+ pub(crate) fn __rust_thunk___ZN17NontrivialMembersC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<NontrivialMembers>,
+ __param_0: ctor::RvalueReference<'b, NontrivialMembers>,
+ );
pub(crate) fn __rust_thunk___ZN17NontrivialMembersD1Ev<'a>(__this: *mut NontrivialMembers);
#[link_name = "_Z21TakesByConstReferenceRK10Nontrivial"]
pub(crate) fn __rust_thunk___Z21TakesByConstReferenceRK10Nontrivial<'a>(
diff --git a/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api_impl.cc
index 1ddd46d..bea2d9e 100644
--- a/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/nontrivial_type_rs_api_impl.cc
@@ -12,19 +12,32 @@
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN16NontrivialInlineC1Ei(
class NontrivialInline* __this, int field) {
- rs_api_impl_support ::construct_at(__this, field);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(field)>(field));
+}
+extern "C" void __rust_thunk___ZN16NontrivialInlineC1EOS_(
+ class NontrivialInline* __this, class NontrivialInline&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN16NontrivialInlineD1Ev(
class NontrivialInline* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN16NontrivialInline14MemberFunctionEv(
class NontrivialInline* __this) {
__this->MemberFunction();
}
+extern "C" void __rust_thunk___ZN17NontrivialMembersC1EOS_(
+ class NontrivialMembers* __this, class NontrivialMembers&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
extern "C" void __rust_thunk___ZN17NontrivialMembersD1Ev(
class NontrivialMembers* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
static_assert(sizeof(class Nontrivial) == 4);
diff --git a/rs_bindings_from_cc/test/golden/polymorphic_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/polymorphic_rs_api_impl.cc
index 55ea575..7079da2 100644
--- a/rs_bindings_from_cc/test/golden/polymorphic_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/polymorphic_rs_api_impl.cc
@@ -12,19 +12,21 @@
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN16PolymorphicClassC1Ev(
class PolymorphicClass* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN16PolymorphicClassC1ERKS_(
class PolymorphicClass* __this, const class PolymorphicClass& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" class PolymorphicClass& __rust_thunk___ZN16PolymorphicClassaSERKS_(
class PolymorphicClass* __this, const class PolymorphicClass& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN16PolymorphicClassD1Ev(
class PolymorphicClass* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
static_assert(sizeof(class PolymorphicClass) == 8);
diff --git a/rs_bindings_from_cc/test/golden/private_members_rs_api.rs b/rs_bindings_from_cc/test/golden/private_members_rs_api.rs
index 621e364..ed446ae 100644
--- a/rs_bindings_from_cc/test/golden/private_members_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/private_members_rs_api.rs
@@ -36,9 +36,16 @@
}
}
-// rs_bindings_from_cc/test/golden/private_members.h;l=10
-// Error while generating bindings for item 'SomeClass::SomeClass':
-// Parameter #0 is not supported: Unsupported type 'class SomeClass &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, SomeClass>> for SomeClass {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, SomeClass>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN9SomeClassC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/private_members.h;l=10
// Error while generating bindings for item 'SomeClass::operator=':
@@ -46,7 +53,7 @@
// rs_bindings_from_cc/test/golden/private_members.h;l=10
// Error while generating bindings for item 'SomeClass::operator=':
-// Parameter #0 is not supported: Unsupported type 'class SomeClass &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
impl SomeClass {
#[inline(always)]
@@ -71,6 +78,10 @@
pub(crate) fn __rust_thunk___ZN9SomeClassC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<SomeClass>,
);
+ pub(crate) fn __rust_thunk___ZN9SomeClassC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<SomeClass>,
+ __param_0: ctor::RvalueReference<'b, SomeClass>,
+ );
#[link_name = "_ZN9SomeClass13public_methodEv"]
pub(crate) fn __rust_thunk___ZN9SomeClass13public_methodEv<'a>(__this: &'a mut SomeClass);
#[link_name = "_ZN9SomeClass20public_static_methodEv"]
diff --git a/rs_bindings_from_cc/test/golden/private_members_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/private_members_rs_api_impl.cc
index b296b7b..3f47436 100644
--- a/rs_bindings_from_cc/test/golden/private_members_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/private_members_rs_api_impl.cc
@@ -11,18 +11,30 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN9SomeClassC1Ev(class SomeClass* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN9SomeClassC1ERKS_(
class SomeClass* __this, const class SomeClass& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN9SomeClassC1EOS_(class SomeClass* __this,
+ class SomeClass&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN9SomeClassD1Ev(class SomeClass* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class SomeClass& __rust_thunk___ZN9SomeClassaSERKS_(
class SomeClass* __this, const class SomeClass& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class SomeClass& __rust_thunk___ZN9SomeClassaSEOS_(
+ class SomeClass* __this, class SomeClass&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class SomeClass) == 8);
diff --git a/rs_bindings_from_cc/test/golden/static_methods_rs_api.rs b/rs_bindings_from_cc/test/golden/static_methods_rs_api.rs
index 02ccc76..7dab28c 100644
--- a/rs_bindings_from_cc/test/golden/static_methods_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/static_methods_rs_api.rs
@@ -35,9 +35,16 @@
}
}
-// rs_bindings_from_cc/test/golden/static_methods.h;l=10
-// Error while generating bindings for item 'SomeClass::SomeClass':
-// Parameter #0 is not supported: Unsupported type 'class SomeClass &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, SomeClass>> for SomeClass {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, SomeClass>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN9SomeClassC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/static_methods.h;l=10
// Error while generating bindings for item 'SomeClass::operator=':
@@ -45,7 +52,7 @@
// rs_bindings_from_cc/test/golden/static_methods.h;l=10
// Error while generating bindings for item 'SomeClass::operator=':
-// Parameter #0 is not supported: Unsupported type 'class SomeClass &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
impl SomeClass {
/// Example of a factory method.
@@ -80,6 +87,10 @@
pub(crate) fn __rust_thunk___ZN9SomeClassC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<SomeClass>,
);
+ pub(crate) fn __rust_thunk___ZN9SomeClassC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<SomeClass>,
+ __param_0: ctor::RvalueReference<'b, SomeClass>,
+ );
#[link_name = "_ZN9SomeClass21static_factory_methodEi"]
pub(crate) fn __rust_thunk___ZN9SomeClass21static_factory_methodEi(
initial_value_of_field: i32,
diff --git a/rs_bindings_from_cc/test/golden/static_methods_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/static_methods_rs_api_impl.cc
index 377b38c..b14bc75 100644
--- a/rs_bindings_from_cc/test/golden/static_methods_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/static_methods_rs_api_impl.cc
@@ -11,18 +11,30 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN9SomeClassC1Ev(class SomeClass* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN9SomeClassC1ERKS_(
class SomeClass* __this, const class SomeClass& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN9SomeClassC1EOS_(class SomeClass* __this,
+ class SomeClass&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN9SomeClassD1Ev(class SomeClass* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class SomeClass& __rust_thunk___ZN9SomeClassaSERKS_(
class SomeClass* __this, const class SomeClass& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class SomeClass& __rust_thunk___ZN9SomeClassaSEOS_(
+ class SomeClass* __this, class SomeClass&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class SomeClass) == 4);
diff --git a/rs_bindings_from_cc/test/golden/trivial_type_rs_api.rs b/rs_bindings_from_cc/test/golden/trivial_type_rs_api.rs
index dabe8b7..2ca4ac6 100644
--- a/rs_bindings_from_cc/test/golden/trivial_type_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/trivial_type_rs_api.rs
@@ -37,9 +37,16 @@
}
}
-// rs_bindings_from_cc/test/golden/trivial_type.h;l=12
-// Error while generating bindings for item 'Trivial::Trivial':
-// Parameter #0 is not supported: Unsupported type 'struct Trivial &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, Trivial>> for Trivial {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, Trivial>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN7TrivialC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/trivial_type.h;l=12
// Error while generating bindings for item 'Trivial::operator=':
@@ -47,7 +54,7 @@
// rs_bindings_from_cc/test/golden/trivial_type.h;l=12
// Error while generating bindings for item 'Trivial::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct Trivial &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
/// Defaulted special member functions are trivial on a struct with only trivial
/// members.
@@ -72,13 +79,20 @@
// Error while generating bindings for item 'TrivialWithDefaulted::operator=':
// Bindings for this kind of operator are not supported
-// rs_bindings_from_cc/test/golden/trivial_type.h;l=23
-// Error while generating bindings for item 'TrivialWithDefaulted::TrivialWithDefaulted':
-// Parameter #0 is not supported: Unsupported type 'struct TrivialWithDefaulted &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, TrivialWithDefaulted>> for TrivialWithDefaulted {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, TrivialWithDefaulted>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN20TrivialWithDefaultedC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/trivial_type.h;l=24
// Error while generating bindings for item 'TrivialWithDefaulted::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct TrivialWithDefaulted &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
/// This struct is trivial, and therefore trivially relocatable etc., but still
/// not safe to pass by reference as it is not final.
@@ -106,9 +120,18 @@
}
}
-// rs_bindings_from_cc/test/golden/trivial_type.h;l=33
-// Error while generating bindings for item 'TrivialNonfinal::TrivialNonfinal':
-// Parameter #0 is not supported: Unsupported type 'struct TrivialNonfinal &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> ctor::CtorNew<ctor::RvalueReference<'b, TrivialNonfinal>> for TrivialNonfinal {
+ type CtorType = impl ctor::Ctor<Output = Self>;
+ #[inline(always)]
+ fn ctor_new(__param_0: ctor::RvalueReference<'b, TrivialNonfinal>) -> Self::CtorType {
+ ctor::FnCtor::new(move |dest: std::pin::Pin<&mut std::mem::MaybeUninit<Self>>| unsafe {
+ crate::detail::__rust_thunk___ZN15TrivialNonfinalC1EOS_(
+ std::pin::Pin::into_inner_unchecked(dest),
+ __param_0,
+ );
+ })
+ }
+}
// rs_bindings_from_cc/test/golden/trivial_type.h;l=33
// Error while generating bindings for item 'TrivialNonfinal::operator=':
@@ -116,7 +139,7 @@
// rs_bindings_from_cc/test/golden/trivial_type.h;l=33
// Error while generating bindings for item 'TrivialNonfinal::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct TrivialNonfinal &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
#[inline(always)]
pub fn TakesByValue(trivial: Trivial) {
@@ -167,13 +190,25 @@
pub(crate) fn __rust_thunk___ZN7TrivialC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<Trivial>,
);
+ pub(crate) fn __rust_thunk___ZN7TrivialC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<Trivial>,
+ __param_0: ctor::RvalueReference<'b, Trivial>,
+ );
pub(crate) fn __rust_thunk___ZN20TrivialWithDefaultedC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<TrivialWithDefaulted>,
);
+ pub(crate) fn __rust_thunk___ZN20TrivialWithDefaultedC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<TrivialWithDefaulted>,
+ __param_0: ctor::RvalueReference<'b, TrivialWithDefaulted>,
+ );
pub(crate) fn __rust_thunk___ZN15TrivialNonfinalC1ERKS_<'a, 'b>(
__this: &'a mut std::mem::MaybeUninit<TrivialNonfinal>,
__param_0: &'b TrivialNonfinal,
);
+ pub(crate) fn __rust_thunk___ZN15TrivialNonfinalC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<TrivialNonfinal>,
+ __param_0: ctor::RvalueReference<'b, TrivialNonfinal>,
+ );
#[link_name = "_Z12TakesByValue7Trivial"]
pub(crate) fn __rust_thunk___Z12TakesByValue7Trivial(trivial: Trivial);
#[link_name = "_Z25TakesWithDefaultedByValue20TrivialWithDefaulted"]
diff --git a/rs_bindings_from_cc/test/golden/trivial_type_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/trivial_type_rs_api_impl.cc
index a629c56..4baf9b9 100644
--- a/rs_bindings_from_cc/test/golden/trivial_type_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/trivial_type_rs_api_impl.cc
@@ -11,53 +11,92 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN7TrivialC1Ev(class Trivial* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN7TrivialC1ERKS_(
class Trivial* __this, const class Trivial& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN7TrivialC1EOS_(class Trivial* __this,
+ class Trivial&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN7TrivialD1Ev(class Trivial* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class Trivial& __rust_thunk___ZN7TrivialaSERKS_(
class Trivial* __this, const class Trivial& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class Trivial& __rust_thunk___ZN7TrivialaSEOS_(
+ class Trivial* __this, class Trivial&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN20TrivialWithDefaultedC1Ev(
class TrivialWithDefaulted* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN20TrivialWithDefaultedC1ERKS_(
class TrivialWithDefaulted* __this,
const class TrivialWithDefaulted& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" class TrivialWithDefaulted&
__rust_thunk___ZN20TrivialWithDefaultedaSERKS_(
class TrivialWithDefaulted* __this,
const class TrivialWithDefaulted& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN20TrivialWithDefaultedC1EOS_(
+ class TrivialWithDefaulted* __this,
+ class TrivialWithDefaulted&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class TrivialWithDefaulted&
+__rust_thunk___ZN20TrivialWithDefaultedaSEOS_(
+ class TrivialWithDefaulted* __this,
+ class TrivialWithDefaulted&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN20TrivialWithDefaultedD1Ev(
class TrivialWithDefaulted* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN15TrivialNonfinalC1Ev(
class TrivialNonfinal* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN15TrivialNonfinalC1ERKS_(
class TrivialNonfinal* __this, const class TrivialNonfinal& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN15TrivialNonfinalC1EOS_(
+ class TrivialNonfinal* __this, class TrivialNonfinal&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN15TrivialNonfinalD1Ev(
class TrivialNonfinal* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class TrivialNonfinal& __rust_thunk___ZN15TrivialNonfinalaSERKS_(
class TrivialNonfinal* __this, const class TrivialNonfinal& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class TrivialNonfinal& __rust_thunk___ZN15TrivialNonfinalaSEOS_(
+ class TrivialNonfinal* __this, class TrivialNonfinal&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class Trivial) == 4);
diff --git a/rs_bindings_from_cc/test/golden/types.h b/rs_bindings_from_cc/test/golden/types.h
index 41bbb5a..771b453 100644
--- a/rs_bindings_from_cc/test/golden/types.h
+++ b/rs_bindings_from_cc/test/golden/types.h
@@ -76,6 +76,9 @@
const SomeStruct* const_struct_ptr_field;
SomeStruct& struct_ref_field;
const SomeStruct& const_struct_ref_field;
+ // TODO(b/226580208): Uncomment when these don't cause struct import to fail.
+ // SomeStruct&& struct_rvalue_ref_field;
+ // const SomeStruct&& const_struct_rvalue_ref_field;
};
inline void VoidReturningFunction() {}
diff --git a/rs_bindings_from_cc/test/golden/types_rs_api.rs b/rs_bindings_from_cc/test/golden/types_rs_api.rs
index 4a72c48..2f1c176 100644
--- a/rs_bindings_from_cc/test/golden/types_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/types_rs_api.rs
@@ -36,9 +36,16 @@
}
}
-// rs_bindings_from_cc/test/golden/types.h;l=13
-// Error while generating bindings for item 'SomeStruct::SomeStruct':
-// Parameter #0 is not supported: Unsupported type 'struct SomeStruct &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, SomeStruct>> for SomeStruct {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, SomeStruct>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN10SomeStructC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/types.h;l=13
// Error while generating bindings for item 'SomeStruct::operator=':
@@ -46,7 +53,7 @@
// rs_bindings_from_cc/test/golden/types.h;l=13
// Error while generating bindings for item 'SomeStruct::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct SomeStruct &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
// rs_bindings_from_cc/test/golden/types.h;l=15
// Error while generating bindings for item 'SomeUnion':
@@ -108,9 +115,16 @@
pub const_struct_ref_field: *const SomeStruct,
}
-// rs_bindings_from_cc/test/golden/types.h;l=17
-// Error while generating bindings for item 'FieldTypeTestStruct::FieldTypeTestStruct':
-// Parameter #0 is not supported: Unsupported type 'struct FieldTypeTestStruct &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, FieldTypeTestStruct>> for FieldTypeTestStruct {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, FieldTypeTestStruct>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN19FieldTypeTestStructC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
#[inline(always)]
pub fn VoidReturningFunction() {
@@ -126,6 +140,14 @@
pub(crate) fn __rust_thunk___ZN10SomeStructC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<SomeStruct>,
);
+ pub(crate) fn __rust_thunk___ZN10SomeStructC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<SomeStruct>,
+ __param_0: ctor::RvalueReference<'b, SomeStruct>,
+ );
+ pub(crate) fn __rust_thunk___ZN19FieldTypeTestStructC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<FieldTypeTestStruct>,
+ __param_0: ctor::RvalueReference<'b, FieldTypeTestStruct>,
+ );
pub(crate) fn __rust_thunk___Z21VoidReturningFunctionv();
}
}
diff --git a/rs_bindings_from_cc/test/golden/types_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/types_rs_api_impl.cc
index 3c8e3bd..004330b 100644
--- a/rs_bindings_from_cc/test/golden/types_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/types_rs_api_impl.cc
@@ -11,27 +11,47 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN10SomeStructC1Ev(class SomeStruct* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN10SomeStructC1ERKS_(
class SomeStruct* __this, const class SomeStruct& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN10SomeStructC1EOS_(
+ class SomeStruct* __this, class SomeStruct&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN10SomeStructD1Ev(class SomeStruct* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class SomeStruct& __rust_thunk___ZN10SomeStructaSERKS_(
class SomeStruct* __this, const class SomeStruct& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class SomeStruct& __rust_thunk___ZN10SomeStructaSEOS_(
+ class SomeStruct* __this, class SomeStruct&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN19FieldTypeTestStructC1ERKS_(
class FieldTypeTestStruct* __this,
const class FieldTypeTestStruct& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN19FieldTypeTestStructC1EOS_(
+ class FieldTypeTestStruct* __this, class FieldTypeTestStruct&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN19FieldTypeTestStructD1Ev(
class FieldTypeTestStruct* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___Z21VoidReturningFunctionv() {
VoidReturningFunction();
diff --git a/rs_bindings_from_cc/test/golden/unsupported_rs_api.rs b/rs_bindings_from_cc/test/golden/unsupported_rs_api.rs
index e8adf6a..f0862dc 100644
--- a/rs_bindings_from_cc/test/golden/unsupported_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/unsupported_rs_api.rs
@@ -5,7 +5,7 @@
// Automatically @generated Rust bindings for C++ target
// //rs_bindings_from_cc/test/golden:unsupported_cc
#![rustfmt::skip]
-#![feature(const_ptr_offset_from, custom_inner_attributes, negative_impls)]
+#![feature(const_ptr_offset_from, custom_inner_attributes, negative_impls, type_alias_impl_trait)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
@@ -25,9 +25,18 @@
impl !Unpin for NontrivialCustomType {}
-// rs_bindings_from_cc/test/golden/unsupported.h;l=11
-// Error while generating bindings for item 'NontrivialCustomType::NontrivialCustomType':
-// Parameter #0 is not supported: Unsupported type 'struct NontrivialCustomType &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> ctor::CtorNew<ctor::RvalueReference<'b, NontrivialCustomType>> for NontrivialCustomType {
+ type CtorType = impl ctor::Ctor<Output = Self>;
+ #[inline(always)]
+ fn ctor_new(__param_0: ctor::RvalueReference<'b, NontrivialCustomType>) -> Self::CtorType {
+ ctor::FnCtor::new(move |dest: std::pin::Pin<&mut std::mem::MaybeUninit<Self>>| unsafe {
+ crate::detail::__rust_thunk___ZN20NontrivialCustomTypeC1EOS_(
+ std::pin::Pin::into_inner_unchecked(dest),
+ __param_0,
+ );
+ })
+ }
+}
// rs_bindings_from_cc/test/golden/unsupported.h;l=16
// Error while generating bindings for item 'UnsupportedParamType':
@@ -69,9 +78,16 @@
}
}
-// rs_bindings_from_cc/test/golden/unsupported.h;l=30
-// Error while generating bindings for item 'ContainingStruct::ContainingStruct':
-// Parameter #0 is not supported: Unsupported type 'struct ContainingStruct &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, ContainingStruct>> for ContainingStruct {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, ContainingStruct>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN16ContainingStructC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/unsupported.h;l=30
// Error while generating bindings for item 'ContainingStruct::operator=':
@@ -79,7 +95,7 @@
// rs_bindings_from_cc/test/golden/unsupported.h;l=30
// Error while generating bindings for item 'ContainingStruct::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct ContainingStruct &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
// rs_bindings_from_cc/test/golden/unsupported.h;l=31
// Error while generating bindings for item 'ContainingStruct::NestedStruct':
@@ -99,9 +115,18 @@
#[allow(unused_imports)]
use super::*;
extern "C" {
+ #[link_name = "_ZN20NontrivialCustomTypeC1EOS_"]
+ pub(crate) fn __rust_thunk___ZN20NontrivialCustomTypeC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<NontrivialCustomType>,
+ __param_0: ctor::RvalueReference<'b, NontrivialCustomType>,
+ );
pub(crate) fn __rust_thunk___ZN16ContainingStructC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<ContainingStruct>,
);
+ pub(crate) fn __rust_thunk___ZN16ContainingStructC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<ContainingStruct>,
+ __param_0: ctor::RvalueReference<'b, ContainingStruct>,
+ );
}
}
diff --git a/rs_bindings_from_cc/test/golden/unsupported_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/unsupported_rs_api_impl.cc
index 8986bd5..d54bae4 100644
--- a/rs_bindings_from_cc/test/golden/unsupported_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/unsupported_rs_api_impl.cc
@@ -12,23 +12,35 @@
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN20NontrivialCustomTypeD1Ev(
class NontrivialCustomType* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN16ContainingStructC1Ev(
class ContainingStruct* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN16ContainingStructC1ERKS_(
class ContainingStruct* __this, const class ContainingStruct& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN16ContainingStructC1EOS_(
+ class ContainingStruct* __this, class ContainingStruct&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN16ContainingStructD1Ev(
class ContainingStruct* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class ContainingStruct& __rust_thunk___ZN16ContainingStructaSERKS_(
class ContainingStruct* __this, const class ContainingStruct& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class ContainingStruct& __rust_thunk___ZN16ContainingStructaSEOS_(
+ class ContainingStruct* __this, class ContainingStruct&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class NontrivialCustomType) == 4);
diff --git a/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api.rs b/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api.rs
index 8d85ba0..186bddf 100644
--- a/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api.rs
@@ -55,7 +55,7 @@
// rs_bindings_from_cc/test/golden/user_of_base_class.h;l=15
// Error while generating bindings for item 'Derived2::Derived2':
-// Parameter #0 is not supported: Unsupported type 'struct Derived2 &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct Derived2 &&': Unsupported type: && without lifetime
// rs_bindings_from_cc/test/golden/user_of_base_class.h;l=15
// Error while generating bindings for item 'Derived2::operator=':
@@ -63,7 +63,7 @@
// rs_bindings_from_cc/test/golden/user_of_base_class.h;l=15
// Error while generating bindings for item 'Derived2::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct Derived2 &&': Unsupported clang::Type class 'RValueReference'
+// Parameter #0 is not supported: Unsupported type 'struct Derived2 &&': Unsupported type: && without lifetime
// CRUBIT_RS_BINDINGS_FROM_CC_TEST_GOLDEN_USER_OF_BASE_CLASS_H_
diff --git a/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api_impl.cc
index c3fce68..e3e62b1 100644
--- a/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/user_of_base_class_rs_api_impl.cc
@@ -11,18 +11,20 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN8Derived2C1Ev(class Derived2* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN8Derived2C1ERKS_(
class Derived2* __this, const class Derived2& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN8Derived2D1Ev(class Derived2* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class Derived2& __rust_thunk___ZN8Derived2aSERKS_(
class Derived2* __this, const class Derived2& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class Derived2) == 16);
diff --git a/rs_bindings_from_cc/test/golden/user_of_imported_type_rs_api.rs b/rs_bindings_from_cc/test/golden/user_of_imported_type_rs_api.rs
index f29c5a7..59a7948 100644
--- a/rs_bindings_from_cc/test/golden/user_of_imported_type_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/user_of_imported_type_rs_api.rs
@@ -40,9 +40,16 @@
}
}
-// rs_bindings_from_cc/test/golden/user_of_imported_type.h;l=14
-// Error while generating bindings for item 'UserOfImportedType::UserOfImportedType':
-// Parameter #0 is not supported: Unsupported type 'struct UserOfImportedType &&': Unsupported clang::Type class 'RValueReference'
+impl<'b> From<ctor::RvalueReference<'b, UserOfImportedType>> for UserOfImportedType {
+ #[inline(always)]
+ fn from(__param_0: ctor::RvalueReference<'b, UserOfImportedType>) -> Self {
+ let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
+ unsafe {
+ crate::detail::__rust_thunk___ZN18UserOfImportedTypeC1EOS_(&mut tmp, __param_0);
+ tmp.assume_init()
+ }
+ }
+}
// rs_bindings_from_cc/test/golden/user_of_imported_type.h;l=14
// Error while generating bindings for item 'UserOfImportedType::operator=':
@@ -50,7 +57,7 @@
// rs_bindings_from_cc/test/golden/user_of_imported_type.h;l=14
// Error while generating bindings for item 'UserOfImportedType::operator=':
-// Parameter #0 is not supported: Unsupported type 'struct UserOfImportedType &&': Unsupported clang::Type class 'RValueReference'
+// Bindings for this kind of operator are not supported
// CRUBIT_RS_BINDINGS_FROM_CC_TEST_GOLDEN_USER_OF_IMPORTED_TYPE_H_
@@ -65,6 +72,10 @@
pub(crate) fn __rust_thunk___ZN18UserOfImportedTypeC1Ev<'a>(
__this: &'a mut std::mem::MaybeUninit<UserOfImportedType>,
);
+ pub(crate) fn __rust_thunk___ZN18UserOfImportedTypeC1EOS_<'a, 'b>(
+ __this: &'a mut std::mem::MaybeUninit<UserOfImportedType>,
+ __param_0: ctor::RvalueReference<'b, UserOfImportedType>,
+ );
}
}
diff --git a/rs_bindings_from_cc/test/golden/user_of_imported_type_rs_api_impl.cc b/rs_bindings_from_cc/test/golden/user_of_imported_type_rs_api_impl.cc
index a2f59e9..d4a3bd8 100644
--- a/rs_bindings_from_cc/test/golden/user_of_imported_type_rs_api_impl.cc
+++ b/rs_bindings_from_cc/test/golden/user_of_imported_type_rs_api_impl.cc
@@ -12,22 +12,35 @@
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
extern "C" void __rust_thunk___ZN18UserOfImportedTypeC1Ev(
class UserOfImportedType* __this) {
- rs_api_impl_support ::construct_at(__this);
+ rs_api_impl_support ::construct_at(std ::forward<decltype(__this)>(__this));
}
extern "C" void __rust_thunk___ZN18UserOfImportedTypeC1ERKS_(
class UserOfImportedType* __this,
const class UserOfImportedType& __param_0) {
- rs_api_impl_support ::construct_at(__this, __param_0);
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" void __rust_thunk___ZN18UserOfImportedTypeC1EOS_(
+ class UserOfImportedType* __this, class UserOfImportedType&& __param_0) {
+ rs_api_impl_support ::construct_at(
+ std ::forward<decltype(__this)>(__this),
+ std ::forward<decltype(__param_0)>(__param_0));
}
extern "C" void __rust_thunk___ZN18UserOfImportedTypeD1Ev(
class UserOfImportedType* __this) {
- std ::destroy_at(__this);
+ std ::destroy_at(std ::forward<decltype(__this)>(__this));
}
extern "C" class UserOfImportedType&
__rust_thunk___ZN18UserOfImportedTypeaSERKS_(
class UserOfImportedType* __this,
const class UserOfImportedType& __param_0) {
- return __this->operator=(__param_0);
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
+}
+extern "C" class UserOfImportedType&
+__rust_thunk___ZN18UserOfImportedTypeaSEOS_(
+ class UserOfImportedType* __this, class UserOfImportedType&& __param_0) {
+ return __this->operator=(std ::forward<decltype(__param_0)>(__param_0));
}
static_assert(sizeof(class UserOfImportedType) == 8);
diff --git a/rs_bindings_from_cc/test/struct/nonunpin/nonunpin.h b/rs_bindings_from_cc/test/struct/nonunpin/nonunpin.h
index fa97d4d..a66b3d7 100644
--- a/rs_bindings_from_cc/test/struct/nonunpin/nonunpin.h
+++ b/rs_bindings_from_cc/test/struct/nonunpin/nonunpin.h
@@ -6,6 +6,7 @@
#define CRUBIT_RS_BINDINGS_FROM_CC_TEST_STRUCT_NONUNPIN_NONUNPIN_H_
#include <cstddef>
+#include <utility>
#pragma clang lifetime_elision
// A deliberately !Unpin class.
@@ -14,14 +15,32 @@
explicit Nonunpin(int value)
: value_(value), addr_(reinterpret_cast<size_t>(this)) {}
Nonunpin(const Nonunpin& other) : Nonunpin(other.value_) {}
+ Nonunpin(Nonunpin&& other) : Nonunpin(other.value_) { other.value_ = 0; }
~Nonunpin() {}
size_t addr() const { return addr_; }
int value() const { return value_; }
void set_value(int new_value) { value_ = new_value; }
+ Nonunpin& AsMutRef() { return *this; }
+ Nonunpin&& AsRvalueRef() { return std::move(*this); }
+
+ const Nonunpin& AsConstRef() const { return *this; }
+ const Nonunpin&& AsConstRvalueRef() const { return std::move(*this); }
+
private:
int value_;
size_t addr_;
};
+inline int GetValueFromMutRef(Nonunpin& nonunpin) { return nonunpin.value(); }
+inline int GetValueFromConstRef(const Nonunpin& nonunpin) {
+ return nonunpin.value();
+}
+inline int GetValueFromRvalueRef(Nonunpin&& nonunpin) {
+ return nonunpin.value();
+}
+inline int GetValueFromConstRvalueRef(const Nonunpin&& nonunpin) {
+ return nonunpin.value();
+}
+
#endif // CRUBIT_RS_BINDINGS_FROM_CC_TEST_STRUCT_NONUNPIN_NONUNPIN_H_
diff --git a/rs_bindings_from_cc/test/struct/nonunpin/nonunpin_test.rs b/rs_bindings_from_cc/test/struct/nonunpin/nonunpin_test.rs
index bd83dec..92f12e9 100644
--- a/rs_bindings_from_cc/test/struct/nonunpin/nonunpin_test.rs
+++ b/rs_bindings_from_cc/test/struct/nonunpin/nonunpin_test.rs
@@ -5,7 +5,9 @@
//#[cfg(test)]
mod tests {
use ctor::CtorNew as _;
+ use ctor::{ConstRvalueReference, RvalueReference};
use nonunpin::Nonunpin;
+ use std::pin::Pin;
/// When a value is constructed in-place, it is initialized, has the correct
/// address.
@@ -17,6 +19,19 @@
assert_eq!(x.value(), 42);
assert_eq!(x.addr(), &*x as *const _ as usize);
}
+ #[test]
+ fn test_move() {
+ ctor::emplace! {
+ let mut x = Nonunpin::ctor_new(42);
+ let mut y = ctor::mov(x.as_mut());
+ }
+
+ assert_eq!(x.value(), 0); // moved-from
+ assert_eq!(y.value(), 42); // moved-to
+
+ assert_eq!(x.addr(), &*x as *const _ as usize);
+ assert_eq!(y.addr(), &*y as *const _ as usize);
+ }
#[test]
fn test_copy() {
@@ -40,4 +55,29 @@
x.as_mut().set_value(24);
assert_eq!(x.value(), 24);
}
+
+ /// Test that the struct can be returned and passed as all the reference
+ /// types.
+ #[test]
+ fn test_ref() {
+ ctor::emplace! {
+ let mut x = Nonunpin::ctor_new(42);
+ }
+ {
+ let x: Pin<&mut Nonunpin> = x.as_mut().AsMutRef();
+ assert_eq!(nonunpin::GetValueFromMutRef(x), 42);
+ }
+ {
+ let x: &Nonunpin = x.AsConstRef();
+ assert_eq!(nonunpin::GetValueFromConstRef(x), 42);
+ }
+ {
+ let x: RvalueReference<Nonunpin> = x.as_mut().AsRvalueRef();
+ assert_eq!(nonunpin::GetValueFromRvalueRef(x), 42);
+ }
+ {
+ let x: ConstRvalueReference<Nonunpin> = x.AsConstRvalueRef();
+ assert_eq!(nonunpin::GetValueFromConstRvalueRef(x), 42);
+ }
+ }
}