diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-12-26 21:46:03 +0000 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2025-01-16 14:00:31 +0000 |
commit | 432859bf783a7dc9fb81f267c5159c60435973cb (patch) | |
tree | f0581fcf770e63924f3094074b4e2266cfc3fc9e /gcc/rust/ast/rust-path.cc | |
parent | 955c4f7e587c082f0d364e4305c78b35822bd6ab (diff) | |
download | gcc-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-path.cc')
-rw-r--r-- | gcc/rust/ast/rust-path.cc | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/gcc/rust/ast/rust-path.cc b/gcc/rust/ast/rust-path.cc index 3a7e6e3..02f1f1b 100644 --- a/gcc/rust/ast/rust-path.cc +++ b/gcc/rust/ast/rust-path.cc @@ -136,8 +136,11 @@ PathExprSegment::as_string () const } std::string -RegularPath::as_string () const +Path::as_string () const { + // FIXME: Impl for lang items + rust_assert (kind == Kind::Regular); + std::string str; for (const auto &segment : segments) @@ -149,15 +152,11 @@ RegularPath::as_string () const return str; } -std::string -LangItemPath::as_string () const -{ - return "#[lang = \"" + LangItem::ToString (kind) + "\"]"; -} - SimplePath -RegularPath::convert_to_simple_path (bool with_opening_scope_resolution) const +Path::convert_to_simple_path (bool with_opening_scope_resolution) const { + rust_assert (kind == Kind::Regular); + if (!has_segments ()) return SimplePath::create_empty (); @@ -191,18 +190,6 @@ RegularPath::convert_to_simple_path (bool with_opening_scope_resolution) const } void -RegularPath::accept_vis (ASTVisitor &vis) -{ - vis.visit (*this); -} - -void -LangItemPath::accept_vis (ASTVisitor &vis) -{ - vis.visit (*this); -} - -void PathInExpression::accept_vis (ASTVisitor &vis) { vis.visit (*this); @@ -216,7 +203,7 @@ PathInExpression::as_string () const if (has_opening_scope_resolution) str = "::"; - return str + path->as_string (); + return str + Path::as_string (); } std::string @@ -316,7 +303,7 @@ TypePathFunction::as_string () const std::string QualifiedPathInExpression::as_string () const { - return path_type.as_string () + "::" + path->as_string (); + return path_type.as_string () + "::" + Path::as_string (); } std::string |