Skip to content

using librustc fails when trying to compile a second time #19371

Closed
@jaredly

Description

@jaredly

The first time it works just fine, but it seems there's some global state somewhere that's messing with the parser. Here's the code: http://is.gd/K0dYsK

The main looks like:

fn main() {
    println!("Start");
    let src = "fn main() { println!(\"Awesome\"); }".to_string();

    let out = Path::new("/tmp/awesome".to_string());

    compile(src.clone(), out.clone(), None);

    println!("[[first worked]]");

    //this should work too, but it seems there's some state being held on to somewere, in the parser?
    compile(src.clone(), out.clone(), None);

    println!("[[second worked]]")
}

And the error is:

<anon>:1:1: 1:3 error: expected item, found `fn`
<anon>:1 fn main() { println!("Awesome"); }
         ^~
task '<main>' panicked at 'Box<Any>', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:86
playpen: application terminated with error code 101

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an AST

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions