Skip to content

Shebangs as comments #1772

@mcandre

Description

@mcandre

Can we treat shebangs as comments for those who like doing #!/usr/bin/env rustx?

It would be nice to compile or interpret the same Rust code as desired, but currently, when you try to compile Rust code with a shebang, you get an ugly syntax error.

hello.rs:

#!/usr/bin/env rustx

use std;

fn main() {
    std::io::println("Hello World!");
}

expected output:

$ rustc hello.rs 
$ ./hello
Hello World!

actual output:

$ rustc hello.rs 
hello.rs:1:1: 1:2 error: expecting '[' but found '!'
hello.rs:1 #!/usr/bin/env rustx

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions