diff options
author | John Hodge <tpg@mutabah.net> | 2016-07-17 14:38:49 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-07-17 14:38:49 +0800 |
commit | ba403ec3e36af2655849b8599eaa76d4205a5a7c (patch) | |
tree | 9195f5df032e830cc605061e96161f2822533b87 | |
parent | cba4603c178b886fa2579c6fc814e3e31b76b8dd (diff) | |
download | mrust-ba403ec3e36af2655849b8599eaa76d4205a5a7c.tar.gz |
HIR Typecheck - (minor) Clean up of odd variable naming
-rw-r--r-- | src/hir_typeck/helpers.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index 36449281..8f9f5f85 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -1310,9 +1310,9 @@ bool TraitResolution::has_associated_type(const ::HIR::TypeRef& input) const (Primitive, ), (Path, - TU_MATCH(::HIR::Path::Data, (e.path.m_data), (e2), + TU_MATCH(::HIR::Path::Data, (e.path.m_data), (pe), (Generic, - for(auto& arg : e2.m_params.m_types) + for(auto& arg : pe.m_params.m_types) arg = expand_associated_types(sp, mv$(arg)); ), (UfcsInherent, @@ -1326,24 +1326,24 @@ bool TraitResolution::has_associated_type(const ::HIR::TypeRef& input) const DEBUG("Locating associated type for " << e.path); - *e2.type = expand_associated_types(sp, mv$(*e2.type)); + *pe.type = expand_associated_types(sp, mv$(*pe.type)); // - If it's a closure, then the only trait impls are those generated by typeck - TU_IFLET(::HIR::TypeRef::Data, e2.type->m_data, Closure, te, + TU_IFLET(::HIR::TypeRef::Data, pe.type->m_data, Closure, te, const auto trait_fn = this->m_crate.get_lang_item_path(sp, "fn"); const auto trait_fn_mut = this->m_crate.get_lang_item_path(sp, "fn_mut"); const auto trait_fn_once = this->m_crate.get_lang_item_path(sp, "fn_once"); - if( e2.trait.m_path == trait_fn || e2.trait.m_path == trait_fn_mut || e2.trait.m_path == trait_fn_once ) { - if( e2.item == "Output" ) { + if( pe.trait.m_path == trait_fn || pe.trait.m_path == trait_fn_mut || pe.trait.m_path == trait_fn_once ) { + if( pe.item == "Output" ) { return te.m_rettype->clone(); } else { - ERROR(sp, E0000, "No associated type " << e2.item << " for trait " << e2.trait); + ERROR(sp, E0000, "No associated type " << pe.item << " for trait " << pe.trait); } } else { - ERROR(sp, E0000, "No implementation of " << e2.trait << " for " << *e2.type); + ERROR(sp, E0000, "No implementation of " << pe.trait << " for " << *pe.type); } ) @@ -1358,11 +1358,11 @@ bool TraitResolution::has_associated_type(const ::HIR::TypeRef& input) const DEBUG("Trait bound - " << be.type << " : " << be.trait); // 1. Check if the type matches // - TODO: This should be a fuzzier match? - if( be.type != *e2.type ) + if( be.type != *pe.type ) return false; - // 2. Check if the trait (or any supertrait) includes e2.trait - if( be.trait.m_path == e2.trait ) { - auto it = be.trait.m_type_bounds.find(e2.item); + // 2. Check if the trait (or any supertrait) includes pe.trait + if( be.trait.m_path == pe.trait ) { + auto it = be.trait.m_type_bounds.find(pe.item); // 1. Check if the bounds include the desired item if( it == be.trait.m_type_bounds.end() ) { // If not, assume it's opaque and return as such @@ -1377,10 +1377,10 @@ bool TraitResolution::has_associated_type(const ::HIR::TypeRef& input) const } bool found_supertrait = this->find_named_trait_in_trait(sp, - e2.trait.m_path, e2.trait.m_params, - *be.trait.m_trait_ptr, be.trait.m_path.m_path, be.trait.m_path.m_params, *e2.type, - [&e2,&input,&assume_opaque](const auto&, const auto& x, const auto& assoc){ - auto it = assoc.find(e2.item); + pe.trait.m_path, pe.trait.m_params, + *be.trait.m_trait_ptr, be.trait.m_path.m_path, be.trait.m_path.m_params, *pe.type, + [&pe,&input,&assume_opaque](const auto&, const auto& x, const auto& assoc){ + auto it = assoc.find(pe.item); if( it != assoc.end() ) { assume_opaque = false; DEBUG("Found associated type " << input << " = " << it->second); @@ -1390,7 +1390,7 @@ bool TraitResolution::has_associated_type(const ::HIR::TypeRef& input) const } ); if( found_supertrait ) { - auto it = be.trait.m_type_bounds.find(e2.item); + auto it = be.trait.m_type_bounds.find(pe.item); // 1. Check if the bounds include the desired item if( it == be.trait.m_type_bounds.end() ) { // If not, assume it's opaque and return as such @@ -1437,10 +1437,10 @@ bool TraitResolution::has_associated_type(const ::HIR::TypeRef& input) const } // If the type of this UfcsKnown is ALSO a UfcsKnown - Check if it's bounded by this trait with equality - // Use bounds on other associated types too (if `e2.type` was resolved to a fixed associated type) - TU_IFLET(::HIR::TypeRef::Data, e2.type->m_data, Path, te_inner, + // Use bounds on other associated types too (if `pe.type` was resolved to a fixed associated type) + TU_IFLET(::HIR::TypeRef::Data, pe.type->m_data, Path, te_inner, TU_IFLET(::HIR::Path::Data, te_inner.path.m_data, UfcsKnown, pe_inner, - // TODO: Search for equality bounds on this associated type (e3) that match the entire type (e2) + // TODO: Search for equality bounds on this associated type (pe_inner) that match the entire type (pe) // - Does simplification of complex associated types const auto& trait_ptr = this->m_crate.get_trait_by_path(sp, pe_inner.trait.m_path); const auto& assoc_ty = trait_ptr.m_types.at(pe_inner.item); @@ -1464,8 +1464,8 @@ bool TraitResolution::has_associated_type(const ::HIR::TypeRef& input) const { // If the bound is for Self and the outer trait // - TODO: Parameters? - if( bound.m_path == e2.trait ) { - auto it = bound.m_type_bounds.find( e2.item ); + if( bound.m_path == pe.trait ) { + auto it = bound.m_type_bounds.find( pe.item ); if( it != bound.m_type_bounds.end() ) { if( monomorphise_type_needed(it->second) ) { input = monomorphise_type_with(sp, it->second, cb_placeholders_trait); @@ -1478,22 +1478,22 @@ bool TraitResolution::has_associated_type(const ::HIR::TypeRef& input) const } } } - DEBUG("e2 = " << *e2.type << ", input = " << input); + DEBUG("pe = " << *pe.type << ", input = " << input); ) ) // 2. Crate-level impls // TODO: Search for the actual trait containing this associated type ::HIR::GenericPath trait_path; - if( !this->trait_contains_type(sp, e2.trait, this->m_crate.get_trait_by_path(sp, e2.trait.m_path), e2.item, trait_path) ) - BUG(sp, "Cannot find associated type " << e2.item << " anywhere in trait " << e2.trait); - //e2.trait = mv$(trait_path); + if( !this->trait_contains_type(sp, pe.trait, this->m_crate.get_trait_by_path(sp, pe.trait.m_path), pe.item, trait_path) ) + BUG(sp, "Cannot find associated type " << pe.item << " anywhere in trait " << pe.trait); + //pe.trait = mv$(trait_path); - rv = this->find_trait_impls_crate(sp, trait_path.m_path, trait_path.m_params, *e2.type, [&](const auto& , const auto& args, const auto& assoc) { - DEBUG("Found impl for " << e2.trait.m_path << args << " with types {" << assoc << "}"); - auto it = assoc.find( e2.item ); + rv = this->find_trait_impls_crate(sp, trait_path.m_path, trait_path.m_params, *pe.type, [&](const auto& , const auto& args, const auto& assoc) { + DEBUG("Found impl for " << pe.trait.m_path << args << " with types {" << assoc << "}"); + auto it = assoc.find( pe.item ); if( it == assoc.end() ) - ERROR(sp, E0000, "Couldn't find assocated type " << e2.item << " in " << e2.trait); + ERROR(sp, E0000, "Couldn't find assocated type " << pe.item << " in " << pe.trait); DEBUG("Converted UfcsKnown - " << e.path << " = " << it->second); input = it->second.clone(); |