diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-09-10 18:11:20 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-09-10 18:11:20 +0800 |
commit | 22ce602788b285b303854a095a0c340274a76b06 (patch) | |
tree | 5e5b1562c69bfca32ab0ddfa21953eb7cb768cb0 /src/hir_expand | |
parent | 24fe34bfd1fa06d4aacba07e752134d5774884be (diff) | |
download | mrust-22ce602788b285b303854a095a0c340274a76b06.tar.gz |
Consteval - Litle tweaks
Diffstat (limited to 'src/hir_expand')
-rw-r--r-- | src/hir_expand/const_eval_full.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/hir_expand/const_eval_full.cpp b/src/hir_expand/const_eval_full.cpp index 04575a6e..39bbce02 100644 --- a/src/hir_expand/const_eval_full.cpp +++ b/src/hir_expand/const_eval_full.cpp @@ -468,10 +468,14 @@ namespace { if( e.type != ::HIR::BorrowType::Shared ) { MIR_BUG(state, "Only shared borrows are allowed in constants"); } - - if( e.val.is_Static() ) { + if( const auto* p = e.val.opt_Deref() ) { + if( p->val->is_Deref() ) + MIR_TODO(state, "Undo nested deref coercion - " << *p->val); + val = read_lval(*p->val); + } + else if( const auto* p = e.val.opt_Static() ) { // Borrow of a static, emit BorrowOf with the same path - val = ::HIR::Literal::make_BorrowOf( e.val.as_Static().clone() ); + val = ::HIR::Literal::make_BorrowOf( p->clone() ); } else { auto inner_val = read_lval(e.val); |