about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-05-30 23:08:58 +0200
committerGitHub <noreply@github.com>2020-05-30 23:08:58 +0200
commit32481bc80ada911e638cde861d17eddc8338d49a (patch)
treeda8e13f64c13a96a09f37c28b2cd85d70296d1cc /src/test
parent8f1c0d0a10761b70d74bec7a537a25cb54f42b61 (diff)
parent21755b58c900cd5d14422ebd980fe11390e021fe (diff)
downloadrust-32481bc80ada911e638cde861d17eddc8338d49a.tar.gz
rust-32481bc80ada911e638cde861d17eddc8338d49a.zip
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.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/parser/shebang/shebang-doc-comment.rs6
-rw-r--r--src/test/ui/parser/shebang/shebang-doc-comment.stderr8
2 files changed, 14 insertions, 0 deletions
diff --git a/src/test/ui/parser/shebang/shebang-doc-comment.rs b/src/test/ui/parser/shebang/shebang-doc-comment.rs
new file mode 100644
index 00000000000..7dbb9eebc75
--- /dev/null
+++ b/src/test/ui/parser/shebang/shebang-doc-comment.rs
@@ -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.
diff --git a/src/test/ui/parser/shebang/shebang-doc-comment.stderr b/src/test/ui/parser/shebang/shebang-doc-comment.stderr
new file mode 100644
index 00000000000..f524f556837
--- /dev/null
+++ b/src/test/ui/parser/shebang/shebang-doc-comment.stderr
@@ -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
+