Revert "Eliminate a copy in syntax::parse::new_parser_from_file"
This reverts commit 2bb3b63ec4
.
(I was confused.)
This commit is contained in:
parent
2bb3b63ec4
commit
85fbfa25d7
15 changed files with 43 additions and 88 deletions
|
@ -271,7 +271,7 @@ fn check_variants_T<T: copy>(
|
||||||
// testing the string for stability is easier and ok for now.
|
// testing the string for stability is easier and ok for now.
|
||||||
let handler = diagnostic::mk_handler(none);
|
let handler = diagnostic::mk_handler(none);
|
||||||
let str3 =
|
let str3 =
|
||||||
~as_str(bind pprust::print_crate(
|
@as_str(bind pprust::print_crate(
|
||||||
codemap,
|
codemap,
|
||||||
diagnostic::mk_span_handler(handler, codemap),
|
diagnostic::mk_span_handler(handler, codemap),
|
||||||
crate2,
|
crate2,
|
||||||
|
@ -417,7 +417,7 @@ fn check_compiling(filename: str) -> happiness {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn parse_and_print(code: ~str) -> str {
|
fn parse_and_print(code: @str) -> str {
|
||||||
let filename = "tmp.rs";
|
let filename = "tmp.rs";
|
||||||
let cm = codemap::new_codemap();
|
let cm = codemap::new_codemap();
|
||||||
let handler = diagnostic::mk_handler(none);
|
let handler = diagnostic::mk_handler(none);
|
||||||
|
@ -507,7 +507,7 @@ fn file_might_not_converge(filename: str) -> bool {
|
||||||
ret false;
|
ret false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_roundtrip_convergence(+code: ~str, maxIters: uint) {
|
fn check_roundtrip_convergence(code: @str, maxIters: uint) {
|
||||||
|
|
||||||
let mut i = 0u;
|
let mut i = 0u;
|
||||||
let mut newv = code;
|
let mut newv = code;
|
||||||
|
@ -516,7 +516,7 @@ fn check_roundtrip_convergence(+code: ~str, maxIters: uint) {
|
||||||
while i < maxIters {
|
while i < maxIters {
|
||||||
oldv = newv;
|
oldv = newv;
|
||||||
if content_might_not_converge(*oldv) { ret; }
|
if content_might_not_converge(*oldv) { ret; }
|
||||||
newv = ~parse_and_print(oldv);
|
newv = @parse_and_print(oldv);
|
||||||
if oldv == newv { break; }
|
if oldv == newv { break; }
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
|
@ -538,7 +538,7 @@ fn check_convergence(files: [str]) {
|
||||||
#error("pp convergence tests: %u files", vec::len(files));
|
#error("pp convergence tests: %u files", vec::len(files));
|
||||||
for files.each {|file|
|
for files.each {|file|
|
||||||
if !file_might_not_converge(file) {
|
if !file_might_not_converge(file) {
|
||||||
let s = ~result::get(io::read_whole_file_str(file));
|
let s = @result::get(io::read_whole_file_str(file));
|
||||||
if !content_might_not_converge(*s) {
|
if !content_might_not_converge(*s) {
|
||||||
#error("pp converge: %s", file);
|
#error("pp converge: %s", file);
|
||||||
// Change from 7u to 2u once
|
// Change from 7u to 2u once
|
||||||
|
@ -557,7 +557,7 @@ fn check_variants(files: [str], cx: context) {
|
||||||
cont;
|
cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
let s = ~result::get(io::read_whole_file_str(file));
|
let s = @result::get(io::read_whole_file_str(file));
|
||||||
if contains(*s, "#") {
|
if contains(*s, "#") {
|
||||||
cont; // Macros are confusing
|
cont; // Macros are confusing
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ mod std {
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
A standard function to use to indicate unreachable code. Because the
|
A standard function to use to indicate unreachable code. Because the
|
||||||
function is guaranteed to fail, typestate will correctly identify
|
function is guaranteed to fail typestate will correctly identify
|
||||||
any code paths following the appearance of this function as unreachable.
|
any code paths following the appearance of this function as unreachable.
|
||||||
"]
|
"]
|
||||||
fn unreachable() -> ! {
|
fn unreachable() -> ! {
|
||||||
|
|
|
@ -650,24 +650,6 @@ fn read_whole_file_str(file: str) -> result<str, str> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Returns the result as a unique boxed string rather than a string
|
|
||||||
*/
|
|
||||||
fn read_whole_file_ref(file: str) -> result<~str, str> {
|
|
||||||
let f = os::as_c_charp(file, {|pathbuf|
|
|
||||||
os::as_c_charp("r", {|modebuf|
|
|
||||||
libc::fopen(pathbuf, modebuf)
|
|
||||||
})
|
|
||||||
});
|
|
||||||
ret if f as uint == 0u { result::err("error opening " + file) }
|
|
||||||
else unsafe {
|
|
||||||
let buf : ~mut [const u8] = ~mut [const];
|
|
||||||
let self = FILE_reader(f, true);
|
|
||||||
while (!self.eof()) { *buf += self.read_bytes(2048u); }
|
|
||||||
result::ok(str::unsafe::from_bytes_move(buf))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME implement this in a low-level way. Going through the abstractions is
|
// FIXME implement this in a low-level way. Going through the abstractions is
|
||||||
// pointless. // #2004
|
// pointless. // #2004
|
||||||
fn read_whole_file(file: str) -> result<[u8], str> {
|
fn read_whole_file(file: str) -> result<[u8], str> {
|
||||||
|
|
|
@ -123,19 +123,6 @@ fn from_bytes(vv: [u8]) -> str unsafe {
|
||||||
ret unsafe::from_bytes(vv);
|
ret unsafe::from_bytes(vv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "
|
|
||||||
Convert a unique vector of bytes (passed by move)
|
|
||||||
to a unique boxed UTF-8 string
|
|
||||||
|
|
||||||
# Failure
|
|
||||||
|
|
||||||
Fails if invalid UTF-8
|
|
||||||
"]
|
|
||||||
fn from_bytes_move(-vv: ~mut [const u8]) -> ~str unsafe {
|
|
||||||
assert is_utf8(::unsafe::reinterpret_cast(vv));
|
|
||||||
ret unsafe::from_bytes_move(vv);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
Convert a byte to a UTF-8 string
|
Convert a byte to a UTF-8 string
|
||||||
|
|
||||||
|
@ -1644,7 +1631,6 @@ mod unsafe {
|
||||||
from_buf,
|
from_buf,
|
||||||
from_c_str,
|
from_c_str,
|
||||||
from_bytes,
|
from_bytes,
|
||||||
from_bytes_move,
|
|
||||||
slice_bytes,
|
slice_bytes,
|
||||||
push_byte,
|
push_byte,
|
||||||
pop_byte,
|
pop_byte,
|
||||||
|
@ -1699,13 +1685,6 @@ mod unsafe {
|
||||||
ret scopy;
|
ret scopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn from_bytes_move(-v: ~mut [const u8]) -> ~str unsafe {
|
|
||||||
*v += [0u8];
|
|
||||||
let s: ~str = ::unsafe::reinterpret_cast(v);
|
|
||||||
::unsafe::forget(v);
|
|
||||||
s
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
Converts a byte to a string.
|
Converts a byte to a string.
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ enum file_substr {
|
||||||
}
|
}
|
||||||
|
|
||||||
type filemap =
|
type filemap =
|
||||||
@{name: filename, substr: file_substr, src: ~str,
|
@{name: filename, substr: file_substr, src: @str,
|
||||||
start_pos: file_pos, mut lines: [file_pos]};
|
start_pos: file_pos, mut lines: [file_pos]};
|
||||||
|
|
||||||
type codemap = @{mut files: [filemap]};
|
type codemap = @{mut files: [filemap]};
|
||||||
|
@ -48,7 +48,7 @@ type loc = {file: filemap, line: uint, col: uint};
|
||||||
fn new_codemap() -> codemap { @{mut files: [] } }
|
fn new_codemap() -> codemap { @{mut files: [] } }
|
||||||
|
|
||||||
fn new_filemap_w_substr(filename: filename, substr: file_substr,
|
fn new_filemap_w_substr(filename: filename, substr: file_substr,
|
||||||
-src: ~str,
|
src: @str,
|
||||||
start_pos_ch: uint, start_pos_byte: uint)
|
start_pos_ch: uint, start_pos_byte: uint)
|
||||||
-> filemap {
|
-> filemap {
|
||||||
ret @{name: filename, substr: substr, src: src,
|
ret @{name: filename, substr: substr, src: src,
|
||||||
|
@ -56,7 +56,7 @@ fn new_filemap_w_substr(filename: filename, substr: file_substr,
|
||||||
mut lines: [{ch: start_pos_ch, byte: start_pos_byte}]};
|
mut lines: [{ch: start_pos_ch, byte: start_pos_byte}]};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_filemap(filename: filename, -src: ~str,
|
fn new_filemap(filename: filename, src: @str,
|
||||||
start_pos_ch: uint, start_pos_byte: uint)
|
start_pos_ch: uint, start_pos_byte: uint)
|
||||||
-> filemap {
|
-> filemap {
|
||||||
ret new_filemap_w_substr(filename, fss_none, src,
|
ret new_filemap_w_substr(filename, fss_none, src,
|
||||||
|
|
|
@ -121,7 +121,7 @@ fn expand_crate(parse_sess: parse::parse_sess,
|
||||||
with *afp};
|
with *afp};
|
||||||
let f = make_fold(f_pre);
|
let f = make_fold(f_pre);
|
||||||
let cm = parse_expr_from_source_str("<core-macros>",
|
let cm = parse_expr_from_source_str("<core-macros>",
|
||||||
~core_macros(),
|
@core_macros(),
|
||||||
cfg,
|
cfg,
|
||||||
parse_sess);
|
parse_sess);
|
||||||
|
|
||||||
|
|
|
@ -73,22 +73,20 @@ fn parse_crate_from_source_file(input: str, cfg: ast::crate_cfg,
|
||||||
ret r;
|
ret r;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_crate_from_source_str(name: str, source: ~str,
|
fn parse_crate_from_source_str(name: str, source: @str, cfg: ast::crate_cfg,
|
||||||
cfg: ast::crate_cfg, sess: parse_sess) -> @ast::crate {
|
sess: parse_sess) -> @ast::crate {
|
||||||
// FIXME: Get rid of copy once there's a snapshot
|
|
||||||
let p = new_parser_from_source_str(
|
let p = new_parser_from_source_str(
|
||||||
sess, cfg, name, codemap::fss_none, @(*source));
|
sess, cfg, name, codemap::fss_none, source);
|
||||||
let r = parser::parse_crate_mod(p, cfg);
|
let r = parser::parse_crate_mod(p, cfg);
|
||||||
sess.chpos = p.reader.chpos;
|
sess.chpos = p.reader.chpos;
|
||||||
sess.byte_pos = sess.byte_pos + p.reader.pos;
|
sess.byte_pos = sess.byte_pos + p.reader.pos;
|
||||||
ret r;
|
ret r;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_expr_from_source_str(name: str, source: ~str,
|
fn parse_expr_from_source_str(name: str, source: @str, cfg: ast::crate_cfg,
|
||||||
cfg: ast::crate_cfg, sess: parse_sess) -> @ast::expr {
|
sess: parse_sess) -> @ast::expr {
|
||||||
// FIXME: Get rid of copy once there's a snapshot
|
|
||||||
let p = new_parser_from_source_str(
|
let p = new_parser_from_source_str(
|
||||||
sess, cfg, name, codemap::fss_none, @(*source));
|
sess, cfg, name, codemap::fss_none, source);
|
||||||
let r = parser::parse_expr(p);
|
let r = parser::parse_expr(p);
|
||||||
sess.chpos = p.reader.chpos;
|
sess.chpos = p.reader.chpos;
|
||||||
sess.byte_pos = sess.byte_pos + p.reader.pos;
|
sess.byte_pos = sess.byte_pos + p.reader.pos;
|
||||||
|
@ -136,15 +134,12 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader,
|
||||||
restricted_keywords: token::restricted_keyword_table()}
|
restricted_keywords: token::restricted_keyword_table()}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: still taking an @ b/c #ast using this.
|
|
||||||
Fix when there's a snapshot */
|
|
||||||
fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg,
|
fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg,
|
||||||
name: str, ss: codemap::file_substr,
|
name: str, ss: codemap::file_substr,
|
||||||
source: @str) -> parser {
|
source: @str) -> parser {
|
||||||
let ftype = parser::SOURCE_FILE;
|
let ftype = parser::SOURCE_FILE;
|
||||||
let filemap = codemap::new_filemap_w_substr
|
let filemap = codemap::new_filemap_w_substr
|
||||||
// FIXME: remove copy once there's a new snap
|
(name, ss, source, sess.chpos, sess.byte_pos);
|
||||||
(name, ss, ~(*source), sess.chpos, sess.byte_pos);
|
|
||||||
sess.cm.files += [filemap];
|
sess.cm.files += [filemap];
|
||||||
let itr = @interner::mk(str::hash, str::eq);
|
let itr = @interner::mk(str::hash, str::eq);
|
||||||
let rdr = lexer::new_reader(sess.span_diagnostic,
|
let rdr = lexer::new_reader(sess.span_diagnostic,
|
||||||
|
@ -153,10 +148,12 @@ fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, path: str,
|
fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, path: str,
|
||||||
ftype: parser::file_type) -> parser {
|
ftype: parser::file_type) ->
|
||||||
let src = alt io::read_whole_file_ref(path) {
|
parser {
|
||||||
|
let src = alt io::read_whole_file_str(path) {
|
||||||
result::ok(src) {
|
result::ok(src) {
|
||||||
src
|
// FIXME: This copy is unfortunate
|
||||||
|
@src
|
||||||
}
|
}
|
||||||
result::err(e) {
|
result::err(e) {
|
||||||
sess.span_diagnostic.handler().fatal(e)
|
sess.span_diagnostic.handler().fatal(e)
|
||||||
|
|
|
@ -154,7 +154,7 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
|
||||||
path: str,
|
path: str,
|
||||||
srdr: io::reader) ->
|
srdr: io::reader) ->
|
||||||
{cmnts: [cmnt], lits: [lit]} {
|
{cmnts: [cmnt], lits: [lit]} {
|
||||||
let src = ~str::from_bytes(srdr.read_whole_stream());
|
let src = @str::from_bytes(srdr.read_whole_stream());
|
||||||
let itr = @interner::mk::<str>(str::hash, str::eq);
|
let itr = @interner::mk::<str>(str::hash, str::eq);
|
||||||
let rdr = new_reader(span_diagnostic,
|
let rdr = new_reader(span_diagnostic,
|
||||||
codemap::new_filemap(path, src, 0u, 0u), itr);
|
codemap::new_filemap(path, src, 0u, 0u), itr);
|
||||||
|
|
|
@ -6,7 +6,7 @@ export reader, new_reader, next_token, is_whitespace;
|
||||||
|
|
||||||
type reader = @{
|
type reader = @{
|
||||||
span_diagnostic: diagnostic::span_handler,
|
span_diagnostic: diagnostic::span_handler,
|
||||||
src: ~str,
|
src: @str,
|
||||||
mut col: uint,
|
mut col: uint,
|
||||||
mut pos: uint,
|
mut pos: uint,
|
||||||
mut curr: char,
|
mut curr: char,
|
||||||
|
|
|
@ -124,7 +124,7 @@ fn to_str(in: interner<str>, t: token) -> str {
|
||||||
|
|
||||||
/* Literals */
|
/* Literals */
|
||||||
LIT_INT(c, ast::ty_char) {
|
LIT_INT(c, ast::ty_char) {
|
||||||
// FIXME: escape. (#2306)
|
// FIXME: escape.
|
||||||
let mut tmp = "'";
|
let mut tmp = "'";
|
||||||
str::push_char(tmp, c as char);
|
str::push_char(tmp, c as char);
|
||||||
str::push_char(tmp, '\'');
|
str::push_char(tmp, '\'');
|
||||||
|
@ -140,7 +140,7 @@ fn to_str(in: interner<str>, t: token) -> str {
|
||||||
ret interner::get::<str>(in, s) +
|
ret interner::get::<str>(in, s) +
|
||||||
ast_util::float_ty_to_str(t);
|
ast_util::float_ty_to_str(t);
|
||||||
}
|
}
|
||||||
LIT_STR(s) { // FIXME: escape. (#2306)
|
LIT_STR(s) { // FIXME: escape.
|
||||||
ret "\"" + interner::get::<str>(in, s) + "\"";
|
ret "\"" + interner::get::<str>(in, s) + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: str)
|
||||||
if !input_is_stdin(input) {
|
if !input_is_stdin(input) {
|
||||||
parse::parse_crate_from_file(input, cfg, sess.parse_sess)
|
parse::parse_crate_from_file(input, cfg, sess.parse_sess)
|
||||||
} else {
|
} else {
|
||||||
let src = ~str::from_bytes(io::stdin().read_whole_stream());
|
let src = @str::from_bytes(io::stdin().read_whole_stream());
|
||||||
parse::parse_crate_from_source_str(input, src, cfg, sess.parse_sess)
|
parse::parse_crate_from_source_str(input, src, cfg, sess.parse_sess)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,7 @@ type ctxt = {
|
||||||
|
|
||||||
type srv_owner<T> = fn(srv: srv) -> T;
|
type srv_owner<T> = fn(srv: srv) -> T;
|
||||||
type ctxt_handler<T> = fn~(ctxt: ctxt) -> T;
|
type ctxt_handler<T> = fn~(ctxt: ctxt) -> T;
|
||||||
/* The idea is that a parser takes an input of type U,
|
type parser = fn~(session::session, str) -> @ast::crate;
|
||||||
which lets us have parsers that either take unboxed or
|
|
||||||
boxed strings. */
|
|
||||||
type parser<U> = fn~(session::session, U) -> @ast::crate;
|
|
||||||
|
|
||||||
enum msg {
|
enum msg {
|
||||||
handle_request(fn~(ctxt)),
|
handle_request(fn~(ctxt)),
|
||||||
|
@ -51,14 +48,14 @@ enum srv = {
|
||||||
};
|
};
|
||||||
|
|
||||||
fn from_str<T>(source: str, owner: srv_owner<T>) -> T {
|
fn from_str<T>(source: str, owner: srv_owner<T>) -> T {
|
||||||
run(owner, ~source, parse::from_str_sess)
|
run(owner, source, parse::from_str_sess)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_file<T>(file: str, owner: srv_owner<T>) -> T {
|
fn from_file<T>(file: str, owner: srv_owner<T>) -> T {
|
||||||
run(owner, file, parse::from_file_sess)
|
run(owner, file, parse::from_file_sess)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run<T, U: send>(owner: srv_owner<T>, +source: U, parse: parser<U>) -> T {
|
fn run<T>(owner: srv_owner<T>, source: str, parse: parser) -> T {
|
||||||
|
|
||||||
let srv_ = srv({
|
let srv_ = srv({
|
||||||
ch: task::spawn_listener {|po|
|
ch: task::spawn_listener {|po|
|
||||||
|
@ -71,7 +68,7 @@ fn run<T, U: send>(owner: srv_owner<T>, +source: U, parse: parser<U>) -> T {
|
||||||
ret res;
|
ret res;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn act<U>(po: comm::port<msg>, source: U, parse: parser<U>) {
|
fn act(po: comm::port<msg>, source: str, parse: parser) {
|
||||||
let (sess, ignore_errors) = build_session();
|
let (sess, ignore_errors) = build_session();
|
||||||
|
|
||||||
let ctxt = build_ctxt(
|
let ctxt = build_ctxt(
|
||||||
|
|
|
@ -289,7 +289,7 @@ fn should_extract_tys() {
|
||||||
mod test {
|
mod test {
|
||||||
|
|
||||||
fn mk_doc(source: str) -> doc::doc {
|
fn mk_doc(source: str) -> doc::doc {
|
||||||
let ast = parse::from_str(~source);
|
let ast = parse::from_str(source);
|
||||||
extract(ast, "")
|
extract(ast, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn extract_should_use_default_crate_name() {
|
fn extract_should_use_default_crate_name() {
|
||||||
let source = ~"";
|
let source = "";
|
||||||
let ast = parse::from_str(source);
|
let ast = parse::from_str(source);
|
||||||
let doc = extract(ast, "burp");
|
let doc = extract(ast, "burp");
|
||||||
assert doc.cratemod().name() == "burp";
|
assert doc.cratemod().name() == "burp";
|
||||||
|
|
|
@ -354,7 +354,7 @@ fn default_seq_fold_type<T>(
|
||||||
#[test]
|
#[test]
|
||||||
fn default_fold_should_produce_same_doc() {
|
fn default_fold_should_produce_same_doc() {
|
||||||
let source = "mod a { fn b() { } mod c { fn d() { } } }";
|
let source = "mod a { fn b() { } mod c { fn d() { } } }";
|
||||||
let ast = parse::from_str(~source);
|
let ast = parse::from_str(source);
|
||||||
let doc = extract::extract(ast, "");
|
let doc = extract::extract(ast, "");
|
||||||
let fld = default_seq_fold(());
|
let fld = default_seq_fold(());
|
||||||
let folded = fld.fold_doc(fld, doc);
|
let folded = fld.fold_doc(fld, doc);
|
||||||
|
@ -364,7 +364,7 @@ fn default_fold_should_produce_same_doc() {
|
||||||
#[test]
|
#[test]
|
||||||
fn default_fold_should_produce_same_consts() {
|
fn default_fold_should_produce_same_consts() {
|
||||||
let source = "const a: int = 0;";
|
let source = "const a: int = 0;";
|
||||||
let ast = parse::from_str(~source);
|
let ast = parse::from_str(source);
|
||||||
let doc = extract::extract(ast, "");
|
let doc = extract::extract(ast, "");
|
||||||
let fld = default_seq_fold(());
|
let fld = default_seq_fold(());
|
||||||
let folded = fld.fold_doc(fld, doc);
|
let folded = fld.fold_doc(fld, doc);
|
||||||
|
@ -374,7 +374,7 @@ fn default_fold_should_produce_same_consts() {
|
||||||
#[test]
|
#[test]
|
||||||
fn default_fold_should_produce_same_enums() {
|
fn default_fold_should_produce_same_enums() {
|
||||||
let source = "enum a { b }";
|
let source = "enum a { b }";
|
||||||
let ast = parse::from_str(~source);
|
let ast = parse::from_str(source);
|
||||||
let doc = extract::extract(ast, "");
|
let doc = extract::extract(ast, "");
|
||||||
let fld = default_seq_fold(());
|
let fld = default_seq_fold(());
|
||||||
let folded = fld.fold_doc(fld, doc);
|
let folded = fld.fold_doc(fld, doc);
|
||||||
|
@ -384,7 +384,7 @@ fn default_fold_should_produce_same_enums() {
|
||||||
#[test]
|
#[test]
|
||||||
fn default_parallel_fold_should_produce_same_doc() {
|
fn default_parallel_fold_should_produce_same_doc() {
|
||||||
let source = "mod a { fn b() { } mod c { fn d() { } } }";
|
let source = "mod a { fn b() { } mod c { fn d() { } } }";
|
||||||
let ast = parse::from_str(~source);
|
let ast = parse::from_str(source);
|
||||||
let doc = extract::extract(ast, "");
|
let doc = extract::extract(ast, "");
|
||||||
let fld = default_par_fold(());
|
let fld = default_par_fold(());
|
||||||
let folded = fld.fold_doc(fld, doc);
|
let folded = fld.fold_doc(fld, doc);
|
||||||
|
|
|
@ -27,18 +27,18 @@ fn from_file(file: str) -> @ast::crate {
|
||||||
file, [], new_parse_sess())
|
file, [], new_parse_sess())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_str(source: ~str) -> @ast::crate {
|
fn from_str(source: str) -> @ast::crate {
|
||||||
parse::parse_crate_from_source_str(
|
parse::parse_crate_from_source_str(
|
||||||
"-", source, [], new_parse_sess())
|
"-", @source, [], new_parse_sess())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_file_sess(sess: session::session, &&file: str) -> @ast::crate {
|
fn from_file_sess(sess: session::session, file: str) -> @ast::crate {
|
||||||
parse::parse_crate_from_file(file, cfg(sess), sess.parse_sess)
|
parse::parse_crate_from_file(file, cfg(sess), sess.parse_sess)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_str_sess(sess: session::session, &&source: ~str) -> @ast::crate {
|
fn from_str_sess(sess: session::session, source: str) -> @ast::crate {
|
||||||
parse::parse_crate_from_source_str(
|
parse::parse_crate_from_source_str(
|
||||||
"-", source, cfg(sess), sess.parse_sess)
|
"-", @source, cfg(sess), sess.parse_sess)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cfg(sess: session::session) -> ast::crate_cfg {
|
fn cfg(sess: session::session) -> ast::crate_cfg {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue