diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-29 22:36:00 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-29 22:36:00 +0800 |
commit | dd5c79878df49d0010b51dfff0c1fa6f4879adec (patch) | |
tree | 3ab1143d7314f7d010556feb34baa333bba7ef3d | |
parent | 47aa9f92d06d2c5c5b8b49689a5df0475e3ac30f (diff) | |
download | mrust-dd5c79878df49d0010b51dfff0c1fa6f4879adec.tar.gz |
MIR Cleanup - Derefence FnMut/Fn for fn points
-rw-r--r-- | src/mir/check.cpp | 2 | ||||
-rw-r--r-- | src/mir/cleanup.cpp | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/mir/check.cpp b/src/mir/check.cpp index 7d6b431a..9e83df8c 100644 --- a/src/mir/check.cpp +++ b/src/mir/check.cpp @@ -605,7 +605,7 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path const auto& ty = state.get_lvalue_type(tmp, e.fcn.as_Value()); if( ! ty.m_data.is_Function() ) { - //MIR_BUG(state, "Call Fcn::Value with non-function type - " << ty); + MIR_BUG(state, "Call Fcn::Value with non-function type - " << ty); } } // Typecheck arguments and return value diff --git a/src/mir/cleanup.cpp b/src/mir/cleanup.cpp index 27410462..b2861b4f 100644 --- a/src/mir/cleanup.cpp +++ b/src/mir/cleanup.cpp @@ -1049,7 +1049,11 @@ void MIR_Cleanup(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path, { e.args.push_back( ::MIR::LValue::make_Field({ box$(args_lvalue.clone()), i }) ); } - e.fcn = mv$(fcn_lvalue); + // If the trait is Fn/FnMut, dereference the input value. + if( pe.trait.m_path == resolve.m_lang_FnOnce ) + e.fcn = mv$(fcn_lvalue); + else + e.fcn = ::MIR::LValue::make_Deref({ box$(fcn_lvalue) }); } } ) |