rs_bindings_from_cc: Add a reproducer for template instantiation that involves a private type.
PiperOrigin-RevId: 577124828
Change-Id: I25faf56662e12bef6741b2374c2a7fb3e128953a
diff --git a/rs_bindings_from_cc/test/templates/type_alias_access_rule/BUILD b/rs_bindings_from_cc/test/templates/type_alias_access_rule/BUILD
new file mode 100644
index 0000000..a86e8f5
--- /dev/null
+++ b/rs_bindings_from_cc/test/templates/type_alias_access_rule/BUILD
@@ -0,0 +1,26 @@
+"""Test that Crubit-generated bindings conform to C++ access specifier rules, when template
+instantiation references a private type.
+"""
+
+load("//common:crubit_wrapper_macros_oss.bzl", "crubit_rust_test")
+load("//rs_bindings_from_cc/test:test_bindings.bzl", "crubit_test_cc_library")
+
+package(default_applicable_licenses = ["//:license"])
+
+crubit_test_cc_library(
+ name = "type_alias_access_rule",
+ hdrs = ["type_alias_access_rule.h"],
+)
+
+crubit_rust_test(
+ name = "main",
+ srcs = ["test.rs"],
+ cc_deps = [
+ ":type_alias_access_rule",
+ ],
+ # Disabled as it currently doesn't compile: b/305987013.
+ tags = [
+ "manual",
+ "notap",
+ ],
+)
diff --git a/rs_bindings_from_cc/test/templates/type_alias_access_rule/test.rs b/rs_bindings_from_cc/test/templates/type_alias_access_rule/test.rs
new file mode 100644
index 0000000..d5661c1
--- /dev/null
+++ b/rs_bindings_from_cc/test/templates/type_alias_access_rule/test.rs
@@ -0,0 +1,10 @@
+// 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
+
+#[cfg(test)]
+mod tests {
+
+ #[test]
+ fn test_compile() {}
+}
diff --git a/rs_bindings_from_cc/test/templates/type_alias_access_rule/type_alias_access_rule.h b/rs_bindings_from_cc/test/templates/type_alias_access_rule/type_alias_access_rule.h
new file mode 100644
index 0000000..8fc288b
--- /dev/null
+++ b/rs_bindings_from_cc/test/templates/type_alias_access_rule/type_alias_access_rule.h
@@ -0,0 +1,21 @@
+// 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 CRUBIT_RS_BINDINGS_FROM_CC_TEST_TEMPLATES_TYPE_ALIAS_TYPE_ALIAS_ACCESS_RULE_H_
+#define CRUBIT_RS_BINDINGS_FROM_CC_TEST_TEMPLATES_TYPE_ALIAS_TYPE_ALIAS_ACCESS_RULE_H_
+
+#pragma clang lifetime_elision
+
+template <typename T>
+class A final {};
+
+class B final {
+ private:
+ struct PrivateMember;
+
+ public:
+ A<PrivateMember> a_;
+};
+
+#endif // CRUBIT_RS_BINDINGS_FROM_CC_TEST_TEMPLATES_TYPE_ALIAS_TYPE_ALIAS_ACCESS_RULE_H_