diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-31 14:07:45 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-31 14:07:45 +0800 |
commit | 5deed177a5a6fcd7bad86c8dd4f5866f7b578de3 (patch) | |
tree | 5e5ed81e55a0c6a89ab51ff5127adb0ae5607357 /src/mir/cleanup.cpp | |
parent | 7ef1d63e51f4fa14def0a1fabe7a988e5d50ec82 (diff) | |
download | mrust-5deed177a5a6fcd7bad86c8dd4f5866f7b578de3.tar.gz |
MIR - Fix a bit of invalid MIR
Diffstat (limited to 'src/mir/cleanup.cpp')
-rw-r--r-- | src/mir/cleanup.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/mir/cleanup.cpp b/src/mir/cleanup.cpp index 8a5ee1dc..f790c78a 100644 --- a/src/mir/cleanup.cpp +++ b/src/mir/cleanup.cpp @@ -120,13 +120,33 @@ const ::HIR::Literal* MIR_Cleanup_GetConstant(const Span& sp, const StaticTraitR if( best_impl ) { - out_ty = best_impl->m_constants.find(pe.item)->second.data.m_type.clone(); + const auto& val = best_impl->m_constants.find(pe.item)->second.data; + out_ty = val.m_type.clone(); // TODO: Obtain `out_ty` by monomorphising the type in the trait. - return &best_impl->m_constants.find(pe.item)->second.data.m_value_res; + return &val.m_value_res; } ), (UfcsInherent, + const ::HIR::TypeImpl* best_impl = nullptr; // TODO: Associated constants (inherent) + resolve.m_crate.find_type_impls(*pe.type, [&](const auto& ty)->const auto& { return ty; }, + [&](const auto& impl) { + auto it = impl.m_constants.find(pe.item); + if( it == impl.m_constants.end() ) + return false; + // TODO: Bounds checks. + // TODO: Impl specialisation? + best_impl = &impl; + return it->second.is_specialisable; + }); + if( best_impl ) + { + const auto& val = best_impl->m_constants.find(pe.item)->second.data; + if( monomorphise_type_needed(val.m_type) ) + TODO(sp, "Monomorphise constant type - " << val.m_type << " for " << path); + out_ty = val.m_type.clone(); + return &val.m_value_res; + } ) ) return nullptr; |