diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-01-30 14:38:00 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-30 14:38:00 -0800 |
commit | bdd034b07a02a1a886ac8b94a81327608f6124b3 (patch) | |
tree | 101ae271ec9e4391769688bab315c4aa8a5aa284 /src/codegen/mod.rs | |
parent | 5fc308136d6f1d49f7786922ecea232727bcb024 (diff) | |
parent | a46971c201c276b9a9706f22876a67b51d08de97 (diff) |
Auto merge of #461 - emilio:clean-naming, r=fitzgen
ir: Cleanup name duplication in aliases and named types.
It's just dumb.
r? @fitzgen
Diffstat (limited to 'src/codegen/mod.rs')
-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) |