summaryrefslogtreecommitdiffstats
path: root/tests/ui/parser/shebang
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/parser/shebang
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/parser/shebang')
-rw-r--r--tests/ui/parser/shebang/issue-71471-ignore-tidy.rs2
-rw-r--r--tests/ui/parser/shebang/issue-71471-ignore-tidy.stderr8
-rw-r--r--tests/ui/parser/shebang/multiline-attrib.rs7
-rw-r--r--tests/ui/parser/shebang/regular-attrib.rs5
-rw-r--r--tests/ui/parser/shebang/shebang-and-attrib.rs9
-rw-r--r--tests/ui/parser/shebang/shebang-comment.rs6
-rw-r--r--tests/ui/parser/shebang/shebang-doc-comment.rs3
-rw-r--r--tests/ui/parser/shebang/shebang-doc-comment.stderr8
-rw-r--r--tests/ui/parser/shebang/shebang-empty.rs4
-rw-r--r--tests/ui/parser/shebang/shebang-must-start-file.rs6
-rw-r--r--tests/ui/parser/shebang/shebang-must-start-file.stderr8
-rw-r--r--tests/ui/parser/shebang/shebang-space.rs5
-rw-r--r--tests/ui/parser/shebang/sneaky-attrib.rs16
-rw-r--r--tests/ui/parser/shebang/valid-shebang.rs6
14 files changed, 93 insertions, 0 deletions
diff --git a/tests/ui/parser/shebang/issue-71471-ignore-tidy.rs b/tests/ui/parser/shebang/issue-71471-ignore-tidy.rs
new file mode 100644
index 000000000..a25051808
--- /dev/null
+++ b/tests/ui/parser/shebang/issue-71471-ignore-tidy.rs
@@ -0,0 +1,2 @@
+
+#!B //~ expected `[`, found `B`
diff --git a/tests/ui/parser/shebang/issue-71471-ignore-tidy.stderr b/tests/ui/parser/shebang/issue-71471-ignore-tidy.stderr
new file mode 100644
index 000000000..896a9dc83
--- /dev/null
+++ b/tests/ui/parser/shebang/issue-71471-ignore-tidy.stderr
@@ -0,0 +1,8 @@
+error: expected `[`, found `B`
+ --> $DIR/issue-71471-ignore-tidy.rs:2:3
+ |
+LL | #!B
+ | ^ expected `[`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/parser/shebang/multiline-attrib.rs b/tests/ui/parser/shebang/multiline-attrib.rs
new file mode 100644
index 000000000..931c94c7f
--- /dev/null
+++ b/tests/ui/parser/shebang/multiline-attrib.rs
@@ -0,0 +1,7 @@
+#!
+[allow(unused_variables)]
+// check-pass
+
+fn main() {
+ let x = 5;
+}
diff --git a/tests/ui/parser/shebang/regular-attrib.rs b/tests/ui/parser/shebang/regular-attrib.rs
new file mode 100644
index 000000000..ca8fb0830
--- /dev/null
+++ b/tests/ui/parser/shebang/regular-attrib.rs
@@ -0,0 +1,5 @@
+#![allow(unused_variables)]
+// check-pass
+fn main() {
+ let x = 5;
+}
diff --git a/tests/ui/parser/shebang/shebang-and-attrib.rs b/tests/ui/parser/shebang/shebang-and-attrib.rs
new file mode 100644
index 000000000..61b89c655
--- /dev/null
+++ b/tests/ui/parser/shebang/shebang-and-attrib.rs
@@ -0,0 +1,9 @@
+#!/usr/bin/env run-cargo-script
+
+// check-pass
+#![allow(unused_variables)]
+
+
+fn main() {
+ let x = 5;
+}
diff --git a/tests/ui/parser/shebang/shebang-comment.rs b/tests/ui/parser/shebang/shebang-comment.rs
new file mode 100644
index 000000000..2b1ab0c57
--- /dev/null
+++ b/tests/ui/parser/shebang/shebang-comment.rs
@@ -0,0 +1,6 @@
+#!//bin/bash
+
+// check-pass
+fn main() {
+ println!("a valid shebang (that is also a rust comment)")
+}
diff --git a/tests/ui/parser/shebang/shebang-doc-comment.rs b/tests/ui/parser/shebang/shebang-doc-comment.rs
new file mode 100644
index 000000000..72866753e
--- /dev/null
+++ b/tests/ui/parser/shebang/shebang-doc-comment.rs
@@ -0,0 +1,3 @@
+#!///bin/bash
+[allow(unused_variables)]
+//~^ ERROR expected item, found `[`
diff --git a/tests/ui/parser/shebang/shebang-doc-comment.stderr b/tests/ui/parser/shebang/shebang-doc-comment.stderr
new file mode 100644
index 000000000..2227d45ec
--- /dev/null
+++ b/tests/ui/parser/shebang/shebang-doc-comment.stderr
@@ -0,0 +1,8 @@
+error: expected item, found `[`
+ --> $DIR/shebang-doc-comment.rs:2:1
+ |
+LL | [allow(unused_variables)]
+ | ^ expected item
+
+error: aborting due to previous error
+
diff --git a/tests/ui/parser/shebang/shebang-empty.rs b/tests/ui/parser/shebang/shebang-empty.rs
new file mode 100644
index 000000000..e38cc637e
--- /dev/null
+++ b/tests/ui/parser/shebang/shebang-empty.rs
@@ -0,0 +1,4 @@
+#!
+
+// check-pass
+fn main() {}
diff --git a/tests/ui/parser/shebang/shebang-must-start-file.rs b/tests/ui/parser/shebang/shebang-must-start-file.rs
new file mode 100644
index 000000000..e0392572d
--- /dev/null
+++ b/tests/ui/parser/shebang/shebang-must-start-file.rs
@@ -0,0 +1,6 @@
+// something on the first line for tidy
+#!/bin/bash //~ expected `[`, found `/`
+
+fn main() {
+ println!("ok!");
+}
diff --git a/tests/ui/parser/shebang/shebang-must-start-file.stderr b/tests/ui/parser/shebang/shebang-must-start-file.stderr
new file mode 100644
index 000000000..50543e8bd
--- /dev/null
+++ b/tests/ui/parser/shebang/shebang-must-start-file.stderr
@@ -0,0 +1,8 @@
+error: expected `[`, found `/`
+ --> $DIR/shebang-must-start-file.rs:2:3
+ |
+LL | #!/bin/bash
+ | ^ expected `[`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/parser/shebang/shebang-space.rs b/tests/ui/parser/shebang/shebang-space.rs
new file mode 100644
index 000000000..0978b759d
--- /dev/null
+++ b/tests/ui/parser/shebang/shebang-space.rs
@@ -0,0 +1,5 @@
+#!
+
+// check-pass
+// ignore-tidy-end-whitespace
+fn main() {}
diff --git a/tests/ui/parser/shebang/sneaky-attrib.rs b/tests/ui/parser/shebang/sneaky-attrib.rs
new file mode 100644
index 000000000..b406cc3aa
--- /dev/null
+++ b/tests/ui/parser/shebang/sneaky-attrib.rs
@@ -0,0 +1,16 @@
+#!//bin/bash
+
+
+// This could not possibly be a shebang & also a valid rust file, since a Rust file
+// can't start with `[`
+/*
+ [ (mixing comments to also test that we ignore both types of comments)
+
+ */
+
+[allow(unused_variables)]
+
+// check-pass
+fn main() {
+ let x = 5;
+}
diff --git a/tests/ui/parser/shebang/valid-shebang.rs b/tests/ui/parser/shebang/valid-shebang.rs
new file mode 100644
index 000000000..e480d3da3
--- /dev/null
+++ b/tests/ui/parser/shebang/valid-shebang.rs
@@ -0,0 +1,6 @@
+#!/usr/bin/env run-cargo-script
+
+// check-pass
+fn main() {
+ println!("Hello World!");
+}