summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-17 08:13:45 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-17 08:13:45 +0800
commitf4c730973e17471b95cc385787647a7cec7d95a8 (patch)
treeb29001912e4725a2e96514c123298c8cd24d16a8 /src
parente503135eb7aa91bd28256b7f91b62ee265b47fdf (diff)
downloadmrust-f4c730973e17471b95cc385787647a7cec7d95a8.tar.gz
HIR Typecheck Expr - (minor) Commenting and debug in tracking box inferrence failure
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/expr_cs.cpp15
-rw-r--r--src/hir_typeck/helpers.cpp3
2 files changed, 13 insertions, 5 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 529a2366..2cfd6fc4 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -3329,13 +3329,22 @@ namespace {
// CoerceUnsized trait
// - Only valid for generic or path destination types
- if( ty_dst.m_data.is_Generic() || ty_dst.m_data.is_Path() ) {
-
+ if( ty_dst.m_data.is_Generic() || ty_dst.m_data.is_Path() )
+ {
const auto& lang_CoerceUnsized = context.m_crate.get_lang_item_path(sp, "coerce_unsized");
+
::HIR::PathParams pp;
pp.m_types.push_back( ty_dst.clone() );
+
+ // PROBLEM: In the desugaring of `box`, it's required that the container type propagate backwards through the coercion point
+ // - However, there's still a coercion point that needs to apply to the contained type.
+ // - `let foo: Box<[i32]> = box [1, 2, 3];`
+ // - Special-casing `Box` here could work (assuming that Box can only coerce to Box, and applying unsizing coercion rules to the inner)
+
+ //bool fuzzy_match = false;
bool found = context.m_resolve.find_trait_impls(sp, lang_CoerceUnsized, pp, ty_src, [&](auto impl, auto cmp) {
- // TODO: Allow fuzzy match if only match
+ // TODO: Allow fuzzy match if it's the only matching possibility
+ DEBUG("[check_coerce] cmp=" << cmp << ", impl=" << impl);
return cmp == ::HIR::Compare::Equal;
});
if( found )
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index 8f98f676..b35d6438 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -932,7 +932,7 @@ bool TraitResolution::find_trait_impls(const Span& sp,
static ::std::map< ::std::string, ::HIR::TypeRef> null_assoc;
const auto& type = this->m_ivars.get_type(ty);
- TRACE_FUNCTION_F("trait = " << trait << ", type = " << type);
+ TRACE_FUNCTION_F("trait = " << trait << params << ", type = " << type);
if( trait == this->m_crate.get_lang_item_path(sp, "sized") ) {
TU_MATCH_DEF(::HIR::TypeRef::Data, (type.m_data), (e),
@@ -1741,7 +1741,6 @@ bool TraitResolution::find_trait_impls_bound(const Span& sp, const ::HIR::Simple
return this->iterate_bounds([&](const auto& b) {
TU_IFLET(::HIR::GenericBound, b, TraitBound, e,
const auto& b_params = e.trait.m_path.m_params;
- DEBUG("(bound) - " << e.type << " : " << e.trait);
// TODO: Allow fuzzy equality?
if( e.type == type )
{