Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-allowed default type paramters #2556

Merged
merged 1 commit into from
Aug 17, 2023

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
9 checks passed
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