aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-path.h
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-12-21 22:56:52 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:55:45 +0100
commit9c50565e333621a8f7715db38adda442b1fe8a00 (patch)
tree74c9cc71177eeeffb91b818c79b03123ff4b574e /gcc/rust/ast/rust-path.h
parentc583545a9adaba0ab9d369f82b5f9bb1577e5f6e (diff)
downloadgcc-9c50565e333621a8f7715db38adda442b1fe8a00.zip
gcc-9c50565e333621a8f7715db38adda442b1fe8a00.tar.gz
gcc-9c50565e333621a8f7715db38adda442b1fe8a00.tar.bz2
gccrs: ast: Add new Kind enums for more precise downcasting
This commit adds things like Item::Kind, Expr::Kind, etc, and implements the associated `get_*_kind` functions. It also removes the more generic AST::Kind enum we were using, which was incomplete and painful to use. gcc/rust/ChangeLog: * ast/rust-ast.h: Add new Kind enums, remove Node class. * ast/rust-builtin-ast-nodes.h: Use new Kind enums. * ast/rust-expr.h (class LoopLabel): Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.h: Likewise. * expand/rust-macro-builtins-helpers.cc: Likewise. * expand/rust-macro-builtins-utility.cc (MacroBuiltin::concat_handler): Likewise. (MacroBuiltin::stringify_handler): Likewise. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise. * resolve/rust-early-name-resolver.cc: Likewise. * hir/rust-ast-lower.cc (ASTLoweringBlock::visit): Likewise.
Diffstat (limited to 'gcc/rust/ast/rust-path.h')
-rw-r--r--gcc/rust/ast/rust-path.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h
index 4e26b2f..b7eba44 100644
--- a/gcc/rust/ast/rust-path.h
+++ b/gcc/rust/ast/rust-path.h
@@ -850,6 +850,11 @@ public:
Pattern::Kind get_pattern_kind () override { return Pattern::Kind::Path; }
+ Expr::Kind get_expr_kind () const override
+ {
+ return Expr::Kind::PathInExpression;
+ }
+
protected:
PathInExpression (std::vector<Attribute> &&outer_attrs,
bool has_opening_scope_resolution, location_t locus,
@@ -1516,6 +1521,11 @@ public:
rust_unreachable ();
}
+ Expr::Kind get_expr_kind () const override
+ {
+ return Expr::Kind::QualifiedPathInExpression;
+ }
+
protected:
/* Use covariance to implement clone function as returning this object
* rather than base */