Allow aliases and C++ opaque types to be trivial.
This change allows aliases:
type Foo = bindgen::Bar;
and C++ opaque types:
type Foo;
to declare that they're 'trivial' in the sense that:
* They have trivial move constructors
* They have no destructors
and therefore may be passed and owned by value in Rust.
A subsequent commit will add C++ static assertions.
This commit is a BREAKING CHANGE as it requires existing
ExternTypes to gain a new associated type
diff --git a/syntax/check.rs b/syntax/check.rs
index 147984e..cfac236 100644
--- a/syntax/check.rs
+++ b/syntax/check.rs
@@ -338,6 +338,7 @@
|| cx.types.cxx.contains(ident)
&& !cx.types.structs.contains_key(ident)
&& !cx.types.enums.contains_key(ident)
+ && !cx.types.required_trivial_aliases.contains(ident)
|| cx.types.rust.contains(ident)
}
@@ -376,7 +377,11 @@
} else if cx.types.enums.contains_key(ident) {
"enum".to_owned()
} else if cx.types.cxx.contains(ident) {
- "C++ type".to_owned()
+ if cx.types.required_trivial_aliases.contains(ident) {
+ "trivial C++ type".to_owned()
+ } else {
+ "non-trivial C++ type".to_owned()
+ }
} else if cx.types.rust.contains(ident) {
"opaque Rust type".to_owned()
} else if Atom::from(ident) == Some(CxxString) {