diff options
author | John Hodge <tpg@mutabah.net> | 2017-01-26 17:00:43 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-01-26 17:00:43 +0800 |
commit | 5922055228afdd976a0f3ebd934cd70f6f3b6fee (patch) | |
tree | adc134e9d8eaa07cf2da21a0019f46a25f70e467 | |
parent | e1ecb003fcc66eceb818c097c3b0e659d7067b0f (diff) | |
download | mrust-5922055228afdd976a0f3ebd934cd70f6f3b6fee.tar.gz |
HIR Typecheck - Fix quirks from rust_os
-rw-r--r-- | src/hir_conv/expand_type.cpp | 6 | ||||
-rw-r--r-- | src/hir_typeck/outer.cpp | 16 | ||||
-rw-r--r-- | src/hir_typeck/static.cpp | 2 |
3 files changed, 22 insertions, 2 deletions
diff --git a/src/hir_conv/expand_type.cpp b/src/hir_conv/expand_type.cpp index b37ea1ca..747ff545 100644 --- a/src/hir_conv/expand_type.cpp +++ b/src/hir_conv/expand_type.cpp @@ -1,5 +1,9 @@ /* - * Expand `type` aliases in HIR + * MRustC - Rust Compiler + * - By John Hodge (Mutabah/thePowersGang) + * + * hir_conv/expand_type.cpp + * - Expand `type` aliases in HIR */ #include "main_bindings.hpp" #include <hir/hir.hpp> diff --git a/src/hir_typeck/outer.cpp b/src/hir_typeck/outer.cpp index c3f4e770..6358e47e 100644 --- a/src/hir_typeck/outer.cpp +++ b/src/hir_typeck/outer.cpp @@ -254,6 +254,19 @@ namespace { const Span& sp = _sp; ::HIR::Visitor::visit_type(ty); + #if 0 + if( const auto* te = ty.m_data.opt_Generic() ) + { + if(te->name == "Self" && te->binding == 0xFFFF) { + if( m_self_types.empty() ) + ERROR(sp, E0000, "Self appeared in unexpected location"); + if( !m_self_types.back() ) + ERROR(sp, E0000, "Self appeared in unexpected location"); + ty = m_self_types.back()->clone(); + } + } + #endif + TU_IFLET(::HIR::TypeRef::Data, ty.m_data, Path, e, TU_MATCH( ::HIR::Path::Data, (e.path.m_data), (pe), (Generic, @@ -537,6 +550,7 @@ namespace { void visit_params(::HIR::GenericParams& params) override { + TRACE_FUNCTION_F(params.fmt_args()); for(auto& tps : params.m_types) this->visit_type( tps.m_default ); @@ -637,6 +651,8 @@ namespace { void visit_function(::HIR::ItemPath p, ::HIR::Function& item) override { auto _ = m_resolve.set_item_generics(item.m_params); + // NOTE: Superfluous... except that it makes the params valid for the return type. + visit_params(item.m_params); m_fcn_path = &p; m_fcn_ptr = &item; diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp index fc48f5ac..9f1276bf 100644 --- a/src/hir_typeck/static.cpp +++ b/src/hir_typeck/static.cpp @@ -1141,7 +1141,7 @@ bool StaticTraitResolve::find_named_trait_in_trait(const Span& sp, { TRACE_FUNCTION_F(des << des_params << " from " << trait_path << pp); if( pp.m_types.size() != trait_ptr.m_params.m_types.size() ) { - BUG(sp, "Incorrect number of parameters for trait"); + BUG(sp, "Incorrect number of parameters for trait - " << trait_path << pp); } auto monomorph_cb = [&](const auto& gt)->const auto& { |