diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-01-12 18:51:59 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-01-12 18:51:59 +0800 |
commit | c31f5534f50f986f7c5d2121490213280bbec986 (patch) | |
tree | 0074f17cc9876f4a9db18cdb0ff5d42b49a93df9 /src | |
parent | 6d0fe344e94670f2ac0e21094238181f38b0daec (diff) | |
download | mrust-c31f5534f50f986f7c5d2121490213280bbec986.tar.gz |
HIR Typecheck - Debugging tweaks
Diffstat (limited to 'src')
-rw-r--r-- | src/hir/visitor.cpp | 6 | ||||
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 9 | ||||
-rw-r--r-- | src/hir_typeck/helpers.cpp | 8 | ||||
-rw-r--r-- | src/hir_typeck/impl_ref.cpp | 2 |
4 files changed, 19 insertions, 6 deletions
diff --git a/src/hir/visitor.cpp b/src/hir/visitor.cpp index 87b790ae..5c9c0dfa 100644 --- a/src/hir/visitor.cpp +++ b/src/hir/visitor.cpp @@ -229,18 +229,21 @@ void ::HIR::Visitor::visit_enum(::HIR::ItemPath p, ::HIR::Enum& item) } void ::HIR::Visitor::visit_union(::HIR::ItemPath p, ::HIR::Union& item) { + TRACE_FUNCTION_F(p); this->visit_params(item.m_params); for(auto& var : item.m_variants) this->visit_type(var.second.ent); } void ::HIR::Visitor::visit_associatedtype(ItemPath p, ::HIR::AssociatedType& item) { + TRACE_FUNCTION_F(p); for(auto& bound : item.m_trait_bounds) this->visit_trait_path(bound); this->visit_type(item.m_default); } void ::HIR::Visitor::visit_function(::HIR::ItemPath p, ::HIR::Function& item) { + TRACE_FUNCTION_F(p); this->visit_params(item.m_params); for(auto& arg : item.m_args) { @@ -252,11 +255,13 @@ void ::HIR::Visitor::visit_function(::HIR::ItemPath p, ::HIR::Function& item) } void ::HIR::Visitor::visit_static(::HIR::ItemPath p, ::HIR::Static& item) { + TRACE_FUNCTION_F(p); this->visit_type(item.m_type); this->visit_expr(item.m_value); } void ::HIR::Visitor::visit_constant(::HIR::ItemPath p, ::HIR::Constant& item) { + TRACE_FUNCTION_F(p); this->visit_params(item.m_params); this->visit_type(item.m_type); this->visit_expr(item.m_value); @@ -264,6 +269,7 @@ void ::HIR::Visitor::visit_constant(::HIR::ItemPath p, ::HIR::Constant& item) void ::HIR::Visitor::visit_params(::HIR::GenericParams& params) { + TRACE_FUNCTION_F(params.fmt_args() << params.fmt_bounds()); for(auto& tps : params.m_types) this->visit_type( tps.m_default ); for(auto& bound : params.m_bounds ) diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index a0634022..4a5171f5 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -256,6 +256,7 @@ namespace { void apply_bounds_as_rules(Context& context, const Span& sp, const ::HIR::GenericParams& params_def, t_cb_generic monomorph_cb, bool is_impl_level) { + TRACE_FUNCTION; for(const auto& bound : params_def.m_bounds) { TU_MATCH(::HIR::GenericBound, (bound), (be), @@ -409,11 +410,13 @@ namespace { // --- Monomorphise the argument/return types (into current context) for(const auto& arg : fcn.m_args) { - DEBUG("Arg " << arg.first << ": " << arg.second); + TRACE_FUNCTION_FR(path << " - Arg " << arg.first << ": " << arg.second, "Arg " << arg.first << " : " << cache.m_arg_types.back()); cache.m_arg_types.push_back( monomorphise_type_with(sp, arg.second, monomorph_cb, false) ); } - DEBUG("Ret " << fcn.m_return); - cache.m_arg_types.push_back( monomorphise_type_with(sp, fcn.m_return, monomorph_cb, false) ); + { + TRACE_FUNCTION_FR(path << " - Ret " << fcn.m_return, "Ret " << cache.m_arg_types.back()); + cache.m_arg_types.push_back( monomorphise_type_with(sp, fcn.m_return, monomorph_cb, false) ); + } // --- Apply bounds by adding them to the associated type ruleset apply_bounds_as_rules(context, sp, *cache.m_fcn_params, cache.m_monomorph_cb, /*is_impl_level=*/false); diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index 5853a9dc..d4d16aad 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -2292,6 +2292,10 @@ bool TraitResolution::find_trait_impls_bound(const Span& sp, const ::HIR::Simple ) ) + //if(type.m_data.is_Infer()) { + // return false; + //} + // NOTE: Even if the type is completely unknown (infer or unbound UFCS), search the bound list. // TODO: A bound can imply something via its associated types. How deep can this go? @@ -2930,9 +2934,9 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp, auto i_tp = impl.get_trait_params(); for(auto& t : i_tp.m_types) this->expand_associated_types_inplace( sp, t, {} ); - DEBUG(real_type << " ?= " << i_ty); + DEBUG("[ftic_check_params] " << real_type << " ?= " << i_ty); cmp &= real_type .match_test_generics_fuzz(sp, i_ty, cb_infer, cb_match); - DEBUG(real_trait_path.m_params << " ?= " << i_tp); + DEBUG("[ftic_check_params] " << real_trait_path.m_params << " ?= " << i_tp); cmp &= real_trait_path.m_params .match_test_generics_fuzz(sp, i_tp, cb_infer, cb_match); DEBUG("[ftic_check_params] - Re-check result: " << cmp); } diff --git a/src/hir_typeck/impl_ref.cpp b/src/hir_typeck/impl_ref.cpp index 1aa8fc2b..86f88648 100644 --- a/src/hir_typeck/impl_ref.cpp +++ b/src/hir_typeck/impl_ref.cpp @@ -198,11 +198,11 @@ bool ImplRef::type_is_specialisable(const char* name) const static Span sp; TU_MATCH(Data, (this->m_data), (e), (TraitImpl, - DEBUG("name=" << name << " " << *this); auto it = e.impl->m_types.find(name); if( it == e.impl->m_types.end() ) return ::HIR::TypeRef(); const ::HIR::TypeRef& tpl_ty = it->second.data; + DEBUG("name=" << name << " tpl_ty=" << tpl_ty << " " << *this); if( monomorphise_type_needed(tpl_ty) ) { return monomorphise_type_with(sp, tpl_ty, this->get_cb_monomorph_traitimpl(sp)); } |