lexer: Tiny improvement to shebang detection

Lexer now discerns between regular comments and doc comments, so use that.
The change only affects the choice of reported errors.
This commit is contained in:
Vadim Petrochenkov 2020-09-02 00:22:47 +03:00
parent eb9e7c357e
commit b1491eacfc
3 changed files with 14 additions and 13 deletions

View file

@ -1,6 +1,3 @@
#!///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.
//~^ ERROR expected item, found `[`

View file

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