Skip to content

Commit 3c89c31

Browse files
powerboat9CohenArthur
authored andcommitted
Modify multiple definition error
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Modify error message. * resolve/rust-ast-resolve-implitem.h (ResolveToplevelImplItem::visit): Likewise. (ResolveTopLevelTraitItems::visit): Likewise. (ResolveToplevelExternItem::visit): Likewise. * resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): Likewise. * resolve/rust-ast-resolve-stmt.h (ResolveStmt::visit): Likewise. * resolve/rust-ast-resolve-toplevel.h (ResolveTopLevel::visit): Likewise. * resolve/rust-ast-resolve-type.h (ResolveGenericParams::visit): Likewise. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. * rust/compile/redef_error2.rs: Modify expected error. * rust/compile/redef_error5.rs: Likewise. Signed-off-by: Owen Avery <[email protected]>
1 parent 0d7c150 commit 3c89c31

File tree

9 files changed

+43
-45
lines changed

9 files changed

+43
-45
lines changed

gcc/rust/resolve/rust-ast-resolve-expr.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ ResolveExpr::visit (AST::BlockExpr &expr)
287287
CanonicalPath::new_seg (label.get_node_id (), label_name),
288288
label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label,
289289
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
290-
rust_error_at (label.get_locus (), "label redefined multiple times");
290+
rust_error_at (label.get_locus (), "label defined multiple times");
291291
rust_error_at (locus, "was defined here");
292292
});
293293
}
@@ -459,7 +459,7 @@ ResolveExpr::visit (AST::LoopExpr &expr)
459459
CanonicalPath::new_seg (expr.get_node_id (), label_name),
460460
label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label,
461461
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
462-
rust_error_at (label.get_locus (), "label redefined multiple times");
462+
rust_error_at (label.get_locus (), "label defined multiple times");
463463
rust_error_at (locus, "was defined here");
464464
});
465465
}
@@ -535,7 +535,7 @@ ResolveExpr::visit (AST::WhileLoopExpr &expr)
535535
CanonicalPath::new_seg (label.get_node_id (), label_name),
536536
label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label,
537537
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
538-
rust_error_at (label.get_locus (), "label redefined multiple times");
538+
rust_error_at (label.get_locus (), "label defined multiple times");
539539
rust_error_at (locus, "was defined here");
540540
});
541541
}
@@ -564,7 +564,7 @@ ResolveExpr::visit (AST::ForLoopExpr &expr)
564564
CanonicalPath::new_seg (label.get_node_id (), label_name),
565565
label_lifetime_node_id, label.get_locus (), false, Rib::ItemType::Label,
566566
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
567-
rust_error_at (label.get_locus (), "label redefined multiple times");
567+
rust_error_at (label.get_locus (), "label defined multiple times");
568568
rust_error_at (locus, "was defined here");
569569
});
570570
}

gcc/rust/resolve/rust-ast-resolve-implitem.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ResolveToplevelImplItem : public ResolverBase
5151
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
5252
rich_location r (line_table, type.get_locus ());
5353
r.add_range (locus);
54-
rust_error_at (r, "redefined multiple times");
54+
rust_error_at (r, "defined multiple times");
5555
});
5656
}
5757

@@ -67,7 +67,7 @@ class ResolveToplevelImplItem : public ResolverBase
6767
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
6868
rich_location r (line_table, constant.get_locus ());
6969
r.add_range (locus);
70-
rust_error_at (r, "redefined multiple times");
70+
rust_error_at (r, "defined multiple times");
7171
});
7272
}
7373

@@ -84,7 +84,7 @@ class ResolveToplevelImplItem : public ResolverBase
8484
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
8585
rich_location r (line_table, function.get_locus ());
8686
r.add_range (locus);
87-
rust_error_at (r, "redefined multiple times");
87+
rust_error_at (r, "defined multiple times");
8888
});
8989
}
9090

@@ -124,7 +124,7 @@ class ResolveTopLevelTraitItems : public ResolverBase
124124
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
125125
rich_location r (line_table, function.get_locus ());
126126
r.add_range (locus);
127-
rust_error_at (r, "redefined multiple times");
127+
rust_error_at (r, "defined multiple times");
128128
});
129129

130130
mappings.insert_canonical_path (function.get_node_id (), cpath);
@@ -144,7 +144,7 @@ class ResolveTopLevelTraitItems : public ResolverBase
144144
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
145145
rich_location r (line_table, constant.get_locus ());
146146
r.add_range (locus);
147-
rust_error_at (r, "redefined multiple times");
147+
rust_error_at (r, "defined multiple times");
148148
});
149149

