summaryrefslogtreecommitdiffstats
path: root/tests/ui/extern-flag
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/extern-flag
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/extern-flag')
-rw-r--r--tests/ui/extern-flag/auxiliary/somedep.rs3
-rw-r--r--tests/ui/extern-flag/empty-extern-arg.rs6
-rw-r--r--tests/ui/extern-flag/empty-extern-arg.stderr11
-rw-r--r--tests/ui/extern-flag/multiple-opts.rs20
-rw-r--r--tests/ui/extern-flag/multiple-opts.stderr9
-rw-r--r--tests/ui/extern-flag/no-nounused.rs6
-rw-r--r--tests/ui/extern-flag/no-nounused.stderr10
-rw-r--r--tests/ui/extern-flag/noprelude-and-prelude.rs10
-rw-r--r--tests/ui/extern-flag/noprelude-resolves.rs11
-rw-r--r--tests/ui/extern-flag/noprelude.rs7
-rw-r--r--tests/ui/extern-flag/noprelude.stderr9
-rw-r--r--tests/ui/extern-flag/nounused.rs7
-rw-r--r--tests/ui/extern-flag/public-and-private.rs13
-rw-r--r--tests/ui/extern-flag/public-and-private.stderr14
14 files changed, 136 insertions, 0 deletions
diff --git a/tests/ui/extern-flag/auxiliary/somedep.rs b/tests/ui/extern-flag/auxiliary/somedep.rs
new file mode 100644
index 000000000..dd2f373f8
--- /dev/null
+++ b/tests/ui/extern-flag/auxiliary/somedep.rs
@@ -0,0 +1,3 @@
+pub fn somefun() {}
+
+pub struct S;
diff --git a/tests/ui/extern-flag/empty-extern-arg.rs b/tests/ui/extern-flag/empty-extern-arg.rs
new file mode 100644
index 000000000..2f4ae7d8e
--- /dev/null
+++ b/tests/ui/extern-flag/empty-extern-arg.rs
@@ -0,0 +1,6 @@
+// compile-flags: --extern std=
+// error-pattern: extern location for std does not exist
+// needs-unwind since it affects the error output
+// ignore-emscripten missing eh_catch_typeinfo lang item
+
+fn main() {}
diff --git a/tests/ui/extern-flag/empty-extern-arg.stderr b/tests/ui/extern-flag/empty-extern-arg.stderr
new file mode 100644
index 000000000..54b5e66fc
--- /dev/null
+++ b/tests/ui/extern-flag/empty-extern-arg.stderr
@@ -0,0 +1,11 @@
+error: extern location for std does not exist:
+
+error: `#[panic_handler]` function required, but not found
+
+error: language item required, but not found: `eh_personality`
+ |
+ = note: this can occur when a binary crate with `#![no_std]` is compiled for a target where `eh_personality` is defined in the standard library
+ = help: you may be able to compile for a target that doesn't need `eh_personality`, specify a target with `--target` or in `.cargo/config`
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/extern-flag/multiple-opts.rs b/tests/ui/extern-flag/multiple-opts.rs
new file mode 100644
index 000000000..3dc2f1d73
--- /dev/null
+++ b/tests/ui/extern-flag/multiple-opts.rs
@@ -0,0 +1,20 @@
+// aux-crate:priv,noprelude:somedep=somedep.rs
+// compile-flags: -Zunstable-options
+// edition:2018
+
+// Test for multiple options to --extern. Can't test for errors from both
+// options at the same time, so this only checks that noprelude is honored.
+
+#![warn(exported_private_dependencies)]
+
+// Module to avoid adding to prelude.
+pub mod m {
+ extern crate somedep;
+ pub struct PublicType {
+ pub field: somedep::S,
+ }
+}
+
+fn main() {
+ somedep::somefun(); //~ ERROR failed to resolve
+}
diff --git a/tests/ui/extern-flag/multiple-opts.stderr b/tests/ui/extern-flag/multiple-opts.stderr
new file mode 100644
index 000000000..5088fb1c4
--- /dev/null
+++ b/tests/ui/extern-flag/multiple-opts.stderr
@@ -0,0 +1,9 @@
+error[E0433]: failed to resolve: use of undeclared crate or module `somedep`
+ --> $DIR/multiple-opts.rs:19:5
+ |
+LL | somedep::somefun();
+ | ^^^^^^^ use of undeclared crate or module `somedep`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/extern-flag/no-nounused.rs b/tests/ui/extern-flag/no-nounused.rs
new file mode 100644
index 000000000..5ec755952
--- /dev/null
+++ b/tests/ui/extern-flag/no-nounused.rs
@@ -0,0 +1,6 @@
+// aux-crate:somedep=somedep.rs
+// compile-flags: -Zunstable-options -Dunused-crate-dependencies
+// edition:2018
+
+fn main() { //~ ERROR external crate `somedep` unused in `no_nounused`
+}
diff --git a/tests/ui/extern-flag/no-nounused.stderr b/tests/ui/extern-flag/no-nounused.stderr
new file mode 100644
index 000000000..6446c5323
--- /dev/null
+++ b/tests/ui/extern-flag/no-nounused.stderr
@@ -0,0 +1,10 @@
+error: external crate `somedep` unused in `no_nounused`: remove the dependency or add `use somedep as _;`
+ --> $DIR/no-nounused.rs:5:1
+ |
+LL | fn main() {
+ | ^
+ |
+ = note: requested on the command line with `-D unused-crate-dependencies`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/extern-flag/noprelude-and-prelude.rs b/tests/ui/extern-flag/noprelude-and-prelude.rs
new file mode 100644
index 000000000..e6a150b9e
--- /dev/null
+++ b/tests/ui/extern-flag/noprelude-and-prelude.rs
@@ -0,0 +1,10 @@
+// check-pass
+// aux-crate:noprelude:somedep=somedep.rs
+// compile-flags: -Zunstable-options --extern somedep
+// edition:2018
+
+// Having a flag with `noprelude` and one without, will add to the prelude.
+
+fn main() {
+ somedep::somefun();
+}
diff --git a/tests/ui/extern-flag/noprelude-resolves.rs b/tests/ui/extern-flag/noprelude-resolves.rs
new file mode 100644
index 000000000..f69f552b6
--- /dev/null
+++ b/tests/ui/extern-flag/noprelude-resolves.rs
@@ -0,0 +1,11 @@
+// check-pass
+// aux-crate:noprelude:somedep=somedep.rs
+// compile-flags: -Zunstable-options
+// edition:2018
+
+// `extern crate` can be used to add to prelude.
+extern crate somedep;
+
+fn main() {
+ somedep::somefun();
+}
diff --git a/tests/ui/extern-flag/noprelude.rs b/tests/ui/extern-flag/noprelude.rs
new file mode 100644
index 000000000..cdbf34091
--- /dev/null
+++ b/tests/ui/extern-flag/noprelude.rs
@@ -0,0 +1,7 @@
+// aux-crate:noprelude:somedep=somedep.rs
+// compile-flags: -Zunstable-options
+// edition:2018
+
+fn main() {
+ somedep::somefun(); //~ ERROR failed to resolve
+}
diff --git a/tests/ui/extern-flag/noprelude.stderr b/tests/ui/extern-flag/noprelude.stderr
new file mode 100644
index 000000000..578787216
--- /dev/null
+++ b/tests/ui/extern-flag/noprelude.stderr
@@ -0,0 +1,9 @@
+error[E0433]: failed to resolve: use of undeclared crate or module `somedep`
+ --> $DIR/noprelude.rs:6:5
+ |
+LL | somedep::somefun();
+ | ^^^^^^^ use of undeclared crate or module `somedep`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
diff --git a/tests/ui/extern-flag/nounused.rs b/tests/ui/extern-flag/nounused.rs
new file mode 100644
index 000000000..2513986bb
--- /dev/null
+++ b/tests/ui/extern-flag/nounused.rs
@@ -0,0 +1,7 @@
+// check-pass
+// aux-crate:nounused:somedep=somedep.rs
+// compile-flags: -Zunstable-options -Dunused-crate-dependencies
+// edition:2018
+
+fn main() {
+}
diff --git a/tests/ui/extern-flag/public-and-private.rs b/tests/ui/extern-flag/public-and-private.rs
new file mode 100644
index 000000000..a3a81cbf3
--- /dev/null
+++ b/tests/ui/extern-flag/public-and-private.rs
@@ -0,0 +1,13 @@
+// aux-crate:priv:somedep=somedep.rs
+// compile-flags: -Zunstable-options --extern somedep
+// edition:2018
+
+#![deny(exported_private_dependencies)]
+
+// Having a flag with `priv` and one without, will remain private (it is sticky).
+
+pub struct PublicType {
+ pub field: somedep::S, //~ ERROR from private dependency
+}
+
+fn main() {}
diff --git a/tests/ui/extern-flag/public-and-private.stderr b/tests/ui/extern-flag/public-and-private.stderr
new file mode 100644
index 000000000..9dfc10eff
--- /dev/null
+++ b/tests/ui/extern-flag/public-and-private.stderr
@@ -0,0 +1,14 @@
+error: type `S` from private dependency 'somedep' in public interface
+ --> $DIR/public-and-private.rs:10:5
+ |
+LL | pub field: somedep::S,
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/public-and-private.rs:5:9
+ |
+LL | #![deny(exported_private_dependencies)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+