Rollup merge of #72757 - petrochenkov:shebang, r=varkor

rustc_lexer: Optimize shebang detection slightly

Sorry, I just couldn't resist.
It shouldn't make any difference in practice.

Also, documented a previously unnoticed case with doc comments treated as regular comments during shebang detection.
This commit is contained in:
Ralf Jung 2020-05-30 23:08:58 +02:00 committed by GitHub
commit 32481bc80a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 19 deletions

View file

@ -0,0 +1,6 @@
#!///bin/bash
[allow(unused_variables)]
//~^^ ERROR expected `[`, found doc comment
// Doc comment is misinterpreted as a whitespace (regular comment) during shebang detection.
// Even if it wasn't, it would still result in an error, just a different one.

View file

@ -0,0 +1,8 @@
error: expected `[`, found doc comment `///bin/bash`
--> $DIR/shebang-doc-comment.rs:1:3
|
LL | #!///bin/bash
| ^^^^^^^^^^^ expected `[`
error: aborting due to previous error