diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/parser/shebang | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-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.rs | 2 | ||||
-rw-r--r-- | tests/ui/parser/shebang/issue-71471-ignore-tidy.stderr | 8 | ||||
-rw-r--r-- | tests/ui/parser/shebang/multiline-attrib.rs | 7 | ||||
-rw-r--r-- | tests/ui/parser/shebang/regular-attrib.rs | 5 | ||||
-rw-r--r-- | tests/ui/parser/shebang/shebang-and-attrib.rs | 9 | ||||
-rw-r--r-- | tests/ui/parser/shebang/shebang-comment.rs | 6 | ||||
-rw-r--r-- | tests/ui/parser/shebang/shebang-doc-comment.rs | 3 | ||||
-rw-r--r-- | tests/ui/parser/shebang/shebang-doc-comment.stderr | 8 | ||||
-rw-r--r-- | tests/ui/parser/shebang/shebang-empty.rs | 4 | ||||
-rw-r--r-- | tests/ui/parser/shebang/shebang-must-start-file.rs | 6 | ||||
-rw-r--r-- | tests/ui/parser/shebang/shebang-must-start-file.stderr | 8 | ||||
-rw-r--r-- | tests/ui/parser/shebang/shebang-space.rs | 5 | ||||
-rw-r--r-- | tests/ui/parser/shebang/sneaky-attrib.rs | 16 | ||||
-rw-r--r-- | tests/ui/parser/shebang/valid-shebang.rs | 6 |
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!"); +} |