diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-16 23:59:43 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-16 23:59:43 +0800 |
commit | 0fe553a6d29f2e9e4cee4f9e87b0aee55df183fd (patch) | |
tree | e12f7456245ffc7307652ddc47d769e6a2feb681 /src | |
parent | 7cd3195512a85370853c2eb3cff6baf6dfe4db8d (diff) | |
download | mrust-0fe553a6d29f2e9e4cee4f9e87b0aee55df183fd.tar.gz |
HIR Expand Closures - Clone bounds
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_expand/closures.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/hir_expand/closures.cpp b/src/hir_expand/closures.cpp index 07db7379..f0f14b12 100644 --- a/src/hir_expand/closures.cpp +++ b/src/hir_expand/closures.cpp @@ -319,6 +319,29 @@ namespace { BUG(sp, "Generic type " << ty << " unknown"); } }; + auto monomorph = [&](const auto& ty){ return monomorphise_type_with(sp, ty, monomorph_cb); }; + + // - Clone the bounds (from both levels) + auto monomorph_bound = [&](const ::HIR::GenericBound& b)->auto { + TU_MATCHA( (b), (e), + (Lifetime, + return ::HIR::GenericBound(e); ), + (TypeLifetime, + return ::HIR::GenericBound::make_TypeLifetime({ monomorph(e.type), e.valid_for }); ), + (TraitBound, + return ::HIR::GenericBound::make_TraitBound({ monomorph(e.type), monomorphise_traitpath_with(sp, e.trait, monomorph_cb, false) }); ), + (TypeEquality, + return ::HIR::GenericBound::make_TypeEquality({ monomorph(e.type), monomorph(e.other_type) }); ) + ) + throw ""; + }; + for(const auto& bound : m_resolve.impl_generics().m_bounds ) { + params.m_bounds.push_back( monomorph_bound(bound) ); + } + for(const auto& bound : m_resolve.item_generics().m_bounds ) { + params.m_bounds.push_back( monomorph_bound(bound) ); + } + // 2. Iterate over the nodes and rewrite variable accesses to either renumbered locals, or field accesses // - TODO: Monomorphise all referenced types within this |