@@ -2106,19 +2106,8 @@ impl Resolver {
2106
2106
}
2107
2107
2108
2108
fn idents_to_str( idents: ~[ ident] ) -> ~str {
2109
- // XXX: str::connect should do this.
2110
- let mut result = ~"";
2111
- let mut first = true;
2112
- for idents. each( ) |ident| {
2113
- if first {
2114
- first = false ;
2115
- } else {
2116
- result += ~":: ";
2117
- }
2118
- result += self . session. str_of( * ident) ;
2119
- }
2120
- // XXX: Shouldn't copy here. We need string builder functionality.
2121
- return result;
2109
+ let ident_strs = idents. map( |& ident| self . session. str_of( ident) ) ;
2110
+ return str :: connect( ident_strs, ":: ") ;
2122
2111
}
2123
2112
2124
2113
fn import_directive_subclass_to_str( subclass: ImportDirectiveSubclass )
@@ -4524,17 +4513,14 @@ impl Resolver {
4524
4513
// Write the result into the def map.
4525
4514
debug ! ( "(resolving type) writing resolution for `%s` \
4526
4515
(id %d)",
4527
- connect( path. idents. map(
4528
- |x| self . session. str_of( * x) ) , ~":: "),
4516
+ self . idents_to_str( path. idents) ,
4529
4517
path_id) ;
4530
4518
self . record_def( path_id, def) ;
4531
4519
}
4532
4520
None => {
4533
4521
self . session. span_err
4534
4522
( ty. span, fmt ! ( "use of undeclared type name `%s`" ,
4535
- connect( path. idents. map(
4536
- |x| self . session. str_of( * x) ) ,
4537
- ~":: ")));
4523
+ self . idents_to_str( path. idents) ) ) ;
4538
4524
}
4539
4525
}
4540
4526
}
@@ -4728,9 +4714,7 @@ impl Resolver {
4728
4714
self . session. span_err(
4729
4715
path. span,
4730
4716
fmt ! ( "`%s` does not name a structure" ,
4731
- connect(path.idents.map(
4732
- |x| self.session.str_of(*x)),
4733
- ~" :: ")));
4717
+ self . idents_to_str( path. idents) ) ) ;
4734
4718
}
4735
4719
}
4736
4720
}
@@ -5126,14 +5110,11 @@ impl Resolver {
5126
5110
Some ( def) => {
5127
5111
// Write the result into the def map.
5128
5112
debug ! ( "(resolving expr) resolved `%s`" ,
5129
- connect( path. idents. map(
5130
- |x| self . session. str_of( * x) ) , ~":: "));
5113
+ self . idents_to_str( path. idents) ) ;
5131
5114
self . record_def( expr. id, def) ;
5132
5115
}
5133
5116
None => {
5134
- let wrong_name =
5135
- connect(path.idents.map(
5136
- |x| self.session.str_of(*x)), ~" :: ") ;
5117
+ let wrong_name = self . idents_to_str( path. idents) ;
5137
5118
if self . name_exists_in_scope_struct( wrong_name) {
5138
5119
self . session. span_err( expr. span,
5139
5120
fmt ! ( "unresolved name: `%s`. \
@@ -5193,9 +5174,7 @@ impl Resolver {
5193
5174
self . session. span_err(
5194
5175
path. span,
5195
5176
fmt ! ( "`%s` does not name a structure" ,
5196
- connect(path.idents.map(
5197
- |x| self.session.str_of(*x)),
5198
- ~" :: ")));
5177
+ self . idents_to_str( path. idents) ) ) ;
5199
5178
}
5200
5179
}
5201
5180
@@ -5514,7 +5493,7 @@ impl Resolver {
5514
5493
// hit.
5515
5494
//
5516
5495
5517
- /// A somewhat inefficient routine to print out the name of a module.
5496
+ /// A somewhat inefficient routine to obtain the name of a module.
5518
5497
fn module_to_str( module_: @Module ) -> ~str {
5519
5498
let idents = DVec ( ) ;
5520
5499
let mut current_module = module_;
@@ -5537,22 +5516,7 @@ impl Resolver {
5537
5516
if idents. len( ) == 0 {
5538
5517
return ~"???";
5539
5518
}
5540
-
5541
- let mut string = ~" ";
5542
- let mut i = idents.len() - 1;
5543
- loop {
5544
- if i < idents.len() - 1 {
5545
- string += ~" :: ";
5546
- }
5547
- string += self.session.str_of(idents.get_elt(i));
5548
-
5549
- if i == 0 {
5550
- break;
5551
- }
5552
- i -= 1;
5553
- }
5554
-
5555
- return string;
5519
+ return self . idents_to_str( vec:: reversed( idents. get( ) ) ) ;
5556
5520
}
5557
5521
5558
5522
fn dump_module( module_: @Module ) {
0 commit comments