150150
mappings.insert_canonical_path (constant.get_node_id (), cpath);
@@ -162,7 +162,7 @@ class ResolveTopLevelTraitItems : public ResolverBase
162162
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
163163
rich_location r (line_table, type.get_locus ());
164164
r.add_range (locus);
165-
rust_error_at (r, "redefined multiple times");
165+
rust_error_at (r, "defined multiple times");
166166
});
167167

168168
mappings.insert_canonical_path (type.get_node_id (), cpath);
@@ -202,7 +202,7 @@ class ResolveToplevelExternItem : public ResolverBase
202202
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
203203
rich_location r (line_table, function.get_locus ());
204204
r.add_range (locus);
205-
rust_error_at (r, "redefined multiple times");
205+
rust_error_at (r, "defined multiple times");
206206
});
207207

208208
NodeId current_module = resolver->peek_current_module_scope ();
@@ -221,7 +221,7 @@ class ResolveToplevelExternItem : public ResolverBase
221221
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
222222
rich_location r (line_table, item.get_locus ());
223223
r.add_range (locus);
224-
rust_error_at (r, "redefined multiple times");
224+
rust_error_at (r, "defined multiple times");
225225
});
226226

227227
NodeId current_module = resolver->peek_current_module_scope ();
@@ -240,7 +240,7 @@ class ResolveToplevelExternItem : public ResolverBase
240240
rich_location r (line_table, type.get_locus ());
241241
r.add_range (locus);
242242

243-
rust_error_at (r, "redefined multiple times");
243+
rust_error_at (r, "defined multiple times");
244244
});
245245

246246
NodeId current_module = resolver->peek_current_module_scope ();

gcc/rust/resolve/rust-ast-resolve-stmt.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ResolveStmt::visit (AST::StaticItem &var)
7070
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
7171
rich_location r (line_table, var.get_locus ());
7272
r.add_range (locus);
73-
rust_error_at (r, "redefined multiple times");
73+
rust_error_at (r, "defined multiple times");
7474
});
7575

7676
ResolveType::go (var.get_type ());

gcc/rust/resolve/rust-ast-resolve-stmt.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ResolveStmt : public ResolverBase
6363
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
6464
rich_location r (line_table, constant.get_locus ());
6565
r.add_range (locus);
66-
rust_error_at (r, "redefined multiple times");
66+
rust_error_at (r, "defined multiple times");
6767
});
6868

6969
ResolveType::go (constant.get_type ());
@@ -97,7 +97,7 @@ class ResolveStmt : public ResolverBase
9797
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
9898
rich_location r (line_table, struct_decl.get_locus ());
9999
r.add_range (locus);
100-
rust_error_at (r, "redefined multiple times");
100+
rust_error_at (r, "defined multiple times");
101101
});
102102

103103
NodeId scope_node_id = struct_decl.get_node_id ();
@@ -128,7 +128,7 @@ class ResolveStmt : public ResolverBase
128128
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
129129
rich_location r (line_table, enum_decl.get_locus ());
130130
r.add_range (locus);
131-
rust_error_at (r, "redefined multiple times");
131+
rust_error_at (r, "defined multiple times");
132132
});
133133

134134
NodeId scope_node_id = enum_decl.get_node_id ();
@@ -158,7 +158,7 @@ class ResolveStmt : public ResolverBase
158158
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
159159
rich_location r (line_table, item.get_locus ());
160160
r.add_range (locus);
161-
rust_error_at (r, "redefined multiple times");
161+
rust_error_at (r, "defined multiple times");
162162
});
163163

164164
// Done, no fields.
@@ -178,7 +178,7 @@ class ResolveStmt : public ResolverBase
178178
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
179179
rich_location r (line_table, item.get_locus ());
180180
r.add_range (locus);
181-
rust_error_at (r, "redefined multiple times");
181+
rust_error_at (r, "defined multiple times");
182182
});
183183

184184
for (auto &field : item.get_tuple_fields ())
@@ -204,7 +204,7 @@ class ResolveStmt : public ResolverBase
204204
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
205205
rich_location r (line_table, item.get_locus ());
206206
r.add_range (locus);
207-
rust_error_at (r, "redefined multiple times");
207+
rust_error_at (r, "defined multiple times");
208208
});
209209

