@@ -75,7 +75,6 @@ export def_like;
75
75
export dl_def;
76
76
export dl_impl;
77
77
export dl_field;
78
- export path_entry;
79
78
export each_lang_item;
80
79
export each_path;
81
80
export get_item_path;
@@ -468,21 +467,6 @@ fn def_like_to_def(def_like: def_like) -> ast::def {
468
467
}
469
468
}
470
469
471
- // A path.
472
- struct path_entry {
473
- // The full path, separated by '::'.
474
- path_string : ~str ,
475
- // The definition, implementation, or field that this path corresponds to.
476
- def_like : def_like ,
477
- }
478
-
479
- fn path_entry ( +path_string : ~str , def_like : def_like ) -> path_entry {
480
- path_entry {
481
- path_string : path_string,
482
- def_like : def_like
483
- }
484
- }
485
-
486
470
/// Iterates over the language items in the given crate.
487
471
fn each_lang_item ( cdata : cmd , f : & fn ( ast:: node_id , uint ) -> bool ) {
488
472
let root = reader:: Doc ( cdata. data ) ;
@@ -503,7 +487,7 @@ fn each_lang_item(cdata: cmd, f: &fn(ast::node_id, uint) -> bool) {
503
487
/// Iterates over all the paths in the given crate.
504
488
fn each_path ( intr : @ident_interner , cdata : cmd ,
505
489
get_crate_data : GetCrateDataCb ,
506
- f : fn ( path_entry ) -> bool ) {
490
+ f : fn ( & str , def_like ) -> bool ) {
507
491
let root = reader:: Doc ( cdata. data ) ;
508
492
let items = reader:: get_doc ( root, tag_items) ;
509
493
let items_data = reader:: get_doc ( items, tag_items_data) ;
@@ -515,7 +499,8 @@ fn each_path(intr: @ident_interner, cdata: cmd,
515
499
if !broken {
516
500
let path = ast_map:: path_to_str_with_sep (
517
501
item_path ( intr, item_doc) , ~":: ", intr) ;
518
- if path != ~"" {
502
+ let path_is_empty = path. is_empty ( ) ;
503
+ if !path_is_empty {
519
504
// Extract the def ID.
520
505
let def_id = item_def_id ( item_doc, cdata) ;
521
506
@@ -524,10 +509,8 @@ fn each_path(intr: @ident_interner, cdata: cmd,
524
509
let def_like = item_to_def_like ( item_doc, def_id, cdata. cnum ) ;
525
510
526
511
// Hand the information off to the iteratee.
527
- // XXX: Bad copy.
528
- let this_path_entry = path_entry ( copy path, def_like) ;
529
- if !f ( this_path_entry) {
530
- broken = true ; // XXX: This is awful.
512
+ if !f ( path, def_like) {
513
+ broken = true ; // FIXME #4572: This is awful.
531
514
}
532
515
}
533
516
@@ -548,7 +531,7 @@ fn each_path(intr: @ident_interner, cdata: cmd,
548
531
let reexport_name = reader:: doc_as_str ( reexport_name_doc) ;
549
532
550
533
let reexport_path;
551
- if path == ~"" {
534
+ if path_is_empty {
552
535
reexport_path = reexport_name;
553
536
} else {
554
537
reexport_path = path + ~":: " + reexport_name;
@@ -576,10 +559,8 @@ fn each_path(intr: @ident_interner, cdata: cmd,
576
559
debug ! ( "(each_path) yielding reexported \
577
560
item: %s", reexport_path) ;
578
561
579
- let this_path_entry =
580
- path_entry ( reexport_path, def_like) ;
581
- if ( !f ( this_path_entry) ) {
582
- broken = true ; // XXX: This is awful.
562
+ if ( !f ( reexport_path, def_like) ) {
563
+ broken = true ; // FIXME #4572: This is awful.
583
564
}
584
565
}
585
566
}
@@ -1123,12 +1104,12 @@ fn get_crate_vers(data: @~[u8]) -> ~str {
1123
1104
1124
1105
fn iter_crate_items ( intr : @ident_interner , cdata : cmd ,
1125
1106
get_crate_data : GetCrateDataCb ,
1126
- proc : fn ( + path : ~ str , ast:: def_id ) ) {
1127
- for each_path( intr, cdata, get_crate_data) |path_entry | {
1128
- match path_entry . def_like {
1107
+ proc : fn ( path : & str , ast:: def_id ) ) {
1108
+ for each_path( intr, cdata, get_crate_data) |path_string , def_like | {
1109
+ match def_like {
1129
1110
dl_impl( * ) | dl_field => { }
1130
1111
dl_def( def) => {
1131
- proc ( /*bad*/ copy path_entry . path_string ,
1112
+ proc ( path_string,
1132
1113
ast_util:: def_id_of_def ( def) )
1133
1114
}
1134
1115
}
0 commit comments