diff options
-rw-r--r-- | src/hir/from_ast.cpp | 7 | ||||
-rw-r--r-- | src/hir/hir.cpp | 4 | ||||
-rw-r--r-- | src/hir_conv/bind.cpp | 9 | ||||
-rw-r--r-- | src/resolve/absolute.cpp | 6 |
4 files changed, 15 insertions, 11 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index dfe6b8ab..b0768a84 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -690,10 +690,8 @@ for(const auto& t : e.traits) { const auto& tb = t.binding().as_Trait(); - if( tb.trait_ && tb.trait_->is_marker() ) { - v.m_markers.push_back( LowerHIR_GenericPath(ty.span(), t) ); - } - else if( tb.hir && tb.hir->m_is_marker ) { + assert( tb.trait_ || tb.hir ); + if( (tb.trait_ && tb.trait_->is_marker()) || (tb.hir->m_is_marker) ) { v.m_markers.push_back( LowerHIR_GenericPath(ty.span(), t) ); } else { @@ -704,6 +702,7 @@ v.m_trait = LowerHIR_TraitPath(ty.span(), t); } } + ASSERT_BUG(ty.span(), v.m_trait.m_path.m_path.m_components.size() > 0, "TraitObject type didn't contain a data trait - " << ty); return ::HIR::TypeRef( ::HIR::TypeRef::Data::make_TraitObject( mv$(v) ) ); ), (Function, diff --git a/src/hir/hir.cpp b/src/hir/hir.cpp index d0a825f8..6b50c0f2 100644 --- a/src/hir/hir.cpp +++ b/src/hir/hir.cpp @@ -375,9 +375,7 @@ const ::HIR::SimplePath& ::HIR::Crate::get_lang_item_path(const Span& sp, const const ::HIR::TypeItem& ::HIR::Crate::get_typeitem_by_path(const Span& sp, const ::HIR::SimplePath& path) const { - if( path.m_components.size() == 0) { - BUG(sp, "get_typeitem_by_path received invalid path"); - } + ASSERT_BUG(sp, path.m_components.size() > 0, "get_typeitem_by_path received invalid path - " << path); const ::HIR::Module* mod; if( path.m_crate_name != "" ) { diff --git a/src/hir_conv/bind.cpp b/src/hir_conv/bind.cpp index cce11cdf..c6e8fa5d 100644 --- a/src/hir_conv/bind.cpp +++ b/src/hir_conv/bind.cpp @@ -19,11 +19,16 @@ namespace { }; const void* get_type_pointer(const Span& sp, const ::HIR::Crate& crate, const ::HIR::SimplePath& path, Target t) { + // NOTE: Can't share with HIR::Crate::get_typeitem_by_path because it has to handle enum variants + const ::HIR::Module* mod; if( path.m_crate_name != "" ) { - TODO(sp, "Handle extern crates"); + ASSERT_BUG(sp, crate.m_ext_crates.count(path.m_crate_name) > 0, "Crate '" << path.m_crate_name << "' not loaded"); + mod = &crate.m_ext_crates.at(path.m_crate_name)->m_root_module; + } + else { + mod = &crate.m_root_module; } - const ::HIR::Module* mod = &crate.m_root_module; for( unsigned int i = 0; i < path.m_components.size()-1; i ++ ) { const auto& pc = path.m_components[i]; diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp index d537c907..597097aa 100644 --- a/src/resolve/absolute.cpp +++ b/src/resolve/absolute.cpp @@ -781,12 +781,14 @@ namespace { ), (TypeAlias, // TODO: set binding - path = split_into_ufcs_ty(sp, mv$(path), i); + path = split_into_crate(sp, mv$(path), start, crate.m_name); + path = split_into_ufcs_ty(sp, mv$(path), i-start); return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path); ), (Struct, // TODO: set binding - path = split_into_ufcs_ty(sp, mv$(path), i); + path = split_into_crate(sp, mv$(path), start, crate.m_name); + path = split_into_ufcs_ty(sp, mv$(path), i-start); return Resolve_Absolute_Path_BindUFCS(context, sp, mode, path); ), (Enum, |