diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/codegen/mod.rs | 2 | ||||
-rw-r--r-- | src/ir/context.rs | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 0956eb7a..8d1327b3 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -610,6 +610,8 @@ impl CodeGenerator for Type { TypeKind::TypeParam => { // These items don't need code generation, they only need to be // converted to rust types in fields, arguments, and such. + // NOTE(emilio): If you add to this list, make sure to also add + // it to BindgenContext::compute_whitelisted_and_codegen_items. return; } TypeKind::TemplateInstantiation(ref inst) => { diff --git a/src/ir/context.rs b/src/ir/context.rs index 914a89b2..0fe720f9 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -2314,6 +2314,28 @@ If you encounter an error missing from this list, please file an issue or a PR!" return true; } + // Auto-whitelist types that don't need code + // generation if not whitelisting recursively, to + // make the #[derive] analysis not be lame. + if !self.options().whitelist_recursively { + match *ty.kind() { + TypeKind::Void | + TypeKind::NullPtr | + TypeKind::Int(..) | + TypeKind::Float(..) | + TypeKind::Complex(..) | + TypeKind::Array(..) | + TypeKind::Vector(..) | + TypeKind::Pointer(..) | + TypeKind::Reference(..) | + TypeKind::Function(..) | + TypeKind::ResolvedTypeRef(..) | + TypeKind::Opaque | + TypeKind::TypeParam => return true, + _ => {}, + }; + } + // Unnamed top-level enums are special and we // whitelist them via the `whitelisted_vars` filter, // since they're effectively top-level constants, |