diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-21 19:07:11 +1100 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-21 19:07:11 +1100 |
commit | cd88feb4b27bfa415713a19205374835826dc31f (patch) | |
tree | c8d6367a969969b8958a01b1d25f52d6af9dad2b | |
parent | 301fa4ddcd7fd2c929fc78036b8ab349df617c6d (diff) | |
download | mrust-cd88feb4b27bfa415713a19205374835826dc31f.tar.gz |
MIR Gen Match - Correct types for bytestring comparison
-rw-r--r-- | src/mir/from_hir_match.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp index 68f4f24b..611dad0d 100644 --- a/src/mir/from_hir_match.cpp +++ b/src/mir/from_hir_match.cpp @@ -1631,8 +1631,10 @@ int MIR_LowerHIR_Match_Simple__GeneratePattern(MirBuilder& builder, const Span& auto succ_bb = builder.new_bb_unlinked(); - auto test_lval = builder.lvalue_or_temp(sp, ty.clone(), ::MIR::RValue(mv$(cloned_val))); - auto cmp_lval = builder.lvalue_or_temp(sp, ::HIR::CoreType::Bool, ::MIR::RValue::make_BinOp({ val.clone(), ::MIR::eBinOp::EQ, mv$(test_lval) })); + auto inner_val = val.as_Deref().val->clone(); + + auto test_lval = builder.lvalue_or_temp(sp, ::HIR::TypeRef::new_borrow(::HIR::BorrowType::Shared, ty.clone()), ::MIR::RValue(mv$(cloned_val))); + auto cmp_lval = builder.lvalue_or_temp(sp, ::HIR::CoreType::Bool, ::MIR::RValue::make_BinOp({ mv$(inner_val), ::MIR::eBinOp::EQ, mv$(test_lval) })); builder.end_block( ::MIR::Terminator::make_If({ mv$(cmp_lval), succ_bb, fail_bb }) ); builder.set_cur_block(succ_bb); } |