public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] refactor relative type path function into its assoicated file
@ 2022-06-29 10:27 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-29 10:27 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1ea95c3548ce17a4a3604dfc5e2e6661750e5a85
commit 1ea95c3548ce17a4a3604dfc5e2e6661750e5a85
Author: Philip Herron <philip.herron@embecosm.com>
Date: Mon Jun 27 13:07:42 2022 +0100
refactor relative type path function into its assoicated file
Diff:
---
gcc/rust/resolve/rust-ast-resolve-type.cc | 46 +++++++++++++++++++++++++++++
gcc/rust/resolve/rust-ast-resolve.cc | 48 -------------------------------
2 files changed, 46 insertions(+), 48 deletions(-)
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.cc b/gcc/rust/resolve/rust-ast-resolve-type.cc
index 7f6e43a725b..050f3b919e1 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-type.cc
@@ -454,5 +454,51 @@ ResolveRelativeTypePath::go (AST::QualifiedPathInType &path)
return true;
}
+bool
+ResolveRelativeTypePath::resolve_qual_seg (AST::QualifiedPathType &seg,
+ CanonicalPath &result)
+{
+ if (seg.is_error ())
+ {
+ rust_error_at (seg.get_locus (), "segment has error: %s",
+ seg.as_string ().c_str ());
+ return false;
+ }
+
+ auto type = seg.get_type ().get ();
+ NodeId type_resolved_node = ResolveType::go (type, seg.get_node_id ());
+ if (type_resolved_node == UNKNOWN_NODEID)
+ return false;
+
+ const CanonicalPath *impl_type_seg = nullptr;
+ bool ok
+ = mappings->lookup_canonical_path (mappings->get_current_crate (),
+ type_resolved_node, &impl_type_seg);
+ rust_assert (ok);
+
+ if (!seg.has_as_clause ())
+ {
+ result = result.append (*impl_type_seg);
+ return true;
+ }
+
+ NodeId trait_resolved_node
+ = ResolveType::go (&seg.get_as_type_path (), seg.get_node_id ());
+ if (trait_resolved_node == UNKNOWN_NODEID)
+ return false;
+
+ const CanonicalPath *trait_type_seg = nullptr;
+ ok = mappings->lookup_canonical_path (mappings->get_current_crate (),
+ trait_resolved_node, &trait_type_seg);
+ rust_assert (ok);
+
+ CanonicalPath projection
+ = TraitImplProjection::resolve (seg.get_node_id (), *trait_type_seg,
+ *impl_type_seg);
+
+ result = result.append (projection);
+ return true;
+}
+
} // namespace Resolver
} // namespace Rust
diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc
index ff042bc95ea..93fa7c8761c 100644
--- a/gcc/rust/resolve/rust-ast-resolve.cc
+++ b/gcc/rust/resolve/rust-ast-resolve.cc
@@ -111,53 +111,5 @@ NameResolution::go (AST::Crate &crate)
resolver->pop_module_scope ();
}
-// qualified path in type
-
-bool
-ResolveRelativeTypePath::resolve_qual_seg (AST::QualifiedPathType &seg,
- CanonicalPath &result)
-{
- if (seg.is_error ())
- {
- rust_error_at (seg.get_locus (), "segment has error: %s",
- seg.as_string ().c_str ());
- return false;
- }
-
- auto type = seg.get_type ().get ();
- NodeId type_resolved_node = ResolveType::go (type, seg.get_node_id ());
- if (type_resolved_node == UNKNOWN_NODEID)
- return false;
-
- const CanonicalPath *impl_type_seg = nullptr;
- bool ok
- = mappings->lookup_canonical_path (mappings->get_current_crate (),
- type_resolved_node, &impl_type_seg);
- rust_assert (ok);
-
- if (!seg.has_as_clause ())
- {
- result = result.append (*impl_type_seg);
- return true;
- }
-
- NodeId trait_resolved_node
- = ResolveType::go (&seg.get_as_type_path (), seg.get_node_id ());
- if (trait_resolved_node == UNKNOWN_NODEID)
- return false;
-
- const CanonicalPath *trait_type_seg = nullptr;
- ok = mappings->lookup_canonical_path (mappings->get_current_crate (),
- trait_resolved_node, &trait_type_seg);
- rust_assert (ok);
-
- CanonicalPath projection
- = TraitImplProjection::resolve (seg.get_node_id (), *trait_type_seg,
- *impl_type_seg);
-
- result = result.append (projection);
- return true;
-}
-
} // namespace Resolver
} // namespace Rust
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-29 10:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29 10:27 [gcc/devel/rust/master] refactor relative type path function into its assoicated file Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).