blob: 3b9f2a11fb8e3854b38b374e6633db4be2aa7c4a [file] [log] [blame]
Devin Jeanpierred6da7002021-10-21 12:55:20 +00001#![rustfmt::skip]
Michael Forster523dbd42021-10-12 11:05:44 +00002// Part of the Crubit project, under the Apache License v2.0 with LLVM
3// Exceptions. See /LICENSE for license information.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
Googler4c553de2021-12-10 08:28:54 +00006#![feature(const_ptr_offset_from, custom_inner_attributes, negative_impls)]
Michael Forster523dbd42021-10-12 11:05:44 +00007
8use memoffset_unstable_const::offset_of;
Michael Forster523dbd42021-10-12 11:05:44 +00009
Michael Forster523dbd42021-10-12 11:05:44 +000010#[repr(C)]
Devin Jeanpierrebf0d5602021-10-13 20:47:39 +000011pub struct NontrivialCustomType {
Michael Forster523dbd42021-10-12 11:05:44 +000012 pub i: i32,
13}
14
Devin Jeanpierrebf0d5602021-10-13 20:47:39 +000015impl !Unpin for NontrivialCustomType {}
Michael Forster523dbd42021-10-12 11:05:44 +000016
Devin Jeanpierredf4dc8b2021-10-21 12:53:19 +000017// rs_bindings_from_cc/test/golden/unsupported.h;l=4
18// Error while generating bindings for item 'NontrivialCustomType::NontrivialCustomType':
19// Nested classes are not supported yet
20
Devin Jeanpierrebf0d5602021-10-13 20:47:39 +000021// rs_bindings_from_cc/test/golden/unsupported.h;l=5
22// Error while generating bindings for item 'NontrivialCustomType::NontrivialCustomType':
23// Parameter type 'struct NontrivialCustomType &&' is not supported
24
25// rs_bindings_from_cc/test/golden/unsupported.h;l=10
26// Error while generating bindings for item 'UnsupportedParamType':
27// Non-trivial_abi type 'struct NontrivialCustomType' is not supported by value as a parameter
28
29// rs_bindings_from_cc/test/golden/unsupported.h;l=11
Michael Forster523dbd42021-10-12 11:05:44 +000030// Error while generating bindings for item 'UnsupportedReturnType':
Devin Jeanpierrebf0d5602021-10-13 20:47:39 +000031// Non-trivial_abi type 'struct NontrivialCustomType' is not supported by value as a return type
Michael Forster523dbd42021-10-12 11:05:44 +000032
Lukasz Anforowicz0c816f12021-12-15 17:41:49 +000033// rs_bindings_from_cc/test/golden/unsupported.h;l=13
Michael Forster523dbd42021-10-12 11:05:44 +000034// Error while generating bindings for item 'MultipleReasons':
Devin Jeanpierrebf0d5602021-10-13 20:47:39 +000035// Non-trivial_abi type 'struct NontrivialCustomType' is not supported by value as a parameter
Michael Forster523dbd42021-10-12 11:05:44 +000036
Lukasz Anforowicz0c816f12021-12-15 17:41:49 +000037// rs_bindings_from_cc/test/golden/unsupported.h;l=13
Michael Forster523dbd42021-10-12 11:05:44 +000038// Error while generating bindings for item 'MultipleReasons':
Devin Jeanpierrebf0d5602021-10-13 20:47:39 +000039// Non-trivial_abi type 'struct NontrivialCustomType' is not supported by value as a return type
Michael Forster523dbd42021-10-12 11:05:44 +000040
Lukasz Anforowicz0c816f12021-12-15 17:41:49 +000041// rs_bindings_from_cc/test/golden/unsupported.h;l=16
Googlerc8a8e732021-10-19 07:49:24 +000042// Error while generating bindings for item 'ns::FunctionInNamespace':
43// Items contained in namespaces are not supported yet
44
Lukasz Anforowicz0c816f12021-12-15 17:41:49 +000045// rs_bindings_from_cc/test/golden/unsupported.h;l=17
Googlerc8a8e732021-10-19 07:49:24 +000046// Error while generating bindings for item 'ns::StructInNamespace':
47// Items contained in namespaces are not supported yet
48
49// namespace ns
50
Googler21351fc2021-10-19 08:58:04 +000051#[derive(Clone, Copy)]
52#[repr(C)]
53pub struct ContainingStruct {
Googlerf4792062021-10-20 07:21:21 +000054 /// Prevent empty C++ struct being zero-size in Rust.
Lukasz Anforowicz13cf7492021-12-22 15:29:52 +000055 placeholder: std::mem::MaybeUninit<u8>,
Googler21351fc2021-10-19 08:58:04 +000056}
57
Lukasz Anforowicz0c816f12021-12-15 17:41:49 +000058// rs_bindings_from_cc/test/golden/unsupported.h;l=20
Devin Jeanpierredf4dc8b2021-10-21 12:53:19 +000059// Error while generating bindings for item 'ContainingStruct::ContainingStruct':
60// Nested classes are not supported yet
61
Lukasz Anforowicz0c816f12021-12-15 17:41:49 +000062// rs_bindings_from_cc/test/golden/unsupported.h;l=21
Googler21351fc2021-10-19 08:58:04 +000063// Error while generating bindings for item 'ContainingStruct::NestedStruct':
64// Nested classes are not supported yet
65
Lukasz Anforowicz0c816f12021-12-15 17:41:49 +000066// rs_bindings_from_cc/test/golden/unsupported.h;l=21
Devin Jeanpierredf4dc8b2021-10-21 12:53:19 +000067// Error while generating bindings for item 'ContainingStruct::NestedStruct::NestedStruct':
68// Nested classes are not supported yet
69
Lukasz Anforowicz13cf7492021-12-22 15:29:52 +000070impl Default for ContainingStruct {
71 #[inline(always)]
72 fn default() -> Self {
Lukasz Anforowiczbedbdee2022-01-05 01:14:52 +000073 let mut tmp = std::mem::MaybeUninit::<Self>::zeroed();
Lukasz Anforowicz13cf7492021-12-22 15:29:52 +000074 unsafe {
75 crate::detail::__rust_thunk___ZN16ContainingStructC1Ev(tmp.as_mut_ptr());
76 tmp.assume_init()
77 }
78 }
79}
80
Lukasz Anforowicz0c816f12021-12-15 17:41:49 +000081// rs_bindings_from_cc/test/golden/unsupported.h;l=20
Devin Jeanpierre296c6072021-10-27 10:53:05 +000082// Error while generating bindings for item 'ContainingStruct::ContainingStruct':
83// Parameter type 'struct ContainingStruct &&' is not supported
84
Lukasz Anforowicz0c816f12021-12-15 17:41:49 +000085// rs_bindings_from_cc/test/golden/unsupported.h;l=20
Devin Jeanpierre296c6072021-10-27 10:53:05 +000086// Error while generating bindings for item 'ContainingStruct::operator=':
87// Parameter type 'struct ContainingStruct &&' is not supported
88
Michael Forsterf1dce422021-10-13 09:50:16 +000089// CRUBIT_RS_BINDINGS_FROM_CC_TEST_GOLDEN_UNSUPPORTED_H_
90
Devin Jeanpierre296c6072021-10-27 10:53:05 +000091mod detail {
92 use super::*;
93 extern "C" {
Lukasz Anforowicz4ad012b2021-12-15 18:13:40 +000094 pub(crate) fn __rust_thunk___ZN16ContainingStructC1Ev(__this: *mut ContainingStruct);
Devin Jeanpierre296c6072021-10-27 10:53:05 +000095 }
96}
97
Googler454f2652021-12-06 12:53:12 +000098const _: () = assert!(std::mem::size_of::<Option<&i32>>() == std::mem::size_of::<&i32>());
99
Googler209b10a2021-12-06 09:11:57 +0000100const _: () = assert!(std::mem::size_of::<NontrivialCustomType>() == 4usize);
101const _: () = assert!(std::mem::align_of::<NontrivialCustomType>() == 4usize);
102const _: () = assert!(offset_of!(NontrivialCustomType, i) * 8 == 0usize);
Googler21351fc2021-10-19 08:58:04 +0000103
Googler209b10a2021-12-06 09:11:57 +0000104const _: () = assert!(std::mem::size_of::<ContainingStruct>() == 1usize);
105const _: () = assert!(std::mem::align_of::<ContainingStruct>() == 1usize);