summaryrefslogtreecommitdiffstats
path: root/tests/ui/rmeta
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/rmeta
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/rmeta')
-rw-r--r--tests/ui/rmeta/auxiliary/rmeta-meta.rs8
-rw-r--r--tests/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs8
-rw-r--r--tests/ui/rmeta/auxiliary/rmeta-rlib.rs5
-rw-r--r--tests/ui/rmeta/auxiliary/rmeta-rmeta.rs9
-rw-r--r--tests/ui/rmeta/emit-artifact-notifications.polonius.stderr1
-rw-r--r--tests/ui/rmeta/emit-artifact-notifications.rs8
-rw-r--r--tests/ui/rmeta/emit-artifact-notifications.stderr1
-rw-r--r--tests/ui/rmeta/emit-metadata-obj.rs7
-rw-r--r--tests/ui/rmeta/rmeta-lib-pass.rs14
-rw-r--r--tests/ui/rmeta/rmeta-pass.rs15
-rw-r--r--tests/ui/rmeta/rmeta-priv-warn.rs11
-rw-r--r--tests/ui/rmeta/rmeta-rpass.rs18
-rw-r--r--tests/ui/rmeta/rmeta.rs8
-rw-r--r--tests/ui/rmeta/rmeta.stderr9
-rw-r--r--tests/ui/rmeta/rmeta_lib.rs14
-rw-r--r--tests/ui/rmeta/rmeta_lib.stderr4
-rw-r--r--tests/ui/rmeta/rmeta_meta_main.rs14
-rw-r--r--tests/ui/rmeta/rmeta_meta_main.stderr9
18 files changed, 163 insertions, 0 deletions
diff --git a/tests/ui/rmeta/auxiliary/rmeta-meta.rs b/tests/ui/rmeta/auxiliary/rmeta-meta.rs
new file mode 100644
index 000000000..6d8ed95bd
--- /dev/null
+++ b/tests/ui/rmeta/auxiliary/rmeta-meta.rs
@@ -0,0 +1,8 @@
+// no-prefer-dynamic
+// compile-flags: --emit=metadata
+
+#![crate_type="rlib"]
+
+pub struct Foo {
+ pub field: i32,
+}
diff --git a/tests/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs b/tests/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs
new file mode 100644
index 000000000..f5e8c3d2a
--- /dev/null
+++ b/tests/ui/rmeta/auxiliary/rmeta-rlib-rpass.rs
@@ -0,0 +1,8 @@
+// no-prefer-dynamic
+
+#![crate_type="rlib"]
+#![crate_name="rmeta_aux"]
+
+pub struct Foo {
+ pub field: i32,
+}
diff --git a/tests/ui/rmeta/auxiliary/rmeta-rlib.rs b/tests/ui/rmeta/auxiliary/rmeta-rlib.rs
new file mode 100644
index 000000000..4a05710db
--- /dev/null
+++ b/tests/ui/rmeta/auxiliary/rmeta-rlib.rs
@@ -0,0 +1,5 @@
+#![crate_type="rlib"]
+
+pub struct Foo {
+ pub field: i32,
+}
diff --git a/tests/ui/rmeta/auxiliary/rmeta-rmeta.rs b/tests/ui/rmeta/auxiliary/rmeta-rmeta.rs
new file mode 100644
index 000000000..4a6d055a8
--- /dev/null
+++ b/tests/ui/rmeta/auxiliary/rmeta-rmeta.rs
@@ -0,0 +1,9 @@
+// no-prefer-dynamic
+// compile-flags: --emit=metadata
+
+#![crate_type="rlib"]
+#![crate_name="rmeta_aux"]
+
+pub struct Foo {
+ pub field2: i32,
+}
diff --git a/tests/ui/rmeta/emit-artifact-notifications.polonius.stderr b/tests/ui/rmeta/emit-artifact-notifications.polonius.stderr
new file mode 100644
index 000000000..255c7b370
--- /dev/null
+++ b/tests/ui/rmeta/emit-artifact-notifications.polonius.stderr
@@ -0,0 +1 @@
+{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications.polonius/libemit_artifact_notifications.rmeta","emit":"metadata"}
diff --git a/tests/ui/rmeta/emit-artifact-notifications.rs b/tests/ui/rmeta/emit-artifact-notifications.rs
new file mode 100644
index 000000000..984a7fabb
--- /dev/null
+++ b/tests/ui/rmeta/emit-artifact-notifications.rs
@@ -0,0 +1,8 @@
+// compile-flags:--emit=metadata --error-format=json --json artifacts
+// build-pass
+// ignore-pass
+// ^-- needed because `--pass check` does not emit the output needed.
+
+// A very basic test for the emission of artifact notifications in JSON output.
+
+fn main() {}
diff --git a/tests/ui/rmeta/emit-artifact-notifications.stderr b/tests/ui/rmeta/emit-artifact-notifications.stderr
new file mode 100644
index 000000000..b2f0aa757
--- /dev/null
+++ b/tests/ui/rmeta/emit-artifact-notifications.stderr
@@ -0,0 +1 @@
+{"artifact":"$TEST_BUILD_DIR/rmeta/emit-artifact-notifications/libemit_artifact_notifications.rmeta","emit":"metadata"}
diff --git a/tests/ui/rmeta/emit-metadata-obj.rs b/tests/ui/rmeta/emit-metadata-obj.rs
new file mode 100644
index 000000000..334c7cc5b
--- /dev/null
+++ b/tests/ui/rmeta/emit-metadata-obj.rs
@@ -0,0 +1,7 @@
+// compile-flags:--emit=metadata,obj
+// build-pass
+
+// A test for the emission of metadata + obj and other metadata + non-link
+// combinations. See issue #81117.
+
+fn main() {}
diff --git a/tests/ui/rmeta/rmeta-lib-pass.rs b/tests/ui/rmeta/rmeta-lib-pass.rs
new file mode 100644
index 000000000..fdd0516e4
--- /dev/null
+++ b/tests/ui/rmeta/rmeta-lib-pass.rs
@@ -0,0 +1,14 @@
+// compile-flags: --emit=metadata
+// aux-build:rmeta-rlib.rs
+// no-prefer-dynamic
+// build-pass (FIXME(62277): could be check-pass?)
+
+// Check that building a metadata crate works with a dependent, rlib crate.
+// This is a cfail test since there is no executable to run.
+
+extern crate rmeta_rlib;
+use rmeta_rlib::Foo;
+
+pub fn main() {
+ let _ = Foo { field: 42 };
+}
diff --git a/tests/ui/rmeta/rmeta-pass.rs b/tests/ui/rmeta/rmeta-pass.rs
new file mode 100644
index 000000000..4f0db23f4
--- /dev/null
+++ b/tests/ui/rmeta/rmeta-pass.rs
@@ -0,0 +1,15 @@
+// compile-flags: --emit=metadata
+// aux-build:rmeta-meta.rs
+// no-prefer-dynamic
+// build-pass (FIXME(62277): could be check-pass?)
+
+// Check that building a metadata crate works with a dependent, metadata-only
+// crate.
+// This is a cfail test since there is no executable to run.
+
+extern crate rmeta_meta;
+use rmeta_meta::Foo;
+
+pub fn main() {
+ let _ = Foo { field: 42 };
+}
diff --git a/tests/ui/rmeta/rmeta-priv-warn.rs b/tests/ui/rmeta/rmeta-priv-warn.rs
new file mode 100644
index 000000000..430c1f06f
--- /dev/null
+++ b/tests/ui/rmeta/rmeta-priv-warn.rs
@@ -0,0 +1,11 @@
+// compile-flags: --emit=metadata
+// no-prefer-dynamic
+// build-pass (FIXME(62277): could be check-pass?)
+
+#[deny(warnings)]
+
+// Test that we don't get warnings for non-pub main when only emitting metadata.
+// (#38273)
+
+fn main() {
+}
diff --git a/tests/ui/rmeta/rmeta-rpass.rs b/tests/ui/rmeta/rmeta-rpass.rs
new file mode 100644
index 000000000..173a6a394
--- /dev/null
+++ b/tests/ui/rmeta/rmeta-rpass.rs
@@ -0,0 +1,18 @@
+// run-pass
+// Test that using rlibs and rmeta dep crates work together. Specifically, that
+// there can be both an rmeta and an rlib file and rustc will prefer the rmeta
+// file.
+//
+// This behavior is simply making sure this doesn't accidentally change; in this
+// case we want to make sure that the rlib isn't being used as that would cause
+// bugs in -Zbinary-dep-depinfo (see #68298).
+
+// aux-build:rmeta-rmeta.rs
+// aux-build:rmeta-rlib-rpass.rs
+
+extern crate rmeta_aux;
+use rmeta_aux::Foo;
+
+pub fn main() {
+ let _ = Foo { field2: 42 };
+}
diff --git a/tests/ui/rmeta/rmeta.rs b/tests/ui/rmeta/rmeta.rs
new file mode 100644
index 000000000..63ed23650
--- /dev/null
+++ b/tests/ui/rmeta/rmeta.rs
@@ -0,0 +1,8 @@
+// no-prefer-dynamic
+// compile-flags: --emit=metadata
+
+// Check that building a metadata crate finds an error.
+
+fn main() {
+ let _ = Foo; //~ ERROR cannot find value `Foo` in this scope
+}
diff --git a/tests/ui/rmeta/rmeta.stderr b/tests/ui/rmeta/rmeta.stderr
new file mode 100644
index 000000000..d15caeb66
--- /dev/null
+++ b/tests/ui/rmeta/rmeta.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `Foo` in this scope
+ --> $DIR/rmeta.rs:7:13
+ |
+LL | let _ = Foo;
+ | ^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/rmeta/rmeta_lib.rs b/tests/ui/rmeta/rmeta_lib.rs
new file mode 100644
index 000000000..fa6826450
--- /dev/null
+++ b/tests/ui/rmeta/rmeta_lib.rs
@@ -0,0 +1,14 @@
+// build-fail
+// aux-build:rmeta-meta.rs
+// no-prefer-dynamic
+// error-pattern: crate `rmeta_meta` required to be available in rlib format, but was not found
+
+// Check that building a non-metadata crate fails if a dependent crate is
+// metadata-only.
+
+extern crate rmeta_meta;
+use rmeta_meta::Foo;
+
+fn main() {
+ let _ = Foo { field: 42 };
+}
diff --git a/tests/ui/rmeta/rmeta_lib.stderr b/tests/ui/rmeta/rmeta_lib.stderr
new file mode 100644
index 000000000..8a9179cca
--- /dev/null
+++ b/tests/ui/rmeta/rmeta_lib.stderr
@@ -0,0 +1,4 @@
+error: crate `rmeta_meta` required to be available in rlib format, but was not found in this form
+
+error: aborting due to previous error
+
diff --git a/tests/ui/rmeta/rmeta_meta_main.rs b/tests/ui/rmeta/rmeta_meta_main.rs
new file mode 100644
index 000000000..839f350d7
--- /dev/null
+++ b/tests/ui/rmeta/rmeta_meta_main.rs
@@ -0,0 +1,14 @@
+// compile-flags: --emit=metadata
+// aux-build:rmeta-meta.rs
+// no-prefer-dynamic
+
+// Check that building a metadata crate finds an error with a dependent,
+// metadata-only crate.
+
+
+extern crate rmeta_meta;
+use rmeta_meta::Foo;
+
+fn main() {
+ let _ = Foo { field2: 42 }; //~ ERROR struct `Foo` has no field named `field2`
+}
diff --git a/tests/ui/rmeta/rmeta_meta_main.stderr b/tests/ui/rmeta/rmeta_meta_main.stderr
new file mode 100644
index 000000000..0c6ed9afd
--- /dev/null
+++ b/tests/ui/rmeta/rmeta_meta_main.stderr
@@ -0,0 +1,9 @@
+error[E0560]: struct `Foo` has no field named `field2`
+ --> $DIR/rmeta_meta_main.rs:13:19
+ |
+LL | let _ = Foo { field2: 42 };
+ | ^^^^^^ help: a field with a similar name exists: `field`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0560`.