diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2025-03-24 22:49:12 -0400 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2025-04-01 09:19:04 +0000 |
commit | bdfdaef9069a557ac47384c1a845a9e3dcf02ccc (patch) | |
tree | 69bcece9c064f5911ef0019aadbb693ec518dbb1 /gcc/rust/resolve/rust-name-resolution-context.h | |
parent | b8ef598308e7bd08fb40651bf4c17490ccbb855f (diff) | |
download | gcc-bdfdaef9069a557ac47384c1a845a9e3dcf02ccc.zip gcc-bdfdaef9069a557ac47384c1a845a9e3dcf02ccc.tar.gz gcc-bdfdaef9069a557ac47384c1a845a9e3dcf02ccc.tar.bz2 |
nr2.0: Handle global paths
gcc/rust/ChangeLog:
* resolve/rust-forever-stack.h
(ForeverStack::ForeverStack): Initialize extern_prelude.
(ForeverStack::resolve_path): Add parameter
has_opening_scope_resolution.
(ForeverStack::extern_prelude): Add field.
* resolve/rust-forever-stack.hxx: Include rust-edition.h.
(ForeverStacl::resolve_path): Handle global paths (paths with an
opening scope resolution operator).
* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Handle global paths.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::resolve_path): Handle global paths.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entries.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/resolve/rust-name-resolution-context.h')
-rw-r--r-- | gcc/rust/resolve/rust-name-resolution-context.h | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/gcc/rust/resolve/rust-name-resolution-context.h b/gcc/rust/resolve/rust-name-resolution-context.h index d21b868..bb5590e 100644 --- a/gcc/rust/resolve/rust-name-resolution-context.h +++ b/gcc/rust/resolve/rust-name-resolution-context.h @@ -221,6 +221,7 @@ public: template <typename S> tl::optional<Rib::Definition> resolve_path (const std::vector<S> &segments, + bool has_opening_scope_resolution, Namespace ns) { std::function<void (const S &, NodeId)> insert_segment_resolution @@ -232,13 +233,17 @@ public: switch (ns) { case Namespace::Values: - return values.resolve_path (segments, insert_segment_resolution); + return values.resolve_path (segments, has_opening_scope_resolution, + insert_segment_resolution); case Namespace::Types: - return types.resolve_path (segments, insert_segment_resolution); + return types.resolve_path (segments, has_opening_scope_resolution, + insert_segment_resolution); case Namespace::Macros: - return macros.resolve_path (segments, insert_segment_resolution); + return macros.resolve_path (segments, has_opening_scope_resolution, + insert_segment_resolution); case Namespace::Labels: - return labels.resolve_path (segments, insert_segment_resolution); + return labels.resolve_path (segments, has_opening_scope_resolution, + insert_segment_resolution); default: rust_unreachable (); } @@ -246,19 +251,45 @@ public: template <typename S, typename... Args> tl::optional<Rib::Definition> resolve_path (const std::vector<S> &segments, + bool has_opening_scope_resolution, Args... ns_args) { std::initializer_list<Namespace> namespaces = {ns_args...}; for (auto ns : namespaces) { - if (auto ret = resolve_path (segments, ns)) + if (auto ret + = resolve_path (segments, has_opening_scope_resolution, ns)) return ret; } return tl::nullopt; } + template <typename... Args> + tl::optional<Rib::Definition> resolve_path (const AST::SimplePath &path, + Args... ns_args) + { + return resolve_path (path.get_segments (), + path.has_opening_scope_resolution (), ns_args...); + } + + template <typename... Args> + tl::optional<Rib::Definition> resolve_path (const AST::PathInExpression &path, + Args... ns_args) + { + return resolve_path (path.get_segments (), path.opening_scope_resolution (), + ns_args...); + } + + template <typename... Args> + tl::optional<Rib::Definition> resolve_path (const AST::TypePath &path, + Args... ns_args) + { + return resolve_path (path.get_segments (), + path.has_opening_scope_resolution_op (), ns_args...); + } + private: /* Map of "usage" nodes which have been resolved to a "definition" node */ std::map<Usage, Definition> resolved_nodes; |