aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-forever-stack.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/resolve/rust-forever-stack.hxx')
-rw-r--r--gcc/rust/resolve/rust-forever-stack.hxx46
1 files changed, 34 insertions, 12 deletions
diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx
index a6e0b30..885f282 100644
--- a/gcc/rust/resolve/rust-forever-stack.hxx
+++ b/gcc/rust/resolve/rust-forever-stack.hxx
@@ -77,7 +77,7 @@ ForeverStack<N>::push_inner (Rib rib, Link link)
rust_assert (&cursor_reference.get () == &root);
// Prelude doesn't have an access path
rust_assert (!link.path);
- update_cursor (this->prelude);
+ update_cursor (this->lang_prelude);
return;
}
// If the link does not exist, we create it and emplace a new `Node` with the
@@ -319,16 +319,16 @@ ForeverStack<N>::get (const Identifier &name)
template <Namespace N>
tl::optional<Rib::Definition>
-ForeverStack<N>::get_prelude (const Identifier &name)
+ForeverStack<N>::get_lang_prelude (const Identifier &name)
{
- return prelude.rib.get (name.as_string ());
+ return lang_prelude.rib.get (name.as_string ());
}
template <Namespace N>
tl::optional<Rib::Definition>
-ForeverStack<N>::get_prelude (const std::string &name)
+ForeverStack<N>::get_lang_prelude (const std::string &name)
{
- return prelude.rib.get (name);
+ return lang_prelude.rib.get (name);
}
template <>
@@ -571,7 +571,7 @@ ForeverStack<N>::resolve_segments (
if (current_node->is_root () && !searched_prelude)
{
searched_prelude = true;
- current_node = &prelude;
+ current_node = &lang_prelude;
continue;
}
@@ -594,6 +594,26 @@ ForeverStack<N>::resolve_segments (
return *current_node;
}
+template <>
+inline tl::optional<Rib::Definition>
+ForeverStack<Namespace::Types>::resolve_final_segment (Node &final_node,
+ std::string &seg_name,
+ bool is_lower_self)
+{
+ if (is_lower_self)
+ return Rib::Definition::NonShadowable (final_node.id);
+ else
+ return final_node.rib.get (seg_name);
+}
+
+template <Namespace N>
+tl::optional<Rib::Definition>
+ForeverStack<N>::resolve_final_segment (Node &final_node, std::string &seg_name,
+ bool is_lower_self)
+{
+ return final_node.rib.get (seg_name);
+}
+
template <Namespace N>
template <typename S>
tl::optional<Rib::Definition>
@@ -621,7 +641,8 @@ ForeverStack<N>::resolve_path (
= get (unwrap_type_segment (segments.back ()).as_string ());
if (!res)
- res = get_prelude (unwrap_type_segment (segments.back ()).as_string ());
+ res = get_lang_prelude (
+ unwrap_type_segment (segments.back ()).as_string ());
if (res && !res->is_ambiguous ())
insert_segment_resolution (segments.back (), res->get_node_id ());
@@ -643,15 +664,16 @@ ForeverStack<N>::resolve_path (
if (final_node.rib.kind == Rib::Kind::TraitOrImpl)
return tl::nullopt;
- std::string seg_name
- = unwrap_type_segment (segments.back ()).as_string ();
+ auto &seg = unwrap_type_segment (segments.back ());
+ std::string seg_name = seg.as_string ();
// assuming this can't be a lang item segment
- tl::optional<Rib::Definition> res = final_node.rib.get (seg_name);
-
+ tl::optional<Rib::Definition> res
+ = resolve_final_segment (final_node, seg_name,
+ seg.is_lower_self_seg ());
// Ok we didn't find it in the rib, Lets try the prelude...
if (!res)
- res = get_prelude (seg_name);
+ res = get_lang_prelude (seg_name);
if (res && !res->is_ambiguous ())
insert_segment_resolution (segments.back (), res->get_node_id ());