diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2017-03-09 11:12:19 -0800 |
---|---|---|
committer | Nick Fitzgerald <fitzgen@gmail.com> | 2017-03-09 13:56:53 -0800 |
commit | 72ab471539fcf2809f82e2dd980c59352a67eba4 (patch) | |
tree | f289269f0515be72051f9216e94f4b68ba40350e | |
parent | b914a099942c0c788c24684928cfb96c75912902 (diff) |
Simplify control flow in TemplateInstantiation's ToRustTy
If we hit a case where we generate an opaque blob instead of an instantiation of
a generic, then we won't ever be attaching generic parameters, and can bail out
of the function early.
-rw-r--r-- | src/codegen/mod.rs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 9209be44..49b320ae 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -2361,7 +2361,7 @@ impl ToRustTy for TemplateInstantiation { // instantiation. if ty == aster::AstBuilder::new().ty().unit().unwrap() { if let Some(layout) = self_ty.layout(ctx) { - ty = BlobTyBuilder::new(layout).build().unwrap() + return BlobTyBuilder::new(layout).build(); } } @@ -2376,9 +2376,7 @@ impl ToRustTy for TemplateInstantiation { debug_assert!(ctx.resolve_type_through_type_refs(decl) .is_opaque()); let layout = self_ty.layout(ctx).unwrap_or(Layout::zero()); - ty = BlobTyBuilder::new(layout).build().unwrap(); - - vec![] + return BlobTyBuilder::new(layout).build(); }; // TODO: If the decl type is a template class/struct |