Add wrapper struct integration-ish tests for crubit features.
PiperOrigin-RevId: 524414871
diff --git a/rs_bindings_from_cc/test/crubit_features/BUILD b/rs_bindings_from_cc/test/crubit_features/BUILD
index 01988f2..9d0a41f 100644
--- a/rs_bindings_from_cc/test/crubit_features/BUILD
+++ b/rs_bindings_from_cc/test/crubit_features/BUILD
@@ -35,6 +35,12 @@
deps = [":definition_disabled"],
)
+crubit_test_cc_library(
+ name = "wrapper_struct_enabled",
+ hdrs = ["wrapper_struct_enabled.h"],
+ deps = [":definition_disabled"],
+)
+
rust_test(
name = "test",
srcs = ["test.rs"],
@@ -44,6 +50,7 @@
":definition_disabled",
":definition_enabled",
":func_enabled",
+ ":wrapper_struct_enabled",
],
proc_macro_deps = [
":item_exists",
diff --git a/rs_bindings_from_cc/test/crubit_features/definition_disabled.h b/rs_bindings_from_cc/test/crubit_features/definition_disabled.h
index d25709f..cabcd6c 100644
--- a/rs_bindings_from_cc/test/crubit_features/definition_disabled.h
+++ b/rs_bindings_from_cc/test/crubit_features/definition_disabled.h
@@ -5,12 +5,12 @@
#ifndef THIRD_PARTY_CRUBIT_RS_BINDINGS_FROM_CC_TEST_CRUBIT_FEATURES_DEFINITION_DISABLED_H_
#define THIRD_PARTY_CRUBIT_RS_BINDINGS_FROM_CC_TEST_CRUBIT_FEATURES_DEFINITION_DISABLED_H_
-struct DisabledStruct {
+struct DisabledStruct final {
unsigned char x;
};
template <typename T>
-struct DisabledTemplate {
+struct DisabledTemplate final {
T x;
};
diff --git a/rs_bindings_from_cc/test/crubit_features/test.rs b/rs_bindings_from_cc/test/crubit_features/test.rs
index dd6ef70..a983bb2 100644
--- a/rs_bindings_from_cc/test/crubit_features/test.rs
+++ b/rs_bindings_from_cc/test/crubit_features/test.rs
@@ -84,3 +84,12 @@
assert!(!value_exists!(func_enabled::FuncReturnsDisabledTemplate));
}
}
+
+mod structs {
+ use super::*;
+ #[test]
+ fn test_struct_enabled() {
+ // The generated field assertions will handle the rest.
+ assert!(type_exists!(wrapper_struct_enabled::EnabledStructWithDisabledField));
+ }
+}
diff --git a/rs_bindings_from_cc/test/crubit_features/wrapper_struct_enabled.h b/rs_bindings_from_cc/test/crubit_features/wrapper_struct_enabled.h
new file mode 100644
index 0000000..3d39cc4
--- /dev/null
+++ b/rs_bindings_from_cc/test/crubit_features/wrapper_struct_enabled.h
@@ -0,0 +1,14 @@
+// Part of the Crubit project, under the Apache License v2.0 with LLVM
+// Exceptions. See /LICENSE for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#ifndef THIRD_PARTY_CRUBIT_RS_BINDINGS_FROM_CC_TEST_CRUBIT_FEATURES_WRAPPER_STRUCT_ENABLED_H_
+#define THIRD_PARTY_CRUBIT_RS_BINDINGS_FROM_CC_TEST_CRUBIT_FEATURES_WRAPPER_STRUCT_ENABLED_H_
+
+#include "rs_bindings_from_cc/test/crubit_features/definition_disabled.h"
+
+struct EnabledStructWithDisabledField final {
+ DisabledStruct x;
+ int y;
+};
+
+#endif // THIRD_PARTY_CRUBIT_RS_BINDINGS_FROM_CC_TEST_CRUBIT_FEATURES_WRAPPER_STRUCT_ENABLED_H_