@@ -47,7 +47,7 @@ export crate_map;
47
47
tag scope {
48
48
scope_crate( @ast: : crate ) ;
49
49
scope_item ( @ast:: item) ;
50
- scope_fn ( ast:: fn_decl, vec [ ast:: ty_param] ) ;
50
+ scope_fn ( ast:: fn_decl, ast:: ty_param[ ] ) ;
51
51
scope_native_item ( @ast:: native_item) ;
52
52
scope_loop ( @ast:: local) ; // there's only 1 decl per loop.
53
53
scope_block ( ast:: block) ;
@@ -346,7 +346,7 @@ fn visit_native_item_with_scope(&@ast::native_item ni, &scopes sc,
346
346
visit:: visit_native_item ( ni, cons ( scope_native_item ( ni) , @sc) , v) ;
347
347
}
348
348
349
- fn visit_fn_with_scope ( & @env e , & ast:: _fn f, & vec [ ast:: ty_param ] tp , & span sp,
349
+ fn visit_fn_with_scope( & @env e , & ast:: _fn f, & ast:: ty_param[ ] tp, & span sp,
350
350
& fn_ident name, node_id id, & scopes sc,
351
351
& vt[ scopes] v) {
352
352
// here's where we need to set up the mapping
@@ -376,7 +376,7 @@ fn visit_expr_with_scope(&@ast::expr x, &scopes sc, &vt[scopes] v) {
376
376
case ( ast:: expr_for_each( ?d, _, _) ) {
377
377
cons[ scope] ( scope_loop( d) , @sc)
378
378
}
379
- case ( ast:: expr_fn ( ?f) ) { cons ( scope_fn ( f. decl , [ ] ) , @sc) }
379
+ case ( ast:: expr_fn( ?f) ) { cons( scope_fn( f. decl, ~ [ ] ) , @sc) }
380
380
case ( _) { sc }
381
381
} ;
382
382
visit:: visit_expr( x, new_sc, v) ;
@@ -638,8 +638,7 @@ fn lookup_in_scope(&env e, scopes sc, &span sp, &ident name, namespace ns) ->
638
638
}
639
639
case ( scope_native_item ( ?it) ) {
640
640
alt ( it. node ) {
641
- case ( ast:: native_item_fn ( _, ?decl, ?ty_params) )
642
- {
641
+ case ( ast:: native_item_fn ( _, ?decl, ?ty_params) ) {
643
642
ret lookup_in_fn ( name, decl, ty_params, ns) ;
644
643
}
645
644
}
@@ -690,7 +689,7 @@ fn lookup_in_scope(&env e, scopes sc, &span sp, &ident name, namespace ns) ->
690
689
691
690
}
692
691
693
- fn lookup_in_ty_params ( & ident name, & vec [ ast:: ty_param ] ty_params ) ->
692
+ fn lookup_in_ty_params ( & ident name, & ast:: ty_param[ ] ty_params) ->
694
693
option:: t [ def] {
695
694
auto i = 0 u ;
696
695
for ( ast:: ty_param tp in ty_params) {
@@ -720,7 +719,7 @@ fn lookup_in_pat(&ident name, &ast::pat pat) -> option::t[def] {
720
719
}
721
720
722
721
fn lookup_in_fn( & ident name, & ast:: fn_decl decl,
723
- & vec [ ast:: ty_param] ty_params,
722
+ & ast:: ty_param[ ] ty_params,
724
723
namespace ns) -> option:: t[ def] {
725
724
alt ( ns) {
726
725
case ( ns_value) {
@@ -736,7 +735,7 @@ fn lookup_in_fn(&ident name, &ast::fn_decl decl,
736
735
}
737
736
}
738
737
739
- fn lookup_in_obj( & ident name, & ast:: _obj ob, & vec [ ast:: ty_param] ty_params,
738
+ fn lookup_in_obj( & ident name, & ast:: _obj ob, & ast:: ty_param[ ] ty_params,
740
739
namespace ns) -> option:: t[ def] {
741
740
alt ( ns) {
742
741
case ( ns_value) {
@@ -1229,18 +1228,22 @@ fn check_item(@env e, &@ast::item i, &() x, &vt[()] v) {
1229
1228
alt ( i. node ) {
1230
1229
case ( ast:: item_fn ( ?f, ?ty_params) ) {
1231
1230
check_fn ( * e, i. span , f) ;
1232
- ensure_unique ( * e, i. span , ty_params, ident_id, "type parameter" ) ;
1231
+ ensure_unique_ivec ( * e, i. span , ty_params, ident_id,
1232
+ "type parameter" ) ;
1233
1233
}
1234
1234
case ( ast:: item_obj ( ?ob, ?ty_params, _) ) {
1235
1235
fn field_name ( & ast:: obj_field field) -> ident { ret field. ident ; }
1236
- ensure_unique ( * e, i. span , ob. fields , field_name, "object field" ) ;
1236
+ ensure_unique_ivec ( * e, i. span , ob. fields , field_name,
1237
+ "object field" ) ;
1237
1238
for ( @ast:: method m in ob. methods) {
1238
1239
check_fn ( * e, m. span , m. node . meth ) ;
1239
1240
}
1240
- ensure_unique ( * e, i. span , ty_params, ident_id, "type parameter" ) ;
1241
+ ensure_unique_ivec ( * e, i. span , ty_params, ident_id,
1242
+ "type parameter" ) ;
1241
1243
}
1242
1244
case ( ast:: item_tag ( _, ?ty_params) ) {
1243
- ensure_unique ( * e, i. span , ty_params, ident_id, "type parameter" ) ;
1245
+ ensure_unique_ivec ( * e, i. span , ty_params, ident_id,
1246
+ "type parameter" ) ;
1244
1247
}
1245
1248
case ( _) { }
1246
1249
}
@@ -1315,7 +1318,7 @@ fn check_block(@env e, &ast::block b, &() x, &vt[()] v) {
1315
1318
1316
1319
fn check_fn( & env e, & span sp, & ast:: _fn f) {
1317
1320
fn arg_name( & ast:: arg a) -> ident { ret a. ident; }
1318
- ensure_unique ( e, sp, f. decl . inputs , arg_name, "argument" ) ;
1321
+ ensure_unique_ivec ( e, sp, f. decl . inputs , arg_name, "argument" ) ;
1319
1322
}
1320
1323
1321
1324
type checker = @rec ( mutable vec[ ident] seen, str kind, session sess) ;
@@ -1341,6 +1344,14 @@ fn ensure_unique[T](&env e, &span sp, &vec[T] elts, fn(&T) -> ident id,
1341
1344
auto ch = checker ( e, kind) ;
1342
1345
for ( T elt in elts) { add_name ( ch, sp, id ( elt) ) ; }
1343
1346
}
1347
+
1348
+ // FIXME: Remove me.
1349
+ fn ensure_unique_ivec[ T ] ( & env e, & span sp, & T [ ] elts, fn ( & T ) -> ident id,
1350
+ & str kind) {
1351
+ auto ch = checker ( e, kind) ;
1352
+ for ( T elt in elts) { add_name ( ch, sp, id ( elt) ) ; }
1353
+ }
1354
+
1344
1355
// Local Variables:
1345
1356
// mode: rust
1346
1357
// fill-column: 78;
0 commit comments