Skip to content

Commit 95606a1

Browse files
committed
---
yaml --- r: 13794 b: refs/heads/try c: c5e03e0 h: refs/heads/master v: v3
1 parent 8c58b9f commit 95606a1

File tree

11 files changed

+61
-125
lines changed

11 files changed

+61
-125
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: ab223e06181434dd7b98fa27a8f902f2d15d7759
5+
refs/heads/try: c5e03e0e599e49f74303bbafc6d559f3138b5f72
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/comp/driver/diagnostic.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,6 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
193193
// pull out the lines
194194
if lines.name == "-" { ret; }
195195

196-
// FIXME: reading in the entire file is the worst possible way to
197-
// get access to the necessary lines.
198-
let file = alt io::read_whole_file_str(lines.name) {
199-
result::ok(file) { file }
200-
result::err(e) {
201-
// Hard to report errors while reporting an error
202-
ret;
203-
}
204-
};
205196
let fm = codemap::get_filemap(cm, lines.name);
206197

207198
// arbitrarily only print up to six lines of the error
@@ -215,7 +206,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
215206
// Print the offending lines
216207
for line: uint in display_lines {
217208
io::stdout().write_str(#fmt["%s:%u ", fm.name, line + 1u]);
218-
let s = codemap::get_line(fm, line as int, file);
209+
let s = codemap::get_line(fm, line as int);
219210
if !str::ends_with(s, "\n") { s += "\n"; }
220211
io::stdout().write_str(s);
221212
}

branches/try/src/comp/driver/driver.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn parse_cfgspecs(cfgspecs: [str]) -> ast::crate_cfg {
7777
fn input_is_stdin(filename: str) -> bool { filename == "-" }
7878

7979
fn parse_input(sess: session, cfg: ast::crate_cfg, input: str)
80-
-> {crate: @ast::crate, src: str} {
80+
-> {crate: @ast::crate, src: @str} {
8181
let src = get_input_str(sess, input);
8282
let crate = if !input_is_stdin(input) {
8383
parser::parse_crate_from_file(input, cfg, sess.parse_sess)
@@ -87,7 +87,7 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: str)
8787
{crate: crate, src: src}
8888
}
8989

90-
fn get_input_str(sess: session, infile: str) -> str {
90+
fn get_input_str(sess: session, infile: str) -> @str {
9191
let stream = if !input_is_stdin(infile) {
9292
alt io::file_reader(infile) {
9393
result::ok(reader) { reader }
@@ -96,7 +96,7 @@ fn get_input_str(sess: session, infile: str) -> str {
9696
}
9797
}
9898
} else { io::stdin() };
99-
str::unsafe_from_bytes(stream.read_whole_stream())
99+
@str::unsafe_from_bytes(stream.read_whole_stream())
100100
}
101101

102102
fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
@@ -141,7 +141,7 @@ enum compile_upto {
141141
fn compile_upto(sess: session, cfg: ast::crate_cfg,
142142
input: str, upto: compile_upto,
143143
outputs: option::t<output_filenames>)
144-
-> {crate: @ast::crate, tcx: option::t<ty::ctxt>, src: str} {
144+
-> {crate: @ast::crate, tcx: option::t<ty::ctxt>, src: @str} {
145145
let time_passes = sess.opts.time_passes;
146146
let {crate, src} =
147147
time(time_passes, "parsing", bind parse_input(sess, cfg, input));
@@ -300,7 +300,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str,
300300
ppm_expanded | ppm_normal {}
301301
}
302302
pprust::print_crate(sess.codemap, sess.span_diagnostic, crate, input,
303-
io::string_reader(src), io::stdout(), ann);
303+
io::string_reader(*src), io::stdout(), ann);
304304
}
305305

306306
fn get_os(triple: str) -> option<session::os> {

branches/try/src/comp/syntax/codemap.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ type file_pos = {ch: uint, byte: uint};
1111
* compiler.
1212
*/
1313
type filemap =
14-
@{name: filename, start_pos: file_pos, mutable lines: [file_pos]};
14+
@{name: filename, src: @str,
15+
start_pos: file_pos, mutable lines: [file_pos]};
1516

1617
type codemap = @{mutable files: [filemap]};
1718

1819
type loc = {filename: filename, line: uint, col: uint};
1920

2021
fn new_codemap() -> codemap { ret @{mutable files: []}; }
2122

22-
fn new_filemap(filename: filename, start_pos_ch: uint, start_pos_byte: uint)
23+
fn new_filemap(filename: filename, src: @str,
24+
start_pos_ch: uint, start_pos_byte: uint)
2325
-> filemap {
24-
ret @{name: filename,
26+
ret @{name: filename, src: src,
2527
start_pos: {ch: start_pos_ch, byte: start_pos_byte},
2628
mutable lines: [{ch: start_pos_ch, byte: start_pos_byte}]};
2729
}
@@ -106,7 +108,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
106108
ret @{name: lo.filename, lines: lines};
107109
}
108110

109-
fn get_line(fm: filemap, line: int, file: str) -> str {
111+
fn get_line(fm: filemap, line: int) -> str {
110112
let begin: uint = fm.lines[line].byte - fm.start_pos.byte;
111113
let end: uint;
112114
if line as uint < vec::len(fm.lines) - 1u {
@@ -115,12 +117,12 @@ fn get_line(fm: filemap, line: int, file: str) -> str {
115117
// If we're not done parsing the file, we're at the limit of what's
116118
// parsed. If we just slice the rest of the string, we'll print out
117119
// the remainder of the file, which is undesirable.
118-
end = str::byte_len(file);
119-
let rest = str::slice(file, begin, end);
120+
end = str::byte_len(*fm.src);
121+
let rest = str::slice(*fm.src, begin, end);
120122
let newline = str::index(rest, '\n' as u8);
121123
if newline != -1 { end = begin + (newline as uint); }
122124
}
123-
ret str::slice(file, begin, end);
125+
ret str::slice(*fm.src, begin, end);
124126
}
125127

126128
fn get_filemap(cm: codemap, filename: str) -> filemap {

branches/try/src/comp/syntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn expand_crate(sess: session::session, c: @crate) -> @crate {
7575
{fold_expr: bind expand_expr(exts, cx, _, _, _, afp.fold_expr)
7676
with *afp};
7777
let f = make_fold(f_pre);
78-
let cm = parse_expr_from_source_str("<anon>", core_macros(),
78+
let cm = parse_expr_from_source_str("<anon>", @core_macros(),
7979
sess.opts.cfg,
8080
sess.parse_sess);
8181

branches/try/src/comp/syntax/parse/lexer.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import driver::diagnostic;
1111
type reader = @{
1212
cm: codemap::codemap,
1313
span_diagnostic: diagnostic::span_handler,
14-
src: str,
14+
src: @str,
1515
len: uint,
1616
mutable col: uint,
1717
mutable pos: uint,
@@ -27,11 +27,11 @@ impl reader for reader {
2727
fn get_str_from(start: uint) -> str {
2828
// I'm pretty skeptical about this subtraction. What if there's a
2929
// multi-byte character before the mark?
30-
ret str::slice(self.src, start - 1u, self.pos - 1u);
30+
ret str::slice(*self.src, start - 1u, self.pos - 1u);
3131
}
3232
fn next() -> char {
3333
if self.pos < self.len {
34-
ret str::char_at(self.src, self.pos);
34+
ret str::char_at(*self.src, self.pos);
3535
} else { ret -1 as char; }
3636
}
3737
fn bump() {
@@ -43,7 +43,7 @@ impl reader for reader {
4343
self.filemap.start_pos.byte);
4444
self.col = 0u;
4545
}
46-
let next = str::char_range_at(self.src, self.pos);
46+
let next = str::char_range_at(*self.src, self.pos);
4747
self.pos = next.next;
4848
self.curr = next.ch;
4949
} else { self.curr = -1 as char; }
@@ -57,16 +57,16 @@ impl reader for reader {
5757

5858
fn new_reader(cm: codemap::codemap,
5959
span_diagnostic: diagnostic::span_handler,
60-
src: str, filemap: codemap::filemap,
60+
filemap: codemap::filemap,
6161
itr: @interner::interner<str>) -> reader {
6262
let r = @{cm: cm,
6363
span_diagnostic: span_diagnostic,
64-
src: src, len: str::byte_len(src),
64+
src: filemap.src, len: str::byte_len(*filemap.src),
6565
mutable col: 0u, mutable pos: 0u, mutable curr: -1 as char,
6666
mutable chpos: filemap.start_pos.ch, mutable strs: [],
6767
filemap: filemap, interner: itr};
6868
if r.pos < r.len {
69-
let next = str::char_range_at(r.src, r.pos);
69+
let next = str::char_range_at(*r.src, r.pos);
7070
r.pos = next.next;
7171
r.curr = next.ch;
7272
}
@@ -672,10 +672,10 @@ fn gather_comments_and_literals(cm: codemap::codemap,
672672
path: str,
673673
srdr: io::reader) ->
674674
{cmnts: [cmnt], lits: [lit]} {
675-
let src = str::unsafe_from_bytes(srdr.read_whole_stream());
675+
let src = @str::unsafe_from_bytes(srdr.read_whole_stream());
676676
let itr = @interner::mk::<str>(str::hash, str::eq);
677-
let rdr = new_reader(cm, span_diagnostic, src,
678-
codemap::new_filemap(path, 0u, 0u), itr);
677+
let rdr = new_reader(cm, span_diagnostic,
678+
codemap::new_filemap(path, src, 0u, 0u), itr);
679679
let comments: [cmnt] = [];
680680
let literals: [lit] = [];
681681
let first_read: bool = true;

branches/try/src/comp/syntax/parse/parser.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,28 @@ fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, path: str,
9898
let src = alt io::read_whole_file_str(path) {
9999
result::ok(src) {
100100
// FIXME: This copy is unfortunate
101-
src
101+
@src
102102
}
103103
result::err(e) {
104104
sess.span_diagnostic.handler().fatal(e)
105105
}
106106
};
107-
let filemap = codemap::new_filemap(path, sess.chpos, sess.byte_pos);
107+
let filemap = codemap::new_filemap(path, src,
108+
sess.chpos, sess.byte_pos);
108109
sess.cm.files += [filemap];
109110
let itr = @interner::mk(str::hash, str::eq);
110-
let rdr = lexer::new_reader(sess.cm, sess.span_diagnostic, src, filemap,
111-
itr);
111+
let rdr = lexer::new_reader(sess.cm, sess.span_diagnostic, filemap, itr);
112112
ret new_parser(sess, cfg, rdr, ftype);
113113
}
114114

115115
fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg,
116-
name: str, source: str) -> parser {
116+
name: str, source: @str) -> parser {
117117
let ftype = SOURCE_FILE;
118-
let filemap = codemap::new_filemap(name, sess.chpos, sess.byte_pos);
118+
let filemap = codemap::new_filemap(name, source,
119+
sess.chpos, sess.byte_pos);
119120
sess.cm.files += [filemap];
120121
let itr = @interner::mk(str::hash, str::eq);
121-
let rdr = lexer::new_reader(sess.cm, sess.span_diagnostic, source,
122+
let rdr = lexer::new_reader(sess.cm, sess.span_diagnostic,
122123
filemap, itr);
123124
ret new_parser(sess, cfg, rdr, ftype);
124125
}
@@ -2462,7 +2463,7 @@ fn parse_crate_from_source_file(input: str, cfg: ast::crate_cfg,
24622463
}
24632464

24642465

2465-
fn parse_expr_from_source_str(name: str, source: str, cfg: ast::crate_cfg,
2466+
fn parse_expr_from_source_str(name: str, source: @str, cfg: ast::crate_cfg,
24662467
sess: parse_sess) -> @ast::expr {
24672468
let p = new_parser_from_source_str(sess, cfg, name, source);
24682469
let r = parse_expr(p);
@@ -2471,7 +2472,7 @@ fn parse_expr_from_source_str(name: str, source: str, cfg: ast::crate_cfg,
24712472
ret r;
24722473
}
24732474

2474-
fn parse_crate_from_source_str(name: str, source: str, cfg: ast::crate_cfg,
2475+
fn parse_crate_from_source_str(name: str, source: @str, cfg: ast::crate_cfg,
24752476
sess: parse_sess) -> @ast::crate {
24762477
let p = new_parser_from_source_str(sess, cfg, name, source);
24772478
let r = parse_crate_mod(p, cfg);

branches/try/src/fuzzer/fuzzer.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ fn check_variants_T<T: copy>(
261261
// string for stability is easier and ok for now.
262262
let handler = diagnostic::mk_handler(none);
263263
let str3 =
264-
as_str(bind pprust::print_crate(
264+
@as_str(bind pprust::print_crate(
265265
codemap,
266266
diagnostic::mk_span_handler(handler, codemap),
267267
crate2,
@@ -274,8 +274,8 @@ fn check_variants_T<T: copy>(
274274
}
275275
tm_run {
276276
let file_label = #fmt("rusttmp/%s_%s_%u_%u", last_part(filename), thing_label, i, j);
277-
let safe_to_run = !(content_is_dangerous_to_run(str3) || has_raw_pointers(*crate2));
278-
check_whole_compiler(str3, file_label, safe_to_run);
277+
let safe_to_run = !(content_is_dangerous_to_run(*str3) || has_raw_pointers(*crate2));
278+
check_whole_compiler(*str3, file_label, safe_to_run);
279279
}
280280
}
281281
}
@@ -414,7 +414,7 @@ fn check_compiling(filename: str) -> happiness {
414414
}
415415

416416

417-
fn parse_and_print(code: str) -> str {
417+
fn parse_and_print(code: @str) -> str {
418418
let filename = "tmp.rs";
419419
let cm = codemap::new_codemap();
420420
let handler = diagnostic::mk_handler(none);
@@ -425,14 +425,14 @@ fn parse_and_print(code: str) -> str {
425425
mutable chpos: 0u,
426426
mutable byte_pos: 0u
427427
};
428-
write_file(filename, code);
428+
write_file(filename, *code);
429429
let crate = parser::parse_crate_from_source_str(
430430
filename, code, [], sess);
431431
ret as_str(bind pprust::print_crate(sess.cm,
432432
sess.span_diagnostic,
433433
crate,
434434
filename,
435-
io::string_reader(code), _,
435+
io::string_reader(*code), _,
436436
pprust::no_ann()));
437437
}
438438

@@ -506,16 +506,16 @@ fn file_might_not_converge(filename: str) -> bool {
506506
ret false;
507507
}
508508

509-
fn check_roundtrip_convergence(code: str, maxIters: uint) {
509+
fn check_roundtrip_convergence(code: @str, maxIters: uint) {
510510

511511
let i = 0u;
512512
let new = code;
513513
let old = code;
514514

515515
while i < maxIters {
516516
old = new;
517-
if content_might_not_converge(old) { ret; }
518-
new = parse_and_print(old);
517+
if content_might_not_converge(*old) { ret; }
518+
new = @parse_and_print(old);
519519
if old == new { break; }
520520
i += 1u;
521521
}
@@ -524,8 +524,8 @@ fn check_roundtrip_convergence(code: str, maxIters: uint) {
524524
#error("Converged after %u iterations", i);
525525
} else {
526526
#error("Did not converge after %u iterations!", i);
527-
write_file("round-trip-a.rs", old);
528-
write_file("round-trip-b.rs", new);
527+
write_file("round-trip-a.rs", *old);
528+
write_file("round-trip-b.rs", *new);
529529
std::run::run_program("diff",
530530
["-w", "-u", "round-trip-a.rs",
531531
"round-trip-b.rs"]);
@@ -537,8 +537,8 @@ fn check_convergence(files: [str]) {
537537
#error("pp convergence tests: %u files", vec::len(files));
538538
for file in files {
539539
if !file_might_not_converge(file) {
540-
let s = result::get(io::read_whole_file_str(file));
541-
if !content_might_not_converge(s) {
540+
let s = @result::get(io::read_whole_file_str(file));
541+
if !content_might_not_converge(*s) {
542542
#error("pp converge: %s", file);
543543
// Change from 7u to 2u once https://github.com/graydon/rust/issues/850 is fixed
544544
check_roundtrip_convergence(s, 7u);
@@ -554,14 +554,14 @@ fn check_variants(files: [str], cx: context) {
554554
cont;
555555
}
556556

557-
let s = result::get(io::read_whole_file_str(file));
558-
if contains(s, "#") {
557+
let s = @result::get(io::read_whole_file_str(file));
558+
if contains(*s, "#") {
559559
cont; // Macros are confusing
560560
}
561-
if cx.mode == tm_converge && content_might_not_converge(s) {
561+
if cx.mode == tm_converge && content_might_not_converge(*s) {
562562
cont;
563563
}
564-
if cx.mode == tm_run && content_is_dangerous_to_compile(s) {
564+
if cx.mode == tm_run && content_is_dangerous_to_compile(*s) {
565565
cont;
566566
}
567567

@@ -584,7 +584,7 @@ fn check_variants(files: [str], cx: context) {
584584
sess.span_diagnostic,
585585
crate,
586586
file,
587-
io::string_reader(s), _,
587+
io::string_reader(*s), _,
588588
pprust::no_ann())));
589589
check_variants_of_ast(*crate, sess.cm, file, cx);
590590
}

0 commit comments

Comments
 (0)