Skip to content

Commit d90db20

Browse files
committed
---
yaml --- r: 5011 b: refs/heads/master c: 3dc2419 h: refs/heads/master i: 5009: 86e8079 5007: 43e1d12 v: v3
1 parent 302ce86 commit d90db20

File tree

5 files changed

+51
-46
lines changed

5 files changed

+51
-46
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 9fb085560d969eb654c0fe0f0e1501dfb3665280
2+
refs/heads/master: 3dc24194434ee918a2ee6e02065c1f11dfb10415

trunk/src/comp/driver/session.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import std::option;
1010
import std::option::some;
1111
import std::option::none;
1212
import std::str;
13+
import std::istr;
1314
import syntax::parse::parser::parse_sess;
1415

1516
tag os { os_win32; os_macos; os_linux; }
@@ -60,34 +61,38 @@ obj session(targ_cfg: @config,
6061
fn get_cstore() -> metadata::cstore::cstore { cstore }
6162
fn span_fatal(sp: span, msg: str) -> ! {
6263
// FIXME: Use constants, but rustboot doesn't know how to export them.
63-
codemap::emit_error(some(sp), msg, parse_sess.cm);
64+
codemap::emit_error(some(sp), istr::from_estr(msg), parse_sess.cm);
6465
fail;
6566
}
6667
fn fatal(msg: str) -> ! {
67-
codemap::emit_error(none, msg, parse_sess.cm);
68+
codemap::emit_error(none, istr::from_estr(msg), parse_sess.cm);
6869
fail;
6970
}
7071
fn span_err(sp: span, msg: str) {
71-
codemap::emit_error(some(sp), msg, parse_sess.cm);
72+
codemap::emit_error(some(sp), istr::from_estr(msg), parse_sess.cm);
7273
err_count += 1u;
7374
}
7475
fn err(msg: str) {
75-
codemap::emit_error(none, msg, parse_sess.cm);
76+
codemap::emit_error(none, istr::from_estr(msg), parse_sess.cm);
7677
err_count += 1u;
7778
}
7879
fn abort_if_errors() {
7980
if err_count > 0u { self.fatal("aborting due to previous errors"); }
8081
}
8182
fn span_warn(sp: span, msg: str) {
8283
// FIXME: Use constants, but rustboot doesn't know how to export them.
83-
codemap::emit_warning(some(sp), msg, parse_sess.cm);
84+
codemap::emit_warning(some(sp), istr::from_estr(msg), parse_sess.cm);
85+
}
86+
fn warn(msg: str) {
87+
codemap::emit_warning(none, istr::from_estr(msg), parse_sess.cm);
8488
}
85-
fn warn(msg: str) { codemap::emit_warning(none, msg, parse_sess.cm); }
8689
fn span_note(sp: span, msg: str) {
8790
// FIXME: Use constants, but rustboot doesn't know how to export them.
88-
codemap::emit_note(some(sp), msg, parse_sess.cm);
91+
codemap::emit_note(some(sp), istr::from_estr(msg), parse_sess.cm);
92+
}
93+
fn note(msg: str) {
94+
codemap::emit_note(none, istr::from_estr(msg), parse_sess.cm);
8995
}
90-
fn note(msg: str) { codemap::emit_note(none, msg, parse_sess.cm); }
9196
fn span_bug(sp: span, msg: str) -> ! {
9297
self.span_fatal(sp, #fmt["internal compiler error %s", msg]);
9398
}
@@ -107,7 +112,7 @@ obj session(targ_cfg: @config,
107112
ret syntax::parse::parser::next_node_id(parse_sess);
108113
}
109114
fn span_str(sp: span) -> str {
110-
ret codemap::span_to_str(sp, self.get_codemap());
115+
ret istr::to_estr(codemap::span_to_str(sp, self.get_codemap()));
111116
}
112117
fn set_main_id(d: node_id) { main_fn = some(d); }
113118
fn get_main_id() -> option::t<node_id> { main_fn }

trunk/src/comp/syntax/codemap.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -73,51 +73,52 @@ tag opt_span {
7373
}
7474
type span = {lo: uint, hi: uint, expanded_from: opt_span};
7575

76-
fn span_to_str(sp: &span, cm: &codemap) -> str {
76+
fn span_to_str(sp: &span, cm: &codemap) -> istr {
7777
let cur = sp;
78-
let res = "";
78+
let res = ~"";
7979
let prev_file = none;
8080
while true {
8181
let lo = lookup_char_pos(cm, cur.lo);
8282
let hi = lookup_char_pos(cm, cur.hi);
83-
res +=
83+
res += istr::from_estr(
8484
#fmt["%s:%u:%u: %u:%u",
8585
if some(lo.filename) == prev_file {
8686
"-"
8787
} else {
8888
istr::to_estr(lo.filename)
89-
}, lo.line, lo.col, hi.line, hi.col];
89+
}, lo.line, lo.col, hi.line, hi.col]);
9090
alt cur.expanded_from {
9191
os_none. { break; }
9292
os_some(new_sp) {
9393
cur = *new_sp;
9494
prev_file = some(lo.filename);
95-
res += "<<";
95+
res += ~"<<";
9696
}
9797
}
9898
}
9999

100100
ret res;
101101
}
102102

