about summary refs log tree commit diff
path: root/tests/run-make
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-06-17 00:23:28 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-06-17 00:23:28 +0200
commit5b49b68f3074c2ea8d3ca87ce779657c7db11f73 (patch)
treedf587384363082186709da236c6571f6daaf5f54 /tests/run-make
parent8217b412a235407243f2516ebc859e7b3af8345a (diff)
downloadrust-5b49b68f3074c2ea8d3ca87ce779657c7db11f73.tar.gz
rust-5b49b68f3074c2ea8d3ca87ce779657c7db11f73.zip
Migrate `run-make/used` to `rmake.rs`
Diffstat (limited to 'tests/run-make')
-rw-r--r--tests/run-make/used/Makefile7
-rw-r--r--tests/run-make/used/rmake.rs15
2 files changed, 15 insertions, 7 deletions
diff --git a/tests/run-make/used/Makefile b/tests/run-make/used/Makefile
deleted file mode 100644
index e80eb9e4020..00000000000
--- a/tests/run-make/used/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-include ../tools.mk
-
-# ignore-windows-msvc
-
-all:
-	$(RUSTC) -C opt-level=3 --emit=obj used.rs
-	nm $(TMPDIR)/used.o | $(CGREP) FOO
diff --git a/tests/run-make/used/rmake.rs b/tests/run-make/used/rmake.rs
new file mode 100644
index 00000000000..56ef5c6b9cc
--- /dev/null
+++ b/tests/run-make/used/rmake.rs
@@ -0,0 +1,15 @@
+// This test ensures that the compiler is keeping static variables, even if not referenced
+// by another part of the program, in the output object file.
+//
+// It comes from #39987 which implements this RFC for the #[used] attribute:
+// https://rust-lang.github.io/rfcs/2386-used.html
+
+//@ ignore-msvc
+
+use run_make_support::{cmd, rustc};
+
+fn main() {
+    rustc().opt_level("3").emit("obj").input("used.rs").run();
+
+    cmd("nm").arg("used.o").run().assert_stdout_contains("FOO");
+}