@@ -5484,6 +5484,25 @@ fn collect_native_item(&@crate_ctxt cx, @ast.native_item i) -> @crate_ctxt {
5484
5484
5485
5485
fn collect_item( & @crate_ctxt cx, @ast. item i) -> @crate_ctxt {
5486
5486
5487
+ alt ( i. node) {
5488
+ case ( ast. item_const( ?name, _, _, ?cid, _) ) {
5489
+ cx. items. insert( cid, i) ;
5490
+ }
5491
+
5492
+ case ( ast. item_mod( ?name, ?m, ?mid) ) {
5493
+ cx. items. insert( mid, i) ;
5494
+ }
5495
+
5496
+ case ( ast. item_tag( _, ?variants, ?tps, ?tag_id) ) {
5497
+ cx. items. insert( tag_id, i) ;
5498
+ }
5499
+
5500
+ case ( _) { /* fall through */ }
5501
+ }
5502
+ ret cx;
5503
+ }
5504
+
5505
+ fn collect_item_pass2( & @crate_ctxt cx, @ast. item i) -> @crate_ctxt {
5487
5506
alt ( i. node) {
5488
5507
case ( ast. item_fn( ?name, ?f, ?tps, ?fid, ?ann) ) {
5489
5508
cx. items. insert( fid, i) ;
@@ -5500,18 +5519,6 @@ fn collect_item(&@crate_ctxt cx, @ast.item i) -> @crate_ctxt {
5500
5519
}
5501
5520
}
5502
5521
5503
- case ( ast. item_const( ?name, _, _, ?cid, _) ) {
5504
- cx. items. insert( cid, i) ;
5505
- }
5506
-
5507
- case ( ast. item_mod( ?name, ?m, ?mid) ) {
5508
- cx. items. insert( mid, i) ;
5509
- }
5510
-
5511
- case ( ast. item_tag( _, ?variants, ?tps, ?tag_id) ) {
5512
- cx. items. insert( tag_id, i) ;
5513
- }
5514
-
5515
5522
case ( _) { /* fall through */ }
5516
5523
}
5517
5524
ret cx;
@@ -5523,11 +5530,20 @@ fn collect_items(@crate_ctxt cx, @ast.crate crate) {
5523
5530
let fold. ast_fold[ @crate_ctxt] fld =
5524
5531
fold. new_identity_fold[ @crate_ctxt] ( ) ;
5525
5532
5526
- fld = @rec( update_env_for_item = bind collect_item( _, _) ,
5527
- update_env_for_native_item = bind collect_native_item( _, _)
5528
- with * fld ) ;
5533
+ // FIXME: if ty_tag had a pointer directly to the definition instead
5534
+ // of a def_id, we wouldn't need the second pass.
5529
5535
5530
- fold. fold_crate[ @crate_ctxt] ( cx, fld, crate ) ;
5536
+ auto fld1 =
5537
+ @rec( update_env_for_item = bind collect_item( _, _) ,
5538
+ update_env_for_native_item = bind collect_native_item( _, _)
5539
+ with * fld ) ;
5540
+
5541
+ fold. fold_crate[ @crate_ctxt] ( cx, fld1, crate ) ;
5542
+
5543
+ auto fld2 = @rec( update_env_for_item = bind collect_item_pass2( _, _)
5544
+ with * fld ) ;
5545
+
5546
+ fold. fold_crate[ @crate_ctxt] ( cx, fld2, crate ) ;
5531
5547
}
5532
5548
5533
5549
fn collect_tag_ctor( & @crate_ctxt cx, @ast. item i) -> @crate_ctxt {
0 commit comments