summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-06-09 13:13:32 +0800
committerJohn Hodge <tpg@mutabah.net>2016-06-09 13:13:32 +0800
commitc7726dad29863b414eafb5c1dda532819eadbc53 (patch)
tree2a5e5fe821a5b2519b00be5024d50d5b9502d9f4 /src
parent7e1bc662acdbfecbc3c32b6012240779a6b3bbe3 (diff)
downloadmrust-c7726dad29863b414eafb5c1dda532819eadbc53.tar.gz
HIR Typecheck - Use associated type bounds for finding UFCS methods
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/expr.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/hir_typeck/expr.cpp b/src/hir_typeck/expr.cpp
index 24f1519c..c952de4f 100644
--- a/src/hir_typeck/expr.cpp
+++ b/src/hir_typeck/expr.cpp
@@ -1497,9 +1497,26 @@ namespace {
// UFCS known - Assuming that it's reached the maximum resolvable level (i.e. a type within is generic), search for trait bounds on the type
const auto& trait = this->m_crate.get_trait_by_path(sp, e.trait.m_path);
const auto& assoc_ty = trait.m_types.at( e.item );
- const auto& ty_bounds = assoc_ty.m_params.m_bounds;
// NOTE: The bounds here have 'Self' = the type
- DEBUG("TODO: Search bounds assoc type bounds - type " << e.item << assoc_ty.m_params.fmt_bounds());
+ for(const auto& bound : assoc_ty.m_params.m_bounds )
+ {
+ TU_IFLET(::HIR::GenericBound, bound, TraitBound, be,
+ assert(be.trait.m_trait_ptr);
+ ::HIR::GenericPath final_trait_path;
+ if( !this->trait_contains_method(sp, be.trait.m_path, *be.trait.m_trait_ptr, method_name, final_trait_path) )
+ continue ;
+ DEBUG("- Found trait " << final_trait_path);
+
+ // Found the method, return the UFCS path for it
+ fcn_path = ::HIR::Path( ::HIR::Path::Data::make_UfcsKnown({
+ box$( ty.clone() ),
+ mv$(final_trait_path),
+ method_name,
+ {}
+ }) );
+ return deref_count;
+ )
+ }
}
else {
// 2. Search for inherent methods