summaryrefslogtreecommitdiffstats
path: root/third_party/rust/cstr/tests/compile_fail
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/cstr/tests/compile_fail')
-rw-r--r--third_party/rust/cstr/tests/compile_fail/empty.rs5
-rw-r--r--third_party/rust/cstr/tests/compile_fail/empty.stderr7
-rw-r--r--third_party/rust/cstr/tests/compile_fail/interior-nul.rs5
-rw-r--r--third_party/rust/cstr/tests/compile_fail/interior-nul.stderr5
-rw-r--r--third_party/rust/cstr/tests/compile_fail/non-str.rs7
-rw-r--r--third_party/rust/cstr/tests/compile_fail/non-str.stderr17
-rw-r--r--third_party/rust/cstr/tests/compile_fail/trash-after.rs5
-rw-r--r--third_party/rust/cstr/tests/compile_fail/trash-after.stderr5
8 files changed, 56 insertions, 0 deletions
diff --git a/third_party/rust/cstr/tests/compile_fail/empty.rs b/third_party/rust/cstr/tests/compile_fail/empty.rs
new file mode 100644
index 0000000000..0ac967273e
--- /dev/null
+++ b/third_party/rust/cstr/tests/compile_fail/empty.rs
@@ -0,0 +1,5 @@
+use cstr::cstr;
+
+fn main() {
+ let _foo = cstr!();
+}
diff --git a/third_party/rust/cstr/tests/compile_fail/empty.stderr b/third_party/rust/cstr/tests/compile_fail/empty.stderr
new file mode 100644
index 0000000000..68bda07fab
--- /dev/null
+++ b/third_party/rust/cstr/tests/compile_fail/empty.stderr
@@ -0,0 +1,7 @@
+error: unexpected end of input, expected one of: byte string literal, string literal, identifier
+ --> $DIR/empty.rs:4:16
+ |
+4 | let _foo = cstr!();
+ | ^^^^^^^
+ |
+ = note: this error originates in the macro `cstr` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/cstr/tests/compile_fail/interior-nul.rs b/third_party/rust/cstr/tests/compile_fail/interior-nul.rs
new file mode 100644
index 0000000000..a6876aeb1d
--- /dev/null
+++ b/third_party/rust/cstr/tests/compile_fail/interior-nul.rs
@@ -0,0 +1,5 @@
+use cstr::cstr;
+
+fn main() {
+ let _foo = cstr!("foo\0bar");
+}
diff --git a/third_party/rust/cstr/tests/compile_fail/interior-nul.stderr b/third_party/rust/cstr/tests/compile_fail/interior-nul.stderr
new file mode 100644
index 0000000000..0c6ced1a45
--- /dev/null
+++ b/third_party/rust/cstr/tests/compile_fail/interior-nul.stderr
@@ -0,0 +1,5 @@
+error: nul byte found in the literal
+ --> $DIR/interior-nul.rs:4:22
+ |
+4 | let _foo = cstr!("foo\0bar");
+ | ^^^^^^^^^^
diff --git a/third_party/rust/cstr/tests/compile_fail/non-str.rs b/third_party/rust/cstr/tests/compile_fail/non-str.rs
new file mode 100644
index 0000000000..172b145590
--- /dev/null
+++ b/third_party/rust/cstr/tests/compile_fail/non-str.rs
@@ -0,0 +1,7 @@
+use cstr::cstr;
+
+fn main() {
+ let _foo = cstr!(1);
+ let _foo = cstr!(("a"));
+ let _foo = cstr!(&1);
+}
diff --git a/third_party/rust/cstr/tests/compile_fail/non-str.stderr b/third_party/rust/cstr/tests/compile_fail/non-str.stderr
new file mode 100644
index 0000000000..bbbf7e7169
--- /dev/null
+++ b/third_party/rust/cstr/tests/compile_fail/non-str.stderr
@@ -0,0 +1,17 @@
+error: expected one of: byte string literal, string literal, identifier
+ --> $DIR/non-str.rs:4:22
+ |
+4 | let _foo = cstr!(1);
+ | ^
+
+error: expected one of: byte string literal, string literal, identifier
+ --> $DIR/non-str.rs:5:22
+ |
+5 | let _foo = cstr!(("a"));
+ | ^^^^^
+
+error: expected one of: byte string literal, string literal, identifier
+ --> $DIR/non-str.rs:6:22
+ |
+6 | let _foo = cstr!(&1);
+ | ^
diff --git a/third_party/rust/cstr/tests/compile_fail/trash-after.rs b/third_party/rust/cstr/tests/compile_fail/trash-after.rs
new file mode 100644
index 0000000000..5e4f7c3f08
--- /dev/null
+++ b/third_party/rust/cstr/tests/compile_fail/trash-after.rs
@@ -0,0 +1,5 @@
+use cstr::cstr;
+
+fn main() {
+ let _foo = cstr!("foo" + "bar");
+}
diff --git a/third_party/rust/cstr/tests/compile_fail/trash-after.stderr b/third_party/rust/cstr/tests/compile_fail/trash-after.stderr
new file mode 100644
index 0000000000..d6bb1530af
--- /dev/null
+++ b/third_party/rust/cstr/tests/compile_fail/trash-after.stderr
@@ -0,0 +1,5 @@
+error: unexpected token
+ --> $DIR/trash-after.rs:4:28
+ |
+4 | let _foo = cstr!("foo" + "bar");
+ | ^