aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-02-20 14:46:03 -0500
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:21:08 +0100
commite1af468856241e339ad4f7b6c5af68d033b34b4c (patch)
treeccfe410b8f6eb59c70bfeb4a3281e9029f6c9d72 /gcc/rust/backend
parentc3e0c8b8108b823caea82df15edb0de3aa58fa8a (diff)
downloadgcc-e1af468856241e339ad4f7b6c5af68d033b34b4c.zip
gcc-e1af468856241e339ad4f7b6c5af68d033b34b4c.tar.gz
gcc-e1af468856241e339ad4f7b6c5af68d033b34b4c.tar.bz2
gccrs: Add AltPattern HIR node
Example: match x { 0 | 1 => true, _ => false } gcc/rust/ChangeLog: * backend/rust-compile-fnparam.h: (CompileFnParam::visit): Add AltPattern visitor. * backend/rust-compile-pattern.h: (CompilePatternCaseLabelExpr::visit): Add AltPattern visitor. (CompilePatternBindings::visit): Add AltPattern visitor. (CompilePatternLet::visit): Add AltPattern visitor. * backend/rust-compile-resolve-path.h: (ResolvePathRef::visit): Add AltPattern visitor. * backend/rust-compile-var-decl.h: (CompileVarDecl::visit): Add AltPattern visitor. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Add AltPattern visitor. * checks/errors/rust-const-checker.h: (ConstChecker::visit): Add AltPattern visitor. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Add AltPattern visitor. * checks/errors/rust-unsafe-checker.h: (UnsafeChecker::visit): Add AltPattern visitor. * hir/rust-hir-dump.cc (Dump::visit): Add AltPattern visitor. * hir/rust-hir-dump.h: (Dump::visit): Add AltPattern visitor. * hir/tree/rust-hir-full-decls.h (class AltPattern): Add forward declaration. * hir/tree/rust-hir-pattern.h (class AltPattern): New class. * hir/tree/rust-hir-visitor.h: (HIRFullVisitor::visit): Add AltPattern visitor. (HIRFullVisitorBase::visit): Add AltPattern visitor. (HIRPatternVisitor::visit): Add AltPattern visitor. * hir/tree/rust-hir.h: (Pattern::PatternType::ALT): New enumerator. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Add AltPattern visitor. * typecheck/rust-hir-type-check-pattern.h: (TypeCheckPattern::visit): Add AltPattern visitor. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-fnparam.h1
-rw-r--r--gcc/rust/backend/rust-compile-pattern.h20
-rw-r--r--gcc/rust/backend/rust-compile-resolve-path.h1
-rw-r--r--gcc/rust/backend/rust-compile-var-decl.h1
4 files changed, 23 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-fnparam.h b/gcc/rust/backend/rust-compile-fnparam.h
index 289ecee..6f7f0653 100644
--- a/gcc/rust/backend/rust-compile-fnparam.h
+++ b/gcc/rust/backend/rust-compile-fnparam.h
@@ -39,6 +39,7 @@ public:
void visit (HIR::TupleStructPattern &) override;
// Empty visit for unused Pattern HIR nodes.
+ void visit (HIR::AltPattern &) override {}
void visit (HIR::LiteralPattern &) override {}
void visit (HIR::PathInExpression &) override {}
void visit (HIR::QualifiedPathInExpression &) override {}
diff --git a/gcc/rust/backend/rust-compile-pattern.h b/gcc/rust/backend/rust-compile-pattern.h
index 0d53cd5..a7bd115 100644
--- a/gcc/rust/backend/rust-compile-pattern.h
+++ b/gcc/rust/backend/rust-compile-pattern.h
@@ -39,6 +39,13 @@ public:
void visit (HIR::WildcardPattern &pattern) override;
void visit (HIR::RangePattern &pattern) override;
+ // unsupported
+ void visit (HIR::AltPattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "alternate pattern case labels not supported");
+ }
+
// Empty visit for unused Pattern HIR nodes.
void visit (HIR::IdentifierPattern &) override {}
void visit (HIR::LiteralPattern &) override;
@@ -70,6 +77,13 @@ public:
void visit (HIR::StructPattern &pattern) override;
void visit (HIR::TupleStructPattern &pattern) override;
+ // unsupported
+ void visit (HIR::AltPattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "alternate pattern bindings not supported");
+ }
+
// Empty visit for unused Pattern HIR nodes.
void visit (HIR::IdentifierPattern &) override {}
void visit (HIR::LiteralPattern &) override {}
@@ -104,6 +118,12 @@ public:
void visit (HIR::TuplePattern &) override;
// check for unimplemented Pattern HIR nodes.
+ void visit (HIR::AltPattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "alternate pattern let statements not supported");
+ }
+
void visit (HIR::LiteralPattern &pattern) override
{
rust_sorry_at (pattern.get_locus (),
diff --git a/gcc/rust/backend/rust-compile-resolve-path.h b/gcc/rust/backend/rust-compile-resolve-path.h
index 8aedb16..93b0a7f 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.h
+++ b/gcc/rust/backend/rust-compile-resolve-path.h
@@ -50,6 +50,7 @@ public:
void visit (HIR::RangePattern &) override {}
void visit (HIR::ReferencePattern &) override {}
void visit (HIR::SlicePattern &) override {}
+ void visit (HIR::AltPattern &) override {}
void visit (HIR::StructPattern &) override {}
void visit (HIR::TuplePattern &) override {}
void visit (HIR::TupleStructPattern &) override {}
diff --git a/gcc/rust/backend/rust-compile-var-decl.h b/gcc/rust/backend/rust-compile-var-decl.h
index a4aa7cf8..9a3fcb5 100644
--- a/gcc/rust/backend/rust-compile-var-decl.h
+++ b/gcc/rust/backend/rust-compile-var-decl.h
@@ -54,6 +54,7 @@ public:
}
// Empty visit for unused Pattern HIR nodes.
+ void visit (HIR::AltPattern &) override {}
void visit (HIR::LiteralPattern &) override {}
void visit (HIR::PathInExpression &) override {}
void visit (HIR::QualifiedPathInExpression &) override {}