about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-05-06 14:50:47 +0200
committerGitHub <noreply@github.com>2025-05-06 14:50:47 +0200
commit9d05497ff630b9775507fad5e8ec075680d18612 (patch)
tree4eef0b7d3e9a6611bcf20f61d73c7a657214937a
parentebd12fcc5e440b6d29aec127035aefd6f4894ea5 (diff)
parentcbaa73beca9a7b62c6400669e47e09958e8804ab (diff)
downloadrust-9d05497ff630b9775507fad5e8ec075680d18612.tar.gz
rust-9d05497ff630b9775507fad5e8ec075680d18612.zip
Rollup merge of #140681 - jieyouxu:test_helpers, r=petrochenkov
Don't ignore compiler stderr in `lib-defaults.rs`

Closes #54222.

- Don't ignore compiler stderr.
- Document test intent.
- Move under `tests/ui/link-native-libs/` instead.

This was previously discussed on https://web.archive.org/web/20181028094402/https://botbot.me/mozilla/rust-tools/2017-02-21/?page=1.

try-job: armhf-gnu
try-job: test-various
try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: x86_64-mingw-1
try-job: aarch64-apple
try-job: x86_64-apple-1
-rw-r--r--tests/ui/abi/lib-defaults.rs15
-rw-r--r--tests/ui/link-native-libs/lib-defaults.rs17
2 files changed, 17 insertions, 15 deletions
diff --git a/tests/ui/abi/lib-defaults.rs b/tests/ui/abi/lib-defaults.rs
deleted file mode 100644
index 2c2cad4f82d..00000000000
--- a/tests/ui/abi/lib-defaults.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-//@ run-pass
-//@ dont-check-compiler-stderr (rust-lang/rust#54222)
-
-//@ compile-flags: -lrust_test_helpers
-
-#[link(name = "rust_test_helpers", kind = "static")]
-extern "C" {
-    pub fn rust_dbg_extern_identity_u32(x: u32) -> u32;
-}
-
-fn main() {
-    unsafe {
-        rust_dbg_extern_identity_u32(42);
-    }
-}
diff --git a/tests/ui/link-native-libs/lib-defaults.rs b/tests/ui/link-native-libs/lib-defaults.rs
new file mode 100644
index 00000000000..4e38adb643d
--- /dev/null
+++ b/tests/ui/link-native-libs/lib-defaults.rs
@@ -0,0 +1,17 @@
+//! By default, `-l NAME` without an explicit kind will default to dylib. However, if there's also
+//! an `#[link(name = NAME, kind = KIND)]` attribute with an explicit `KIND`, it should override the
+//! CLI flag. In particular, this should not result in any duplicate flag warnings from the linker.
+
+//@ run-pass
+//@ compile-flags: -lrust_test_helpers
+
+#[link(name = "rust_test_helpers", kind = "static")]
+extern "C" {
+    pub fn rust_dbg_extern_identity_u32(x: u32) -> u32;
+}
+
+fn main() {
+    unsafe {
+        rust_dbg_extern_identity_u32(42);
+    }
+}