210210
for (auto &field : item.get_struct_fields ())
@@ -230,7 +230,7 @@ class ResolveStmt : public ResolverBase
230230
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
231231
rich_location r (line_table, item.get_locus ());
232232
r.add_range (locus);
233-
rust_error_at (r, "redefined multiple times");
233+
rust_error_at (r, "defined multiple times");
234234
});
235235

236236
// Done, no fields.
@@ -251,7 +251,7 @@ class ResolveStmt : public ResolverBase
251251
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
252252
rich_location r (line_table, struct_decl.get_locus ());
253253
r.add_range (locus);
254-
rust_error_at (r, "redefined multiple times");
254+
rust_error_at (r, "defined multiple times");
255255
});
256256

257257
NodeId scope_node_id = struct_decl.get_node_id ();
@@ -287,7 +287,7 @@ class ResolveStmt : public ResolverBase
287287
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
288288
rich_location r (line_table, union_decl.get_locus ());
289289
r.add_range (locus);
290-
rust_error_at (r, "redefined multiple times");
290+
rust_error_at (r, "defined multiple times");
291291
});
292292

293293
NodeId scope_node_id = union_decl.get_node_id ();
@@ -323,7 +323,7 @@ class ResolveStmt : public ResolverBase
323323
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
324324
rich_location r (line_table, function.get_locus ());
325325
r.add_range (locus);
326-
rust_error_at (r, "redefined multiple times");
326+
rust_error_at (r, "defined multiple times");
327327
});
328328

329329
NodeId scope_node_id = function.get_node_id ();

gcc/rust/resolve/rust-ast-resolve-toplevel.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ResolveTopLevel : public ResolverBase
5858
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
5959
rich_location r (line_table, module.get_locus ());
6060
r.add_range (locus);
61-
rust_error_at (r, "redefined multiple times");
61+
rust_error_at (r, "defined multiple times");
6262
});
6363

6464
NodeId current_module = resolver->peek_current_module_scope ();
@@ -88,7 +88,7 @@ class ResolveTopLevel : public ResolverBase
8888
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
8989
rich_location r (line_table, alias.get_locus ());
9090
r.add_range (locus);
91-
rust_error_at (r, "redefined multiple times");
91+
rust_error_at (r, "defined multiple times");
9292
});
9393

9494
NodeId current_module = resolver->peek_current_module_scope ();
@@ -110,7 +110,7 @@ class ResolveTopLevel : public ResolverBase
110110
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
111111
rich_location r (line_table, struct_decl.get_locus ());
112112
r.add_range (locus);
113-
rust_error_at (r, "redefined multiple times");
113+
rust_error_at (r, "defined multiple times");
114114
});
115115

116116
NodeId current_module = resolver->peek_current_module_scope ();
@@ -132,7 +132,7 @@ class ResolveTopLevel : public ResolverBase
132132
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
133133
rich_location r (line_table, enum_decl.get_locus ());
134134
r.add_range (locus);
135-
rust_error_at (r, "redefined multiple times");
135+
rust_error_at (r, "defined multiple times");
136136
});
137137

138138
resolver->push_new_module_scope (enum_decl.get_node_id ());
@@ -158,7 +158,7 @@ class ResolveTopLevel : public ResolverBase
158158
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
159159
rich_location r (line_table, item.get_locus ());
160160
r.add_range (locus);
161-
rust_error_at (r, "redefined multiple times");
161+
rust_error_at (r, "defined multiple times");
162162
});
163163

164164
mappings.insert_canonical_path (item.get_node_id (), cpath);
@@ -180,7 +180,7 @@ class ResolveTopLevel : public ResolverBase
180180
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
181181
rich_location r (line_table, item.get_locus ());
182182
r.add_range (locus);
183-
rust_error_at (r, "redefined multiple times");
183+
rust_error_at (r, "defined multiple times");
184184
});
185185

186186
mappings.insert_canonical_path (item.get_node_id (), cpath);
@@ -202,7 +202,7 @@ class ResolveTopLevel : public ResolverBase
202202
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
203203
rich_location r (line_table, item.get_locus ());
204204
r.add_range (locus);
205-
rust_error_at (r, "redefined multiple times");
205+
rust_error_at (r, "defined multiple times");
206206
});
207207

208208
mappings.insert_canonical_path (item.get_node_id (), cpath);
@@ -224,7 +224,7 @@ class ResolveTopLevel : public ResolverBase
224224
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
225225
rich_location r (line_table, item.get_locus ());
226226
r.add_range (locus);
227-
rust_error_at (r, "redefined multiple times");
227+
rust_error_at (r, "defined multiple times");
228228
});
229229

