Skip to content

Tolerate malformed comments in shebang lookahead - #2331

Merged
traviscross merged 1 commit into
masterfrom
TC/fix-shebang-grammar
Aug 18, 2026
Merged

Tolerate malformed comments in shebang lookahead#2331
traviscross merged 1 commit into
masterfrom
TC/fix-shebang-grammar

Conversation

@traviscross

Copy link
Copy Markdown
Contributor

Our SHEBANG rule did not accept #!/*, even though that's a valid shebang per rustc. The trouble is the interaction between the negative lookahead and the cut within BLOCK_COMMENT: the cut forces an immediate error even within the context of a negative lookahead. We rely on that semantic elsewhere.

To fix this, let's add a SHEBANG_BLOCK_COMMENT rule that accepts what rustc does.

cc @ehuss

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 18, 2026
Our `SHEBANG` rule did not accept `#!/*`, even though that's a valid
shebang per `rustc`.  The trouble is the interaction between the
negative lookahead and the cut within `BLOCK_COMMENT`: the cut forces
an immediate error even within the context of a negative lookahead.
We rely on that semantic elsewhere.

To fix this, let's add a `SHEBANG_BLOCK_COMMENT` rule that accepts
what `rustc` does.
@traviscross
traviscross force-pushed the TC/fix-shebang-grammar branch from c0e1d10 to 853831a Compare August 18, 2026 23:25
@traviscross traviscross changed the title Make the shebang lookahead tolerate malformed comments Tolerate malformed comments in shebang lookahead Aug 18, 2026
@traviscross

Copy link
Copy Markdown
Contributor Author

cc @mattheww

@traviscross

Copy link
Copy Markdown
Contributor Author

cc #2325

@traviscross traviscross removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 18, 2026
@traviscross
traviscross added this pull request to the merge queue Aug 18, 2026
@traviscross

Copy link
Copy Markdown
Contributor Author

Thanks again, @mattheww, for flagging the divergences here.

Merged via the queue into master with commit 3b38834 Aug 18, 2026
7 checks passed
@mattheww

Copy link
Copy Markdown
Contributor

I think given this change, commit 5b328bc from #2330 is unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants