summaryrefslogtreecommitdiffstats
path: root/src/test/ui/extenv
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/extenv
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/extenv')
-rw-r--r--src/test/ui/extenv/extenv-arg-2-not-string-literal.rs1
-rw-r--r--src/test/ui/extenv/extenv-arg-2-not-string-literal.stderr8
-rw-r--r--src/test/ui/extenv/extenv-no-args.rs1
-rw-r--r--src/test/ui/extenv/extenv-no-args.stderr8
-rw-r--r--src/test/ui/extenv/extenv-not-defined-custom.rs1
-rw-r--r--src/test/ui/extenv/extenv-not-defined-custom.stderr10
-rw-r--r--src/test/ui/extenv/extenv-not-defined-default.rs4
-rw-r--r--src/test/ui/extenv/extenv-not-defined-default.stderr10
-rw-r--r--src/test/ui/extenv/extenv-not-string-literal.rs1
-rw-r--r--src/test/ui/extenv/extenv-not-string-literal.stderr8
-rw-r--r--src/test/ui/extenv/extenv-too-many-args.rs1
-rw-r--r--src/test/ui/extenv/extenv-too-many-args.stderr8
-rw-r--r--src/test/ui/extenv/issue-55897.rs20
-rw-r--r--src/test/ui/extenv/issue-55897.stderr40
14 files changed, 121 insertions, 0 deletions
diff --git a/src/test/ui/extenv/extenv-arg-2-not-string-literal.rs b/src/test/ui/extenv/extenv-arg-2-not-string-literal.rs
new file mode 100644
index 000000000..66dced478
--- /dev/null
+++ b/src/test/ui/extenv/extenv-arg-2-not-string-literal.rs
@@ -0,0 +1 @@
+fn main() { env!("one", 10); } //~ ERROR: expected string literal
diff --git a/src/test/ui/extenv/extenv-arg-2-not-string-literal.stderr b/src/test/ui/extenv/extenv-arg-2-not-string-literal.stderr
new file mode 100644
index 000000000..258e2b347
--- /dev/null
+++ b/src/test/ui/extenv/extenv-arg-2-not-string-literal.stderr
@@ -0,0 +1,8 @@
+error: expected string literal
+ --> $DIR/extenv-arg-2-not-string-literal.rs:1:25
+ |
+LL | fn main() { env!("one", 10); }
+ | ^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/extenv/extenv-no-args.rs b/src/test/ui/extenv/extenv-no-args.rs
new file mode 100644
index 000000000..9f221ed10
--- /dev/null
+++ b/src/test/ui/extenv/extenv-no-args.rs
@@ -0,0 +1 @@
+fn main() { env!(); } //~ ERROR: env! takes 1 or 2 arguments
diff --git a/src/test/ui/extenv/extenv-no-args.stderr b/src/test/ui/extenv/extenv-no-args.stderr
new file mode 100644
index 000000000..318ed635b
--- /dev/null
+++ b/src/test/ui/extenv/extenv-no-args.stderr
@@ -0,0 +1,8 @@
+error: env! takes 1 or 2 arguments
+ --> $DIR/extenv-no-args.rs:1:13
+ |
+LL | fn main() { env!(); }
+ | ^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/extenv/extenv-not-defined-custom.rs b/src/test/ui/extenv/extenv-not-defined-custom.rs
new file mode 100644
index 000000000..30b72783f
--- /dev/null
+++ b/src/test/ui/extenv/extenv-not-defined-custom.rs
@@ -0,0 +1 @@
+fn main() { env!("__HOPEFULLY_NOT_DEFINED__", "my error message"); } //~ ERROR: my error message
diff --git a/src/test/ui/extenv/extenv-not-defined-custom.stderr b/src/test/ui/extenv/extenv-not-defined-custom.stderr
new file mode 100644
index 000000000..e7da4e046
--- /dev/null
+++ b/src/test/ui/extenv/extenv-not-defined-custom.stderr
@@ -0,0 +1,10 @@
+error: my error message
+ --> $DIR/extenv-not-defined-custom.rs:1:13
+ |
+LL | fn main() { env!("__HOPEFULLY_NOT_DEFINED__", "my error message"); }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/extenv/extenv-not-defined-default.rs b/src/test/ui/extenv/extenv-not-defined-default.rs
new file mode 100644
index 000000000..30a06a254
--- /dev/null
+++ b/src/test/ui/extenv/extenv-not-defined-default.rs
@@ -0,0 +1,4 @@
+fn main() {
+ env!("__HOPEFULLY_NOT_DEFINED__");
+ //~^ ERROR: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined
+}
diff --git a/src/test/ui/extenv/extenv-not-defined-default.stderr b/src/test/ui/extenv/extenv-not-defined-default.stderr
new file mode 100644
index 000000000..884875dca
--- /dev/null
+++ b/src/test/ui/extenv/extenv-not-defined-default.stderr
@@ -0,0 +1,10 @@
+error: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined
+ --> $DIR/extenv-not-defined-default.rs:2:5
+ |
+LL | env!("__HOPEFULLY_NOT_DEFINED__");
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/extenv/extenv-not-string-literal.rs b/src/test/ui/extenv/extenv-not-string-literal.rs
new file mode 100644
index 000000000..3eaa0b5da
--- /dev/null
+++ b/src/test/ui/extenv/extenv-not-string-literal.rs
@@ -0,0 +1 @@
+fn main() { env!(10, "two"); } //~ ERROR: expected string literal
diff --git a/src/test/ui/extenv/extenv-not-string-literal.stderr b/src/test/ui/extenv/extenv-not-string-literal.stderr
new file mode 100644
index 000000000..342a9f709
--- /dev/null
+++ b/src/test/ui/extenv/extenv-not-string-literal.stderr
@@ -0,0 +1,8 @@
+error: expected string literal
+ --> $DIR/extenv-not-string-literal.rs:1:18
+ |
+LL | fn main() { env!(10, "two"); }
+ | ^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/extenv/extenv-too-many-args.rs b/src/test/ui/extenv/extenv-too-many-args.rs
new file mode 100644
index 000000000..1adbee583
--- /dev/null
+++ b/src/test/ui/extenv/extenv-too-many-args.rs
@@ -0,0 +1 @@
+fn main() { env!("one", "two", "three"); } //~ ERROR: env! takes 1 or 2 arguments
diff --git a/src/test/ui/extenv/extenv-too-many-args.stderr b/src/test/ui/extenv/extenv-too-many-args.stderr
new file mode 100644
index 000000000..54150a332
--- /dev/null
+++ b/src/test/ui/extenv/extenv-too-many-args.stderr
@@ -0,0 +1,8 @@
+error: env! takes 1 or 2 arguments
+ --> $DIR/extenv-too-many-args.rs:1:13
+ |
+LL | fn main() { env!("one", "two", "three"); }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/extenv/issue-55897.rs b/src/test/ui/extenv/issue-55897.rs
new file mode 100644
index 000000000..64c4107e8
--- /dev/null
+++ b/src/test/ui/extenv/issue-55897.rs
@@ -0,0 +1,20 @@
+use prelude::*; //~ ERROR unresolved import `prelude`
+
+mod unresolved_env {
+ use env; //~ ERROR unresolved import `env`
+
+ include!(concat!(env!("NON_EXISTENT"), "/data.rs"));
+ //~^ ERROR cannot determine resolution for the macro `env`
+}
+
+mod nonexistent_env {
+ include!(concat!(env!("NON_EXISTENT"), "/data.rs"));
+ //~^ ERROR environment variable `NON_EXISTENT` not defined
+}
+
+mod erroneous_literal {
+ include!(concat!("NON_EXISTENT"suffix, "/data.rs"));
+ //~^ ERROR suffixes on a string literal are invalid
+}
+
+fn main() {}
diff --git a/src/test/ui/extenv/issue-55897.stderr b/src/test/ui/extenv/issue-55897.stderr
new file mode 100644
index 000000000..d2ac0b830
--- /dev/null
+++ b/src/test/ui/extenv/issue-55897.stderr
@@ -0,0 +1,40 @@
+error: environment variable `NON_EXISTENT` not defined
+ --> $DIR/issue-55897.rs:11:22
+ |
+LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs"));
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: suffixes on a string literal are invalid
+ --> $DIR/issue-55897.rs:16:22
+ |
+LL | include!(concat!("NON_EXISTENT"suffix, "/data.rs"));
+ | ^^^^^^^^^^^^^^^^^^^^ invalid suffix `suffix`
+
+error[E0432]: unresolved import `prelude`
+ --> $DIR/issue-55897.rs:1:5
+ |
+LL | use prelude::*;
+ | ^^^^^^^
+ | |
+ | unresolved import
+ | help: a similar path exists: `std::prelude`
+
+error[E0432]: unresolved import `env`
+ --> $DIR/issue-55897.rs:4:9
+ |
+LL | use env;
+ | ^^^ no `env` in the root
+
+error: cannot determine resolution for the macro `env`
+ --> $DIR/issue-55897.rs:6:22
+ |
+LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs"));
+ | ^^^
+ |
+ = note: import resolution is stuck, try simplifying macro imports
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0432`.