]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: refactoring rust_error_at "redefined multiple times"
authorSri Ganesh Thota <sriganeshthota12345@gmail.com>
Tue, 25 Mar 2025 13:00:58 +0000 (18:30 +0530)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 8 Apr 2025 08:17:15 +0000 (10:17 +0200)
gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-base.h (redefined_error): created a function for
rust_error_at for redefined at multiple times.
* resolve/rust-ast-resolve-implitem.h: changed rust_error_at to redefined_error.
* resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): changed rust_error_at to
redefined_error.
* resolve/rust-ast-resolve-stmt.h: changed rust_error_at to redefined_error.
* resolve/rust-ast-resolve-toplevel.h: changed rust_error_at to redefined_error.

Signed-off-by: Sri Ganesh Thota <sriganeshthota12345@gmail.com>
gcc/rust/resolve/rust-ast-resolve-base.h
gcc/rust/resolve/rust-ast-resolve-implitem.h
gcc/rust/resolve/rust-ast-resolve-stmt.cc
gcc/rust/resolve/rust-ast-resolve-stmt.h
gcc/rust/resolve/rust-ast-resolve-toplevel.h

index 0d497f81eacc97c21e03917c1f074a1c08bef5f8..ab74e84f079798a4613c8fdeb1486c8adbb499ac 100644 (file)
 
 namespace Rust {
 namespace Resolver {
+inline void
+redefined_error (const rich_location &loc)
+{
+  rust_error_at (loc, "redefined multiple times");
+}
 
 class ResolverBase : public AST::ASTVisitor
 {
index 971bf8faee2e7f3ff56f7c4b2f7ca2fb63ef7f29..2081697fe8f817a050ef1a302fe385d0b60ee7ff 100644 (file)
@@ -51,7 +51,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, type.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
   }
 
@@ -67,7 +67,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, constant.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
   }
 
@@ -84,7 +84,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, function.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
   }
 
@@ -124,7 +124,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, function.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     mappings.insert_canonical_path (function.get_node_id (), cpath);
@@ -144,7 +144,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, constant.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     mappings.insert_canonical_path (constant.get_node_id (), cpath);
@@ -162,7 +162,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, type.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     mappings.insert_canonical_path (type.get_node_id (), cpath);
@@ -202,7 +202,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, function.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId current_module = resolver->peek_current_module_scope ();
@@ -221,7 +221,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, item.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId current_module = resolver->peek_current_module_scope ();
@@ -239,8 +239,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, type.get_locus ());
        r.add_range (locus);
-
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId current_module = resolver->peek_current_module_scope ();
index fefb522aec713303b7cefffbf76b31bc9361220f..bfba302d29d1cf4fed9dbc6f066eb7fd00ab055e 100644 (file)
@@ -70,7 +70,7 @@ ResolveStmt::visit (AST::StaticItem &var)
     [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
       rich_location r (line_table, var.get_locus ());
       r.add_range (locus);
-      rust_error_at (r, "defined multiple times");
+      redefined_error (r);
     });
 
   ResolveType::go (var.get_type ());
index 6c99d6a6f6c0ab0fab02eb20b903e04ee179069c..d413a7c17ae66b82fe93cc1f8d7f8ccc368cb270 100644 (file)
@@ -63,7 +63,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, constant.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     ResolveType::go (constant.get_type ());
@@ -98,7 +98,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, struct_decl.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId scope_node_id = struct_decl.get_node_id ();
@@ -129,7 +129,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, enum_decl.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId scope_node_id = enum_decl.get_node_id ();
@@ -159,7 +159,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, item.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     // Done, no fields.
@@ -179,7 +179,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, item.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     for (auto &field : item.get_tuple_fields ())
@@ -205,7 +205,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, item.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     for (auto &field : item.get_struct_fields ())
@@ -231,7 +231,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, item.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     // Done, no fields.
@@ -252,7 +252,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, struct_decl.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId scope_node_id = struct_decl.get_node_id ();
@@ -288,7 +288,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, union_decl.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId scope_node_id = union_decl.get_node_id ();
@@ -324,7 +324,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, function.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId scope_node_id = function.get_node_id ();
index 379ccabae25b4c362cd3432b65171356884b4ba6..f52fb8a4d168b9d06b341458705005d9660a443f 100644 (file)
@@ -58,7 +58,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, module.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId current_module = resolver->peek_current_module_scope ();
@@ -88,7 +88,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, alias.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId current_module = resolver->peek_current_module_scope ();
@@ -110,7 +110,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, struct_decl.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId current_module = resolver->peek_current_module_scope ();
@@ -132,7 +132,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, enum_decl.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     resolver->push_new_module_scope (enum_decl.get_node_id ());
@@ -158,7 +158,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, item.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     mappings.insert_canonical_path (item.get_node_id (), cpath);
@@ -180,7 +180,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, item.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     mappings.insert_canonical_path (item.get_node_id (), cpath);
@@ -202,7 +202,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, item.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     mappings.insert_canonical_path (item.get_node_id (), cpath);
@@ -224,7 +224,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, item.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     mappings.insert_canonical_path (item.get_node_id (), cpath);
@@ -246,7 +246,7 @@ public:
       = [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
       rich_location r (line_table, struct_decl.get_locus ());
       r.add_range (locus);
-      rust_error_at (r, "defined multiple times");
+      redefined_error (r);
     };
 
     resolver->get_type_scope ().insert (path, struct_decl.get_node_id (),
@@ -277,7 +277,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, union_decl.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId current_module = resolver->peek_current_module_scope ();
@@ -297,7 +297,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, var.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId current_module = resolver->peek_current_module_scope ();
@@ -318,7 +318,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, constant.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId current_module = resolver->peek_current_module_scope ();
@@ -340,7 +340,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, function.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     NodeId current_module = resolver->peek_current_module_scope ();
@@ -388,7 +388,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, impl_block.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     for (auto &impl_item : impl_block.get_impl_items ())
@@ -408,7 +408,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, trait.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
 
     for (auto &item : trait.get_trait_items ())
@@ -480,7 +480,7 @@ public:
       [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
        rich_location r (line_table, extern_crate.get_locus ());
        r.add_range (locus);
-       rust_error_at (r, "defined multiple times");
+       redefined_error (r);
       });
   }