diff options
-rw-r--r-- | src/hir_typeck/helpers.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index c7fb4019..c5d12d7d 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -629,7 +629,9 @@ void HMTypeInferrence::expand_ivars(::HIR::TypeRef& type) (Generic, ), (TraitObject, - // TODO: Iterate all paths + this->expand_ivars_params(e.m_trait.m_path.m_params); + for(auto& marker : e.m_markers) + this->expand_ivars_params(marker.m_params); ), (Array, this->expand_ivars(*e.inner); @@ -648,7 +650,9 @@ void HMTypeInferrence::expand_ivars(::HIR::TypeRef& type) this->expand_ivars(*e.inner); ), (Function, - // No ivars allowed? + this->expand_ivars(*e.m_rettype); + for(auto& ty : e.m_arg_types) + this->expand_ivars(ty); ), (Closure, this->expand_ivars(*e.m_rettype); @@ -702,6 +706,9 @@ void HMTypeInferrence::add_ivars(::HIR::TypeRef& type) ), (TraitObject, // Iterate all paths + this->add_ivars_params(e.m_trait.m_path.m_params); + for(auto& marker : e.m_markers) + this->add_ivars_params(marker.m_params); ), (Array, add_ivars(*e.inner); @@ -720,8 +727,9 @@ void HMTypeInferrence::add_ivars(::HIR::TypeRef& type) add_ivars(*e.inner); ), (Function, - // No ivars allowed - // TODO: Check? + add_ivars(*e.m_rettype); + for(auto& ty : e.m_arg_types) + add_ivars(ty); ), (Closure, // Shouldn't be possible @@ -791,7 +799,7 @@ void HMTypeInferrence::set_ivar_to(unsigned int slot, ::HIR::TypeRef type) check_type_class_primitive(sp, type, l_e.ty_class, e); ), (Infer, - // TODO: Check for right having a ty_class + // Check for right having a ty_class if( e.ty_class != ::HIR::InferClass::None && e.ty_class != l_e.ty_class ) { ERROR(sp, E0000, "Unifying types with mismatching literal classes"); } @@ -1233,7 +1241,6 @@ bool TraitResolution::find_trait_impls(const Span& sp, const auto& type = self.m_ivars.get_type(ty); TU_MATCH_DEF(::HIR::TypeRef::Data, (type.m_data), (e), ( - // TODO: Search for impls? TODO(sp, "Search for Copy impl on " << type); ), (Primitive, @@ -1634,12 +1641,9 @@ void TraitResolution::expand_associated_types_inplace__UfcsKnown(const Span& sp, } }; D _(*this, input.clone()); + // State stack to avoid infinite recursion LList<const ::HIR::TypeRef*> stack(&prev_stack, &m_eat_active_stack.back()); - // TODO: State stack to avoid infinite recursion - // Example: - // IVar 181 = <::ops::Range<<_/*181*/ as ::iter::iterator::Iterator>::Item/*U*/,>/*S*/ as ::iter::traits::IntoIterator>::IntoIter/*U*/ - // The above infinitely recurses due to the recursion here. expand_associated_types_inplace(sp, *pe.type, stack); // - If it's a closure, then the only trait impls are those generated by typeck @@ -2313,6 +2317,9 @@ unsigned int TraitResolution::autoderef_find_method(const Span& sp, const HIR::t deref_count += 1; ) + // TODO: This appears to dereference a &mut to call a `self: Self` method, where it should use the trait impl on &mut Self. + // - Shouldn't deref to get a by-value receiver.// unless it's via a &move. + do { const auto& ty = this->m_ivars.get_type(*current_ty); if( ty.m_data.is_Infer() ) { |