diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-07-22 02:47:56 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-07-22 02:51:29 +0200 |
commit | bff026cae90607bb836acf9a08cd01c8749d971a (patch) | |
tree | cbe8675b6810d485670c95315887ec92acb8c117 /src | |
parent | ed4facfb519023dac2d9782f7c4cb74396005dc0 (diff) |
analysis: Account for template instantiations of opaque types in the derive debug analysis.
We have a special-case for them in codegen to generate a blob, that can derive
debug.
This is a regression from #824, and hit stylo.
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/analysis/derive_debug.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/ir/analysis/derive_debug.rs b/src/ir/analysis/derive_debug.rs index 6e72da1f..b9b0be10 100644 --- a/src/ir/analysis/derive_debug.rs +++ b/src/ir/analysis/derive_debug.rs @@ -4,6 +4,7 @@ use super::{ConstrainResult, MonotoneFramework}; use std::collections::HashSet; use std::collections::HashMap; use ir::context::{BindgenContext, ItemId}; +use ir::item::IsOpaque; use ir::traversal::EdgeKind; use ir::ty::RUST_DERIVE_IN_ARRAY_LIMIT; use ir::ty::TypeKind; @@ -260,19 +261,23 @@ impl<'ctx, 'gen> MonotoneFramework for CannotDeriveDebug<'ctx, 'gen> { return self.insert(id); } - let ty_cannot_derive = template.template_definition() + let template_definition = template.template_definition() .into_resolver() .through_type_refs() .through_type_aliases() - .resolve(self.ctx) + .resolve(self.ctx); + + let ty_cannot_derive = template_definition .as_type() .expect("Instantiations of a non-type?") .as_comp() .and_then(|c| { - // For non-type template parameters, we generate an opaque - // blob, and in this case the instantiation has a better - // idea of the layout than the definition does. - if c.has_non_type_template_params() { + // For non-type template parameters, or opaque template + // definitions, we generate an opaque blob, and in this + // case the instantiation has a better idea of the + // layout than the definition does. + if template_definition.is_opaque(self.ctx, &()) || + c.has_non_type_template_params() { let opaque = ty.layout(self.ctx) .or_else(|| { self.ctx |