public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7932] gccrs: [E0391] Detected type dependency cycle
@ 2024-01-16 18:08 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:b620e1d19f19325afe1d49ee8e2b8f6782a19761

commit r14-7932-gb620e1d19f19325afe1d49ee8e2b8f6782a19761
Author: Muhammad Mahad <mahadtxt@gmail.com>
Date:   Tue Aug 15 21:29:03 2023 +0500

    gccrs: [E0391] Detected type dependency cycle
    
    This errorcode & message emits when cycle
    detected when computing the super predicates
    of `x` which requires computing the super
    predicates of `y`, which again requires
    computing the super predicates of `x`,
    completing the cycle.
    
    gcc/rust/ChangeLog:
    
            * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait):
            Updated errorcode & more userfriendly message.
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/issue-1589.rs: Updated comment for dejagnu.
            * rust/compile/trait-cycle.rs: New relevant test.
    
    Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>

Diff:
---
 gcc/rust/typecheck/rust-hir-trait-resolve.cc | 5 ++++-
 gcc/testsuite/rust/compile/issue-1589.rs     | 4 ++--
 gcc/testsuite/rust/compile/trait-cycle.rs    | 4 ++++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-trait-resolve.cc b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
index b99fe2341af..1d6a9fbdd37 100644
--- a/gcc/rust/typecheck/rust-hir-trait-resolve.cc
+++ b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
@@ -156,7 +156,10 @@ TraitResolver::resolve_trait (HIR::Trait *trait_reference)
   DefId trait_id = trait_reference->get_mappings ().get_defid ();
   if (context->trait_query_in_progress (trait_id))
     {
-      rust_error_at (trait_reference->get_locus (), "trait cycle detected");
+      rust_error_at (
+	trait_reference->get_locus (), ErrorCode::E0391,
+	"cycle detected when computing the super predicates of %qs",
+	trait_reference->get_name ().as_string ().c_str ());
       return &TraitReference::error_node ();
     }
 
diff --git a/gcc/testsuite/rust/compile/issue-1589.rs b/gcc/testsuite/rust/compile/issue-1589.rs
index 45f2415a813..1dd7a45286c 100644
--- a/gcc/testsuite/rust/compile/issue-1589.rs
+++ b/gcc/testsuite/rust/compile/issue-1589.rs
@@ -2,7 +2,7 @@
 pub trait Sized {}
 
 pub trait A: B {}
-// { dg-error "trait cycle detected" "" { target *-*-* } .-1 }
+// { dg-error "cycle detected when computing the super predicates of .A." "" { target *-*-* } .-1 }
 
 pub trait B: A {}
-// { dg-error "trait cycle detected" "" { target *-*-* } .-1 }
+// { dg-error "cycle detected when computing the super predicates of .B." "" { target *-*-* } .-1 }
diff --git a/gcc/testsuite/rust/compile/trait-cycle.rs b/gcc/testsuite/rust/compile/trait-cycle.rs
new file mode 100644
index 00000000000..3bcadbbdbd7
--- /dev/null
+++ b/gcc/testsuite/rust/compile/trait-cycle.rs
@@ -0,0 +1,4 @@
+pub trait FirstTrait: SecondTrait {}
+// { dg-error "cycle detected when computing the super predicates of .FirstTrait." "" { target *-*-* } .-1 }
+pub trait SecondTrait: FirstTrait {}
+// { dg-error "cycle detected when computing the super predicates of .SecondTrait." "" { target *-*-* } .-1 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-16 18:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:08 [gcc r14-7932] gccrs: [E0391] Detected type dependency cycle Arthur Cohen

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).