-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo
(for cargo script) and rustc disagee on shebangs
#15170
Comments
The key problem is Ours is implemented to the textual description ( Part of our intention with the frontmatter syntax is we don't have to have a full Rust parser, so I worry about having to deal with some of this extra syntax. |
An example of something that rustc considers to not have a shebang: #!// Hello
[allow(dead_code)]
fn main() {
println!("Hello, world!");
} I lean towards
|
rustc considers the following valid and without a shebang: ```rust // Hello [allow(dead_code)] fn main() { println!("Hello, world!"); } ``` and ```rustc [allow(dead_code)] fn main() { println!("Hello, world!"); } ``` In both cases, we consider it to have a shebang. This commit documents that intention. We could add our own heuristics (e.g. `#!` with only whitespace is not a shebang) but we should either be a subset or intentionally different than rustc (e.g. require a non `[`-prefixes interpreter) rather than do both. This will be reflected in the tracking issue which will handle the final decision for the team on this matter. Fixes rust-lang#15170
### What does this PR try to resolve? rustc considers the following valid and without a shebang: ```rust // Hello [allow(dead_code)] fn main() { println!("Hello, world!"); } ``` and ```rustc [allow(dead_code)] fn main() { println!("Hello, world!"); } ``` In both cases, we consider it to have a shebang. This commit documents that intention. We could add our own heuristics (e.g. `#!` with only whitespace is not a shebang) but we should either be a subset or intentionally different than rustc (e.g. require a non `[`-prefixes interpreter) rather than do both. Fixes #15170 ### How should we test and review this PR? This will be reflected in the tracking issue which will handle the final decision for the team on this matter. ### Additional information
Rustc has logic to detect and ignore shebangs
https://github.com/rust-lang/rust/blob/6171d944aea415a3023d4262e0895aa3b18c771f/compiler/rustc_lexer/src/lib.rs#L255-L278
Cargo needs something similar for knowing whether we should look for a frontmatter
cargo/src/cargo/util/toml/embedded.rs
Lines 195 to 215 in e3fa31e
These differ and we need to decide how we want to reconcile these
Originally reported in #14857 (comment)
The text was updated successfully, but these errors were encountered: