public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Remove unused class ResolveTypeToCanonicalPath and generation of a path from qualified type paths
@ 2022-06-29 10:28 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-29 10:28 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:76aeea68f518dba8a29bd7ad82e049ad106fe8bd
commit 76aeea68f518dba8a29bd7ad82e049ad106fe8bd
Author: Philip Herron <philip.herron@embecosm.com>
Date: Tue Jun 28 14:18:11 2022 +0100
Remove unused class ResolveTypeToCanonicalPath and generation of a path from qualified type paths
Diff:
---
gcc/rust/resolve/rust-ast-resolve-type.cc | 77 +++----------------------------
gcc/rust/resolve/rust-ast-resolve-type.h | 11 +----
2 files changed, 8 insertions(+), 80 deletions(-)
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.cc b/gcc/rust/resolve/rust-ast-resolve-type.cc
index 0d15e175da0..4260ec4f33f 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-type.cc
@@ -24,26 +24,6 @@ namespace Resolver {
// rust-ast-resolve-type.h
-std::string
-ResolveTypeToCanonicalPath::canonicalize_generic_args (AST::GenericArgs &args)
-{
- std::string buf;
-
- size_t i = 0;
- size_t total = args.get_type_args ().size ();
-
- for (auto &ty_arg : args.get_type_args ())
- {
- buf += ty_arg->as_string ();
- if ((i + 1) < total)
- buf += ",";
-
- i++;
- }
-
- return "<" + buf + ">";
-}
-
void
ResolveType::visit (AST::ArrayType &type)
{
@@ -291,20 +271,18 @@ ResolveRelativeTypePath::go (AST::TypePath &path, NodeId &resolved_node_id)
// qualified type paths
-ResolveRelativeQualTypePath::ResolveRelativeQualTypePath (
- CanonicalPath qualified_path)
- : result (qualified_path), failure_flag (false)
+ResolveRelativeQualTypePath::ResolveRelativeQualTypePath ()
+ : failure_flag (false)
{}
bool
ResolveRelativeQualTypePath::go (AST::QualifiedPathInType &path)
{
- CanonicalPath result = CanonicalPath::create_empty ();
- ResolveRelativeQualTypePath o (result);
+ ResolveRelativeQualTypePath o;
// resolve the type and trait path
auto &qualified_path = path.get_qualified_path_type ();
- if (!o.resolve_qual_seg (qualified_path, result))
+ if (!o.resolve_qual_seg (qualified_path))
return false;
// qualified types are similar to other paths in that we cannot guarantee
@@ -329,8 +307,7 @@ ResolveRelativeQualTypePath::go (AST::QualifiedPathInType &path)
}
bool
-ResolveRelativeQualTypePath::resolve_qual_seg (AST::QualifiedPathType &seg,
- CanonicalPath &result)
+ResolveRelativeQualTypePath::resolve_qual_seg (AST::QualifiedPathType &seg)
{
if (seg.is_error ())
{
@@ -344,34 +321,14 @@ ResolveRelativeQualTypePath::resolve_qual_seg (AST::QualifiedPathType &seg,
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;
- }
+ 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
- = CanonicalPath::trait_impl_projection_seg (seg.get_node_id (),
- *trait_type_seg,
- *impl_type_seg);
-
- result = result.append (projection);
return true;
}
@@ -386,24 +343,7 @@ ResolveRelativeQualTypePath::visit (AST::TypePathSegmentGeneric &seg)
return;
}
- if (!seg.has_generic_args ())
- {
- auto ident_segment
- = CanonicalPath::new_seg (seg.get_node_id (),
- seg.get_ident_segment ().as_string ());
- result = result.append (ident_segment);
- return;
- }
-
ResolveType::type_resolve_generic_args (seg.get_generic_args ());
-
- std::string generics = ResolveTypeToCanonicalPath::canonicalize_generic_args (
- seg.get_generic_args ());
- auto generic_segment
- = CanonicalPath::new_seg (seg.get_node_id (),
- seg.get_ident_segment ().as_string ()
- + "::" + generics);
- result = result.append (generic_segment);
}
void
@@ -416,11 +356,6 @@ ResolveRelativeQualTypePath::visit (AST::TypePathSegment &seg)
seg.as_string ().c_str ());
return;
}
-
- CanonicalPath ident_seg
- = CanonicalPath::new_seg (seg.get_node_id (),
- seg.get_ident_segment ().as_string ());
- result = result.append (ident_seg);
}
} // namespace Resolver
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h
index 733cfe770c8..664e68865ec 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -25,12 +25,6 @@
namespace Rust {
namespace Resolver {
-class ResolveTypeToCanonicalPath
-{
-public:
- static std::string canonicalize_generic_args (AST::GenericArgs &args);
-};
-
class ResolveRelativeTypePath
{
public:
@@ -49,12 +43,11 @@ public:
void visit (AST::TypePathSegment &seg) override;
protected:
- bool resolve_qual_seg (AST::QualifiedPathType &seg, CanonicalPath &result);
+ bool resolve_qual_seg (AST::QualifiedPathType &seg);
private:
- ResolveRelativeQualTypePath (CanonicalPath qualified_path);
+ ResolveRelativeQualTypePath ();
- CanonicalPath result;
bool failure_flag;
};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-29 10:28 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:28 [gcc/devel/rust/master] Remove unused class ResolveTypeToCanonicalPath and generation of a path from qualified type paths 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).