From: Philip Herron <[email protected]>
gcc/rust/ChangeLog:
* typecheck/rust-tyty.cc (ParamType::clone): add guard
Signed-off-by: Philip Herron <[email protected]>
Tested on x86_64-pc-linux-gnu.
---
gcc/rust/typecheck/rust-tyty.cc | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index 51adb831e4c..93061b1fcf6 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -3810,6 +3810,13 @@ ParamType::get_name () const
BaseType *
ParamType::clone () const
{
+ static std::vector<HirId> active;
+ bool cycle = Resolver::ScopedPush<HirId>::contains (active, get_ty_ref ());
+ if (cycle)
+ return new ParamType (is_trait_self, get_symbol (), ident.locus, get_ref
(),
+ get_ty_ref (), {}, get_combined_refs ());
+
+ Resolver::ScopedPush<HirId> guard (active, get_ty_ref ());
return new ParamType (is_trait_self, get_symbol (), ident.locus, get_ref (),
get_ty_ref (), get_specified_bounds (),
get_combined_refs ());
--
2.55.0