@@ -1209,7 +1209,9 @@ fn check_for_collisions(&@env e, &ast::crate c) {
1209
1209
auto v =
1210
1210
@rec( visit_item=bind check_item( e, _, _, _) ,
1211
1211
visit_block=bind check_block( e, _, _, _) ,
1212
- visit_arm=bind check_arm( e, _, _, _)
1212
+ visit_arm=bind check_arm( e, _, _, _) ,
1213
+ visit_expr=bind check_expr( e, _, _, _) ,
1214
+ visit_ty=bind check_ty( e, _, _, _)
1213
1215
with * visit:: default_visitor( ) ) ;
1214
1216
visit:: visit_crate ( c , ( ) , visit:: mk_vt ( v ) ) ;
1215
1217
}
@@ -1255,33 +1257,33 @@ fn mie_span(&mod_index_entry mie) -> span {
1255
1257
} ;
1256
1258
}
1257
1259
1258
- fn check_item( @env e, & @ast:: item i, & ( ) x, & vt[ ( ) ] v) {
1260
+ fn check_item( & @env e, & @ast:: item i, & ( ) x, & vt[ ( ) ] v) {
1259
1261
visit:: visit_item ( i, x, v) ;
1260
1262
alt ( i. node ) {
1261
1263
case ( ast:: item_fn ( ?f, ?ty_params) ) {
1262
1264
check_fn ( * e, i. span , f) ;
1263
- ensure_unique_ivec ( * e, i. span , ty_params, ident_id,
1265
+ ensure_unique ( * e, i. span , ty_params, ident_id,
1264
1266
"type parameter" ) ;
1265
1267
}
1266
1268
case ( ast:: item_obj ( ?ob, ?ty_params, _) ) {
1267
1269
fn field_name ( & ast:: obj_field field) -> ident { ret field. ident ; }
1268
- ensure_unique_ivec ( * e, i. span , ob. fields , field_name,
1270
+ ensure_unique ( * e, i. span , ob. fields , field_name,
1269
1271
"object field" ) ;
1270
1272
for ( @ast:: method m in ob. methods) {
1271
1273
check_fn ( * e, m. span , m. node . meth ) ;
1272
1274
}
1273
- ensure_unique_ivec ( * e, i. span , ty_params, ident_id,
1275
+ ensure_unique ( * e, i. span , ty_params, ident_id,
1274
1276
"type parameter" ) ;
1275
1277
}
1276
1278
case ( ast:: item_tag ( _, ?ty_params) ) {
1277
- ensure_unique_ivec ( * e, i. span , ty_params, ident_id,
1279
+ ensure_unique ( * e, i. span , ty_params, ident_id,
1278
1280
"type parameter" ) ;
1279
1281
}
1280
1282
case ( _) { }
1281
1283
}
1282
1284
}
1283
1285
1284
- fn check_arm ( @env e , & ast:: arm a, & ( ) x, & vt[ ( ) ] v) {
1286
+ fn check_arm ( & @env e , & ast:: arm a, & ( ) x, & vt[ ( ) ] v) {
1285
1287
visit:: visit_arm ( a , x , v ) ;
1286
1288
fn walk_pat ( checker ch, & @ast:: pat p) {
1287
1289
alt ( p. node ) {
@@ -1323,7 +1325,7 @@ fn check_arm(@env e, &ast::arm a, &() x, &vt[()] v) {
1323
1325
}
1324
1326
}
1325
1327
1326
- fn check_block ( @env e , & ast:: blk b, & ( ) x, & vt[ ( ) ] v) {
1328
+ fn check_block ( & @env e , & ast:: blk b, & ( ) x, & vt[ ( ) ] v) {
1327
1329
visit:: visit_block ( b , x , v ) ;
1328
1330
auto values = checker ( * e, "value" ) ;
1329
1331
auto types = checker ( * e, "type" ) ;
@@ -1371,7 +1373,29 @@ fn check_block(@env e, &ast::blk b, &() x, &vt[()] v) {
1371
1373
1372
1374
fn check_fn ( & env e, & span sp, & ast:: _fn f) {
1373
1375
fn arg_name ( & ast:: arg a) -> ident { ret a. ident ; }
1374
- ensure_unique_ivec ( e, sp, f. decl . inputs , arg_name, "argument" ) ;
1376
+ ensure_unique ( e, sp, f. decl . inputs , arg_name, "argument" ) ;
1377
+ }
1378
+
1379
+ fn check_expr ( & @env e , & @ast:: expr ex, & ( ) x, & vt[ ( ) ] v) {
1380
+ alt ex. node {
1381
+ ast: : expr_rec( ?fields , _) {
1382
+ fn field_name ( & ast:: field f) -> ident { ret f. node . ident ; }
1383
+ ensure_unique ( * e, ex. span , fields, field_name, "field name" ) ;
1384
+ }
1385
+ _ { }
1386
+ }
1387
+ visit:: visit_expr( ex, x, v) ;
1388
+ }
1389
+
1390
+ fn check_ty( & @env e, & @ast:: ty ty, & ( ) x, & vt[ ( ) ] v) {
1391
+ alt ty. node {
1392
+ ast:: ty_rec ( ?fields) {
1393
+ fn field_name ( & ast:: ty_field f) -> ident { ret f. node . ident ; }
1394
+ ensure_unique ( * e, ty. span , fields, field_name, "field name" ) ;
1395
+ }
1396
+ _ { }
1397
+ }
1398
+ visit:: visit_ty ( ty, x, v) ;
1375
1399
}
1376
1400
1377
1401
type checker = @rec( mutable ident[ ] seen, str kind, session sess) ;
@@ -1398,13 +1422,6 @@ fn ensure_unique[T](&env e, &span sp, &T[] elts, fn(&T) -> ident id,
1398
1422
for ( T elt in elts) { add_name( ch, sp, id( elt) ) ; }
1399
1423
}
1400
1424
1401
- // FIXME: Remove me.
1402
- fn ensure_unique_ivec[ T ] ( & env e, & span sp, & T [ ] elts, fn( & T ) -> ident id,
1403
- & str kind) {
1404
- auto ch = checker( e, kind) ;
1405
- for ( T elt in elts) { add_name( ch, sp, id( elt) ) ; }
1406
- }
1407
-
1408
1425
// Local Variables:
1409
1426
// mode: rust
1410
1427
// fill-column: 78;
0 commit comments