From: Owen Avery <[email protected]>
gcc/rust/ChangeLog:
* hir/rust-ast-lower-item.cc
(ASTLoweringItem::visit): Keep going after a duplicate field is
found.
gcc/testsuite/ChangeLog:
* rust/execute/same_field_name.rs: Move to...
* rust/compile/same_field_name.rs: ...here and adjust expected
errors.
Signed-off-by: Owen Avery <[email protected]>
---
gcc/rust/hir/rust-ast-lower-item.cc | 2 +-
gcc/testsuite/rust/{execute => compile}/same_field_name.rs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
rename gcc/testsuite/rust/{execute => compile}/same_field_name.rs (76%)
diff --git a/gcc/rust/hir/rust-ast-lower-item.cc
b/gcc/rust/hir/rust-ast-lower-item.cc
index 1810d16d515..66ccafa4f52 100644
--- a/gcc/rust/hir/rust-ast-lower-item.cc
+++ b/gcc/rust/hir/rust-ast-lower-item.cc
@@ -217,7 +217,7 @@ ASTLoweringItem::visit (AST::StructStruct &struct_decl)
field.get_outer_attrs ());
if (struct_field_name_exists (fields, translated_field))
- break;
+ continue;
fields.push_back (std::move (translated_field));
}
diff --git a/gcc/testsuite/rust/execute/same_field_name.rs
b/gcc/testsuite/rust/compile/same_field_name.rs
similarity index 76%
rename from gcc/testsuite/rust/execute/same_field_name.rs
rename to gcc/testsuite/rust/compile/same_field_name.rs
index d57562b39a6..8e5b78c7436 100644
--- a/gcc/testsuite/rust/execute/same_field_name.rs
+++ b/gcc/testsuite/rust/compile/same_field_name.rs
@@ -1,7 +1,7 @@
// https://doc.rust-lang.org/error_codes/E0124.html
fn main() {
struct Foo {
- field1: i32, // { dg-error "field .field1. is already declared" }
+ field1: i32,
field1: i32, // { dg-error "field .field1. is already declared" }
field1: i32, // { dg-error "field .field1. is already declared" }
}
--
2.49.0