diff options
author | John Hodge <tpg@mutabah.net> | 2016-11-20 09:30:33 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-11-20 09:30:33 +0800 |
commit | 3365774a335dd562fc555b23edb5f29d34b3023b (patch) | |
tree | 523fcb85e25784e32f579a6362d7a4df242b0ade | |
parent | a6aae2e4413789e548a30fd9cb421cc2f6964b14 (diff) | |
download | mrust-3365774a335dd562fc555b23edb5f29d34b3023b.tar.gz |
HIR - Allow arrays with unknown sizes to be cloned
-rw-r--r-- | src/hir_typeck/common.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/hir_typeck/common.cpp b/src/hir_typeck/common.cpp index fa83723c..742f22c4 100644 --- a/src/hir_typeck/common.cpp +++ b/src/hir_typeck/common.cpp @@ -255,9 +255,11 @@ bool monomorphise_type_needed(const ::HIR::TypeRef& tpl) ), (Array, if( e.size_val == ~0u ) { - BUG(sp, "Attempting to clone array with unknown size - " << tpl); + rv = ::HIR::TypeRef( ::HIR::TypeRef::Data::make_Array({ box$(clone_ty_with(sp, *e.inner, callback)), e.size, ~0u }) ); + } + else { + rv = ::HIR::TypeRef::new_array( clone_ty_with(sp, *e.inner, callback), e.size_val ); } - rv = ::HIR::TypeRef::new_array( clone_ty_with(sp, *e.inner, callback), e.size_val ); ), (Slice, rv = ::HIR::TypeRef::new_slice( clone_ty_with(sp, *e.inner, callback) ); |