Skip to content

Commit

Permalink
parse_crate_from_source_str takes a parse_sess, not codemap
Browse files Browse the repository at this point in the history
This was causing problems when reading from stdin for subsequent passes that
needed to generate node ids.
  • Loading branch information
brson committed Aug 3, 2011
1 parent 97a8784 commit e4da7c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/comp/driver/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn parse_input_src(sess: session::session, cfg: &ast::crate_cfg,
}.read_whole_stream();
let src = str::unsafe_from_bytes_ivec(srcbytes);
let crate = parser::parse_crate_from_source_str(infile, src, cfg,
sess.get_codemap());
sess.get_parse_sess());
ret {crate: crate, src: src};
}

Expand Down
3 changes: 1 addition & 2 deletions src/comp/syntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2317,8 +2317,7 @@ fn parse_crate_from_source_file(input: &str, cfg: &ast::crate_cfg,
}

fn parse_crate_from_source_str(name: &str, source: &str, cfg: &ast::crate_cfg,
cm: &codemap::codemap) -> @ast::crate {
let sess = @{cm: cm, mutable next_id: 0};
sess: &parse_sess) -> @ast::crate {
let ftype = SOURCE_FILE;
let filemap = codemap::new_filemap(name, 0u, 0u);
sess.cm.files += ~[filemap];
Expand Down
14 changes: 7 additions & 7 deletions src/fuzzer/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ fn check_whole_compiler(code: &str) {

fn parse_and_print(code: &str) -> str {
let filename = "tmp.rs";
let codemap = codemap::new_codemap();
let sess = @{cm: codemap::new_codemap(), mutable next_id: 0};
//write_file(filename, code);
let crate =
parser::parse_crate_from_source_str(filename, code, ~[], codemap);
ret as_str(bind pprust::print_crate(codemap, crate, filename,
parser::parse_crate_from_source_str(filename, code, ~[], sess);
ret as_str(bind pprust::print_crate(sess.cm, crate, filename,
ioivec::string_reader(code), _,
pprust::no_ann()));
}
Expand Down Expand Up @@ -336,12 +336,12 @@ fn check_variants(files: &str[]) {
let s = ioivec::read_whole_file_str(file);
if content_is_dangerous_to_modify(s) || content_is_confusing(s) { cont; }
log_err "check_variants: " + file;
let codemap = codemap::new_codemap();
let crate = parser::parse_crate_from_source_str(file, s, ~[], codemap);
log_err as_str(bind pprust::print_crate(codemap, crate, file,
let sess = @{cm: codemap::new_codemap(), mutable next_id: 0};
let crate = parser::parse_crate_from_source_str(file, s, ~[], sess);
log_err as_str(bind pprust::print_crate(sess.cm, crate, file,
ioivec::string_reader(s), _,
pprust::no_ann()));
check_variants_of_ast(*crate, codemap, file);
check_variants_of_ast(*crate, sess.cm, file);
}
}
}
Expand Down

0 comments on commit e4da7c5

Please sign in to comment.