summaryrefslogtreecommitdiffstats
path: root/src/test/ui/parser/shebang
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/parser/shebang')
-rw-r--r--src/test/ui/parser/shebang/issue-71471-ignore-tidy.rs2
-rw-r--r--src/test/ui/parser/shebang/issue-71471-ignore-tidy.stderr8
-rw-r--r--src/test/ui/parser/shebang/multiline-attrib.rs7
-rw-r--r--src/test/ui/parser/shebang/regular-attrib.rs5
-rw-r--r--src/test/ui/parser/shebang/shebang-and-attrib.rs9
-rw-r--r--src/test/ui/parser/shebang/shebang-comment.rs6
-rw-r--r--src/test/ui/parser/shebang/shebang-doc-comment.rs3
-rw-r--r--src/test/ui/parser/shebang/shebang-doc-comment.stderr8
-rw-r--r--src/test/ui/parser/shebang/shebang-empty.rs4
-rw-r--r--src/test/ui/parser/shebang/shebang-must-start-file.rs6
-rw-r--r--src/test/ui/parser/shebang/shebang-must-start-file.stderr8
-rw-r--r--src/test/ui/parser/shebang/shebang-space.rs5
-rw-r--r--src/test/ui/parser/shebang/sneaky-attrib.rs16
-rw-r--r--src/test/ui/parser/shebang/valid-shebang.rs6
14 files changed, 93 insertions, 0 deletions
diff --git a/src/test/ui/parser/shebang/issue-71471-ignore-tidy.rs b/src/test/ui/parser/shebang/issue-71471-ignore-tidy.rs
new file mode 100644
index 000000000..a25051808
--- /dev/null
+++ b/src/test/ui/parser/shebang/issue-71471-ignore-tidy.rs
@@ -0,0 +1,2 @@
+
+#!B //~ expected `[`, found `B`
diff --git a/src/test/ui/parser/shebang/issue-71471-ignore-tidy.stderr b/src/test/ui/parser/shebang/issue-71471-ignore-tidy.stderr
new file mode 100644
index 000000000..896a9dc83
--- /dev/null
+++ b/src/test/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/src/test/ui/parser/shebang/multiline-attrib.rs b/src/test/ui/parser/shebang/multiline-attrib.rs
new file mode 100644
index 000000000..931c94c7f
--- /dev/null
+++ b/src/test/ui/parser/shebang/multiline-attrib.rs
@@ -0,0 +1,7 @@
+#!
+[allow(unused_variables)]
+// check-pass
+
+fn main() {
+ let x = 5;
+}
diff --git a/src/test/ui/parser/shebang/regular-attrib.rs b/src/test/ui/parser/shebang/regular-attrib.rs
new file mode 100644
index 000000000..ca8fb0830
--- /dev/null
+++ b/src/test/ui/parser/shebang/regular-attrib.rs
@@ -0,0 +1,5 @@
+#![allow(unused_variables)]
+// check-pass
+fn main() {
+ let x = 5;
+}
diff --git a/src/test/ui/parser/shebang/shebang-and-attrib.rs b/src/test/ui/parser/shebang/shebang-and-attrib.rs
new file mode 100644
index 000000000..61b89c655
--- /dev/null
+++ b/src/test/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/src/test/ui/parser/shebang/shebang-comment.rs b/src/test/ui/parser/shebang/shebang-comment.rs
new file mode 100644
index 000000000..2b1ab0c57
--- /dev/null
+++ b/src/test/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/src/test/ui/parser/shebang/shebang-doc-comment.rs b/src/test/ui/parser/shebang/shebang-doc-comment.rs
new file mode 100644
index 000000000..72866753e
--- /dev/null
+++ b/src/test/ui/parser/shebang/shebang-doc-comment.rs
@@ -0,0 +1,3 @@
+#!///bin/bash
+[allow(unused_variables)]
+//~^ ERROR expected item, found `[`
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 000000000..2227d45ec
--- /dev/null
+++ b/src/test/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/src/test/ui/parser/shebang/shebang-empty.rs b/src/test/ui/parser/shebang/shebang-empty.rs
new file mode 100644
index 000000000..e38cc637e
--- /dev/null
+++ b/src/test/ui/parser/shebang/shebang-empty.rs
@@ -0,0 +1,4 @@
+#!
+
+// check-pass
+fn main() {}
diff --git a/src/test/ui/parser/shebang/shebang-must-start-file.rs b/src/test/ui/parser/shebang/shebang-must-start-file.rs
new file mode 100644
index 000000000..e0392572d
--- /dev/null
+++ b/src/test/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/src/test/ui/parser/shebang/shebang-must-start-file.stderr b/src/test/ui/parser/shebang/shebang-must-start-file.stderr
new file mode 100644
index 000000000..50543e8bd
--- /dev/null
+++ b/src/test/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/src/test/ui/parser/shebang/shebang-space.rs b/src/test/ui/parser/shebang/shebang-space.rs
new file mode 100644
index 000000000..0978b759d
--- /dev/null
+++ b/src/test/ui/parser/shebang/shebang-space.rs
@@ -0,0 +1,5 @@
+#!
+
+// check-pass
+// ignore-tidy-end-whitespace
+fn main() {}
diff --git a/src/test/ui/parser/shebang/sneaky-attrib.rs b/src/test/ui/parser/shebang/sneaky-attrib.rs
new file mode 100644
index 000000000..b406cc3aa
--- /dev/null
+++ b/src/test/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/src/test/ui/parser/shebang/valid-shebang.rs b/src/test/ui/parser/shebang/valid-shebang.rs
new file mode 100644
index 000000000..e480d3da3
--- /dev/null
+++ b/src/test/ui/parser/shebang/valid-shebang.rs
@@ -0,0 +1,6 @@
+#!/usr/bin/env run-cargo-script
+
+// check-pass
+fn main() {
+ println!("Hello World!");
+}