From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/parser/shebang/issue-71471-ignore-tidy.rs | 2 ++ tests/ui/parser/shebang/issue-71471-ignore-tidy.stderr | 8 ++++++++ tests/ui/parser/shebang/multiline-attrib.rs | 7 +++++++ tests/ui/parser/shebang/regular-attrib.rs | 5 +++++ tests/ui/parser/shebang/shebang-and-attrib.rs | 9 +++++++++ tests/ui/parser/shebang/shebang-comment.rs | 6 ++++++ tests/ui/parser/shebang/shebang-doc-comment.rs | 3 +++ tests/ui/parser/shebang/shebang-doc-comment.stderr | 8 ++++++++ tests/ui/parser/shebang/shebang-empty.rs | 4 ++++ tests/ui/parser/shebang/shebang-must-start-file.rs | 6 ++++++ tests/ui/parser/shebang/shebang-must-start-file.stderr | 8 ++++++++ tests/ui/parser/shebang/shebang-space.rs | 5 +++++ tests/ui/parser/shebang/sneaky-attrib.rs | 16 ++++++++++++++++ tests/ui/parser/shebang/valid-shebang.rs | 6 ++++++ 14 files changed, 93 insertions(+) create mode 100644 tests/ui/parser/shebang/issue-71471-ignore-tidy.rs create mode 100644 tests/ui/parser/shebang/issue-71471-ignore-tidy.stderr create mode 100644 tests/ui/parser/shebang/multiline-attrib.rs create mode 100644 tests/ui/parser/shebang/regular-attrib.rs create mode 100644 tests/ui/parser/shebang/shebang-and-attrib.rs create mode 100644 tests/ui/parser/shebang/shebang-comment.rs create mode 100644 tests/ui/parser/shebang/shebang-doc-comment.rs create mode 100644 tests/ui/parser/shebang/shebang-doc-comment.stderr create mode 100644 tests/ui/parser/shebang/shebang-empty.rs create mode 100644 tests/ui/parser/shebang/shebang-must-start-file.rs create mode 100644 tests/ui/parser/shebang/shebang-must-start-file.stderr create mode 100644 tests/ui/parser/shebang/shebang-space.rs create mode 100644 tests/ui/parser/shebang/sneaky-attrib.rs create mode 100644 tests/ui/parser/shebang/valid-shebang.rs (limited to 'tests/ui/parser/shebang') 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!"); +} -- cgit v1.2.3