diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-09-01 11:33:59 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-09-01 11:33:59 +0800 |
commit | ba11854b5d345ff528b87ea80dcaf97f0de06fe9 (patch) | |
tree | 51cfc54fb39ab78142f0bef388e5c21cdfa529a3 /src | |
parent | ce87b125f3e5bd95d046e6ceae2a93fa5d4d674a (diff) | |
download | mrust-ba11854b5d345ff528b87ea80dcaf97f0de06fe9.tar.gz |
HIR Typecheck - Fix edge case where &mut was picked instead of & for ivar possibility
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 918f3cd7..085d5a79 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -5665,8 +5665,18 @@ namespace { { const auto& le = l.m_data.as_Borrow(); ASSERT_BUG(sp, r.m_data.is_Borrow() || r.m_data.is_Pointer(), "Coerce source for borrow isn't a borrow/pointert - " << r); + const auto re_borrow_type = r.m_data.is_Borrow() ? r.m_data.as_Borrow().type : r.m_data.as_Pointer().type; const auto& re_inner = r.m_data.is_Borrow() ? r.m_data.as_Borrow().inner : r.m_data.as_Pointer().inner; + if( le.type < re_borrow_type ) { + return DedupKeep::Left; + } + else if( le.type > re_borrow_type ) { + return DedupKeep::Right; + } + else { + } + // Dereference `*re.inner` until it isn't possible or it equals `*le.inner` // - Repeat going the other direction. if( H::type_derefs_from(sp, context, *le.inner, *re_inner) ) |