summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-11-06 11:20:29 +0800
committerJohn Hodge <tpg@mutabah.net>2016-11-06 11:20:29 +0800
commitdff6b08430f3ff263fb7d890a9e207db94fa0f98 (patch)
treed75561f5c36c347fc714ed1764682fcb87717b0d /src
parent37aadb483f18b24bd45ec242c11a19dc7b695e92 (diff)
downloadmrust-dff6b08430f3ff263fb7d890a9e207db94fa0f98.tar.gz
HIR Typecheck Expr - Fix leaking of a placeholder param
Diffstat (limited to 'src')
-rw-r--r--src/hir/generic_params.cpp2
-rw-r--r--src/hir/type.cpp8
-rw-r--r--src/hir_typeck/expr_cs.cpp6
-rw-r--r--src/hir_typeck/helpers.cpp11
4 files changed, 21 insertions, 6 deletions
diff --git a/src/hir/generic_params.cpp b/src/hir/generic_params.cpp
index 83f141cd..2c9b93d9 100644
--- a/src/hir/generic_params.cpp
+++ b/src/hir/generic_params.cpp
@@ -13,7 +13,7 @@ namespace HIR {
os << e.type << ": '" << e.valid_for;
),
(TraitBound,
- os << e.type << ": " << e.trait.m_path;
+ os << e.type << ": " << e.trait/*.m_path*/;
),
(TypeEquality,
os << e.type << " = " << e.other_type;
diff --git a/src/hir/type.cpp b/src/hir/type.cpp
index bee801e7..226dccf2 100644
--- a/src/hir/type.cpp
+++ b/src/hir/type.cpp
@@ -91,10 +91,12 @@ void ::HIR::TypeRef::fmt(::std::ostream& os) const
os << e.name << "/*";
if( e.binding == 0xFFFF )
os << "";
- else if( e.binding < 256 )
+ else if( e.binding < 1*256 )
os << "I:" << e.binding;
- else if( e.binding < 512 )
- os << "M:" << (e.binding - 256);
+ else if( e.binding < 2*256 )
+ os << "M:" << (e.binding % 256);
+ else if( e.binding < 3*256 )
+ os << "P:" << (e.binding % 256);
else
os << e.binding;
os << "*/";
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 9240cbde..1241f7b6 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -4684,7 +4684,7 @@ namespace {
return false;
}
// if solid or fuzzy, leave as-is
- output_type = out_ty.clone();
+ output_type = mv$( out_ty_o );
}
count += 1;
if( cmp == ::HIR::Compare::Equal ) {
@@ -4754,8 +4754,10 @@ namespace {
}
else if( count == 1 ) {
DEBUG("Only one impl " << v.trait << context.m_ivars.fmt(possible_params) << " for " << context.m_ivars.fmt_type(possible_impl_ty)
- << " - params=" << possible_params << ", ty=" << possible_impl_ty << ", out=" << output_type);
+ << " - out=" << output_type);
// - If there are any magic params in the impl, don't use it yet.
+ // > Ideally, there should be a match_test_generics to resolve the magic impls.
+ DEBUG("> best_impl=" << best_impl);
if( best_impl.has_magic_params() ) {
return false;
}
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index 3c0ab0a3..57552583 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -1884,6 +1884,9 @@ void TraitResolution::expand_associated_types_inplace__UfcsKnown(const Span& sp,
if( ty == ::HIR::TypeRef() )
ERROR(sp, E0000, "Couldn't find assocated type " << pe.item << " in " << pe.trait);
+ if( impl.has_magic_params() )
+ ;
+
// TODO: What if there's multiple impls?
DEBUG("Converted UfcsKnown - " << e.path << " = " << ty);
input = mv$(ty);
@@ -1904,6 +1907,12 @@ void TraitResolution::expand_associated_types_inplace__UfcsKnown(const Span& sp,
if( ty == ::HIR::TypeRef() )
ERROR(sp, E0000, "Couldn't find assocated type " << pe.item << " in " << pe.trait);
+ // Try again later?
+ if( best_impl.has_magic_params() ) {
+ DEBUG("- Placeholder parameters present in impl, can't expand");
+ return ;
+ }
+
DEBUG("Converted UfcsKnown - " << e.path << " = " << ty);
input = mv$(ty);
rv = true;
@@ -2643,6 +2652,8 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
ty_p = &tmp;
}
else {
+ // Expand after extraction, just to make sure.
+ this->expand_associated_types_inplace(sp, tmp, {});
ty_p = &this->m_ivars.get_type(tmp);
}
const auto& ty = *ty_p;