diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-01-30 10:29:09 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-30 10:29:09 -0800 |
commit | 5fc308136d6f1d49f7786922ecea232727bcb024 (patch) | |
tree | d023c19e81df9b36fb5c0f1eeab4f6cc6c82d6f8 /src/codegen/mod.rs | |
parent | 3ef1a277c01e5c146cfdeb112c01c6261555c8b9 (diff) | |
parent | f4d4994c1481baaf0a6e643bf3d3466d35bf950b (diff) |
Auto merge of #384 - emilio:decltype, r=fitzgen
codegen: Do the same workaround we do for template parameters with `typename` on aliases for `decltypes` we can't resolve.
r? @fitzgen
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r-- | src/codegen/mod.rs | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 313ca8b0..c36dd644 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -549,6 +549,26 @@ impl CodeGenerator for Type { inner_item.to_rust_ty(ctx) }; + { + // FIXME(emilio): This is a workaround to avoid generating + // incorrect type aliases because of types that we haven't + // been able to resolve (because, eg, they depend on a + // template parameter). + // + // It's kind of a shame not generating them even when they + // could be referenced, but we already do the same for items + // with invalid template parameters, and at least this way + // they can be replaced, instead of generating plain invalid + // code. + let inner_canon_type = + inner_item.expect_type().canonical_type(ctx); + if inner_canon_type.is_invalid_named_type() { + warn!("Item contained invalid named type, skipping: \ + {:?}, {:?}", item, inner_item); + return; + } + } + let rust_name = ctx.rust_ident(&name); let mut typedef = aster::AstBuilder::new().item().pub_(); @@ -586,9 +606,8 @@ impl CodeGenerator for Type { for template_arg in applicable_template_args.iter() { let template_arg = ctx.resolve_type(*template_arg); if template_arg.is_named() { - let name = template_arg.name().unwrap(); - if name.contains("typename ") { - warn!("Item contained `typename`'d template \ + if template_arg.is_invalid_named_type() { + warn!("Item contained invalid template \ parameter: {:?}", item); return; } |