summaryrefslogtreecommitdiff
path: root/src/mir/cleanup.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2017-01-07 08:36:29 +0800
committerJohn Hodge <tpg@mutabah.net>2017-01-07 08:36:29 +0800
commit56ff9bf90bd78a16ec58cdda87cd00d2e4ec272f (patch)
tree1fb018b174196df196018bbcc568101aa2ed4e12 /src/mir/cleanup.cpp
parent0796f5eef437ff056fb9d77af9f067dfdad31849 (diff)
downloadmrust-56ff9bf90bd78a16ec58cdda87cd00d2e4ec272f.tar.gz
MIR Cleanup - Fix returned type for associated constants
Diffstat (limited to 'src/mir/cleanup.cpp')
-rw-r--r--src/mir/cleanup.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mir/cleanup.cpp b/src/mir/cleanup.cpp
index 60e781b7..12f4149b 100644
--- a/src/mir/cleanup.cpp
+++ b/src/mir/cleanup.cpp
@@ -124,11 +124,13 @@ const ::HIR::Literal* MIR_Cleanup_GetConstant(const Span& sp, const StaticTraitR
if( rv && !best_impl )
{
// Non-trait impl found, return none
+ DEBUG(path << " contains a generic");
}
else
{
- // TODO: Obtain `out_ty` by monomorphising the type in the trait.
- out_ty = trait_cdef.m_type.clone();
+ // Obtain `out_ty` by monomorphising the type in the trait.
+ auto monomorph_cb = monomorphise_type_get_cb(sp, &*pe.type, &pe.trait.m_params, nullptr);
+ out_ty = monomorphise_type_with(sp, trait_cdef.m_type, monomorph_cb);
if( best_impl )
{
ASSERT_BUG(sp, best_impl->m_constants.find(pe.item) != best_impl->m_constants.end(), "Item '" << pe.item << "' missing in impl for " << path);
@@ -174,6 +176,7 @@ const ::HIR::Literal* MIR_Cleanup_GetConstant(const Span& sp, const StaticTraitR
(
if( path == ::HIR::GenericPath() )
MIR_TODO(state, "Literal of type " << ty << " - " << path << " - " << lit);
+ DEBUG("Unknown type " << ty << " - Return BorrowOf");
return ::MIR::Constant( mv$(path) );
),
(Tuple,
@@ -991,8 +994,13 @@ void MIR_Cleanup(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path,
const auto* lit_ptr = MIR_Cleanup_GetConstant(sp, resolve, ce.p, ty);
if( lit_ptr )
{
+ DEBUG("Replace constant " << ce.p << " with " << *lit_ptr);
se.src = MIR_Cleanup_LiteralToRValue(state, mutator, *lit_ptr, mv$(ty), mv$(ce.p));
}
+ else
+ {
+ DEBUG("No replacement for constant " << ce.p);
+ }
)
)