Skip to content
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

Provide helpful diagnostics for shebang lookalikes #137619

Merged
merged 1 commit into from
Mar 14, 2025

Conversation

Pyr0de
Copy link
Contributor

@Pyr0de Pyr0de commented Feb 25, 2025

When [ is not found after a #!, a note will be added to the exisiting error

error: expected `[`, found `/`
 --> src/main.rs:2:3
  |
2 | #!/usr/bin/env -S cargo +nightly -Zscript
  |   ^ expected `[`
  |
  = note: the token sequence `#!` here looks like the start of a shebang interpreter directive but it is not
  = help: if you meant this to be a shebang interpreter directive, move it to the very start of the file

Fixes #137249

r? @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 25, 2025
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an ui test for this

@rust-log-analyzer

This comment has been minimized.

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2025
@Pyr0de Pyr0de force-pushed the issue_137249 branch 2 times, most recently from a5be7fa to c748002 Compare February 27, 2025 06:49
@Pyr0de Pyr0de requested a review from fmease February 28, 2025 08:48
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 28, 2025
Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good! Sorry for the wait. Some small comments

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 11, 2025
@Pyr0de Pyr0de requested a review from fmease March 13, 2025 16:42
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 13, 2025
@fmease
Copy link
Member

fmease commented Mar 14, 2025

Thanks, I love it! @bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 14, 2025

📌 Commit a73e44b has been approved by fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 14, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 14, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang#134720 (Display valid crate types in error message for --crate-type flag)
 - rust-lang#137619 (Provide helpful diagnostics for shebang lookalikes)
 - rust-lang#138353 (remove must_use from <*const T>::expose_provenance)
 - rust-lang#138452 (Remove `RUN_CHECK_WITH_PARALLEL_QUERIES`)
 - rust-lang#138469 (remove comment regarding a removed test directive)
 - rust-lang#138477 (Deny impls for `BikeshedGuaranteedNoDrop`)
 - rust-lang#138485 (Rustc dev guide subtree update)
 - rust-lang#138487 (Pass `CI_JOB_DOC_URL` to Docker)
 - rust-lang#138495 (Take a break from reviews)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 881d237 into rust-lang:master Mar 14, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 14, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 14, 2025
Rollup merge of rust-lang#137619 - Pyr0de:issue_137249, r=fmease

Provide helpful diagnostics for shebang lookalikes

When `[` is not found after a `#!`, a note will be added to the exisiting error

```
error: expected `[`, found `/`
 --> src/main.rs:2:3
  |
2 | #!/usr/bin/env -S cargo +nightly -Zscript
  |   ^ expected `[`
  |
  = note: the token sequence `#!` here looks like the start of a shebang interpreter directive but it is not
  = help: if you meant this to be a shebang interpreter directive, move it to the very start of the file
```

Fixes rust-lang#137249

r? `@fmease`
@Pyr0de Pyr0de deleted the issue_137249 branch March 16, 2025 07:55
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Mar 19, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang#134720 (Display valid crate types in error message for --crate-type flag)
 - rust-lang#137619 (Provide helpful diagnostics for shebang lookalikes)
 - rust-lang#138353 (remove must_use from <*const T>::expose_provenance)
 - rust-lang#138452 (Remove `RUN_CHECK_WITH_PARALLEL_QUERIES`)
 - rust-lang#138469 (remove comment regarding a removed test directive)
 - rust-lang#138477 (Deny impls for `BikeshedGuaranteedNoDrop`)
 - rust-lang#138485 (Rustc dev guide subtree update)
 - rust-lang#138487 (Pass `CI_JOB_DOC_URL` to Docker)
 - rust-lang#138495 (Take a break from reviews)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a more helpful diagnostic on "shebang lookalikes" (and soon "frontmatter lookalikes" too)
6 participants