Add improved error when a field is redefined in a struct constructor #2797
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2381
If a struct type is initialized with one of it's fields repeated it will currently issue an error at the use site. However we would like to give the rust error code and (like rustc) show both the specifications for the field to help the user diagnose the issue.
We move the check after the index for the field has been established so we can look up if the field has already been defined and get it's location.
We update the visit method to return if it has handled an error otherwise we then output a second fatal error as not all the field in the specification have been processed.
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog:
I have read and accept the developers certificate of origin at https://gcc.gnu.org/dco.html