Skip to content

Conversation

MahadMuhammad
Copy link
Contributor

Non-allowed default type paramters

  • Added user friendly message & fixit hint.

gcc/rust/ChangeLog:

* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Added more helpful error message.

gcc/testsuite/ChangeLog:

* rust/compile/generics10.rs: for dejagnu.

gcc/rust/ChangeLog:

	* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit):
	Added more helpful error message.

gcc/testsuite/ChangeLog:

	* rust/compile/generics10.rs: for dejagnu.

Signed-off-by: Muhammad Mahad <[email protected]>
Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@philberty philberty added this pull request to the merge queue Aug 17, 2023
Comment on lines +653 to +661
rich_location rich_locus (line_table, t.get_locus ());
rich_locus.add_fixit_replace (
t.get_locus (), "for more information, see issue #36887 "
"<https://github.com/rust-lang/rust/"
"issues/36887>");
rust_error_at (rich_locus,
"defaults for type parameters are only "
"allowed in %<struct%>, %<enum%>, %<type%>, "
"or %<trait%> definitions");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, it looks good! in a different PR, could you factor these lines in a separate function? this way we can modify the error message without changing it in two places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@philberty left this issue to me to decide, whether to create a separate class for refactoring these errors.

But that seems excessive. What do you think, @CohenArthur? Should I create a separate class or add a refactor function when we encounter these cases?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate class or a separate function is a good idea. I like both :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay :)

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Aug 17, 2023
@CohenArthur CohenArthur added this pull request to the merge queue Aug 17, 2023
Merged via the queue into Rust-GCC:master with commit 8ac2e43 Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants