]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix test same_field_name.rs
authorOwen Avery <powerboat9.gamer@gmail.com>
Sat, 10 May 2025 00:48:18 +0000 (20:48 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:36:42 +0000 (16:36 +0200)
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 <powerboat9.gamer@gmail.com>
gcc/rust/hir/rust-ast-lower-item.cc
gcc/testsuite/rust/compile/same_field_name.rs [moved from gcc/testsuite/rust/execute/same_field_name.rs with 76% similarity]

index 1810d16d515decfe5da803c4f7558d72d459a8e3..66ccafa4f52286a761cfd53a32681adcd89d8a52 100644 (file)
@@ -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));
     }
similarity index 76%
rename from gcc/testsuite/rust/execute/same_field_name.rs
rename to gcc/testsuite/rust/compile/same_field_name.rs
index d57562b39a6449c68796e9a82f3a028bdce626e0..8e5b78c743652ff482fa355f939081bee002a895 100644 (file)
@@ -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" }
     }