@@ -73,51 +73,52 @@ tag opt_span {
73
73
}
74
74
type span = { lo: uint, hi: uint, expanded_from: opt_span} ;
75
75
76
- fn span_to_str ( sp : & span , cm : & codemap ) -> str {
76
+ fn span_to_str ( sp : & span , cm : & codemap ) -> istr {
77
77
let cur = sp;
78
- let res = "" ;
78
+ let res = ~ "";
79
79
let prev_file = none;
80
80
while true {
81
81
let lo = lookup_char_pos ( cm, cur. lo ) ;
82
82
let hi = lookup_char_pos ( cm, cur. hi ) ;
83
- res +=
83
+ res += istr :: from_estr (
84
84
#fmt[ "%s:%u:%u: %u:%u" ,
85
85
if some ( lo. filename ) == prev_file {
86
86
"-"
87
87
} else {
88
88
istr:: to_estr ( lo. filename )
89
- } , lo. line , lo. col , hi. line , hi. col ] ;
89
+ } , lo. line , lo. col , hi. line , hi. col ] ) ;
90
90
alt cur. expanded_from {
91
91
os_none. { break ; }
92
92
os_some ( new_sp) {
93
93
cur = * new_sp;
94
94
prev_file = some ( lo. filename ) ;
95
- res += "<<" ;
95
+ res += ~ "<<";
96
96
}
97
97
}
98
98
}
99
99
100
100
ret res;
101
101
}
102
102
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 ,
104
104
cm : & codemap ) {
105
- let ss = "" ;
105
+ let ss = ~ "";
106
106
let maybe_lines: option:: t < @file_lines > = none;
107
107
alt sp {
108
108
some( ssp) {
109
- ss = span_to_str ( ssp, cm) + " " ;
109
+ ss = span_to_str ( ssp, cm) + ~ " ";
110
110
maybe_lines = some(span_to_lines(ssp, cm));
111
111
}
112
112
none. { }
113
113
}
114
- io:: stdout ( ) . write_str ( istr :: from_estr ( ss ) ) ;
114
+ io::stdout().write_str(ss );
115
115
if term::color_supported() {
116
116
term::fg(io::stdout().get_buf_writer(), color);
117
117
}
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) ] ) ) ;
119
119
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) ] ) ) ;
121
122
122
123
maybe_highlight_lines ( sp, cm, maybe_lines) ;
123
124
}
@@ -129,12 +130,11 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
129
130
some( lines) {
130
131
// If we're not looking at a real file then we can't re-open it to
131
132
// pull out the lines
132
- if lines. name == "-" { ret; }
133
+ if lines. name == ~ "-" { ret; }
133
134
134
135
// FIXME: reading in the entire file is the worst possible way to
135
136
// 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);
138
138
let fm = get_filemap(cm, lines.name);
139
139
140
140
// arbitrarily only print up to six lines of the error
@@ -151,8 +151,8 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
151
151
istr::from_estr(#fmt[" %s: %u ",
152
152
istr::to_estr(fm.name), line + 1u]));
153
153
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 ) ;
156
156
}
157
157
if elided {
158
158
let last_line = display_lines[ vec:: len ( display_lines) - 1 u] ;
@@ -194,17 +194,17 @@ fn maybe_highlight_lines(sp: &option::t<span>, cm: &codemap,
194
194
}
195
195
}
196
196
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) ;
199
199
}
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) ;
202
202
}
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) ;
205
205
}
206
206
207
- type file_lines = { name : str , lines : [ uint ] } ;
207
+ type file_lines = { name : istr , lines : [ uint ] } ;
208
208
209
209
fn span_to_lines ( sp : span , cm : codemap:: codemap ) -> @file_lines {
210
210
let lo = lookup_char_pos ( cm, sp. lo ) ;
@@ -213,10 +213,10 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
213
213
for each i: uint in uint:: range ( lo. line - 1 u, hi. line as uint ) {
214
214
lines += [ i] ;
215
215
}
216
- ret @{ name : istr :: to_estr ( lo. filename ) , lines : lines} ;
216
+ ret @{ name : lo. filename , lines : lines} ;
217
217
}
218
218
219
- fn get_line( fm : filemap , line : int , file : & str ) -> str {
219
+ fn get_line( fm : filemap , line : int , file : & istr ) -> istr {
220
220
let begin: uint = fm. lines [ line] . byte - fm. start_pos . byte ;
221
221
let end: uint ;
222
222
if line as uint < vec:: len ( fm. lines ) - 1 u {
@@ -225,17 +225,17 @@ fn get_line(fm: filemap, line: int, file: &str) -> str {
225
225
// If we're not done parsing the file, we're at the limit of what's
226
226
// parsed. If we just slice the rest of the string, we'll print out
227
227
// 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 ) ;
231
231
if newline != -1 { end = begin + ( newline as uint ) ; }
232
232
}
233
- ret str :: slice ( file, begin, end) ;
233
+ ret istr :: slice ( file, begin, end) ;
234
234
}
235
235
236
- fn get_filemap ( cm : codemap , filename : str ) -> filemap {
236
+ fn get_filemap ( cm : codemap , filename : istr ) -> filemap {
237
237
for fm: filemap in cm. files {
238
- if fm. name == istr :: from_estr ( filename) { ret fm; }
238
+ if fm. name == filename { ret fm; }
239
239
}
240
240
//XXjdm the following triggers a mismatched type bug
241
241
// (or expected function, found _|_)
0 commit comments