Skip to content

Commit

Permalink
gccrs: Invalid order of generic parameters
Browse files Browse the repository at this point in the history
Added more userfriendly message.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_generic_params):
	Added more user friendly message.

gcc/testsuite/ChangeLog:

	* rust/compile/generics13.rs:
	for dejagnu,

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
  • Loading branch information
MahadMuhammad committed Aug 17, 2023
1 parent b9ae354 commit a2d6a99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions gcc/rust/parse/rust-parse-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3142,9 +3142,12 @@ Parser<ManagedTokenSource>::parse_generic_params (EndTokenPred is_end_token)

// FIXME: Add reordering hint
if (order_error)
rust_error_at (generic_params.front ()->get_locus (),
"invalid order for generic parameters: lifetimes should "
"always come before types");
{
Error error (generic_params.front ()->get_locus (),
"invalid order for generic parameters: lifetime parameters "
"must be declared prior to type and const parameters");
add_error (std::move (error));
}

generic_params.shrink_to_fit ();
return generic_params;
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/rust/compile/generics13.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
struct Foo<A, 'a>; // { dg-error "invalid order for generic parameters: lifetimes should always come before types" }
struct Foo<A, 'a>; // { dg-error "invalid order for generic parameters: lifetime parameters must be declared prior to type and const parameters" }

0 comments on commit a2d6a99

Please sign in to comment.