diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-01-30 19:41:13 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-01-30 19:41:13 +0100 |
commit | a46971c201c276b9a9706f22876a67b51d08de97 (patch) | |
tree | 101ae271ec9e4391769688bab315c4aa8a5aa284 /src/codegen | |
parent | f4d4994c1481baaf0a6e643bf3d3466d35bf950b (diff) |
ir: Cleanup name duplication in aliases and named types.
It's just dumb.
Diffstat (limited to 'src/codegen')
-rw-r--r-- | src/codegen/mod.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index c36dd644..436c2bd7 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -507,7 +507,7 @@ impl CodeGenerator for Type { TypeKind::TemplateRef(..) | TypeKind::Function(..) | TypeKind::ResolvedTypeRef(..) | - TypeKind::Named(..) => { + TypeKind::Named => { // These items don't need code generation, they only need to be // converted to rust types in fields, arguments, and such. return; @@ -517,8 +517,8 @@ impl CodeGenerator for Type { } // NB: The code below will pick the correct // applicable_template_args. - TypeKind::TemplateAlias(ref spelling, inner, _) | - TypeKind::Alias(ref spelling, inner) => { + TypeKind::TemplateAlias(inner, _) | + TypeKind::Alias(inner) => { let inner_item = ctx.resolve_item(inner); let name = item.canonical_name(ctx); @@ -534,6 +534,7 @@ impl CodeGenerator for Type { // If this is a known named type, disallow generating anything // for it too. + let spelling = self.name().expect("Unnamed alias?"); if utils::type_from_named(ctx, spelling, inner).is_some() { return; } @@ -2043,14 +2044,15 @@ impl ToRustTy for Type { P(inner_ty) } TypeKind::ResolvedTypeRef(inner) => inner.to_rust_ty(ctx), - TypeKind::TemplateAlias(ref spelling, inner, _) | - TypeKind::Alias(ref spelling, inner) => { + TypeKind::TemplateAlias(inner, _) | + TypeKind::Alias(inner) => { let applicable_named_args = item.applicable_template_args(ctx) .into_iter() .filter(|arg| ctx.resolve_type(*arg).is_named()) .collect::<Vec<_>>(); + let spelling = self.name().expect("Unnamed alias?"); if item.is_opaque(ctx) && !applicable_named_args.is_empty() { // Pray if there's no available layout. let layout = self.layout(ctx).unwrap_or_else(Layout::zero); @@ -2104,7 +2106,7 @@ impl ToRustTy for Type { ty.to_ptr(is_const, ctx.span()) } } - TypeKind::Named(..) => { + TypeKind::Named => { let name = item.canonical_name(ctx); let ident = ctx.rust_ident(&name); quote_ty!(ctx.ext_cx(), $ident) |