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:
commit
32481bc80a
3 changed files with 32 additions and 19 deletions
6
src/test/ui/parser/shebang/shebang-doc-comment.rs
Normal file
6
src/test/ui/parser/shebang/shebang-doc-comment.rs
Normal 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.
|
||||
8
src/test/ui/parser/shebang/shebang-doc-comment.stderr
Normal file
8
src/test/ui/parser/shebang/shebang-doc-comment.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue