public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] gccrs: reuse destructure code in compilation of types
@ 2023-03-20 7:23 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-03-20 7:23 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:254208dc7aea43712f46eb3d732d17d0d6551bfc
commit 254208dc7aea43712f46eb3d732d17d0d6551bfc
Author: Philip Herron <herron.philip@googlemail.com>
Date: Fri Mar 10 13:10:11 2023 +0000
gccrs: reuse destructure code in compilation of types
We can just return error_mark_node instead of our own custom
recursion limit checker code. This makes the backend more reuseable
in error states.
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::TyTyResolveCompile): call destructure
(TyTyResolveCompile::compile): use error_mark_node
(TyTyResolveCompile::visit): use error_mark_node
* backend/rust-compile-type.h: remove recursive ops
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diff:
---
gcc/rust/backend/rust-compile-type.cc | 51 +++++++++++++++--------------------
gcc/rust/backend/rust-compile-type.h | 1 -
2 files changed, 21 insertions(+), 31 deletions(-)
diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc
index a1db6ade9fb..879b89fe1f1 100644
--- a/gcc/rust/backend/rust-compile-type.cc
+++ b/gcc/rust/backend/rust-compile-type.cc
@@ -30,7 +30,7 @@ static const std::string RUST_ENUM_DISR_FIELD_NAME = "RUST$ENUM$DISR";
TyTyResolveCompile::TyTyResolveCompile (Context *ctx, bool trait_object_mode)
: ctx (ctx), trait_object_mode (trait_object_mode),
- translated (error_mark_node), recurisve_ops (0)
+ translated (error_mark_node)
{}
tree
@@ -38,7 +38,8 @@ TyTyResolveCompile::compile (Context *ctx, const TyTy::BaseType *ty,
bool trait_object_mode)
{
TyTyResolveCompile compiler (ctx, trait_object_mode);
- ty->accept_vis (compiler);
+ const TyTy::BaseType *destructured = ty->destructure ();
+ destructured->accept_vis (compiler);
if (compiler.translated != error_mark_node
&& TYPE_NAME (compiler.translated) != NULL)
@@ -97,6 +98,24 @@ TyTyResolveCompile::visit (const TyTy::InferType &)
translated = error_mark_node;
}
+void
+TyTyResolveCompile::visit (const TyTy::ParamType &)
+{
+ translated = error_mark_node;
+}
+
+void
+TyTyResolveCompile::visit (const TyTy::ProjectionType &type)
+{
+ translated = error_mark_node;
+}
+
+void
+TyTyResolveCompile::visit (const TyTy::PlaceholderType &type)
+{
+ translated = error_mark_node;
+}
+
void
TyTyResolveCompile::visit (const TyTy::ClosureType &type)
{
@@ -137,34 +156,6 @@ TyTyResolveCompile::visit (const TyTy::ClosureType &type)
type.get_ident ().locus);
}
-void
-TyTyResolveCompile::visit (const TyTy::ProjectionType &type)
-{
- type.get ()->accept_vis (*this);
-}
-
-void
-TyTyResolveCompile::visit (const TyTy::PlaceholderType &type)
-{
- type.resolve ()->accept_vis (*this);
-}
-
-void
-TyTyResolveCompile::visit (const TyTy::ParamType ¶m)
-{
- if (recurisve_ops++ >= rust_max_recursion_depth)
- {
- rust_error_at (Location (),
- "%<recursion depth%> count exceeds limit of %i (use "
- "%<frust-max-recursion-depth=%> to increase the limit)",
- rust_max_recursion_depth);
- translated = error_mark_node;
- return;
- }
-
- param.resolve ()->accept_vis (*this);
-}
-
void
TyTyResolveCompile::visit (const TyTy::FnType &type)
{
diff --git a/gcc/rust/backend/rust-compile-type.h b/gcc/rust/backend/rust-compile-type.h
index 4fea6baa379..acaa80a982f 100644
--- a/gcc/rust/backend/rust-compile-type.h
+++ b/gcc/rust/backend/rust-compile-type.h
@@ -70,7 +70,6 @@ private:
Context *ctx;
bool trait_object_mode;
tree translated;
- int recurisve_ops;
};
} // namespace Compile
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-20 7:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20 7:23 [gcc/devel/rust/master] gccrs: reuse destructure code in compilation of types 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).