From bfc8dc8e5fb937ccc1e163e5f23d2561f0bd66c9 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 26 Jun 2024 12:04:35 -0400 Subject: [PATCH 1/4] rewrite use-suggestions-rust-2018 to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../use-suggestions-rust-2018/Makefile | 7 ------- .../use-suggestions-rust-2018/rmake.rs | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 8 deletions(-) delete mode 100644 tests/run-make/use-suggestions-rust-2018/Makefile create mode 100644 tests/run-make/use-suggestions-rust-2018/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 cb68589d8a4c2..199d9fd53f391 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -193,7 +193,6 @@ run-make/translation/Makefile run-make/type-mismatch-same-crate-name/Makefile run-make/unknown-mod-stdin/Makefile run-make/unstable-flag-required/Makefile -run-make/use-suggestions-rust-2018/Makefile run-make/used-cdylib-macos/Makefile run-make/volatile-intrinsics/Makefile run-make/wasm-exceptions-nostd/Makefile diff --git a/tests/run-make/use-suggestions-rust-2018/Makefile b/tests/run-make/use-suggestions-rust-2018/Makefile deleted file mode 100644 index 37cd6283c0a6e..0000000000000 --- a/tests/run-make/use-suggestions-rust-2018/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) ep-nested-lib.rs - - $(RUSTC) use-suggestions.rs --edition=2018 --extern ep_nested_lib=$(TMPDIR)/libep_nested_lib.rlib 2>&1 | $(CGREP) "use ep_nested_lib::foo::bar::Baz" - diff --git a/tests/run-make/use-suggestions-rust-2018/rmake.rs b/tests/run-make/use-suggestions-rust-2018/rmake.rs new file mode 100644 index 0000000000000..52c694da75e9a --- /dev/null +++ b/tests/run-make/use-suggestions-rust-2018/rmake.rs @@ -0,0 +1,18 @@ +// The compilation error caused by calling on an unimported crate +// should have a suggestion to write, say, crate::bar::Foo instead +// of just bar::Foo. However, this suggestion used to only appear for +// extern crate statements, not crate struct. After this was fixed in #51456, +// this test checks that the correct suggestion is printed no matter what. +// See https://github.com/rust-lang/rust/issues/51212 + +use run_make_support::{rust_lib_name, rustc}; + +fn main() { + rustc().input("ep-nested-lib.rs").run(); + rustc() + .input("use-suggestions.rs") + .edition("2018") + .extern_("ep_nested_lib", rust_lib_name("ep_nested_lib")) + .run_fail() + .assert_stderr_contains("use ep_nested_lib::foo::bar::Baz"); +} From a6bb92ada7864cbd3bdc3c2a2cb998c0ba512bca Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 26 Jun 2024 13:11:46 -0400 Subject: [PATCH 2/4] rewrite overwrite-input to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/overwrite-input/Makefile | 7 ------- tests/run-make/overwrite-input/file.stderr | 4 +--- tests/run-make/overwrite-input/folder.stderr | 4 +--- tests/run-make/overwrite-input/main.stderr | 6 ------ tests/run-make/overwrite-input/rmake.rs | 13 +++++++++++++ 6 files changed, 15 insertions(+), 20 deletions(-) delete mode 100644 tests/run-make/overwrite-input/Makefile delete mode 100644 tests/run-make/overwrite-input/main.stderr create mode 100644 tests/run-make/overwrite-input/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 199d9fd53f391..9d3c08ec83299 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -119,7 +119,6 @@ run-make/optimization-remarks-dir-pgo/Makefile run-make/optimization-remarks-dir/Makefile run-make/output-type-permutations/Makefile run-make/override-aliased-flags/Makefile -run-make/overwrite-input/Makefile run-make/panic-abort-eh_frame/Makefile run-make/pass-linker-flags-flavor/Makefile run-make/pass-linker-flags-from-dep/Makefile diff --git a/tests/run-make/overwrite-input/Makefile b/tests/run-make/overwrite-input/Makefile deleted file mode 100644 index 721bf62b26b5d..0000000000000 --- a/tests/run-make/overwrite-input/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) main.rs -o main.rs 2> $(TMPDIR)/file.stderr || echo "failed successfully" - $(RUSTC) main.rs -o . 2> $(TMPDIR)/folder.stderr || echo "failed successfully" - $(RUSTC_TEST_OP) "$(TMPDIR)"/file.stderr file.stderr - $(RUSTC_TEST_OP) "$(TMPDIR)"/folder.stderr folder.stderr diff --git a/tests/run-make/overwrite-input/file.stderr b/tests/run-make/overwrite-input/file.stderr index c13a270b067f4..3a741ae3852b8 100644 --- a/tests/run-make/overwrite-input/file.stderr +++ b/tests/run-make/overwrite-input/file.stderr @@ -1,6 +1,4 @@ -warning: ignoring --out-dir flag due to -o flag - error: the input file "main.rs" would be overwritten by the generated executable -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error diff --git a/tests/run-make/overwrite-input/folder.stderr b/tests/run-make/overwrite-input/folder.stderr index 6e51cb812ceb1..30db08428fd91 100644 --- a/tests/run-make/overwrite-input/folder.stderr +++ b/tests/run-make/overwrite-input/folder.stderr @@ -1,6 +1,4 @@ -warning: ignoring --out-dir flag due to -o flag - error: the generated executable for the input file "main.rs" conflicts with the existing directory "." -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error diff --git a/tests/run-make/overwrite-input/main.stderr b/tests/run-make/overwrite-input/main.stderr deleted file mode 100644 index c13a270b067f4..0000000000000 --- a/tests/run-make/overwrite-input/main.stderr +++ /dev/null @@ -1,6 +0,0 @@ -warning: ignoring --out-dir flag due to -o flag - -error: the input file "main.rs" would be overwritten by the generated executable - -error: aborting due to 1 previous error; 1 warning emitted - diff --git a/tests/run-make/overwrite-input/rmake.rs b/tests/run-make/overwrite-input/rmake.rs new file mode 100644 index 0000000000000..b87a7c7e0a851 --- /dev/null +++ b/tests/run-make/overwrite-input/rmake.rs @@ -0,0 +1,13 @@ +// An attempt to set the output `-o` into a directory or a file we cannot write into should indeed +// be an error; but not an ICE (Internal Compiler Error). This test attempts both and checks +// that the standard error matches what is expected. +// See https://github.com/rust-lang/rust/issues/66530 + +use run_make_support::{diff, rustc}; + +fn main() { + let file_out = rustc().input("main.rs").output("main.rs").run_fail().stderr_utf8(); + let folder_out = rustc().input("main.rs").output(".").run_fail().stderr_utf8(); + diff().expected_file("file.stderr").actual_text("actual-file-stderr", file_out).run(); + diff().expected_file("folder.stderr").actual_text("actual-folder-stderr", folder_out).run(); +} From c6bb35750265cc9e630fb49d96ab5721ceb57136 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 26 Jun 2024 13:32:30 -0400 Subject: [PATCH 3/4] rewrite lto-dylib-dep to rmake --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/lto-dylib-dep/Makefile | 11 ----------- tests/run-make/lto-dylib-dep/rmake.rs | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 12 deletions(-) delete mode 100644 tests/run-make/lto-dylib-dep/Makefile create mode 100644 tests/run-make/lto-dylib-dep/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 9d3c08ec83299..9d44b61d5e168 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -94,7 +94,6 @@ run-make/llvm-ident/Makefile run-make/long-linker-command-lines-cmd-exe/Makefile run-make/long-linker-command-lines/Makefile run-make/longjmp-across-rust/Makefile -run-make/lto-dylib-dep/Makefile run-make/lto-linkage-used-attr/Makefile run-make/lto-no-link-whole-rlib/Makefile run-make/lto-smoke-c/Makefile diff --git a/tests/run-make/lto-dylib-dep/Makefile b/tests/run-make/lto-dylib-dep/Makefile deleted file mode 100644 index a9344597d081e..0000000000000 --- a/tests/run-make/lto-dylib-dep/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# Test that we don't run into an assertion when using a Rust dylib dependency -# while compiling with full LTO. -# See https://github.com/rust-lang/rust/issues/59137 - -all: - $(RUSTC) a_dylib.rs --crate-type=dylib -C prefer-dynamic - $(RUSTC) main.rs -C lto - $(call RUN,main) diff --git a/tests/run-make/lto-dylib-dep/rmake.rs b/tests/run-make/lto-dylib-dep/rmake.rs new file mode 100644 index 0000000000000..842fce467d40b --- /dev/null +++ b/tests/run-make/lto-dylib-dep/rmake.rs @@ -0,0 +1,15 @@ +// Compiling with link-time-optimizations (LTO) would previously run into an internal +// compiler error (ICE) if a dylib was passed as a required library. This was due to a +// misplaced assert! call in the compiler, which is now removed. This test checks that +// this bug does not make a resurgence and that dylib+lto compilation succeeds. +// See https://github.com/rust-lang/rust/issues/59137 + +//@ ignore-cross-compile + +use run_make_support::{run, rustc}; + +fn main() { + rustc().input("a_dylib.rs").crate_type("dylib").arg("-Cprefer-dynamic").run(); + rustc().input("main.rs").arg("-Clto").run(); + run("main"); +} From b94eae58772373c59d4a45ba02ce836aec59d1b0 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Wed, 26 Jun 2024 14:02:05 -0400 Subject: [PATCH 4/4] rewrite many-crates-but-no-match to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../many-crates-but-no-match/Makefile | 35 ------------------- .../many-crates-but-no-match/rmake.rs | 31 ++++++++++++++++ 3 files changed, 31 insertions(+), 36 deletions(-) delete mode 100644 tests/run-make/many-crates-but-no-match/Makefile create mode 100644 tests/run-make/many-crates-but-no-match/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 9d44b61d5e168..bdf9536f761d0 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -100,7 +100,6 @@ run-make/lto-smoke-c/Makefile run-make/macos-deployment-target/Makefile run-make/macos-fat-archive/Makefile run-make/manual-link/Makefile -run-make/many-crates-but-no-match/Makefile run-make/metadata-dep-info/Makefile run-make/min-global-align/Makefile run-make/mingw-export-call-convention/Makefile diff --git a/tests/run-make/many-crates-but-no-match/Makefile b/tests/run-make/many-crates-but-no-match/Makefile deleted file mode 100644 index ca0ab8e9e5f41..0000000000000 --- a/tests/run-make/many-crates-but-no-match/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -include ../tools.mk - -# Modelled after ui/changing-crates.rs test, but this one puts -# more than one (mismatching) candidate crate into the search path, -# which did not appear directly expressible in UI testing infrastructure. -# -# Note that we move the built libraries into target direcrtories rather than -# use the `--out-dir` option because the `../tools.mk` file already bakes a -# use of `--out-dir` into the definition of $(RUSTC). - -A1=$(TMPDIR)/a1 -A2=$(TMPDIR)/a2 -A3=$(TMPDIR)/a3 - -# A hack to match distinct lines of output from a single run. -LOG=$(TMPDIR)/log.txt - -all: - mkdir -p $(A1) $(A2) $(A3) - $(RUSTC) --crate-type=rlib crateA1.rs - mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A1) - $(RUSTC) --crate-type=rlib -L $(A1) crateB.rs - $(RUSTC) --crate-type=rlib crateA2.rs - mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A2) - $(RUSTC) --crate-type=rlib crateA3.rs - mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A3) - # Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match - $(RUSTC) -L $(A2) -L $(A3) crateC.rs >$(LOG) 2>&1 || true - $(CGREP) \ - 'found possibly newer version of crate `crateA` which `crateB` depends on' \ - 'note: perhaps that crate needs to be recompiled?' \ - 'crate `crateA`:' \ - 'crate `crateB`:' \ - < $(LOG) - # the 'crate `crateA`' will match two entries. diff --git a/tests/run-make/many-crates-but-no-match/rmake.rs b/tests/run-make/many-crates-but-no-match/rmake.rs new file mode 100644 index 0000000000000..ea4f166b2bd99 --- /dev/null +++ b/tests/run-make/many-crates-but-no-match/rmake.rs @@ -0,0 +1,31 @@ +// An extended version of the ui/changing-crates.rs test, this test puts +// multiple mismatching crates into the search path of crateC (A2 and A3) +// and checks that the standard error contains helpful messages to indicate +// what should be done to fix the issue. +// See https://github.com/rust-lang/rust/issues/13266 + +use run_make_support::{fs_wrapper, rustc}; + +fn main() { + fs_wrapper::create_dir("a1"); + fs_wrapper::create_dir("a2"); + fs_wrapper::create_dir("a3"); + rustc().crate_type("rlib").out_dir("a1").input("crateA1.rs").run(); + rustc().crate_type("rlib").library_search_path("a1").input("crateB.rs").run(); + rustc().crate_type("rlib").out_dir("a2").input("crateA2.rs").run(); + rustc().crate_type("rlib").out_dir("a3").input("crateA3.rs").run(); + // Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match + rustc() + .crate_type("rlib") + .library_search_path("a2") + .library_search_path("a3") + .input("crateC.rs") + .run_fail() + .assert_stderr_contains( + "found possibly newer version of crate `crateA` which `crateB` depends on", + ) + .assert_stderr_contains("note: perhaps that crate needs to be recompiled?") + .assert_stderr_contains("crate `crateA`:") + .assert_stderr_contains("crate `crateB`:"); + // the 'crate `crateA`' will match two entries. +}