aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast-builder.cc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-12-26 21:46:03 +0000
committerCohenArthur <arthur.cohen@embecosm.com>2025-01-16 14:00:31 +0000
commit432859bf783a7dc9fb81f267c5159c60435973cb (patch)
treef0581fcf770e63924f3094074b4e2266cfc3fc9e /gcc/rust/ast/rust-ast-builder.cc
parent955c4f7e587c082f0d364e4305c78b35822bd6ab (diff)
downloadgcc-432859bf783a7dc9fb81f267c5159c60435973cb.zip
gcc-432859bf783a7dc9fb81f267c5159c60435973cb.tar.gz
gcc-432859bf783a7dc9fb81f267c5159c60435973cb.tar.bz2
ast: Refactor how lang item paths are handled.
Lang item typepaths were not handled properly, and required a complete overhaul. All old classes that concerned lang item paths are now modified to use a simpler version of `AST::LangItemPath`, which has been removed. TypePath segments can now be lang items, as this is requied for having generic lang item paths such as PhantomData<T>. gcc/rust/ChangeLog: * ast/rust-path.h: Rework how lang item paths are represented. * ast/rust-path.cc: Likewise. * ast/rust-item.h: Likewise. * ast/rust-ast.cc: Likewise. * ast/rust-ast-collector.cc: Adapt to new lang item path system. * ast/rust-ast-collector.h: Likewise. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast-visitor.h: Likewise. * expand/rust-derive-copy.cc: Likewise. * expand/rust-derive.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-type.cc (ASTLowerTypePath::translate): Likewise. (ASTLowerTypePath::visit): Likewise. * hir/rust-ast-lower-type.h: Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise. * resolve/rust-late-name-resolver-2.0.h: Likewise. * hir/tree/rust-hir-path.cc (TypePathSegment::TypePathSegment): Likewise. (TypePathSegmentGeneric::TypePathSegmentGeneric): Likewise. * hir/tree/rust-hir-path.h: Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Likewise. * ast/rust-ast-builder.cc: Likewise. * ast/rust-ast-builder.h: Likewise.
Diffstat (limited to 'gcc/rust/ast/rust-ast-builder.cc')
-rw-r--r--gcc/rust/ast/rust-ast-builder.cc20
1 files changed, 1 insertions, 19 deletions
diff --git a/gcc/rust/ast/rust-ast-builder.cc b/gcc/rust/ast/rust-ast-builder.cc
index 90832e2..d10b64e 100644
--- a/gcc/rust/ast/rust-ast-builder.cc
+++ b/gcc/rust/ast/rust-ast-builder.cc
@@ -43,15 +43,6 @@ Builder::call (std::unique_ptr<Expr> &&path,
}
std::unique_ptr<Expr>
-Builder::call (std::unique_ptr<Path> &&path,
- std::vector<std::unique_ptr<Expr>> &&args) const
-{
- return call (std::unique_ptr<Expr> (
- new PathInExpression (std::move (path), {}, loc)),
- std::move (args));
-}
-
-std::unique_ptr<Expr>
Builder::call (std::unique_ptr<Expr> &&path, std::unique_ptr<Expr> &&arg) const
{
auto args = std::vector<std::unique_ptr<Expr>> ();
@@ -61,15 +52,6 @@ Builder::call (std::unique_ptr<Expr> &&path, std::unique_ptr<Expr> &&arg) const
}
std::unique_ptr<Expr>
-Builder::call (std::unique_ptr<Path> &&path, std::unique_ptr<Expr> &&arg) const
-{
- auto args = std::vector<std::unique_ptr<Expr>> ();
- args.emplace_back (std::move (arg));
-
- return call (std::move (path), std::move (args));
-}
-
-std::unique_ptr<Expr>
Builder::array (std::vector<std::unique_ptr<Expr>> &&members) const
{
auto elts = std::make_unique<ArrayElemsValues> (std::move (members), loc);
@@ -242,7 +224,7 @@ Builder::wildcard () const
std::unique_ptr<Path>
Builder::lang_item_path (LangItem::Kind kind) const
{
- return std::unique_ptr<Path> (new LangItemPath (kind, loc));
+ return std::unique_ptr<Path> (new PathInExpression (kind, {}, loc));
}
std::unique_ptr<Expr>