Devin Jeanpierre | d6da700 | 2021-10-21 12:55:20 +0000 | [diff] [blame] | 1 | #![rustfmt::skip] |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 2 | // 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 | |
Googler | 4c553de | 2021-12-10 08:28:54 +0000 | [diff] [blame] | 6 | #![feature(const_ptr_offset_from, custom_inner_attributes, negative_impls)] |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 7 | |
| 8 | use memoffset_unstable_const::offset_of; |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 9 | |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 10 | #[repr(C)] |
Devin Jeanpierre | bf0d560 | 2021-10-13 20:47:39 +0000 | [diff] [blame] | 11 | pub struct NontrivialCustomType { |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 12 | pub i: i32, |
| 13 | } |
| 14 | |
Devin Jeanpierre | bf0d560 | 2021-10-13 20:47:39 +0000 | [diff] [blame] | 15 | impl !Unpin for NontrivialCustomType {} |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 16 | |
Devin Jeanpierre | df4dc8b | 2021-10-21 12:53:19 +0000 | [diff] [blame] | 17 | // 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 Jeanpierre | bf0d560 | 2021-10-13 20:47:39 +0000 | [diff] [blame] | 21 | // 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 Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 30 | // Error while generating bindings for item 'UnsupportedReturnType': |
Devin Jeanpierre | bf0d560 | 2021-10-13 20:47:39 +0000 | [diff] [blame] | 31 | // Non-trivial_abi type 'struct NontrivialCustomType' is not supported by value as a return type |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 32 | |
Lukasz Anforowicz | 0c816f1 | 2021-12-15 17:41:49 +0000 | [diff] [blame] | 33 | // rs_bindings_from_cc/test/golden/unsupported.h;l=13 |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 34 | // Error while generating bindings for item 'MultipleReasons': |
Devin Jeanpierre | bf0d560 | 2021-10-13 20:47:39 +0000 | [diff] [blame] | 35 | // Non-trivial_abi type 'struct NontrivialCustomType' is not supported by value as a parameter |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 36 | |
Lukasz Anforowicz | 0c816f1 | 2021-12-15 17:41:49 +0000 | [diff] [blame] | 37 | // rs_bindings_from_cc/test/golden/unsupported.h;l=13 |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 38 | // Error while generating bindings for item 'MultipleReasons': |
Devin Jeanpierre | bf0d560 | 2021-10-13 20:47:39 +0000 | [diff] [blame] | 39 | // Non-trivial_abi type 'struct NontrivialCustomType' is not supported by value as a return type |
Michael Forster | 523dbd4 | 2021-10-12 11:05:44 +0000 | [diff] [blame] | 40 | |
Lukasz Anforowicz | 0c816f1 | 2021-12-15 17:41:49 +0000 | [diff] [blame] | 41 | // rs_bindings_from_cc/test/golden/unsupported.h;l=16 |
Googler | c8a8e73 | 2021-10-19 07:49:24 +0000 | [diff] [blame] | 42 | // Error while generating bindings for item 'ns::FunctionInNamespace': |
| 43 | // Items contained in namespaces are not supported yet |
| 44 | |
Lukasz Anforowicz | 0c816f1 | 2021-12-15 17:41:49 +0000 | [diff] [blame] | 45 | // rs_bindings_from_cc/test/golden/unsupported.h;l=17 |
Googler | c8a8e73 | 2021-10-19 07:49:24 +0000 | [diff] [blame] | 46 | // Error while generating bindings for item 'ns::StructInNamespace': |
| 47 | // Items contained in namespaces are not supported yet |
| 48 | |
| 49 | // namespace ns |
| 50 | |
Googler | 21351fc | 2021-10-19 08:58:04 +0000 | [diff] [blame] | 51 | #[derive(Clone, Copy)] |
| 52 | #[repr(C)] |
| 53 | pub struct ContainingStruct { |
Googler | f479206 | 2021-10-20 07:21:21 +0000 | [diff] [blame] | 54 | /// Prevent empty C++ struct being zero-size in Rust. |
Lukasz Anforowicz | 13cf749 | 2021-12-22 15:29:52 +0000 | [diff] [blame] | 55 | placeholder: std::mem::MaybeUninit<u8>, |
Googler | 21351fc | 2021-10-19 08:58:04 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Lukasz Anforowicz | 0c816f1 | 2021-12-15 17:41:49 +0000 | [diff] [blame] | 58 | // rs_bindings_from_cc/test/golden/unsupported.h;l=20 |
Devin Jeanpierre | df4dc8b | 2021-10-21 12:53:19 +0000 | [diff] [blame] | 59 | // Error while generating bindings for item 'ContainingStruct::ContainingStruct': |
| 60 | // Nested classes are not supported yet |
| 61 | |
Lukasz Anforowicz | 0c816f1 | 2021-12-15 17:41:49 +0000 | [diff] [blame] | 62 | // rs_bindings_from_cc/test/golden/unsupported.h;l=21 |
Googler | 21351fc | 2021-10-19 08:58:04 +0000 | [diff] [blame] | 63 | // Error while generating bindings for item 'ContainingStruct::NestedStruct': |
| 64 | // Nested classes are not supported yet |
| 65 | |
Lukasz Anforowicz | 0c816f1 | 2021-12-15 17:41:49 +0000 | [diff] [blame] | 66 | // rs_bindings_from_cc/test/golden/unsupported.h;l=21 |
Devin Jeanpierre | df4dc8b | 2021-10-21 12:53:19 +0000 | [diff] [blame] | 67 | // Error while generating bindings for item 'ContainingStruct::NestedStruct::NestedStruct': |
| 68 | // Nested classes are not supported yet |
| 69 | |
Lukasz Anforowicz | 13cf749 | 2021-12-22 15:29:52 +0000 | [diff] [blame] | 70 | impl Default for ContainingStruct { |
| 71 | #[inline(always)] |
| 72 | fn default() -> Self { |
Lukasz Anforowicz | bedbdee | 2022-01-05 01:14:52 +0000 | [diff] [blame^] | 73 | let mut tmp = std::mem::MaybeUninit::<Self>::zeroed(); |
Lukasz Anforowicz | 13cf749 | 2021-12-22 15:29:52 +0000 | [diff] [blame] | 74 | unsafe { |
| 75 | crate::detail::__rust_thunk___ZN16ContainingStructC1Ev(tmp.as_mut_ptr()); |
| 76 | tmp.assume_init() |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
Lukasz Anforowicz | 0c816f1 | 2021-12-15 17:41:49 +0000 | [diff] [blame] | 81 | // rs_bindings_from_cc/test/golden/unsupported.h;l=20 |
Devin Jeanpierre | 296c607 | 2021-10-27 10:53:05 +0000 | [diff] [blame] | 82 | // Error while generating bindings for item 'ContainingStruct::ContainingStruct': |
| 83 | // Parameter type 'struct ContainingStruct &&' is not supported |
| 84 | |
Lukasz Anforowicz | 0c816f1 | 2021-12-15 17:41:49 +0000 | [diff] [blame] | 85 | // rs_bindings_from_cc/test/golden/unsupported.h;l=20 |
Devin Jeanpierre | 296c607 | 2021-10-27 10:53:05 +0000 | [diff] [blame] | 86 | // Error while generating bindings for item 'ContainingStruct::operator=': |
| 87 | // Parameter type 'struct ContainingStruct &&' is not supported |
| 88 | |
Michael Forster | f1dce42 | 2021-10-13 09:50:16 +0000 | [diff] [blame] | 89 | // CRUBIT_RS_BINDINGS_FROM_CC_TEST_GOLDEN_UNSUPPORTED_H_ |
| 90 | |
Devin Jeanpierre | 296c607 | 2021-10-27 10:53:05 +0000 | [diff] [blame] | 91 | mod detail { |
| 92 | use super::*; |
| 93 | extern "C" { |
Lukasz Anforowicz | 4ad012b | 2021-12-15 18:13:40 +0000 | [diff] [blame] | 94 | pub(crate) fn __rust_thunk___ZN16ContainingStructC1Ev(__this: *mut ContainingStruct); |
Devin Jeanpierre | 296c607 | 2021-10-27 10:53:05 +0000 | [diff] [blame] | 95 | } |
| 96 | } |
| 97 | |
Googler | 454f265 | 2021-12-06 12:53:12 +0000 | [diff] [blame] | 98 | const _: () = assert!(std::mem::size_of::<Option<&i32>>() == std::mem::size_of::<&i32>()); |
| 99 | |
Googler | 209b10a | 2021-12-06 09:11:57 +0000 | [diff] [blame] | 100 | const _: () = assert!(std::mem::size_of::<NontrivialCustomType>() == 4usize); |
| 101 | const _: () = assert!(std::mem::align_of::<NontrivialCustomType>() == 4usize); |
| 102 | const _: () = assert!(offset_of!(NontrivialCustomType, i) * 8 == 0usize); |
Googler | 21351fc | 2021-10-19 08:58:04 +0000 | [diff] [blame] | 103 | |
Googler | 209b10a | 2021-12-06 09:11:57 +0000 | [diff] [blame] | 104 | const _: () = assert!(std::mem::size_of::<ContainingStruct>() == 1usize); |
| 105 | const _: () = assert!(std::mem::align_of::<ContainingStruct>() == 1usize); |