Skip to content

Commit a2fc2eb

Browse files
garethgareth
authored andcommitted
---
yaml --- r: 52071 b: refs/heads/dist-snap c: 624421a h: refs/heads/master i: 52069: c9f1c67 52067: eaae96d 52063: 1496704 v: v3
1 parent ce28a3f commit a2fc2eb

File tree

2 files changed

+11
-47
lines changed

2 files changed

+11
-47
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: d68954efa09c4cbd16a07d4bd93de688d64074c3
10+
refs/heads/dist-snap: 624421aa3d5d09fd59834c524f1909120685232d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/resolve.rs

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,19 +2106,8 @@ impl Resolver {
21062106
}
21072107

21082108
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, "::");
21222111
}
21232112

21242113
fn import_directive_subclass_to_str(subclass: ImportDirectiveSubclass)
@@ -4524,17 +4513,14 @@ impl Resolver {
45244513
// Write the result into the def map.
45254514
debug!("(resolving type) writing resolution for `%s` \
45264515
(id %d)",
4527-
connect(path.idents.map(
4528-
|x| self.session.str_of(*x)), ~"::"),
4516+
self.idents_to_str(path.idents),
45294517
path_id);
45304518
self.record_def(path_id, def);
45314519
}
45324520
None => {
45334521
self.session.span_err
45344522
(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)));
45384524
}
45394525
}
45404526
}
@@ -4728,9 +4714,7 @@ impl Resolver {
47284714
self.session.span_err(
47294715
path.span,
47304716
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)));
47344718
}
47354719
}
47364720
}
@@ -5126,14 +5110,11 @@ impl Resolver {
51265110
Some(def) => {
51275111
// Write the result into the def map.
51285112
debug!("(resolving expr) resolved `%s`",
5129-
connect(path.idents.map(
5130-
|x| self.session.str_of(*x)), ~"::"));
5113+
self.idents_to_str(path.idents));
51315114
self.record_def(expr.id, def);
51325115
}
51335116
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);
51375118
if self.name_exists_in_scope_struct(wrong_name) {
51385119
self.session.span_err(expr.span,
51395120
fmt!("unresolved name: `%s`. \
@@ -5193,9 +5174,7 @@ impl Resolver {
51935174
self.session.span_err(
51945175
path.span,
51955176
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)));
51995178
}
52005179
}
52015180

@@ -5514,7 +5493,7 @@ impl Resolver {
55145493
// hit.
55155494
//
55165495

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.
55185497
fn module_to_str(module_: @Module) -> ~str {
55195498
let idents = DVec();
55205499
let mut current_module = module_;
@@ -5537,22 +5516,7 @@ impl Resolver {
55375516
if idents.len() == 0 {
55385517
return ~"???";
55395518
}
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()));
55565520
}
55575521

55585522
fn dump_module(module_: @Module) {

0 commit comments

Comments
 (0)