diff options
author | Robert Goss <goss.robert@gmail.com> | 2024-01-16 22:50:51 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-30 12:36:51 +0100 |
commit | 88a27c3bc0f1ecf91699b0dbc38bd00dc87a47a4 (patch) | |
tree | ef6cfa7faddc642bf1665d618e741cc690ef4149 /gcc/c/c-tree.h | |
parent | 7a0c487d2c54b3cf3a83563add89a87220a109c2 (diff) | |
download | gcc-88a27c3bc0f1ecf91699b0dbc38bd00dc87a47a4.zip gcc-88a27c3bc0f1ecf91699b0dbc38bd00dc87a47a4.tar.gz gcc-88a27c3bc0f1ecf91699b0dbc38bd00dc87a47a4.tar.bz2 |
gccrs: Add improved error when a field is redefined in a struct constructor
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:
* typecheck/rust-hir-type-check-struct-field.h: Allow visit to return a bool
* typecheck/rust-hir-type-check-struct.cc: Improve check of repeat fields
gcc/testsuite/ChangeLog:
* rust/compile/repeated_constructor_fields.rs: Added case with constructor field repeated
Signed-off-by: Robert Goss <goss.robert@gmail.com>
Diffstat (limited to 'gcc/c/c-tree.h')
0 files changed, 0 insertions, 0 deletions