103-
fn emit_diagnostic(sp: &option::t<span>, msg: &str, kind: &str, color: u8,
103+
fn emit_diagnostic(sp: &option::t<span>, msg: &istr, kind: &istr, color: u8,
104104
cm: &codemap) {
105-
let ss = "";
105+
let ss = ~"";
106106
let maybe_lines: option::t<@file_lines> = none;
107107
alt sp {
108108
some(ssp) {
109-
ss = span_to_str(ssp, cm) + " ";
109+
ss = span_to_str(ssp, cm) + ~" ";
110110
maybe_lines = some(span_to_lines(ssp, cm));
111111
}
112112
none. { }
113113
}
114-
io::stdout().write_str(istr::from_estr(ss));
114+
io::stdout().write_str(ss);
115115
if term::color_supported() {
116116
term::fg(io::stdout().get_buf_writer(), color);
117117
}
118-
io::stdout().write_str(istr::from_estr(#fmt["%s:", kind]));
118+
io::stdout().write_str(istr::from_estr(#fmt["%s:", istr::to_estr(kind)]));
119119
if term::color_supported() { term::reset(io::stdout().get_buf_writer()); }
120-
io::stdout().write_str(istr::from_estr(#fmt[" %s\n", msg]));
120+
io::stdout().write_str(istr::from_estr(#fmt[" %s\n",
121+
istr::to_estr(msg)]));
121122

122123
maybe_highlight_lines(sp, cm, maybe_lines);
123124
}
@@ -129,12 +130,11 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
129130
some(lines) {
130131
// If we're not looking at a real file then we can't re-open it to
131132
// pull out the lines
132-
if lines.name == "-" { ret; }
133+
if lines.name == ~"-" { ret; }
133134
134135
// FIXME: reading in the entire file is the worst possible way to
135136
// get access to the necessary lines.
136-
let file = istr::to_estr(
137-
io::read_whole_file_str(istr::from_estr(lines.name)));
137+
let file = io::read_whole_file_str(lines.name);
138138
let fm = get_filemap(cm, lines.name);
139139
140140
// arbitrarily only print up to six lines of the error
@@ -151,8 +151,8 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
151151
istr::from_estr(#fmt["%s:%u ",
152152
istr::to_estr(fm.name), line + 1u]));
153153
let s = get_line(fm, line as int, file);
154-
if !str::ends_with(s, "\n") { s += "\n"; }
155-
io::stdout().write_str(istr::from_estr(s));
154+
if !istr::ends_with(s, ~"\n") { s += ~"\n"; }
155+
io::stdout().write_str(s);
156156
}
157157
if elided {
158158
let last_line = display_lines[vec::len(display_lines) - 1u];
@@ -194,17 +194,17 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
194194
}
195195
}
196196

197-
fn emit_warning(sp: &option::t<span>, msg: &str, cm: &codemap) {
198-
emit_diagnostic(sp, msg, "warning", 11u8, cm);
197+
fn emit_warning(sp: &option::t<span>, msg: &istr, cm: &codemap) {
198+
emit_diagnostic(sp, msg, ~"warning", 11u8, cm);
199199
}
200-
fn emit_error(sp: &option::t<span>, msg: &str, cm: &codemap) {
201-
emit_diagnostic(sp, msg, "error", 9u8, cm);
200+
fn emit_error(sp: &option::t<span>, msg: &istr, cm: &codemap) {
201+
emit_diagnostic(sp, msg, ~"error", 9u8, cm);
202202
}
203-
fn emit_note(sp: &option::t<span>, msg: &str, cm: &codemap) {
204-
emit_diagnostic(sp, msg, "note", 10u8, cm);
203+
fn emit_note(sp: &option::t<span>, msg: &istr, cm: &codemap) {
204+
emit_diagnostic(sp, msg, ~"note", 10u8, cm);
205205
}
206206

207-
type file_lines = {name: str, lines: [uint]};
207+
type file_lines = {name: istr, lines: [uint]};
208208

209209
fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
210210
let lo = lookup_char_pos(cm, sp.lo);
@@ -213,10 +213,10 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
213213
for each i: uint in uint::range(lo.line - 1u, hi.line as uint) {
214214
lines += [i];
215215
}
216-
ret @{name: istr::to_estr(lo.filename), lines: lines};
216+
ret @{name: lo.filename, lines: lines};
217217
}
218218

219-
fn get_line(fm: filemap, line: int, file: &str) -> str {
219+
fn get_line(fm: filemap, line: int, file: &istr) -> istr {
220220
let begin: uint = fm.lines[line].byte - fm.start_pos.byte;
221221
let end: uint;
222222
if line as uint < vec::len(fm.lines) - 1u {
@@ -225,17 +225,17 @@ fn get_line(fm: filemap, line: int, file: &str) -> str {
225225
// If we're not done parsing the file, we're at the limit of what's
226226
// parsed. If we just slice the rest of the string, we'll print out
227227
// the remainder of the file, which is undesirable.
228-
end = str::byte_len(file);
229-
let rest = str::slice(file, begin, end);
230-
let newline = str::index(rest, '\n' as u8);
228+
end = istr::byte_len(file);
229+
let rest = istr::slice(file, begin, end);
230+
let newline = istr::index(rest, '\n' as u8);
231231
if newline != -1 { end = begin + (newline as uint); }
232232
}
233-
ret str::slice(file, begin, end);
233+
ret istr::slice(file, begin, end);
234234
}
235235

236-
fn get_filemap(cm: codemap, filename: str) -> filemap {
236+
fn get_filemap(cm: codemap, filename: istr) -> filemap {
237237
for fm: filemap in cm.files {
238-
if fm.name == istr::from_estr(filename) { ret fm; }
238+
if fm.name == filename { ret fm; }
239239
}
240240
//XXjdm the following triggers a mismatched type bug
241241
// (or expected function, found _|_)

trunk/src/comp/syntax/parse/lexer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn new_reader(cm: &codemap::codemap, src: &istr, filemap: codemap::filemap,
8181
fn err(m: &istr) {
8282
codemap::emit_error(
8383
some(ast_util::mk_sp(chpos, chpos)),
84-
istr::to_estr(m), cm);
84+
m, cm);
8585
}
8686
}
8787
let strs: [istr] = [];

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader,
113113
}
114114
fn fatal(m: &istr) -> ! {
115115
codemap::emit_error(some(self.get_span()),
116-
istr::to_estr(m), sess.cm);
116+
m, sess.cm);
117117
fail;
118118
}
119119
fn warn(m: &istr) {
120120
codemap::emit_warning(some(self.get_span()),
121-
istr::to_estr(m), sess.cm);
121+
m, sess.cm);
122122
}
123123
fn restrict(r: restriction) { restr = r; }
124124
fn get_restriction() -> restriction { ret restr; }
@@ -2581,8 +2581,8 @@ fn parse_crate_from_file(input: &istr, cfg: &ast::crate_cfg,
25812581
} else if istr::ends_with(input, ~".rs") {
25822582
parse_crate_from_source_file(input, cfg, sess)
25832583
} else {
2584-
codemap::emit_error(none, "unknown input file type: "
2585-
+ istr::to_estr(input),
2584+
codemap::emit_error(none, ~"unknown input file type: "
2585+
+ input,
25862586
sess.cm);
25872587
fail
25882588
}

0 commit comments

Comments
 (0)