From cae17ff42b711d0de6f5c70b90bd44b76c3d10c4 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 15 May 2024 09:58:47 -0400 Subject: [PATCH 1/2] rewrite panic-impl-transitive --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/panic-impl-transitive/Makefile | 7 ------- tests/run-make/panic-impl-transitive/rmake.rs | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 8 deletions(-) delete mode 100644 tests/run-make/panic-impl-transitive/Makefile create mode 100644 tests/run-make/panic-impl-transitive/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index c2358eff61799..cf72a85218e1b 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -192,7 +192,6 @@ run-make/output-with-hyphens/Makefile run-make/override-aliased-flags/Makefile run-make/overwrite-input/Makefile run-make/panic-abort-eh_frame/Makefile -run-make/panic-impl-transitive/Makefile run-make/pass-linker-flags-flavor/Makefile run-make/pass-linker-flags-from-dep/Makefile run-make/pass-linker-flags/Makefile diff --git a/tests/run-make/panic-impl-transitive/Makefile b/tests/run-make/panic-impl-transitive/Makefile deleted file mode 100644 index 9a271a22e10dd..0000000000000 --- a/tests/run-make/panic-impl-transitive/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -include ../tools.mk - -# NOTE we use --emit=llvm-ir to avoid running the linker (linking will fail because there's no main -# in this crate) -all: - $(RUSTC) panic-impl-provider.rs - $(RUSTC) panic-impl-consumer.rs -C panic=abort --emit=llvm-ir -L $(TMPDIR) diff --git a/tests/run-make/panic-impl-transitive/rmake.rs b/tests/run-make/panic-impl-transitive/rmake.rs new file mode 100644 index 0000000000000..4e25f2410e8cc --- /dev/null +++ b/tests/run-make/panic-impl-transitive/rmake.rs @@ -0,0 +1,14 @@ +// In Rust programs where the standard library is unavailable (#![no_std]), we may be interested +// in customizing how panics are handled. Here, the provider specifies that panics should be handled +// by entering an infinite loop. This test checks that this panic implementation can be transitively +// provided by an external crate. +// --emit=llvm-ir is used to avoid running the linker, as linking will fail due to the lack of main +// function in the crate. +// See https://github.com/rust-lang/rust/pull/50338 + +use run_make_support::{rustc, tmp_dir}; + +fn main() { + rustc().input("panic-impl-provider.rs").run(); + rustc().input("panic-impl-consumer.rs").panic("abort").emit("llvm-ir").library_search_path(tmp_dir()).run(); +} From a7484d2e49e8bec4e6b4c2442f07fdc77bf70966 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 15 May 2024 10:09:19 -0400 Subject: [PATCH 2/2] fix tidy --- tests/run-make/panic-impl-transitive/rmake.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/run-make/panic-impl-transitive/rmake.rs b/tests/run-make/panic-impl-transitive/rmake.rs index 4e25f2410e8cc..86308f593b314 100644 --- a/tests/run-make/panic-impl-transitive/rmake.rs +++ b/tests/run-make/panic-impl-transitive/rmake.rs @@ -10,5 +10,10 @@ use run_make_support::{rustc, tmp_dir}; fn main() { rustc().input("panic-impl-provider.rs").run(); - rustc().input("panic-impl-consumer.rs").panic("abort").emit("llvm-ir").library_search_path(tmp_dir()).run(); + rustc() + .input("panic-impl-consumer.rs") + .panic("abort") + .emit("llvm-ir") + .library_search_path(tmp_dir()) + .run(); }