summaryrefslogtreecommitdiff
path: root/src/hir
diff options
context:
space:
mode:
Diffstat (limited to 'src/hir')
-rw-r--r--src/hir/hir.cpp12
-rw-r--r--src/hir/hir.hpp2
2 files changed, 9 insertions, 5 deletions
diff --git a/src/hir/hir.cpp b/src/hir/hir.cpp
index d4a4c9be..780a8e70 100644
--- a/src/hir/hir.cpp
+++ b/src/hir/hir.cpp
@@ -730,7 +730,7 @@ const ::HIR::SimplePath& ::HIR::Crate::get_lang_item_path_opt(const char* name)
const ::HIR::TypeItem& ::HIR::Crate::get_typeitem_by_path(const Span& sp, const ::HIR::SimplePath& path, bool ignore_crate_name, bool ignore_last_node) const
{
ASSERT_BUG(sp, path.m_components.size() > 0, "get_typeitem_by_path received invalid path - " << path);
- ASSERT_BUG(sp, path.m_components.size() > (ignore_last_node ? 1 : 0), "get_typeitem_by_path received invlaid path - " << path);
+ ASSERT_BUG(sp, path.m_components.size() > (ignore_last_node ? 1 : 0), "get_typeitem_by_path received invalid path - " << path);
const ::HIR::Module* mod;
if( !ignore_crate_name && path.m_crate_name != m_crate_name ) {
@@ -762,9 +762,13 @@ const ::HIR::TypeItem& ::HIR::Crate::get_typeitem_by_path(const Span& sp, const
return it->second->ent;
}
-const ::HIR::Module& ::HIR::Crate::get_mod_by_path(const Span& sp, const ::HIR::SimplePath& path) const
+const ::HIR::Module& ::HIR::Crate::get_mod_by_path(const Span& sp, const ::HIR::SimplePath& path, bool ignore_last_node/*=false*/) const
{
- if( path.m_components.size() == 0 )
+ if( ignore_last_node )
+ {
+ ASSERT_BUG(sp, path.m_components.size() > 0, "get_mod_by_path received invalid path with ignore_last_node=true - " << path);
+ }
+ if( path.m_components.size() == (ignore_last_node ? 1 : 0) )
{
if( path.m_crate_name != m_crate_name )
{
@@ -778,7 +782,7 @@ const ::HIR::Module& ::HIR::Crate::get_mod_by_path(const Span& sp, const ::HIR::
}
else
{
- const auto& ti = this->get_typeitem_by_path(sp, path);
+ const auto& ti = this->get_typeitem_by_path(sp, path, false, ignore_last_node);
TU_IFLET(::HIR::TypeItem, ti, Module, e,
return e;
)
diff --git a/src/hir/hir.hpp b/src/hir/hir.hpp
index 9b40ad1a..f090c67f 100644
--- a/src/hir/hir.hpp
+++ b/src/hir/hir.hpp
@@ -442,7 +442,7 @@ public:
const ::HIR::Struct& get_struct_by_path(const Span& sp, const ::HIR::SimplePath& path) const;
const ::HIR::Union& get_union_by_path(const Span& sp, const ::HIR::SimplePath& path) const;
const ::HIR::Enum& get_enum_by_path(const Span& sp, const ::HIR::SimplePath& path) const;
- const ::HIR::Module& get_mod_by_path(const Span& sp, const ::HIR::SimplePath& path) const;
+ const ::HIR::Module& get_mod_by_path(const Span& sp, const ::HIR::SimplePath& path, bool ignore_last_node=false) const;
const ::HIR::ValueItem& get_valitem_by_path(const Span& sp, const ::HIR::SimplePath& path, bool ignore_crate_name=false) const;
const ::HIR::Function& get_function_by_path(const Span& sp, const ::HIR::SimplePath& path) const;