summaryrefslogtreecommitdiff
path: root/src/mir/from_hir.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-10-08 16:05:02 +0800
committerJohn Hodge <tpg@mutabah.net>2016-10-08 16:05:02 +0800
commit1f4186162c74e9452683298ad7058ed7cc4c1b46 (patch)
tree309a8552a3d10281a0f6c25552f65c38f29691ea /src/mir/from_hir.cpp
parent22ce94a3908c86a068047f985d06371e9b2f7d95 (diff)
downloadmrust-1f4186162c74e9452683298ad7058ed7cc4c1b46.tar.gz
HIR+MIR - Allow unsize between two generics
Diffstat (limited to 'src/mir/from_hir.cpp')
-rw-r--r--src/mir/from_hir.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index 29d8d42c..5111320c 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -989,13 +989,18 @@ namespace {
const auto& ty_in = *ie.inner;
TU_MATCH_DEF( ::HIR::TypeRef::Data, (ty_out.m_data), (e),
(
- TODO(node.span(), "MIR _Unsize to " << ty_out);
+ const auto& lang_Unsize = m_builder.crate().get_lang_item_path(node.span(), "unsize");
+ if( m_builder.resolve().find_impl( node.span(), lang_Unsize, ::HIR::PathParams(ty_out.clone()), ty_in.clone(), [](auto ){ return true; }) )
+ {
+ // - HACK: Emit a cast operation on the pointers. Leave it up to monomorph to 'fix' it
+ m_builder.set_result( node.span(), ::MIR::RValue::make_Cast({ mv$(ptr_lval), node.m_res_type.clone() }) );
+ }
+ else
+ {
+ // Probably an error.
+ TODO(node.span(), "MIR _Unsize to " << ty_out);
+ }
),
- // TODO: Unsize custom types containing a ?Size generic - See the Unsize trait
- //(Path,
- // ),
- //(Generic,
- // ),
(Slice,
if( ty_in.m_data.is_Array() )
{