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>
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 ();
}
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 }
--- /dev/null
+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 }