230230
mappings.insert_canonical_path (item.get_node_id (), cpath);
@@ -246,7 +246,7 @@ class ResolveTopLevel : public ResolverBase
246246
= [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
247247
rich_location r (line_table, struct_decl.get_locus ());
248248
r.add_range (locus);
249-
rust_error_at (r, "redefined multiple times");
249+
rust_error_at (r, "defined multiple times");
250250
};
251251

252252
resolver->get_type_scope ().insert (path, struct_decl.get_node_id (),
@@ -277,7 +277,7 @@ class ResolveTopLevel : public ResolverBase
277277
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
278278
rich_location r (line_table, union_decl.get_locus ());
279279
r.add_range (locus);
280-
rust_error_at (r, "redefined multiple times");
280+
rust_error_at (r, "defined multiple times");
281281
});
282282

283283
NodeId current_module = resolver->peek_current_module_scope ();
@@ -297,7 +297,7 @@ class ResolveTopLevel : public ResolverBase
297297
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
298298
rich_location r (line_table, var.get_locus ());
299299
r.add_range (locus);
300-
rust_error_at (r, "redefined multiple times");
300+
rust_error_at (r, "defined multiple times");
301301
});
302302

303303
NodeId current_module = resolver->peek_current_module_scope ();
@@ -318,7 +318,7 @@ class ResolveTopLevel : public ResolverBase
318318
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
319319
rich_location r (line_table, constant.get_locus ());
320320
r.add_range (locus);
321-
rust_error_at (r, "redefined multiple times");
321+
rust_error_at (r, "defined multiple times");
322322
});
323323

324324
NodeId current_module = resolver->peek_current_module_scope ();
@@ -340,7 +340,7 @@ class ResolveTopLevel : public ResolverBase
340340
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
341341
rich_location r (line_table, function.get_locus ());
342342
r.add_range (locus);
343-
rust_error_at (r, "redefined multiple times");
343+
rust_error_at (r, "defined multiple times");
344344
});
345345

346346
NodeId current_module = resolver->peek_current_module_scope ();
@@ -388,7 +388,7 @@ class ResolveTopLevel : public ResolverBase
388388
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
389389
rich_location r (line_table, impl_block.get_locus ());
390390
r.add_range (locus);
391-
rust_error_at (r, "redefined multiple times");
391+
rust_error_at (r, "defined multiple times");
392392
});
393393

394394
for (auto &impl_item : impl_block.get_impl_items ())
@@ -408,7 +408,7 @@ class ResolveTopLevel : public ResolverBase
408408
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
409409
rich_location r (line_table, trait.get_locus ());
410410
r.add_range (locus);
411-
rust_error_at (r, "redefined multiple times");
411+
rust_error_at (r, "defined multiple times");
412412
});
413413

414414
for (auto &item : trait.get_trait_items ())
@@ -480,7 +480,7 @@ class ResolveTopLevel : public ResolverBase
480480
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
481481
rich_location r (line_table, extern_crate.get_locus ());
482482
r.add_range (locus);
483-
rust_error_at (r, "redefined multiple times");
483+
rust_error_at (r, "defined multiple times");
484484
});
485485
}
486486

gcc/rust/resolve/rust-ast-resolve-type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class ResolveGenericParams : public ResolverBase
160160
Rib::ItemType::Type,
161161
[&] (const CanonicalPath &, NodeId, location_t locus) -> void {
162162
rust_error_at (param.get_locus (),
163-
"generic param redefined multiple times");
163+
"generic param defined multiple times");
164164
rust_error_at (locus, "was defined here");
165165
});
166166

gcc/testsuite/rust/compile/nr2/exclude

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ privacy8.rs
2525
pub_restricted_1.rs
2626
pub_restricted_2.rs
2727
pub_restricted_3.rs
28-
redef_error2.rs
29-
redef_error5.rs
3028
sizeof-stray-infer-var-bug.rs
3129
struct-expr-parse.rs
3230
undeclared_label.rs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const TEST: i32 = 2;
2-
const TEST: f32 = 3.0; // { dg-error "redefined multiple times" }
2+
const TEST: f32 = 3.0; // { dg-error "defined multiple times" }
33

44
fn main() {}

gcc/testsuite/rust/compile/redef_error5.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ struct Foo(i32, bool);
22

33
impl Foo {
44
const TEST: i32 = 123;
5-
const TEST: bool = false; // { dg-error "redefined multiple times" }
5+
const TEST: bool = false; // { dg-error "defined multiple times" }
66
}
77

88
fn main() {}

0 commit comments

Comments
 (0)